示例#1
0
        private void OnActiveViewChanged(object sender, ViewChangeEventArgs e)
        {
            if (HandleActivatingCurrentSelectionProvidingDocumentView(e.View))
            {
                return;
            }

            var selectionProvider = e.View as ISelectionProvider;

            if (selectionProvider == null)
            {
                HandleDeactivatingCurrentSelectionProvidingDocumentView();

                return;
            }

            if (currentSelectionProvider != null)
            {
                currentSelectionProvider.SelectionChanged -= OnSelectionChanged;
            }

            currentSelectionProvider = selectionProvider;
            currentSelectionProvider.SelectionChanged += OnSelectionChanged;

            Selection = currentSelectionProvider.Selection;
        }
示例#2
0
        public void Constructor_WithoutView_ViewSet()
        {
            // Call
            var args = new ViewChangeEventArgs(null);

            // Assert
            Assert.IsNull(args.View);
        }
示例#3
0
        public void Constructor_WithView_ViewSet()
        {
            // Setup
            var view = new MockRepository().StrictMock <IView>();

            // Call
            var args = new ViewChangeEventArgs(view);

            // Assert
            Assert.AreSame(view, args.View);
        }
        private void handler_ViewChanged(object source, ViewChangeEventArgs e)
        {
            IModelView view = e.View;

            if (e.IsAdded)
            {
                foreach (IConstraint constraint in constraints)
                {
                    if (view != null)
                    {
                        IConstraint viewConstraint = constraint.InstallInView(view);
                        if (viewConstraint != null)
                        {
                            List <IConstraint> viewConstraintList;
                            viewConstraints.TryGetValue(view, out viewConstraintList);

                            if (viewConstraintList == null)
                            {
                                viewConstraints[view] = new List <IConstraint>();
                            }

                            viewConstraints[view].Add(viewConstraint);
                        }
                    }
                }
                if (view != null)
                {
                    view.PostContentChange += view_PostContentChange;
                    view.PreContentChange  += view_PreContentChange;
                }
            }
            else
            {
                List <IConstraint> viewConstraintList;
                viewConstraints.TryGetValue(view, out viewConstraintList);
                if (viewConstraintList != null)
                {
                    foreach (IConstraint constraint in viewConstraintList)
                    {
                        constraint.Dispose();
                    }
                    viewConstraintList.Clear();
                }

                if (view != null)
                {
                    viewConstraints.Remove(view);
                    view.PreContentChange  -= view_PreContentChange;
                    view.PostContentChange -= view_PostContentChange;
                }
            }
        }
示例#5
0
        private void ViewManagerViewChange(object sender, ViewChangeEventArgs e)
        {
            switch (e.Status)
            {
            case ViewChangeStatus.Change:
                // Show waiting dialog
                this.Enabled = false;
                this.toolStripStatus.Text         = "Loading ...";
                this.toolStripProgressBar.Visible = true;
                this.toolStripProgressBar.Style   = ProgressBarStyle.Continuous;
                this.toolStripProgressBar.Maximum = 100;
                this.toolStripProgressBar.Minimum = 0;
                this.toolStripProgressBar.Value   = 30;

                this.Update();
                break;

            case ViewChangeStatus.Changing:
                if (!e.IsInDialogMode)
                {
                    // Attach UI to the view
                    // this.pnlMainPanel.Controls.Clear();
                    // pnlMainPanel.Controls.Add(this.ViewManager.CurrentView.UI);
                    // this.Text = this.ViewManager.CurrentView.Name;
                    // this.ViewManager.CurrentView.UI.Dock = DockStyle.Fill;
                    this.Update();
                    this.toolStripProgressBar.Value = 80;
                }
                else
                {
                    // TODO Attach screen when it's needed to show in dialog
                    var viewDialog = new ViewDialog();
                    // viewDialog.AttachToView(this.ViewManager.CurrentView);
                    viewDialog.Closed += new EventHandler(ViewDialogClosed);
                    viewDialog.ShowDialog(this);
                }
                break;

            case ViewChangeStatus.Changed:
                // Close waiting dialog
                this.toolStripProgressBar.Value = 100;
                this.Update();
                this.toolStripStatus.Text = "Ready";
                this.Enabled = true;
                this.toolStripProgressBar.Visible = false;
                break;

            default:
                break;
            }
        }
示例#6
0
        private void OnViewClosed(object sender, ViewChangeEventArgs e)
        {
            if (ReferenceEquals(currentSelectionProvider, e.View))
            {
                currentSelectionProvider.SelectionChanged -= OnSelectionChanged;
                currentSelectionProvider = null;

                Selection = null;
            }

            if (!mainWindow.IsWindowDisposed)
            {
                mainWindow.ValidateItems();
            }
        }