Ejemplo n.º 1
0
        private void WriteWindow(IDockWindow window, string indent = "")
        {
            string id = $"window{_windowCount}";

            _windowCount++;

            if (!_idWindows.ContainsKey(window))
            {
                _idWindows[window] = id;
            }

            Output($"{indent}var {id} = new {window.GetType().Name}()");
            Output($"{indent}{{");
            Output($"{indent}    Id = \"{window.Id}\",");
            Output($"{indent}    X = {FormatDouble(window.X)},");
            Output($"{indent}    Y = {FormatDouble(window.Y)},");
            Output($"{indent}    Width = {FormatDouble(window.Width)},");
            Output($"{indent}    Height = {FormatDouble(window.Height)},");
            Output($"{indent}    Title = \"{window.Title}\",");

            Output($"{indent}}};");

            if (window.Layout is IDock dock)
            {
                WriteDock(dock, indent);
            }
            else
            {
                WriteDock(window.Layout, indent);
            }
        }
Ejemplo n.º 2
0
        private void InitDockingWindow(IDockWindow dockWnd)
        {
            OnDockingWindowAvailable();

            var wnd = dockWnd as Window;

            if (wnd.IsLoaded)
            {
                if (!String.IsNullOrEmpty(StartPageDockDocument.PageFile))
                {
                    DockingWindowResources.Instance.LoadStartPageMenuItems();
                    if (StartPageDockDocument.GlobalShowOnStartup)
                    {
                        ShowStartPage();
                    }
                }
                OnDockingWindowLoaded();
            }
            else
            {
                wnd.Loaded += DockingWindow_Loaded;
            }

            wnd.Closing += DockingWindow_Closing;
            wnd.Closed  += DockingWindow_Closed;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds window to dock windows list.
 /// </summary>
 /// <param name="dock">The views dock.</param>
 /// <param name="window">The window to add.</param>
 public static void AddWindow(this IDock dock, IDockWindow window)
 {
     if (dock.Windows == null)
     {
         dock.Windows = new ObservableCollection <IDockWindow>();
     }
     dock.Windows?.Add(window);
 }
Ejemplo n.º 4
0
 /// <inheritdoc/>
 public virtual void RemoveWindow(IDockWindow window)
 {
     if (window?.Owner is IDock dock)
     {
         window.Destroy();
         dock.Windows?.Remove(window);
     }
 }
Ejemplo n.º 5
0
 ///<inheritdoc/>
 public virtual void RemoveWindow(IDockWindow window)
 {
     if (window?.Owner is IRootDock rootDock)
     {
         window.Exit();
         rootDock.Windows?.Remove(window);
     }
 }
Ejemplo n.º 6
0
 /// <inheritdoc/>
 public virtual void AddWindow(IDock dock, IDockWindow window)
 {
     if (dock.Windows == null)
     {
         dock.Windows = CreateList <IDockWindow>();
     }
     dock.Windows.Add(window);
     Update(window, dock);
 }
Ejemplo n.º 7
0
 ///<inheritdoc/>
 public virtual void AddWindow(IRootDock rootDock, IDockWindow window)
 {
     if (rootDock.Window is null)
     {
         rootDock.Windows = CreateList <IDockWindow>();
     }
     rootDock.Windows.Add(window);
     UpdateDockWindow(window, rootDock);
 }
Ejemplo n.º 8
0
        /// <inheritdoc/>
        public virtual void Update(IDockWindow window, object context)
        {
            window.Host    = GetHost(window.Id);
            window.Context = GetContext(window.Id, context);

            if (window.Layout != null)
            {
                Update(window.Layout, context);
            }
        }
Ejemplo n.º 9
0
        public RemoveEntitiesViewModel(ISourcesCacheProvider cacheProvider, IDockWindow window)
        {
            _cache  = cacheProvider.CurrentCache;
            _window = window;

            Title = "Remove Instances";

            RemoveSourceCommand   = ReactiveCommand.Create <Source>(RemoveSource);
            RemoveInstanceCommand = ReactiveCommand.Create <Instance>(RemoveInstance);
            RemoveMetricCommand   = ReactiveCommand.Create <Metric>(RemoveMetric);

            var filter = this.WhenAnyValue(x => x.FilterText)
                         .Throttle(TimeSpan.FromSeconds(.3))
                         .Publish();

            var dynamicFilterSource = filter
                                      .Select(Filters.CreateFilterSource);
            var dynamicFilterInstance = filter
                                        .Select(Filters.CreateFilterInstance);
            var dynamicFilterMetric = filter
                                      .Select(Filters.CreateFilterMetric);

            filter.Connect()
            .DisposeWith(Disposables);

            _cache.Sources
            .Connect()
            .Filter(dynamicFilterSource)
            .Sort(SortExpressionComparer <Source>
                  .Ascending(x => x.ID))
            .ObserveOnDispatcher()
            .Bind(out _sources)
            .Subscribe()
            .DisposeWith(Disposables);

            _cache.Instances
            .Connect()
            .Filter(dynamicFilterInstance)
            .Sort(SortExpressionComparer <Instance>
                  .Ascending(x => x.ID))
            .ObserveOnDispatcher()
            .Bind(out _instances)
            .Subscribe()
            .DisposeWith(Disposables);

            _cache.Metrics
            .Connect()
            .Filter(dynamicFilterMetric)
            .Sort(SortExpressionComparer <Metric>
                  .Ascending(x => x.ID))
            .ObserveOnDispatcher()
            .Bind(out _metrics)
            .Subscribe()
            .DisposeWith(Disposables);
        }
Ejemplo n.º 10
0
        /// <inheritdoc/>
        public virtual void Update(IDockWindow window, object context, IView owner)
        {
            window.Host    = GetHost(window.Id);
            window.Context = GetContext(window.Id, context);
            window.Owner   = owner;
            window.Factory = this;

            if (window.Layout != null)
            {
                Update(window.Layout, context, window.Layout.Parent);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Clone <see cref="IDockWindow"/> object.
        /// </summary>
        /// <param name="source">The source object.</param>
        /// <returns>The new instance or reference</returns>
        public static IDockWindow?CloneDockWindow(IDockWindow source)
        {
            source.Save();

            var target = source.Factory?.CreateDockWindow();

            if (!(target is null))
            {
                CloneDockWindowProperties(source, target);
            }
            return(target);
        }
Ejemplo n.º 12
0
        public static async Task <GroupCreateDialogResult> ShowGroupCreateDialog(this IDockWindow window)
        {
            var view = (MainWindow)window;

            var dialog = new GroupCreateDialog();

            await view.ShowMetroDialogAsync(dialog);

            var result = await dialog.WaitForButtonPressAsync();

            await view.HideMetroDialogAsync(dialog);

            return(result);
        }
Ejemplo n.º 13
0
        ///<inheritdoc/>
        public virtual void UpdateDockWindow(IDockWindow window, IDockable?owner)
        {
            window.Host = GetHostWindow(window.Id);
            if (!(window.Host is null))
            {
                window.Host.Window = window;
            }

            window.Owner   = owner;
            window.Factory = this;

            if (!(window.Layout is null))
            {
                UpdateDockable(window.Layout, window.Layout.Owner);
            }
        }
        public ManageGroupsViewModel(ISourcesCacheProvider cacheProvider, IDockWindow window)
        {
            _cache  = cacheProvider.CurrentCache;
            _window = window;

            Title = "Manage Groups";

            _cache.Groups
            .Connect()
            .Sort(SortExpressionComparer <Group>
                  .Ascending(x => x.ID))
            .ObserveOnDispatcher()
            .Bind(out _listGroups)
            .Subscribe()
            .DisposeWith(Disposables);

            _cache.InstancesWithoutGroup
            .Connect()
            .Sort(SortExpressionComparer <Instance>
                  .Ascending(x => x.ID))
            .ObserveOnDispatcher()
            .Bind(out _listWithoutGroup)
            .Subscribe()
            .DisposeWith(Disposables);

            var dynamicInListFilter = this
                                      .WhenAnyValue(x => x.SelectedGroup)
                                      .Select(g => (Func <Group, bool>)(x => g != null && x.ID == g.ID));

            _cache.Groups
            .Connect()
            .Filter(dynamicInListFilter)
            .TransformMany(x => x.Instances, x => x.ID)
            .Sort(SortExpressionComparer <Instance>
                  .Ascending(x => x.ID))
            .ObserveOnDispatcher()
            .Bind(out _listInGroup)
            .Subscribe()
            .DisposeWith(Disposables);

            SelectedGroup = ListGroups.FirstOrDefault();

            RemoveGroupCommand = ReactiveCommand.Create <Group>(RemoveGroup);
            CreateGroupCommand = ReactiveCommand.CreateFromTask(CreateGroup);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Clone dock window properties
        /// </summary>
        /// <param name="source">The source dock window.</param>
        /// <param name="target">The target dock window.</param>
        public static void CloneDockWindowProperties(IDockWindow source, IDockWindow target)
        {
            target.Id      = source.Id;
            target.X       = source.X;
            target.Y       = source.Y;
            target.Width   = source.Width;
            target.Height  = source.Height;
            target.Topmost = source.Topmost;
            target.Title   = source.Title;

            if (!(source.Layout is null))
            {
                target.Layout = (IRootDock?)source.Layout.Clone();
            }

            if (!(target.Layout is null))
            {
                target.Layout.Window = target;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Clones <see cref="IDockWindow"/> object.
        /// </summary>
        /// <param name="source">The source object.</param>
        /// <returns>TThe new instance or reference of the <see cref="IDockWindow"/> class.</returns>
        public static IDockWindow CloneDockWindow(IDockWindow source)
        {
            source.Save();

            var dockWindow = source.Factory.CreateDockWindow();

            dockWindow.Id      = source.Id;
            dockWindow.X       = source.X;
            dockWindow.Y       = source.Y;
            dockWindow.Width   = source.Width;
            dockWindow.Height  = source.Height;
            dockWindow.Topmost = source.Topmost;
            dockWindow.Title   = source.Title;
            dockWindow.Layout  = (IRootDock)source.Layout?.Clone();
            if (dockWindow.Layout is IRootDock rootDock)
            {
                rootDock.Window = dockWindow;
            }

            return(dockWindow);
        }
Ejemplo n.º 17
0
        public void display(bool asPopup, ContainerControl parent, int x, int y, bool asCustomPanel, bool inTaskBar)
        {
            this.closeControl(true);
            if (parent != null)
            {
                this.controlParentControl = parent;
            }
            this.controlAsPopup = asPopup;
            int num = this.showTitleBar ? 30 : 0;

            if (!asPopup)
            {
                if (x != -10000)
                {
                    this.controlDockedX = x;
                    this.controlDockedY = y;
                }
                IDockWindow controlParentControl = (IDockWindow)this.controlParentControl;
                if (controlParentControl != null)
                {
                    controlParentControl.AddControl(this.m_self, this.controlDockedX, this.controlDockedY);
                    this.controlActive = true;
                }
            }
            else
            {
                if (!asCustomPanel)
                {
                    this.m_popup = new SHKForm();
                }
                else
                {
                    MyFormBase base2 = new MyFormBase {
                        ShowBar = this.showTitleBar
                    };
                    base2.setGradient(this.topGradientColor, this.bottomGradientColor);
                    this.m_popup = base2;
                }
                if (inTaskBar)
                {
                    this.m_popup.ShowInTaskbar = true;
                }
                this.m_popup.SuspendLayout();
                this.m_popup.Icon       = Resources.shk_icon;
                this.m_popup.ClientSize = new Size(this.m_self.Size.Width, this.m_self.Size.Height);
                bool flag = false;
                if (this.m_self.Name == "ChatScreen")
                {
                    flag = true;
                    this.m_popup.MaximizeBox             = true;
                    this.m_popup.MinimizeBox             = true;
                    this.m_popup.ControlBox              = true;
                    this.m_popup.FormClosing            += new FormClosingEventHandler(((ChatScreen)this.m_self).closeClickForm);
                    ((MyFormBase)this.m_popup).Resizable = true;
                }
                else
                {
                    this.m_popup.MaximizeBox = false;
                    this.m_popup.MinimizeBox = false;
                    this.m_popup.ControlBox  = false;
                }
                this.m_popup.Name = this.m_self.Name + "Popup";
                if (this.controlPopupX == -10000)
                {
                    this.m_popup.StartPosition = FormStartPosition.WindowsDefaultLocation;
                }
                else
                {
                    this.m_popup.StartPosition = FormStartPosition.Manual;
                    this.m_popup.Location      = new Point(this.controlPopupX, this.controlPopupY);
                }
                if (!asCustomPanel)
                {
                    this.m_self.Location = new Point(0, 0);
                }
                else
                {
                    this.m_self.Location       = new Point(0, num);
                    this.m_popup.StartPosition = FormStartPosition.CenterScreen;
                }
                this.m_popup.Text = this.popupTitle;
                if (asCustomPanel)
                {
                    ((MyFormBase)this.m_popup).Title = this.popupTitle;
                    this.m_popup.Text        = this.popupTitle;
                    this.m_self.Anchor       = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
                    this.m_popup.MinimumSize = new Size(this.m_self.Width, this.m_self.Height + num);
                }
                else if (this.sizeableWindow)
                {
                    this.m_self.Anchor       = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
                    this.m_popup.MinimumSize = new Size(this.m_self.MinimumSize.Width, this.m_self.MinimumSize.Height + num);
                }
                else
                {
                    this.m_popup.MinimumSize = new Size(this.m_self.Size.Width, this.m_self.Size.Height);
                }
                this.m_popup.Controls.Add(this.m_self);
                if (asCustomPanel)
                {
                    this.m_popup.FormBorderStyle = FormBorderStyle.None;
                    if (flag)
                    {
                        ((MyFormBase)this.m_popup).ShowClose = true;
                        ((MyFormBase)this.m_popup).showMinMax();
                    }
                }
                else if (!this.sizeableWindow)
                {
                    this.m_popup.FormBorderStyle = FormBorderStyle.FixedToolWindow;
                }
                else if (!flag)
                {
                    this.m_popup.FormBorderStyle = FormBorderStyle.SizableToolWindow;
                }
                else
                {
                    this.m_popup.FormBorderStyle = FormBorderStyle.Sizable;
                }
                this.m_popup.FormClosing += new FormClosingEventHandler(this.formClosingCallback);
                this.m_popup.ResumeLayout(false);
                this.m_popup.PerformLayout();
                this.m_popup.Font = FontManager.GetFont("Microsoft Sans Serif", 8.25f);
                this.m_popup.Show();
                this.controlPopupX = this.m_popup.Location.X;
                this.controlPopupY = this.m_popup.Location.Y;
                this.controlActive = true;
            }
        }
Ejemplo n.º 18
0
        public StartupViewModel(IShell shell, ISourcesCacheProvider cacheProvider, IDockWindow window)
        {
            _shell         = shell;
            _cacheProvider = cacheProvider;
            _window        = window;

            var appConfigStorage = new AppConfigStorage();
            var config           = appConfigStorage.Load();

            Title = "App settings";

            // Title

            AppTitle = shell.Title;
            this.WhenAnyValue(x => x.AppTitle)
            .Subscribe(x => shell.Title = x);

            // Theme

            Accent = config.Accent ?? "Blue";
            IsDark = config.IsDark;
            UpdateTheme();

            this.ObservableForProperty(x => x.Accent)
            .Subscribe(x =>
            {
                config.Accent = x.Value;
                appConfigStorage.Save(config);
                UpdateTheme();
            });
            this.ObservableForProperty(x => x.IsDark)
            .Subscribe(x =>
            {
                config.IsDark = x.Value;
                appConfigStorage.Save(config);
                UpdateTheme();
            });

            // Server Urls

            var urls = config.ServerUrl?
                       .Split(';')
                       .Select(x => Uri.TryCreate(x, UriKind.Absolute, out var result) ? result : null as Uri)
                       .Where(x => x != null)
                       .ToArray();

            ServerUrlsSource = new SourceList <Uri>();
            if (urls != null)
            {
                ServerUrlsSource.AddRange(urls);
                ServerUrl = urls.First();
            }

            ServerUrlsSource
            .Connect()
            .ObserveOnDispatcher()
            .Bind(out _serverUrls)
            .ToCollection()
            .Subscribe(items =>
            {
                config.ServerUrl = string.Join(";", items);
                appConfigStorage.Save(config);
            });

            this.WhenAnyValue(x => x.ServerUrl)
            .Skip(1)
            .Subscribe(_ => UpdateSourcesCache());

            // Authorization Tokens

            var tokens = config.AuthToken?
                         .Split(';')
                         .Where(x => !string.IsNullOrEmpty(x))
                         .ToArray();

            AuthTokensSource = new SourceList <string>();
            if (tokens != null)
            {
                AuthTokensSource.AddRange(tokens);
                AuthToken = tokens.First();
            }

            AuthTokensSource
            .Connect()
            .ObserveOnDispatcher()
            .Bind(out _authTokens)
            .ToCollection()
            .Subscribe(items =>
            {
                config.AuthToken = string.Join(";", items);
                appConfigStorage.Save(config);
            });

            this.WhenAnyValue(x => x.AuthToken)
            .Skip(1)
            .Subscribe(_ => UpdateSourcesCache());

            // Create Commands

            var hasUrl = this.WhenAny(x => x.ServerUrl, x => x.Value != null);

            NewLogCommand       = CreateCommandWithInit(NewLog, hasUrl);
            NewKeepAliveCommand = CreateCommandWithInit(NewKeepAlive, hasUrl);
            NewMetricsCommand   = CreateCommandWithInit(NewMetrics, hasUrl);

            RemoveEntitiesCommand = CreateCommandWithInit(RemoveEntities, hasUrl);
            ManageGroupsCommand   = CreateCommandWithInit(ManageGroups, hasUrl);

            RemoveUrlCommand       = ReactiveCommand.Create <Uri>(url => ServerUrlsSource.Remove(url));
            RemoveAuthTokenCommand = ReactiveCommand.Create <string>(token => AuthTokensSource.Remove(token));

            RefreshCommand = ReactiveCommand.CreateFromTask(Refresh, hasUrl);

            UpdateSourcesCache();
        }
Ejemplo n.º 19
0
 public void ShowSidebar()
 {
     try
     {
         if (_sidebarDock != null)
         {
             _sidebarDock.Show();
         }
         else if (_sidebar == null)
         {
             _sidebar = new SidebarForm(this);
             _sidebarDock = DockWindow(_sidebar, "Probe Sidebar", DockWindowAlignment.Left, k_dockWindowId);
             _sidebar.OnSidebarLoad(CurrentFile);
         }
     }
     catch (Exception ex)
     {
         Errors.Show(_nppWindow, ex);
     }
 }
Ejemplo n.º 20
0
 public void ShowCompilePanel()
 {
     try
     {
         if (_compilePanelDock != null)
         {
             _compilePanelDock.Show();
         }
         else if (_compilePanel == null)
         {
             _compilePanel = new CompilePanel(this);
             _compilePanelDock = DockWindow(_compilePanel, "Probe Compile", DockWindowAlignment.Bottom, k_compilePanelId);
             _compilePanel.OnPanelLoad();
         }
     }
     catch (Exception ex)
     {
         Errors.Show(_nppWindow, ex);
     }
 }
Ejemplo n.º 21
0
        public void FindInProbeFiles()
        {
            try
            {
                using (var form = new FindInProbeFiles.FindDialog())
                {
                    string selected = SelectedText;
                    if (!string.IsNullOrEmpty(selected) && !selected.Contains('\n'))
                    {
                        form.SearchText = selected;
                    }

                    if (form.ShowDialog(NppWindow) == DialogResult.OK)
                    {
                        if (_findInProbeFilesDock != null)
                        {
                            _findInProbeFilesDock.Show();
                        }
                        else
                        {
                            _findInProbeFilesPanel = new FindInProbeFiles.ResultsPanel();
                            _findInProbeFilesDock = DockWindow(_findInProbeFilesPanel, "Find in Probe Files", DockWindowAlignment.Bottom, k_findInProbeFilesPanelId);
                        }

                        if (_findInProbeFilesThread != null) _findInProbeFilesThread.Kill();

                        _findInProbeFilesThread = new FindInProbeFiles.FindThread();
                        _findInProbeFilesThread.Search(form.CreateFindArgs(_findInProbeFilesPanel));
                    }
                }
            }
            catch (Exception ex)
            {
                Errors.Show(NppWindow, ex);
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Removes window from windows list.
 /// </summary>
 /// <param name="dock">The views dock.</param>
 /// <param name="window">The window to remove.</param>
 public static void RemoveWindow(this IDock dock, IDockWindow window)
 {
     dock.Windows?.Remove(window);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes new instance of the <see cref="HostAdapter"/> class.
 /// </summary>
 /// <param name="window">The window instance.</param>
 public HostAdapter(IDockWindow window)
 {
     _window = window;
 }
Ejemplo n.º 24
0
 public static void ShowWebExceptionMessage(this IDockWindow window, WebException e)
 {
     ((MainWindow)window).ShowMessageAsync("Unsuccessful request", WebExceptionToString(e));
 }