private bool DeactivateCurrentView()
 {
     if (this._currentView == null)
     {
         return true;
     }
     bool flag = false;
     if (this._currentView.view.CanDeactivate)
     {
         bool flag2 = true;
         if (this._currentView.view.IsDirty)
         {
             flag2 = this._currentView.view.SaveToDocument();
         }
         if (flag2)
         {
             this._currentView.view.Deactivate(false);
             this._currentView = null;
             flag = true;
         }
     }
     return flag;
 }
 protected override void OnSelectedIndexChanged(EventArgs e)
 {
     this._currentView = null;
     int selectedIndex = this.SelectedIndex;
     if ((selectedIndex != -1) && (selectedIndex < this._views.Count))
     {
         this._currentView = (MultiViewDocumentWindow.ViewInfo) this._views[selectedIndex];
         this.ActivateCurrentView(true);
     }
     base.OnSelectedIndexChanged(e);
 }
 void IDocumentView.Activate(bool viewSwitch)
 {
     if (this._defaultViewIndex != -1)
     {
         this._currentView = (MultiViewDocumentWindow.ViewInfo) this._views[this._defaultViewIndex];
         this.SelectedIndex = this._defaultViewIndex;
         this._defaultViewIndex = -1;
     }
     if (this._currentView != null)
     {
         this._currentView.view.Activate(viewSwitch);
     }
 }
 void IDocumentView.Deactivate(bool closing)
 {
     if (this._currentView != null)
     {
         this._currentView.view.Deactivate(closing);
         this._currentView = null;
     }
 }
 public void AddChildView(Control viewControl, bool isDefault)
 {
     if (viewControl == null)
     {
         throw new ArgumentNullException("viewControl");
     }
     IDocumentView view = viewControl as IDocumentView;
     if (view == null)
     {
         throw new ArgumentException("viewControl must implement IDocumentView", "viewControl");
     }
     MultiViewDocumentWindow.ViewInfo info = new MultiViewDocumentWindow.ViewInfo();
     Image viewImage = view.ViewImage;
     int num = -1;
     if (viewImage != null)
     {
         base.ImageList.Images.Add(viewImage);
         num = base.ImageList.Images.Count - 1;
     }
     string viewName = view.ViewName;
     if (viewName == null)
     {
         viewName = string.Empty;
     }
     viewControl.Dock = DockStyle.Fill;
     Microsoft.Matrix.UIComponents.TabPage page = new Microsoft.Matrix.UIComponents.TabPage();
     page.Text = viewName;
     page.ImageIndex = num;
     if (this._viewBorderStyle == BorderStyle.FixedSingle)
     {
         page.BackColor = SystemColors.ControlDark;
         page.DockPadding.All = 1;
     }
     page.Controls.Add(viewControl);
     base.Tabs.Add(page);
     info.view = view;
     info.viewTab = page;
     info.viewCommandHandler = view as ICommandHandler;
     info.viewToolboxClient = view as IToolboxClient;
     info.viewSelectionContainer = view as ISelectionContainer;
     info.view.DocumentChanged += new EventHandler(this.OnViewDocumentChanged);
     this._views.Add(info);
     if (isDefault || (base.Tabs.Count == 1))
     {
         this._currentView = info;
         this._defaultViewIndex = base.Tabs.Count - 1;
     }
 }