diff --git a/OpenRPA.Interfaces/Config.cs b/OpenRPA.Interfaces/Config.cs index cae9dc2b..18fb0df0 100644 --- a/OpenRPA.Interfaces/Config.cs +++ b/OpenRPA.Interfaces/Config.cs @@ -55,6 +55,7 @@ public class Config public bool use_animate_mouse { get { return GetProperty(null, false); } set { SetProperty(null, value); } } public TimeSpan use_postwait { get { return GetProperty(null, TimeSpan.Zero); } set { SetProperty(null, value); } } public bool minimize { get { return GetProperty(null, true); } set { SetProperty(null, value); } } + public bool minimize_to_tray { get { return GetProperty(null, true); } set { SetProperty(null, value); } } public bool recording_add_to_designer { get { return GetProperty(null, true); } set { SetProperty(null, value); } } public TimeSpan reloadinterval { get { return GetProperty(null, TimeSpan.FromMinutes(5)); } set { SetProperty(null, value); } } public TimeSpan move_animation_run_time { get { return GetProperty(null, TimeSpan.FromMilliseconds(500)); } set { SetProperty(null, value); } } @@ -237,6 +238,7 @@ public void Save(string filename) _ = use_animate_mouse; _ = use_postwait; _ = minimize; + _ = minimize_to_tray; _ = recording_add_to_designer; _ = reloadinterval; _ = move_animation_run_time; diff --git a/OpenRPA.Interfaces/Image/Util.cs b/OpenRPA.Interfaces/Image/Util.cs index c6a1ee6c..ed2c42e2 100644 --- a/OpenRPA.Interfaces/Image/Util.cs +++ b/OpenRPA.Interfaces/Image/Util.cs @@ -272,5 +272,29 @@ public static async Task LoadBitmap(string basepath, string ImageString) } return b; } + public static async Task LoadImages(string xaml) + { + var doc = new System.Xml.XmlDocument(); bool foundone = false; + doc.LoadXml(xaml); + var nodes = doc.SelectNodes("//*[@Image]"); + foreach (System.Xml.XmlNode n in nodes) + { + var image = n.Attributes["Image"].Value; + Console.WriteLine("Image: " + image); + if (System.Text.RegularExpressions.Regex.Match(image, "[a-f0-9]{24}").Success) + { + Log.Debug("Loading image id " + image); + using (var b = await Interfaces.Image.Util.LoadBitmap(image)) + { + image = Interfaces.Image.Util.Bitmap2Base64(b); + } + foundone = true; + n.Attributes["Image"].Value = image; + } + } + if (foundone) return doc.OuterXml; + return xaml; + } + } } diff --git a/OpenRPA.Script/OpenRPA.Script.csproj b/OpenRPA.Script/OpenRPA.Script.csproj index 821b8949..3432dcea 100644 --- a/OpenRPA.Script/OpenRPA.Script.csproj +++ b/OpenRPA.Script/OpenRPA.Script.csproj @@ -87,7 +87,7 @@ - + diff --git a/OpenRPA/MainWindow.xaml.cs b/OpenRPA/MainWindow.xaml.cs index 70643a00..5ddb3bec 100644 --- a/OpenRPA/MainWindow.xaml.cs +++ b/OpenRPA/MainWindow.xaml.cs @@ -442,6 +442,7 @@ private void Window_Closed(object sender, EventArgs e) private void Window_StateChanged(object sender, EventArgs e) { Log.FunctionIndent("MainWindow", "Window_StateChanged"); + if (!Config.local.minimize_to_tray) return; if (WindowState == WindowState.Minimized) { Visibility = Visibility.Hidden; @@ -2469,7 +2470,16 @@ internal bool CanCopy(object _item) { try { - return (SelectedContent is Views.WFDesigner); + if (SelectedContent is Views.WFDesigner) return true; + if (SelectedContent is Views.OpenProject view) + { + var val = view.listWorkflows.SelectedValue; + if (val is Workflow wf) + { + return true; + } + } + return false; } catch (Exception ex) { @@ -2482,14 +2492,34 @@ internal async void OnCopy(object _item) Log.FunctionIndent("MainWindow", "OnCopy"); try { - var designer = (Views.WFDesigner)SelectedContent; - await designer.SaveAsync(); - Workflow workflow = await Workflow.Create(designer.Workflow.Project(), "Copy of " + designer.Workflow.name); - var xaml = designer.Workflow.Xaml; - xaml = Views.WFDesigner.SetWorkflowName(xaml, workflow.name); - workflow.Xaml = xaml; - workflow.name = "Copy of " + designer.Workflow.name; - _onOpenWorkflow(workflow, true); + string xaml = ""; + Workflow workflow = null; + if (SelectedContent is Views.WFDesigner) + { + var designer = (Views.WFDesigner)SelectedContent; + await designer.SaveAsync(); + xaml = designer.Workflow.Xaml; + workflow = await Workflow.Create(designer.Workflow.Project(), "Copy of " + designer.Workflow.name); + workflow.name = "Copy of " + designer.Workflow.name; + xaml = await Interfaces.Image.Util.LoadImages(xaml); + xaml = Views.WFDesigner.SetWorkflowName(xaml, workflow.name); + workflow.Xaml = xaml; + _onOpenWorkflow(workflow, true); + } + if (SelectedContent is Views.OpenProject view) + { + var val = view.listWorkflows.SelectedValue; + if (val is Workflow wf) + { + xaml = wf.Xaml; + workflow = await Workflow.Create(wf.Project(), "Copy of " + wf.name); + workflow.name = "Copy of " + wf.name; + xaml = await Interfaces.Image.Util.LoadImages(xaml); + xaml = Views.WFDesigner.SetWorkflowName(xaml, workflow.name); + workflow.Xaml = xaml; + await workflow.Save(); + } + } } catch (Exception ex) { diff --git a/OpenRPA/OpenRPA.csproj b/OpenRPA/OpenRPA.csproj index 3db2201c..d350c7d5 100644 --- a/OpenRPA/OpenRPA.csproj +++ b/OpenRPA/OpenRPA.csproj @@ -11,7 +11,7 @@ Base UI of OpenRPA, used as part of OpenRPA robot MPL-2.0 https://github.com/open-rpa/openrpa - 1.4.57.5 + 1.4.57.6 openrpa.png Debug;Release;ReleaseNuget;PrepInstaller diff --git a/OpenRPA/Views/OpenProject.xaml b/OpenRPA/Views/OpenProject.xaml index 3ddd2440..46b5e92f 100644 --- a/OpenRPA/Views/OpenProject.xaml +++ b/OpenRPA/Views/OpenProject.xaml @@ -57,6 +57,7 @@ + diff --git a/OpenRPA/Views/OpenProject.xaml.cs b/OpenRPA/Views/OpenProject.xaml.cs index 6d9802bf..e977b81e 100644 --- a/OpenRPA/Views/OpenProject.xaml.cs +++ b/OpenRPA/Views/OpenProject.xaml.cs @@ -100,6 +100,15 @@ public ICommand GetServerVersionCommand return new RelayCommand(OnGetServerVersion, CanGetServerVersion); } } + public ICommand CopyCommand + { + get + { + if (RobotInstance.instance.Window is MainWindow main) return new RelayCommand(main.OnCopy, main.CanCopy); + return null; + } + } + public ICommand SerializableCommand { get