Exemplo n.º 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());
     }
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 6
0
 public void setText(string text)
 {
     GenericTools.RunUI(this, () => {
         this.Label.Text = text;
         // this.SetBounds(rect.X, rect.Y, rect.Width, rect.Height);
     });
 }
Exemplo n.º 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;
            });
        }
Exemplo n.º 8
0
        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());
            }
        }
Exemplo n.º 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;
         }
     });
 }
Exemplo n.º 10
0
 public void NotifyPropertyChanged(string propertyName)
 {
     GenericTools.RunUI(() =>
     {
         PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
     });
 }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 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;
                    });
                });
            }
        }
Exemplo n.º 13
0
 public void Refresh()
 {
     if (Terminal != null)
     {
         Terminal.Refresh();
     }
     GenericTools.RunUI(() => ForceFocus(true));
 }
Exemplo n.º 14
0
 public async Task Update(IProject item, bool skipOnline = false)
 {
     GenericTools.RunUI(() =>
     {
         RobotInstance.instance.Projects.UpdateItem(this, item);
     });
     await Save <Project>(skipOnline);
 }
Exemplo n.º 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);
     });
 }
Exemplo n.º 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);
 }
Exemplo n.º 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());
                }
            });
        }
Exemplo n.º 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());
            }
        }
Exemplo n.º 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);
 }
Exemplo n.º 20
0
        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)
                    {
                    }
                });
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 22
0
        protected override void Execute(NativeActivityContext context)
        {
            var filename = Filename.Get(context);

            GenericTools.RunUI(() =>
            {
                var f = new Playback(filename);
                f.ShowDialog();
            });
        }
Exemplo n.º 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");
                }
            });
        }
Exemplo n.º 24
0
 public bool WaitForText(string Text, TimeSpan Timeout)
 {
     try
     {
         return(emu.WaitForTextOnScreen((int)Timeout.TotalMilliseconds, Text) > -1);
     }
     finally
     {
         GenericTools.RunUI(Refresh);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
                });
            }
        }
Exemplo n.º 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;
            });
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
         });
     });
 }