Exemple #1
0
 public async static Task Initialize()
 {
     try
     {
         CodeEditor ce = null;
         GenericTools.RunUI(() =>
         {
             try
             {
                 ce          = new CodeEditor();
                 ce.document = ce.Initialize();
             }
             catch (Exception ex)
             {
                 Log.Error("CodeEditor.init-inner: " + ex.ToString());
             }
         });
         var completionService = CompletionService.GetService(ce.document);
         var completionList    = await Task.Run(async() => await completionService.GetCompletionsAsync(ce.document, 0));
     }
     catch (Exception ex)
     {
         Log.Error("CodeEditor.init: " + ex.ToString());
     }
 }
        private void CancelOverlay()
        {
            var p = Plugins.recordPlugins.Where(x => x.Name == "Windows").First();

            if (Config.local.record_overlay)
            {
                p.OnMouseMove -= OnMouseMove;
            }
            p.Stop();
            if (_overlayWindow != null)
            {
                GenericTools.RunUI(_overlayWindow, () =>
                {
                    try
                    {
                        _overlayWindow.Visible = true;
                        _overlayWindow.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.ToString());
                    }
                });
            }
            _overlayWindow = null;
        }
Exemple #3
0
 // https://stackoverflow.com/questions/1567017/com-object-that-has-been-separated-from-its-underlying-rcw-cannot-be-used
 public void Disconnect()
 {
     if (!Connected)
     {
         return;
     }
     try
     {
         if (form != null && !form.Disposing)
         {
             GenericTools.RunUI(form, () =>
             {
                 try
                 {
                     if (rdpConnection != null && rdpConnection.Connected == 1)
                     {
                         rdpConnection.Disconnect();
                     }
                 }
                 catch (Exception ex)
                 {
                     Log.Error(ex.ToString());
                 }
             });
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     Dispose();
 }
Exemple #4
0
 // https://stackoverflow.com/questions/1567017/com-object-that-has-been-separated-from-its-underlying-rcw-cannot-be-used
 public void Disconnect()
 {
     if (!Connected)
     {
         return;
     }
     try
     {
         GenericTools.RunUI(form, () =>
         {
             try
             {
                 rdpConnection.Disconnect();
             }
             catch (Exception ex)
             {
                 Log.Error(ex.ToString());
             }
         });
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     Dispose();
 }
Exemple #5
0
 public void SetLastState(string State)
 {
     if (State == "loaded")
     {
         return;
     }
     if (laststate != State)
     {
         laststate = State;
         if (State != "idle" && State != "running")
         {
             Task.Run(async() =>
             {
                 try
                 {
                     await Save <Workflow>(true);
                 }
                 catch (Exception ex)
                 {
                     Log.Error(ex.ToString());
                 }
             });
         }
         GenericTools.RunUI(() => NotifyUIState());
     }
 }
Exemple #6
0
 public void setText(string text)
 {
     GenericTools.RunUI(this, () => {
         this.Label.Text = text;
         // this.SetBounds(rect.X, rect.Y, rect.Width, rect.Height);
     });
 }
Exemple #7
0
        public void StartRecording(FourCC encoder, string outputFolder, int encodingQuality, string filename = null)
        {
            if (IsRecording)
            {
                throw new InvalidOperationException("Already recording.");
            }

            this.encoder         = encoder;
            this.outputFolder    = outputFolder;
            this.encodingQuality = encodingQuality;
            string extension = ".avi";

            if (encoder != KnownFourCCs.Codecs.Uncompressed && encoder != KnownFourCCs.Codecs.MotionJpeg)
            {
                extension = ".mpeg";
            }

            GenericTools.RunUI(() =>
            {
                if (string.IsNullOrEmpty(filename))
                {
                    filename = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
                }
                lastFileName = System.IO.Path.Combine(outputFolder, filename + extension);
                var bitRate  = Mp3AudioEncoderLame.SupportedBitRates.OrderBy(br => br).ElementAt(audioQuality);
                recorder     = new Recorder(lastFileName,
                                            encoder, encodingQuality,
                                            audioSourceIndex, audioWaveFormat, encodeAudio, bitRate);
                IsRecording = true;
            });
        }
        private async Task loadImage()
        {
            try
            {
                System.Drawing.Bitmap b = await Interfaces.Image.Util.LoadBitmap(ImageString);

                if (b != null)
                {
                    b.Dispose();
                }

                var basepath      = Interfaces.Extensions.ProjectsDirectory;
                var imagepath     = System.IO.Path.Combine(basepath, "images");
                var imagefilepath = System.IO.Path.Combine(imagepath, ImageString + ".png");

                if (System.IO.File.Exists(imagefilepath))
                {
                    GenericTools.RunUI(() =>
                    {
                        try
                        {
                            NotifyPropertyChanged("Image");
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex.ToString());
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
Exemple #9
0
 public void UpdateCaret()
 {
     GenericTools.RunUI(() =>
     {
         try
         {
             var _p = rtb.Document.Blocks.ElementAt(CursorY);
             if (_p == null)
             {
                 return;
             }
             TextPointer myTextPointer1 = _p.ContentStart.GetPositionAtOffset(CursorX);
             TextPointer myTextPointer2 = _p.ContentStart.GetPositionAtOffset(CursorX + 2);
             if (myTextPointer2 == null)
             {
                 return;
             }
             // rtb.CaretPosition = myTextPointer2;
             // Redraw();
         }
         catch (Exception ex)
         {
             Log.Error(ex.ToString());
             return;
         }
     });
 }
 public void NotifyPropertyChanged(string propertyName)
 {
     GenericTools.RunUI(() =>
     {
         PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
     });
 }
        protected override void Execute(CodeActivityContext context)
        {
            var shownewfolderbutton = ShowNewFolderButton.Get(context);
            var rootfolder          = RootFolder.Get(context);
            var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();

            folderBrowserDialog.ShowNewFolderButton = shownewfolderbutton;
            if (string.IsNullOrEmpty(rootfolder))
            {
                rootfolder = Environment.SpecialFolder.Desktop.ToString();
            }
            Enum.TryParse(rootfolder, out Environment.SpecialFolder specialfolder);
            folderBrowserDialog.RootFolder = specialfolder;
            System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.Cancel;
            GenericTools.RunUI(() =>
            {
                result = folderBrowserDialog.ShowDialog();
            });
            if (result != System.Windows.Forms.DialogResult.OK)
            {
                context.SetValue(Folder, null);
                return;
            }
            context.SetValue(Folder, folderBrowserDialog.SelectedPath);
        }
Exemple #12
0
        // private Views.PackageManager view;
        public void Initialize(Views.PackageManager view)
        {
            var provider = NuGetPackageManager.Instance.DefaultSourceRepositoryProvider.PackageSourceProvider;
            var sources  = provider.LoadPackageSources();

            view.PackageSources = new System.Collections.ObjectModel.ObservableCollection <PackageSourceWrapper>();
            view.PackageSources.Add(new PackageSourceWrapper());
            foreach (var source in sources)
            {
                view.PackageSources.Add(new PackageSourceWrapper(source));
            }
            if (view.SelectedPackageSource == null)
            {
                //view.SelectedPackageSource = sources.FirstOrDefault();
                Task.Run(async() =>
                {
                    await Task.Delay(100);
                    GenericTools.RunUI(() =>
                    {
                        view.treePackageSources.SelectItem(sources.FirstOrDefault());
                        view.FilterText = "";
                        view.IsBusy     = false;
                    });
                });
            }
        }
Exemple #13
0
 public void Refresh()
 {
     if (Terminal != null)
     {
         Terminal.Refresh();
     }
     GenericTools.RunUI(() => ForceFocus(true));
 }
Exemple #14
0
 public async Task Update(IProject item, bool skipOnline = false)
 {
     GenericTools.RunUI(() =>
     {
         RobotInstance.instance.Projects.UpdateItem(this, item);
     });
     await Save <Project>(skipOnline);
 }
Exemple #15
0
 public void setLocation(System.Drawing.Rectangle rect)
 {
     GenericTools.RunUI(this, () => {
         this.Bounds  = rect;
         this.TopMost = true;
         // this.SetBounds(rect.X, rect.Y, rect.Width, rect.Height);
     });
 }
Exemple #16
0
 private void Emu_Disconnected(Open3270.TNEmulator where, string Reason)
 {
     IsConnected  = false;
     IsConnecting = false;
     NotifyPropertyChanged("Connect");
     System.Windows.Input.CommandManager.InvalidateRequerySuggested();
     GenericTools.RunUI(Redraw);
 }
Exemple #17
0
        internal void OnInstall(object _item)
        {
            IsBusy = true;
            Task.Run(async() =>
            {
                try
                {
                    if (!string.IsNullOrEmpty(SelectedPackageItem.InstalledVersion))
                    {
                        var _minver   = VersionRange.Parse(SelectedPackageItem.InstalledVersion);
                        var _identity = new PackageIdentity(SelectedPackageItem.Id, _minver.MinVersion);

                        // per project or joined ?
                        // string TargetFolder = System.IO.Path.Combine(project.Path, "extensions");
                        string TargetFolder = System.IO.Path.Combine(Interfaces.Extensions.ProjectsDirectory, "extensions");

                        BusyContent = "Uninstalling " + _identity.ToString();
                        NuGetPackageManager.Instance.UninstallPackage(TargetFolder, _identity);
                        SelectedPackageItem.IsInstalled = false;
                    }
                    BusyContent  = "Initializing";
                    var minver   = VersionRange.Parse(SelectedPackageItem.SelectedVersion);
                    var identity = new PackageIdentity(SelectedPackageItem.Id, minver.MinVersion);
                    if (SelectedPackageItem.RequireLicenseAcceptance)
                    {
                        // Request accept
                    }
                    if (project.dependencies == null)
                    {
                        project.dependencies = Newtonsoft.Json.Linq.JObject.Parse("{}");
                    }
                    project.dependencies.Remove(identity.Id);
                    project.dependencies.Add(identity.Id, minver.MinVersion.ToString());
                    BusyContent = "Saving current project settings";
                    await project.Save(false);
                    BusyContent = "Installing NuGet Packages";
                    await project.InstallDependencies(false);
                    NeedsReload = true;
                    //BusyContent = "Reloading Activities Toolbox";
                    //GenericTools.RunUI(()=> WFToolbox.Instance.InitializeActivitiesToolbox());
                    SelectedPackageItem.InstalledVersion = SelectedPackageItem.SelectedVersion;
                    SelectedPackageItem.IsInstalled      = true;
                    IsBusy = false;
                    if (SelectedPackageSource.source == null)
                    {
                        SelectedPackageSource.ClearCache();
                        GenericTools.RunUI(() =>
                        {
                            FilterText = FilterText;
                        });
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            });
        }
Exemple #18
0
        public void init()
        {
            try
            {
                if (PluginConfig.auto_launch_java_bridge)
                {
                    EnsureJavaBridge();
                }
                if (pipeclient == null)
                {
                    var SessionId = System.Diagnostics.Process.GetCurrentProcess().SessionId;
                    pipeclient = new NamedPipeClient <JavaEvent>(SessionId + "_openrpa_javabridge");
                    pipeclient.ServerMessage += Pipeclient_ServerMessage;
                    pipeclient.Connected     += Pipeclient_Connected;
                    pipeclient.Disconnected  += Pipeclient_Disconnected;
                    pipeclient.AutoReconnect  = true;
                    pipeclient.Start();
                }
                if (Initilized)
                {
                    return;
                }
                GenericTools.RunUI(() =>
                {
                    Initilized   = false;
                    _windowCache = new HwndCache();
                    Log.Debug("javahook.init()");
                    accessBridge.Initilized += (e1, e2) =>
                    {
                        Initilized = true;
                        Log.Information("javahook._accessBridge.Initilized");
                        OnInitilized?.Invoke(accessBridge);
                    };
                    try
                    {
                        if (IntPtr.Size == 4)
                        {
                            // accessBridge.Initialize(true);
                            accessBridge.Initialize(false);
                        }
                        else
                        {
                            accessBridge.Initialize(false);
                        }

                        refreshJvms(200);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.ToString());
                    }
                });
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
Exemple #19
0
 public async Task Update(IWorkitemQueue item, bool skipOnline = false)
 {
     GenericTools.RunUI(() =>
     {
         RobotInstance.instance.WorkItemQueues.UpdateItem(this, item);
     });
     isDirty = false;
     await Save <WorkitemQueue>(skipOnline);
 }
        public void OnMouseMove(IRecordPlugin sender, IRecordEvent e)
        {
            if (!Config.local.record_overlay)
            {
                return;
            }
            if (vm.Plugin != null)
            {
                if (!vm.Plugin.ParseMouseMoveAction(ref e))
                {
                    return;
                }
            }
            else
            {
                foreach (var p in Plugins.recordPlugins)
                {
                    if (p.Name != sender.Name)
                    {
                        if (p.ParseMouseMoveAction(ref e))
                        {
                            continue;
                        }
                    }
                }
            }

            // e.Element.Highlight(false, System.Drawing.Color.PaleGreen, TimeSpan.FromSeconds(1));
            if (e.Element != null && _overlayWindow != null)
            {
                GenericTools.RunUI(_overlayWindow, () =>
                {
                    try
                    {
                        _overlayWindow.Visible = true;
                        _overlayWindow.Bounds  = e.Element.Rectangle;
                    }
                    catch (Exception)
                    {
                    }
                });
            }
            else if (_overlayWindow != null)
            {
                GenericTools.RunUI(_overlayWindow, () =>
                {
                    try
                    {
                        _overlayWindow.Visible = false;
                    }
                    catch (Exception)
                    {
                    }
                });
            }
        }
Exemple #21
0
        private void OnMouseUp(InputEventArgs e)
        {
            var thread = new Thread(new ThreadStart(() =>
            {
                Log.Debug(string.Format("IE.Recording::OnMouseUp::begin"));
                var re = new RecordEvent(); re.Button = e.Button;
                var a  = new GetElement {
                    DisplayName = (e.Element.Name).Replace(Environment.NewLine, "").Trim()
                };

                var browser     = new Browser(e.Element.RawElement);
                var htmlelement = browser.ElementFromPoint(e.X, e.Y);
                if (htmlelement == null)
                {
                    return;
                }

                var sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                IESelector sel = null;
                // sel = new IESelector(e.Element.rawElement, null, true);
                GenericTools.RunUI(() =>
                {
                    sel = new IESelector(browser, htmlelement, null, false, e.X, e.Y);
                });
                if (sel == null)
                {
                    return;
                }
                if (sel.Count < 2)
                {
                    return;
                }
                a.Selector   = sel.ToString();
                a.Image      = sel.Last().Element.ImageString();
                re.UIElement = e.Element;
                re.Element   = new IEElement(browser, htmlelement);
                re.Selector  = sel;
                re.X         = e.X;
                re.Y         = e.Y;

                Log.Debug(e.Element.SupportInput + " / " + e.Element.ControlType);
                re.a = new GetElementResult(a);
                if (htmlelement.tagName.ToLower() == "input" && htmlelement.tagName.ToLower() == "select")
                {
                    MSHTML.IHTMLInputElement inputelement = (MSHTML.IHTMLInputElement)htmlelement;
                    re.SupportInput = (inputelement.type.ToLower() == "text" || inputelement.type.ToLower() == "password");
                }

                Log.Debug(string.Format("IE.Recording::OnMouseUp::end {0:mm\\:ss\\.fff}", sw.Elapsed));
                OnUserAction?.Invoke(this, re);
            }));

            thread.IsBackground = true;
            thread.Start();
        }
Exemple #22
0
        protected override void Execute(NativeActivityContext context)
        {
            var filename = Filename.Get(context);

            GenericTools.RunUI(() =>
            {
                var f = new Playback(filename);
                f.ShowDialog();
            });
        }
Exemple #23
0
        public async Task Save(bool skipOnline = false)
        {
            await Save <Project>(skipOnline);

            foreach (var workflow in Workflows.ToList())
            {
                if (workflow.projectid != _id)
                {
                    workflow.projectid = _id;
                }
                await workflow.Save(skipOnline);
            }
            foreach (Detector detector in Detectors.ToList())
            {
                if (detector.projectid != _id)
                {
                    detector.projectid = _id;
                }
                await detector.Save(skipOnline);
            }
            foreach (WorkitemQueue wiq in WorkItemQueues.ToList())
            {
                if (wiq.projectid != _id)
                {
                    wiq.projectid = _id;
                }
                await wiq.Save(skipOnline);
            }
            GenericTools.RunUI(() =>
            {
                if (System.Threading.Monitor.TryEnter(RobotInstance.instance.Projects, Config.local.thread_lock_timeout_seconds * 1000))
                {
                    try
                    {
                        var exists = RobotInstance.instance.Projects.FindById(_id);
                        if (exists == null)
                        {
                            RobotInstance.instance.Projects.Add(this);
                        }
                        if (exists != null)
                        {
                            RobotInstance.instance.Projects.UpdateItem(exists, this);
                        }
                    }
                    finally
                    {
                        System.Threading.Monitor.Exit(RobotInstance.instance.Projects);
                    }
                }
                else
                {
                    throw new LockNotReceivedException("Saving Project");
                }
            });
        }
Exemple #24
0
 public bool WaitForText(string Text, TimeSpan Timeout)
 {
     try
     {
         return(emu.WaitForTextOnScreen((int)Timeout.TotalMilliseconds, Text) > -1);
     }
     finally
     {
         GenericTools.RunUI(Refresh);
     }
 }
Exemple #25
0
        public void SaveFile(string overridepath = null, bool exportImages = false)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }
            if (string.IsNullOrEmpty(Xaml))
            {
                return;
            }
            if (!Project.Workflows.Contains(this))
            {
                Project.Workflows.Add(this);
            }

            var workflowpath = Project.Path;

            if (!string.IsNullOrEmpty(overridepath))
            {
                workflowpath = overridepath;
            }
            var workflowfilepath = System.IO.Path.Combine(workflowpath, Filename);

            if (string.IsNullOrEmpty(workflowfilepath))
            {
                Filename = UniqueFilename();
            }
            else
            {
                var guess   = name.Replace(" ", "_").Replace(".", "") + ".xaml";
                var newName = UniqueFilename();
                if (guess == newName && Filename != guess)
                {
                    System.IO.File.WriteAllText(System.IO.Path.Combine(workflowpath, guess), Xaml);
                    System.IO.File.Delete(workflowfilepath);
                    Filename = guess;
                    return;
                }
            }
            if (exportImages)
            {
                GenericTools.RunUI(async() => {
                    string beforexaml = Xaml;
                    string xaml       = await Views.WFDesigner.LoadImages(beforexaml);
                    //string xaml = Task.Run(() =>
                    //{
                    //    return Views.WFDesigner.LoadImages(beforexaml);
                    //}).Result;
                    System.IO.File.WriteAllText(workflowfilepath, xaml);
                });
                return;
            }
            System.IO.File.WriteAllText(workflowfilepath, Xaml);
        }
Exemple #26
0
        public async Task Save(bool skipOnline = false)
        {
            await Save <Workitem>(skipOnline);

            if (string.IsNullOrEmpty(Config.local.wsurl))
            {
                GenericTools.RunUI(() => {
                    RobotInstance.instance.Workitems.Add(this);
                });
            }
        }
Exemple #27
0
        internal void OnUninstall(object _item)
        {
            IsBusy = true;
            Task.Run(async() =>
            {
                try
                {
                    BusyContent  = "Initializing";
                    var minver   = VersionRange.Parse(SelectedPackageItem.InstalledVersion);
                    var identity = new PackageIdentity(SelectedPackageItem.Id, minver.MinVersion);
                    if (project.dependencies == null)
                    {
                        project.dependencies = Newtonsoft.Json.Linq.JObject.Parse("{}");
                    }
                    project.dependencies.Remove(identity.Id);

                    // per project or joined ?
                    // string TargetFolder = System.IO.Path.Combine(project.Path, "extensions");
                    string TargetFolder = System.IO.Path.Combine(Interfaces.Extensions.ProjectsDirectory, "extensions");

                    BusyContent = "Uninstalling package";
                    NuGetPackageManager.Instance.UninstallPackage(TargetFolder, identity);
                    SelectedPackageItem.IsInstalled = false;
                    BusyContent = "Saving current project settings";
                    await project.Save(false);
                    //BusyContent = "Updating NuGet Packages";
                    //await project.InstallDependencies();
                    //BusyContent = "Reloading Activities Toolbox";
                    //GenericTools.RunUI(() => WFToolbox.Instance.InitializeActivitiesToolbox());
                    SelectedPackageItem.InstalledVersion = "";
                    SelectedPackageItem.IsInstalled      = false;
                    if (NuGetPackageManager.PendingDeletion.Count > 0)
                    {
                        Config.local.files_pending_deletion = NuGetPackageManager.PendingDeletion.ToArray();
                        Config.Save();
                        MessageBox.Show("Please restart the robot for the change to take fully effect");
                    }
                    if (SelectedPackageSource.source == null)
                    {
                        SelectedPackageSource.ClearCache();
                        GenericTools.RunUI(() =>
                        {
                            FilterText = FilterText;
                        });
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
                IsBusy = false;
            });
        }
Exemple #28
0
        protected override void Execute(CodeActivityContext context)
        {
            var isSaveAs         = IsSaveAs.Get(context);
            var initialDirectory = InitialDirectory.Get(context);
            var title            = Title.Get(context);
            var defaultExt       = DefaultExt.Get(context);
            var filter           = Filter.Get(context);
            var filterIndex      = FilterIndex.Get(context);
            var checkFileExists  = CheckFileExists.Get(context);
            var checkPathExists  = CheckPathExists.Get(context);
            var multiselect      = Multiselect.Get(context);

            System.Windows.Forms.FileDialog dialog;
            if (isSaveAs)
            {
                dialog = new System.Windows.Forms.SaveFileDialog();
            }
            else
            {
                dialog = new System.Windows.Forms.OpenFileDialog();
                ((System.Windows.Forms.OpenFileDialog)dialog).Multiselect = multiselect;
            }
            if (!string.IsNullOrEmpty(title))
            {
                dialog.Title = title;
            }
            if (!string.IsNullOrEmpty(defaultExt))
            {
                dialog.DefaultExt = defaultExt;
            }
            if (!string.IsNullOrEmpty(filter))
            {
                dialog.Filter      = filter;
                dialog.FilterIndex = filterIndex;
            }
            dialog.CheckFileExists = checkFileExists;
            dialog.CheckPathExists = checkPathExists;


            System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.Cancel;
            GenericTools.RunUI(() =>
            {
                result = dialog.ShowDialog();
            });
            if (result != System.Windows.Forms.DialogResult.OK)
            {
                context.SetValue(FileName, null);
                context.SetValue(FileNames, null);
                return;
            }
            context.SetValue(FileName, dialog.FileName);
            context.SetValue(FileNames, dialog.FileNames);
        }
Exemple #29
0
        public async static Task Initialize()
        {
            CodeEditor ce = null;

            GenericTools.RunUI(() =>
            {
                ce          = new CodeEditor();
                ce.document = ce.Initialize();
            });
            var completionService = CompletionService.GetService(ce.document);
            var completionList    = await Task.Run(async() => await completionService.GetCompletionsAsync(ce.document, 0));
        }
Exemple #30
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Task.Run(() =>
     {
         var treeelements = vm.Plugin.GetRootElements(vm.Anchor);
         GenericTools.RunUI(this, () =>
         {
             Log.Debug("init selector model, with " + treeelements.Count() + " root elements");
             vm.init(treeelements);
             // vm.FocusElement(vm.Selector);
         });
     });
 }