Пример #1
0
        public bool CloseWindowSync()
        {
            var e = new WorkbenchWindowEventArgs(true, true);

            if (Closing != null)
            {
                foreach (var handler in Closing.GetInvocationList().Cast <WorkbenchWindowAsyncEventHandler> ())
                {
                    handler(this, e).Wait();
                    if (e.Cancel)
                    {
                        break;
                    }
                }
            }

            Closed?.Invoke(this, e);;
            return(true);
        }
Пример #2
0
        public bool CloseWindow(bool force, bool animate)
        {
            bool wasActive = workbench.ActiveWorkbenchWindow == this;
            WorkbenchWindowEventArgs args = new WorkbenchWindowEventArgs(force, wasActive);

            args.Cancel = false;
            OnClosing(args);
            if (args.Cancel)
            {
                return(false);
            }

            workbench.RemoveTab(tab.Index, animate);

            OnClosed(args);

            Destroy();
            return(true);
        }
Пример #3
0
        public bool CloseWindow(bool force, bool fromMenu, int pageNum)
        {
            bool wasActive = workbench.ActiveWorkbenchWindow == this;
            WorkbenchWindowEventArgs args = new WorkbenchWindowEventArgs(force, wasActive);

            args.Cancel = false;
            OnClosing(args);
            if (args.Cancel)
            {
                return(false);
            }

            if (fromMenu == true)
            {
                workbench.RemoveTab(tabControl.PageNum(this));
            }
            else
            {
                workbench.RemoveTab(pageNum);
            }
            OnClosed(args);

            if (subViewContents != null)
            {
                foreach (IAttachableViewContent sv in subViewContents)
                {
                    sv.Dispose();
                }
            }

            content.ContentNameChanged             -= new EventHandler(SetTitleEvent);
            content.DirtyChanged                   -= new EventHandler(SetTitleEvent);
            content.BeforeSave                     -= new EventHandler(BeforeSave);
            content.ContentChanged                 -= new EventHandler(OnContentChanged);
            content.WorkbenchWindow                 = null;
            IdeApp.Workbench.ActiveDocumentChanged -= ActiveDocumentChanged;
            content.Dispose();

            DetachFromPathedDocument();
            Destroy();
            return(true);
        }
Пример #4
0
        void OnWindowClosing(object sender, WorkbenchWindowEventArgs args)
        {
            IWorkbenchWindow window = (IWorkbenchWindow)sender;

            if (!args.Forced && window.ViewContent != null && window.ViewContent.IsDirty)
            {
                AlertButton result = MessageService.GenericAlert(Stock.Warning,
                                                                 GettextCatalog.GetString("Save the changes to document '{0}' before closing?", window.ViewContent.IsUntitled ? window.ViewContent.UntitledName : System.IO.Path.GetFileName(window.ViewContent.ContentName)),
                                                                 GettextCatalog.GetString("If you don't save, all changes will be permanently lost."),
                                                                 AlertButton.CloseWithoutSave, AlertButton.Cancel, window.ViewContent.IsUntitled ? AlertButton.SaveAs : AlertButton.Save);
                if (result == AlertButton.Save || result == AlertButton.SaveAs)
                {
                    if (window.ViewContent.ContentName == null)
                    {
                        FindDocument(window).Save();
                        args.Cancel = window.ViewContent.IsDirty;
                    }
                    else
                    {
                        try {
                            if (window.ViewContent.IsFile)
                            {
                                window.ViewContent.Save(window.ViewContent.ContentName);
                            }
                            else
                            {
                                window.ViewContent.Save();
                            }
                        }
                        catch (Exception ex) {
                            args.Cancel = true;
                            MessageService.ShowException(ex, GettextCatalog.GetString("The document could not be saved."));
                        }
                    }
                }
                else
                {
                    args.Cancel = result != AlertButton.CloseWithoutSave;
                }
            }
        }
Пример #5
0
 void CloseWindowEvent(object sender, WorkbenchWindowEventArgs e)
 {
     SdiWorkspaceWindow f = (SdiWorkspaceWindow) sender;
     if (f.ViewContent != null)
         CloseContent (f.ViewContent);
 }
		void CloseWindowEvent (object sender, WorkbenchWindowEventArgs e)
		{
			SdiWorkspaceWindow f = (SdiWorkspaceWindow) sender;
			
			// Unsubscribe events to avoid memory leaks
			f.TabLabel.CloseClicked -= new EventHandler (closeClicked);
			
			if (f.ViewContent != null) {
				CloseContent (f.ViewContent);
				if (e.WasActive && !SelectLastActiveWindow (f))
					OnActiveWindowChanged(this, null);
			}
			lastActiveWindows.Remove (f);
		}
Пример #7
0
		void CloseWindowEvent (object sender, WorkbenchWindowEventArgs e)
		{
			SdiWorkspaceWindow f = (SdiWorkspaceWindow) sender;
			lastActiveWindows.Remove (f);

			if (f.ViewContent != null) {
				CloseContent (f.ViewContent);
				if (e.WasActive && !SelectLastActiveWindow (f))
					OnActiveWindowChanged(this, null);
			}
			lastActiveWindows.Remove (f);
		}
Пример #8
0
		protected virtual void OnClosed (WorkbenchWindowEventArgs e)
		{
			if (Closed != null) {
				Closed (this, e);
			}
		}
Пример #9
0
		public bool CloseWindow (bool force, bool fromMenu, int pageNum)
		{
			bool wasActive = workbench.ActiveWorkbenchWindow == this;
			WorkbenchWindowEventArgs args = new WorkbenchWindowEventArgs (force, wasActive);
			args.Cancel = false;
			OnClosing (args);
			if (args.Cancel)
				return false;
			if (fromMenu == true) {
				workbench.RemoveTab (tabControl.PageNum(this));
			} else {
				workbench.RemoveTab (pageNum);
			}
			OnClosed (args);
			
			content.ContentNameChanged -= new EventHandler(SetTitleEvent);
			content.DirtyChanged       -= new EventHandler(SetTitleEvent);
			content.BeforeSave         -= new EventHandler(BeforeSave);
			content.ContentChanged     -= new EventHandler (OnContentChanged);
			content.WorkbenchWindow = null;
			
			if (subViewContents != null) {
				foreach (IAttachableViewContent sv in subViewContents) {
					subViewNotebook.Remove (sv.Control);
					sv.Dispose ();
				}
				this.subViewContents = null;
				subViewNotebook.Remove (content.Control);
			}
			DetachFromPathedDocument ();
			content.Dispose ();
			box.Destroy ();
			
			this.subViewToolbar = null;
			this.separatorItem = null;
			
			this.content = null;
			this.subViewNotebook = null;
			this.tabControl = null;
			tabLabel.Destroy ();
			this.tabLabel = null;
			this.tabPage = null;
			
			Destroy ();
			return true;
		}
Пример #10
0
		void workbenchWindowClosingHandler (object sender, WorkbenchWindowEventArgs args)
		{
			if (!disposed)
				Dispose ();
			blockSelected = true;
		}
Пример #11
0
        void OnWindowClosing(object sender, WorkbenchWindowEventArgs args)
        {
            IWorkbenchWindow window = (IWorkbenchWindow)sender;

            if (!args.Forced && window.ViewContent != null && window.ViewContent.IsDirty)
            {
                // This path can be reentered if something else tries to close the window
                // before the user responds to the "Save changes?" dialog.
                // This results in a stack of "Save changes?" dialogs, and unpredictable behavior
                // when responding to all but the first.
                // The Right Fix would be to make it impossible for this to happen.
                // For now, we work around by replacing the OnClosing handler
                // until we get an answer back from the user.
                WorkbenchWindowEventHandler dummyClosing = (aSender, someArgs) => { someArgs.Cancel = true; };
                window.Closing -= OnWindowClosing;
                window.Closing += dummyClosing;

                try {
                    AlertButton result = MessageService.GenericAlert(Stock.Warning,
                                                                     GettextCatalog.GetString("Save the changes to document '{0}' before closing?",
                                                                                              window.ViewContent.IsUntitled
                                                                ? window.ViewContent.UntitledName
                                                                : System.IO.Path.GetFileName(window.ViewContent.ContentName)),
                                                                     GettextCatalog.GetString("If you don't save, all changes will be permanently lost."),
                                                                     AlertButton.CloseWithoutSave, AlertButton.Cancel, window.ViewContent.IsUntitled ? AlertButton.SaveAs : AlertButton.Save);
                    if (result == AlertButton.Save || result == AlertButton.SaveAs)
                    {
                        if (window.ViewContent.ContentName == null)
                        {
                            FindDocument(window).Save();
                            args.Cancel = window.ViewContent.IsDirty;
                        }
                        else
                        {
                            try {
                                if (window.ViewContent.IsFile)
                                {
                                    window.ViewContent.Save(window.ViewContent.ContentName);
                                }
                                else
                                {
                                    window.ViewContent.Save();
                                }
                            }
                            catch (Exception ex) {
                                args.Cancel = true;
                                MessageService.ShowException(ex, GettextCatalog.GetString("The document could not be saved."));
                            }
                        }
                    }
                    else
                    {
                        args.Cancel = result != AlertButton.CloseWithoutSave;
                        if (!args.Cancel)
                        {
                            window.ViewContent.DiscardChanges();
                        }
                    }
                } finally {
                    window.Closing -= dummyClosing;
                    window.Closing += OnWindowClosing;
                }
            }
        }
		void workbenchWindowClosingHandler (object sender, WorkbenchWindowEventArgs args)
		{
			if (activated)
				suppressSerialisation = true;
		}