Esempio n. 1
0
        public bool TryRemove(WorkspaceWindow window)
        {
            try
            {
                this._suppressEvent = true;

                TabItem dc = GetTabItem(window.Title);
                if (dc != null)
                {
                    var args = new WorkspaceWindowClosingEventArgs(window);
                    this.OnWindowClosing(args);
                    if (args.Cancel)
                    {
                        return(false);
                    }

                    this._tabControl.Items.Remove(dc);

                    //处理内存泄漏:当没有页签时,清除SelectedItem属性,
                    //否则仍旧保留了最后一个页面的值在DependencyObject的_effectiveValues中
                    if (this._tabControl.Items.Count == 0)
                    {
                        this._tabControl.SelectedItem = null;
                    }

                    this.OnWindowClosed(new WorkspaceWindowChangedEventArgs(window, null));
                }

                return(true);
            }
            finally
            {
                this._suppressEvent = false;
            }
        }
Esempio n. 2
0
        private void OnWindowClosing(WorkspaceWindowClosingEventArgs e)
        {
            var handler = this.WindowClosing;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 3
0
 private void OnWindowClosing(WorkspaceWindowClosingEventArgs e)
 {
     var handler = this.WindowClosing;
     if (handler != null) handler(this, e);
 }
Esempio n. 4
0
        public bool TryRemove(WorkspaceWindow window)
        {
            try
            {
                this._suppressEvent = true;

                TabItem dc = GetTabItem(window.Title);
                if (dc != null)
                {
                    var args = new WorkspaceWindowClosingEventArgs(window);
                    this.OnWindowClosing(args);
                    if (args.Cancel) { return false; }

                    this._tabControl.Items.Remove(dc);

                    //处理内存泄漏:当没有页签时,清除SelectedItem属性,
                    //否则仍旧保留了最后一个页面的值在DependencyObject的_effectiveValues中
                    if (this._tabControl.Items.Count == 0)
                    {
                        this._tabControl.SelectedItem = null;
                    }

                    this.OnWindowClosed(new WorkspaceWindowChangedEventArgs(window, null));
                }

                return true;
            }
            finally
            {
                this._suppressEvent = false;
            }
        }
Esempio n. 5
0
 void workSpace_WindowClosing(object sender, WorkspaceWindowClosingEventArgs e)
 {
     if (e.Window == this._ownerWindow)
     {
         this.SaveIfDirty(() => e.Cancel = true);
     }
 }