Beispiel #1
0
 protected virtual void OnDockWindowCloseRequest(DockWindow window, out bool cancel)
 {
     if (window is DocumentWindow)
     {
         cancel = editorForm.ShowDialogAndSaveDocument(window) == null;
     }
     else
     {
         cancel = false;                 // for non document windows.
     }
 }
Beispiel #2
0
 public virtual void AddDockWindow(DockWindow window, bool floatingWindow, bool select)
 {
     if (floatingWindow)
     {
         AddToFloatspace(window, select);
     }
     else
     {
         AddToWorkspace(window, select);
     }
 }
        //TODO: remove "bool select"
        KryptonDockingFloatspace AddToFloatspace(DockWindow window, bool select, Point location, Size clientSize)
        {
            AddDockWindowInternal(window, true);

            var floatingWindow = dockingManager.AddFloatingWindow("DockingFloating", new KryptonPage[] { window.KryptonPage }, location, clientSize);

            //TEST: no need selection
            //if( select )
            //	SelectDockWindow( window );

            return(floatingWindow.FloatspaceElement);
        }
Beispiel #4
0
        protected KryptonWorkspaceCell GetWorkspaceCell(DockWindow window)
        {
            var space = dockingManager.FindPageElement(window.KryptonPage) as KryptonDockingSpace;

            if (space != null)
            {
                return(space.CellForPage(window.KryptonPage.UniqueName));
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        int GetDockWindowIndex(DockWindow window)
        {
            var cell = GetWorkspaceCell(window);

            if (cell != null)
            {
                return(cell.Pages.IndexOf(window.KryptonPage));
            }
            else
            {
                return(-1);
            }
        }
        protected override void OnDockWindowCloseRequest(DockWindow window, out bool cancel)
        {
            //disable closing 'Root object' on second level
            var documentWindow = window as DocumentWindow;

            if (documentWindow != null && documentWindow.ObjectOfWindow == documentWindow.Document.ResultObject && !documentWindow.OpenAsSettings)
            {
                cancel = true;
                return;
            }

            base.OnDockWindowCloseRequest(window, out cancel);
        }
        protected void AddDockWindowInternal(DockWindow window, bool allowDocking, KryptonPage existPage = null)
        {
            CreatePage(window, true, existPage);

            dockWindows.Add(window.KryptonPage, window);
            window.KryptonPage.Disposed       += KryptonPage_Disposed;
            window.KryptonPage.VisibleChanged += KryptonPage_VisibleChanged;

            if (!allowDocking)
            {
                window.KryptonPage.ClearFlags(KryptonPageFlags.DockingAllowAutoHidden | KryptonPageFlags.DockingAllowDocked);
            }

            OnDockWindowAdded(window);
        }
        KryptonDockingWorkspace AddToWorkspace(DockWindow window, bool select)
        {
            AddDockWindowInternal(window, false);

            var workspace = dockingManager.AddToWorkspace("DockingWorkspace", new KryptonPage[] { window.KryptonPage });

            // call PerformLayout() to workspace.DockableWorkspaceControl.ActiveCell update !
            workspace.DockableWorkspaceControl.PerformLayout();

            if (select)
            {
                SelectDockWindow(window);
            }

            return(workspace);
        }
        protected virtual KryptonPage CreatePage(DockWindow window, bool createCloseButton, KryptonPage existPage = null)
        {
            var uniqueName = window.IsSystemWindow ? window.GetType().Name : string.Empty;

            // unique name only for DockWindow.
            if (window is DocumentWindow)
            {
                Debug.Assert(string.IsNullOrEmpty(uniqueName));
            }

            KryptonPage page = existPage ?? CreatePage(uniqueName, createCloseButton);

            window.Dock = DockStyle.Fill;
            page.Controls.Add(window);
            return(page);
        }
        public virtual void SelectDockWindow(DockWindow window)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            var space = dockingManager.FindPageElement(window.KryptonPage) as KryptonDockingSpace;

            space.SelectPage(window.KryptonPage.UniqueName);

            // focus window
            var cell = space.CellForPage(window.KryptonPage.UniqueName);

            cell.Focus();
        }
        protected override void OnDockWindowLoading(DockWindow window, DockPageLoadingEventArgs e)
        {
            if (window == null)
            {
                var config = new WindowConfig();
                config.Load(e.XmlReader);

                window = EditorAPI.CreateWindowImpl(WorkspaceWindow.Document, config.ObjectPath, config.OpenAsSettings);
                AddDockWindowInternal(window, false, e.Page);
            }
            else
            {
                //window already created
            }

            //window.OnLoading( e.XmlReader );
        }
Beispiel #12
0
 public override void SelectDockWindow(DockWindow window)
 {
     if (window != null)
     {
         if (window is DocumentWindow wnd && wnd.IsWindowInWorkspace)
         {
             var workspaceWindow = FindWorkspaceWindow(wnd);
             if (workspaceWindow != null)
             {
                 workspaceWindow.WorkspaceController.SelectDockWindow(window);
             }
         }
         else
         {
             base.SelectDockWindow(window);
         }
     }
Beispiel #13
0
        //return: Cancel
        internal bool ShowDialogAndSaveDocument(DockWindow window)
        {
            var documentWindow = window as DocumentWindow;

            if (documentWindow == null)
            {
                return(false);
            }

            // If the page is dirty then we need to ask if it should be saved
            if (documentWindow.IsMainWindowInWorkspace && !documentWindow.IsDocumentSaved())
            {
                EDialogResult result;
                if (window.ShowDialogAndSaveDocumentAutoAnswer.HasValue)
                {
                    result = window.ShowDialogAndSaveDocumentAutoAnswer.Value;
                }
                else
                {
                    var text = EditorLocalization.Translate("General", "Save changes to the following files?") + "\n";
                    text  += "\n" + documentWindow.Document.Name;
                    result = EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNoCancel);
                }

                switch (result)
                {
                case EDialogResult.Cancel:

                    //!!!!тут?
                    EditorAPI.SetRestartApplication(false);

                    return(true);

                case EDialogResult.Yes:
                    //!!!!check error, return null
                    documentWindow.SaveDocument();
                    return(false);

                case EDialogResult.No:
                    return(false);
                }
            }

            return(false);
        }
        KryptonDockingWorkspace InsertToWorkspace(DockWindow window, bool select, int index)
        {
            AddDockWindowInternal(window, false);

            var workspace = dockingManager.ResolvePath("DockingWorkspace") as KryptonDockingWorkspace;

            workspace.CellInsert(workspace.DockableWorkspaceControl.ActiveCell, index, window.KryptonPage);

            // call PerformLayout() to workspace.DockableWorkspaceControl.ActiveCell update !
            //workspace.DockableWorkspaceControl.PerformLayout();

            if (select)
            {
                SelectDockWindow(window);
            }

            return(workspace);
        }
        public override void AddDockWindow(DockWindow window, bool floatingWindow, bool select)
        {
            Debug.Assert(window is DocumentWindow);

            var documentWindow = (DocumentWindow)window;

            if (documentWindow.Document == null)
            {
                throw new ArgumentNullException(nameof(documentWindow.Document));
            }

            if (documentWindow.Document != WorkspaceWindow.Document)
            {
                throw new ArgumentException(nameof(documentWindow.Document) + " should be equal to the " + nameof(WorkspaceWindow.Document));
            }

            base.AddDockWindow(window, floatingWindow, select);
        }
        protected override void OnDockWindowRemoved(DockWindow window)
        {
            Debug.Assert(window is DocumentWindow);
            Debug.Assert(((DocumentWindow)window).IsWindowInWorkspace);

            var documentWindow = (DocumentWindow)window;

            documentWindow.IsWindowInWorkspace = false;

            if (!relocationProcess & !disposing)
            {
                var ownerFormController = editorForm.WorkspaceController;

                // если закрывается "главное" окно, то закрываем все связанные окна в воркспейсе и сам воркспейс.
                if (documentWindow.IsMainWindowInWorkspace)
                {
                    // при закрытия воркспейса его дочерние окна будут удалены.
                    ownerFormController.RemoveDockWindow(WorkspaceWindow, true);
                }
                else
                {
                    // если после закрытия остаётся одно окно, то закрываем воркспейс.
                    // а оставшееся окно перемещаем в корневой воркспейс.
                    bool needWindowsRelocation = dockWindows.Count() == 1;
                    if (needWindowsRelocation)
                    {
                        relocationProcess = true;
                        var relocationWindow = dockWindows.First().Value;
                        this.RemoveDockWindow(relocationWindow, false);

                        ownerFormController.ReplaceDockWindow(WorkspaceWindow, relocationWindow, true, true);

                        relocationProcess = false;
                    }
                }
            }

            base.OnDockWindowRemoved(window);
        }
        public void ReplaceDockWindow(DockWindow oldWindow, DockWindow newWindow, bool disposeOldWindow, bool select)
        {
            if (IsWindowFloating(oldWindow))
            {
                var space          = (KryptonDockingFloatspace)dockingManager.FindPageElement(oldWindow.KryptonPage);
                var floatingWindow = space.GetParentType(typeof(KryptonDockingFloatingWindow)) as KryptonDockingFloatingWindow;

                var pos  = floatingWindow.FloatingWindow.Location;
                var size = floatingWindow.FloatingWindow.ClientSize;
                RemoveDockWindow(oldWindow, disposeOldWindow);
                AddToFloatspace(newWindow, select, pos, size);
            }
            else
            {
                int index = GetDockWindowIndex(oldWindow);
                if (index == -1)
                {
                    throw new Exception($"Window {oldWindow} not found !");
                }
                RemoveDockWindow(oldWindow, disposeOldWindow);
                InsertToWorkspace(newWindow, select, index);
            }
        }
Beispiel #18
0
        protected virtual KryptonPage CreatePage(DockWindow window, bool createCloseButton, KryptonPage existPage = null)
        {
            var uniqueName = window.IsSystemWindow ? window.GetType().Name : string.Empty;

            // unique name only for DockWindow.
            if (window is DocumentWindow)
            {
                Debug.Assert(string.IsNullOrEmpty(uniqueName));
            }

            KryptonPage page = existPage ?? CreatePage(uniqueName, createCloseButton);

            page.associatedDockWindow = window;

            window.Dock = DockStyle.Fill;

            var size = window.DefaultAutoHiddenSlideSize;

            page.AutoHiddenSlideSize = new Size(size.X, size.Y);

            page.Controls.Add(window);
            return(page);
        }
 public virtual void RemoveDockWindow(DockWindow window, bool dispose)
 {
     RemoveDockWindow(window.KryptonPage, dispose);
 }
Beispiel #20
0
        //public static List<DocumentWindow> GetDocumentWindowsOnSecondLevelWithObject( object obj )
        //{
        //	if( obj == null )
        //		Log.Fatal( "EditorAPI: GetDocumentWindowsOnSecondLevelWithObject: obj == null." );

        //	var result = new List<DocumentWindow>();

        //	foreach( var dockWindow in EditorForm.Instance.WorkspaceController.GetDockWindowsRecursive() )
        //	{
        //		var documentWindow = dockWindow as DocumentWindow;
        //		if( documentWindow != null && documentWindow.IsWindowInWorkspace && documentWindow.ObjectOfWindow == obj )
        //			result.Add( documentWindow );
        //	}

        //	return result;
        //}

        //public static void CloseDockWindowsOnSecondLevelWithObject( object obj )
        //{
        //	foreach( var window in GetDocumentWindowsOnSecondLevelWithObject( obj ) )
        //		window.Close();
        //}

        public static void SelectDockWindow(DockWindow window)
        {
            EditorForm.Instance.WorkspaceController.SelectDockWindow(window);
        }
 protected virtual void OnDockWindowLoading(DockWindow window, DockPageLoadingEventArgs e)
 {
 }
 protected virtual void OnDockWindowSaving(DockWindow window, DockPageSavingEventArgs e)
 {
 }
 //TODO: remove "bool select"
 KryptonDockingFloatspace AddToFloatspace(DockWindow window, bool select)
 {
     //!!!!save settings for each window
     window.CalculateBigSizeForFloatingWindowDependingScreenSize(out Point position, out Size size);
     return(AddToFloatspace(window, select, position, size));
 }
 protected virtual void OnDockWindowRemoved(DockWindow window)
 {
     //DockWindowRemoved?.Invoke(this, new DockWindowEventArgs(window));
 }
Beispiel #25
0
 public DockWindowEventArgs(DockWindow dockWindow)
 {
     DockWindow = dockWindow;
 }
        bool IsWindowFloating(DockWindow window)
        {
            var space = dockingManager.FindPageElement(window.KryptonPage);

            return(space is KryptonDockingFloatspace);
        }
        int GetDockWindowIndex(DockWindow window)
        {
            var cell = GetWorkspaceCell(window);

            return(cell.Pages.IndexOf(window.KryptonPage));
        }