protected override void OnTabClosing(CancelableMdiTabEventArgs e)
        {
            base.OnTabClosing(e);

            // just in case the user of the mdi tab workspace
            // wants the tab to be opened, cancel it if the workspace
            // is being explicitly told to remove the smart part
            if (e.Tab == this.tabForcingClosed)
            {
                e.Cancel = false;
            }

            if (!e.Cancel && this.composer.ContainsItem(e.Tab))
            {
                // TODO call off their close method?

                Control smartPart = this.GetSmartPart(e.Tab);

                if (null != smartPart)
                {
                    WorkspaceCancelEventArgs args = new WorkspaceCancelEventArgs(smartPart);

                    this.OnSmartPartClosing(args);

                    if (args.Cancel)
                    {
                        e.Cancel = true;
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Raises the <see cref="SmartPartClosing"/> event using the specified
 /// event argument.
 /// </summary>
 /// <param name="e">The arguments to pass to the event.</param>
 protected void RaiseSmartPartClosing(WorkspaceCancelEventArgs e)
 {
     if (this.SmartPartClosing != null)
     {
         this.SmartPartClosing(this, e);
     }
 }
        private void SmartPartClosingEventHandler(object sender, WorkspaceCancelEventArgs e)
        {
            // SCC has detected the user wants to close a control ...
            object o1 = e.SmartPart;

            if (o1 is IDialogView)
            {
                IDialogView OmsControl = o1 as DialogView;
                if (OmsControl.IsOKToClose())
                {
                    // backend has already confirmed it is OK to close, go on and close ...
                    e.Cancel = false;
                }
                else
                {
                    // do not close the control yet, backend has to confirm it is OK first
                    e.Cancel = true;
                    object o2 = OmsControl.TrimControl;
                    if (o2 is inUC)
                    {
                        inUC TrimControl = o2 as inUC;
                        TrimControl.requestClose();
                    }
                }
            }
        }
Beispiel #4
0
 public void RaiseSmartPartClosing(WorkspaceCancelEventArgs e)
 {
     if (SmartPartClosing != null)
     {
         SmartPartClosing(this, e);
     }
 }
Beispiel #5
0
        private void Workspace_AskSaveWorkspace(object sender, WorkspaceCancelEventArgs e)
        {
            var result = MessageBox.Show("Sie haben ungespeicherte Änderungen, möchten Sie diese Speichern?", "ungespeicherte Änderungen", MessageBoxButton.YesNoCancel, MessageBoxImage.Information);

            e.Cancel = result == MessageBoxResult.Cancel;
            e.DoSave = result == MessageBoxResult.Yes;
        }
 /// <summary>
 /// Raises the <see cref="SmartPartClosing"/> event.
 /// </summary>
 protected virtual void OnSmartPartClosing(WorkspaceCancelEventArgs e)
 {
     if (SmartPartClosing != null)
     {
         SmartPartClosing(this, e);
     }
 }
Beispiel #7
0
        private void WorkspaceSmartPartClosing(object sender, WorkspaceCancelEventArgs e)
        {
            if (e.SmartPart == editorView)
            {
                if (editorView.Modified)
                {
                    DialogResult result = MessageBox.Show("Do you want to save the changes to " + DocumentTitle + "?",
                                                          Application.ProductName, MessageBoxButtons.YesNoCancel,
                                                          MessageBoxIcon.Warning);
                    switch (result)
                    {
                    case DialogResult.Yes:
                        BundleRuntime.Instance.GetFirstOrDefaultService <ICommandBusService>().PublicCommand(
                            CommandNames.Save);
                        //WorkItem.Commands[CommandNames.Save].Execute();
                        break;

                    case DialogResult.No:
                        break;

                    case DialogResult.Cancel:
                        e.Cancel = true;
                        break;

                    default:
                        Debug.Assert(false, "The default case is not allowed!");
                        break;
                    }
                }
            }
        }
 void _deckWorkspace_SmartPartClosing(object sender, WorkspaceCancelEventArgs e)
 {
     if (_smartParts.ContainsKey(e.SmartPart))
     {
         _toolStrip.Items.Remove(_smartParts[e.SmartPart]);
     }
 }
        private void WorkspaceSmartPartClosingEventHandler(object sender, WorkspaceCancelEventArgs e)
        {
            EventHandler <WorkspaceCancelEventArgs> temp = SmartPartClosing;

            if (temp != null)
            {
                temp(sender, e);
            }
        }
Beispiel #10
0
 /// <summary>
 /// Called as a smart part is closing.  We need to save the layout if we are closing the tab view
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void AuditTrail_SmartPartClosing(object sender, WorkspaceCancelEventArgs e)
 {
     // Ok which smart part is closing - if a tab view call it's save layout function
     if (e.SmartPart == WorkItem.Items[Layton.Cab.Interface.ViewNames.MainTabView])
     {
         AuditTrailTabView tabView = e.SmartPart as AuditTrailTabView;
         tabView.SaveLayout();
     }
 }
Beispiel #11
0
        private void OnSmartPartClosing(object sender, WorkspaceCancelEventArgs e)
        {
            Control control = (Control)e.SmartPart;

            if (control != null)
            {
                Shell.ErrorListControl.RemoveAll(control);
            }
        }
 private void SmartPartClosing(object sender, WorkspaceCancelEventArgs e)
 {
     if (e.SmartPart == view)
     {
         var workSpace = BundleRuntime.Instance.GetFirstOrDefaultService <IWorkspace>();
         // Do not close the window, only hide it.
         workSpace.Hide(view);
         e.Cancel = true;
     }
 }
Beispiel #13
0
        private WorkspaceCancelEventArgs FireWindowFormClosing(object smartPart)
        {
            WorkspaceCancelEventArgs e = new WorkspaceCancelEventArgs(smartPart);

            if (this.WindowFormClosing != null)
            {
                this.WindowFormClosing(this, e);
            }
            return(e);
        }
Beispiel #14
0
 /// <summary>
 /// 数据列表关闭事件
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Microsoft.Practices.CompositeUI.SmartParts.WorkspaceCancelEventArgs"/> instance containing the event data.</param>
 private void DataList_SmartPartClosing(object sender, WorkspaceCancelEventArgs e)
 {
     AuthorizationAttribute[] attrs = (AuthorizationAttribute[])e.SmartPart.GetType().GetCustomAttributes(typeof(AuthorizationAttribute), true);
     if (attrs.Length > 0)
     {
         try {
             StoreLayout((Control)e.SmartPart, attrs[0]);
         }
         catch { }
     }
 }
Beispiel #15
0
        private void contentWorkspace_SmartPartActivating(object sender, WorkspaceCancelEventArgs e)
        {
            //uncomment this code to see how you can use the SmartPartActivating event to optionally cancel smart part activations
            //NOTE: IWorkspace.SmartPartActivating is not a standard part of CAB, so note that you will be tying yourself to this implementation
            //of CAB. I had to add this event myself for my own benefit

            //if (MessageBox.Show("Navigate to '" + e.SmartPart + "'?", "Confirm Navigation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            //{
            //    e.Cancel = true;
            //}
        }
Beispiel #16
0
            private WorkspaceCancelEventArgs FireWindowFormClosing(object smartPart)
            {
                var cancelArgs = new WorkspaceCancelEventArgs(smartPart);

                if (WindowFormClosing != null)
                {
                    WindowFormClosing(this, cancelArgs);
                }

                return(cancelArgs);
            }
Beispiel #17
0
        /// <summary>
        /// Raises the <see cref="SmartPartClosing"/> event.
        /// </summary>
        /// <param name="smartPart">The smart part that is being closed.</param>
        protected WorkspaceCancelEventArgs RaiseSmartPartClosing(object smartPart)
        {
            if (smartPart is ElementHost)
            {
                smartPart = elementHosts.Unwrap((ElementHost)activeSmartPart);
            }
            WorkspaceCancelEventArgs cancelArgs = new WorkspaceCancelEventArgs(smartPart);

            RaiseSmartPartClosing(cancelArgs);

            return(cancelArgs);
        }
Beispiel #18
0
 protected override void OnClosing(CancelEventArgs e)
 {
     if (base.Controls.Count > 0)
     {
         WorkspaceCancelEventArgs args = this.FireWindowFormClosing(this.m_Control);
         e.Cancel = args.Cancel;
         if (!args.Cancel)
         {
             this.m_Control.Hide();
         }
     }
     base.OnClosing(e);
 }
Beispiel #19
0
 void ModuleController_SmartPartClosing(object sender, WorkspaceCancelEventArgs e)
 {
     log.Debug("PartModelingManager.ModuleController.ModuleController_SmartPartClosing");
     if (_partModelingWorkItem.Status != WorkItemStatus.Terminated)
     {
         log.Debug("Part modeling Terminate");
         _partModelingWorkItem.Terminate();
     }
     if (_sketcherWorkItem.Status != WorkItemStatus.Terminated)
     {
         log.Debug("Sketcher Terminate");
         _sketcherWorkItem.Terminate();
     }
 }
Beispiel #20
0
            /// <summary>
            /// Handles the Closing Event
            /// </summary>
            /// <param name="e"></param>
            protected override void OnClosing(CancelEventArgs e)
            {
                if (Controls.Count > 0)
                {
                    WorkspaceCancelEventArgs cancelArgs = FireWindowFormClosing(Controls[0]);
                    e.Cancel = cancelArgs.Cancel;

                    if (cancelArgs.Cancel == false && Controls.Count > 0)
                    {
                        Controls[0].Hide();
                    }
                }

                base.OnClosing(e);
            }
 private void DockPanel_ClosingPanel(object sender, DockPanelCancelEventArgs e)
 {
     if (sender != null && sender is DockPanel)
     {
         foreach (KeyValuePair <Control, DockPanel> kvp in DockPanels)
         {
             if (kvp.Value == sender)
             {
                 WorkspaceCancelEventArgs canc = RaiseSmartPartClosing(kvp.Key);
                 e.Cancel = canc.Cancel;
                 break;
             }
         }
     }
     RaiseSmartPartClosing(e);
 }
Beispiel #22
0
        /// <summary>
        /// Closes the smart part and resets (sets to null) the <see cref="ActiveSmartPart"/>.
        /// </summary>
        /// <exception cref="ArgumentException">The smartPart
        /// was not previously shown in the workspace.</exception>
        /// <exception cref="ArgumentException">The smartPart cannot be
        /// assigned to TSmartPart.</exception>
        public void Close(object smartPart)
        {
            Guard.ArgumentNotNull(smartPart, "smartPart");
            if (smartPart is UIElement)
            {
                smartPart = elementHosts.Wrap(smartPart as UIElement);
            }
            ThrowIfUnsupportedSP(smartPart);
            ThrowIfSmartPartNotShownPreviously((TSmartPart)smartPart);

            WorkspaceCancelEventArgs cancelArgs = RaiseSmartPartClosing(smartPart);

            if (cancelArgs.Cancel == false)
            {
                CloseInternal((TSmartPart)smartPart);
            }
        }
        public DockWorkspace()
        {
            _composer = new WorkspaceComposer <UIElement, SmartPartInfo>(this);

            Workspace workspace = new Workspace();

            workspace.Background = null;

            TabbedMdiHost host = new TabbedMdiHost();

            workspace.Content = host;

            TabbedMdiContainer container = new TabbedMdiContainer();

            host.Content = container;

            this.Content = workspace;

            this.WindowClosing += (s, e) =>
            {
                if (!_isLoading)
                {
                    WorkspaceCancelEventArgs args = new WorkspaceCancelEventArgs(e.Window.Content);
                    RaiseSmartPartClosing(args);
                    e.Cancel = args.Cancel;
                }
            };

            this.WindowClosed += (s, e) =>
            {
                if (!_isLoading)
                {
                    _isClosing = true;
                    Close(e.Window.Content);
                    _isClosing = false;
                }
            };

            this.WindowActivated += (s, e) =>
            {
                Activate(e.Window.Content);
            };
        }
        public void Close(object smartPart)
        {
            if (smartParts.IndexOf(smartPart) >= 0)
            {
                WorkspaceCancelEventArgs args = new WorkspaceCancelEventArgs(smartPart);

                RaiseSmartPartClosing(args);

                if (!args.Cancel)
                {
                    smartParts.Remove(smartPart);

                    RaiseSmartPartClosed(new WorkspaceEventArgs(smartPart));

                    if (smartParts.Count > 0)
                    {
                        Activate(smartParts[smartParts.Count - 1]);
                    }
                }
            }
        }
        private void SmartPartClosingEventHandler(object sender, WorkspaceCancelEventArgs e)
        {
            NavigationEntry entry = FindEntryForSmartPart(e.SmartPart);

            historyList.Remove(entry);
            navigationEntryCollection.Remove(entry);

            if (historyList.Count > 1)
            {
                Activate(historyList[0].SmartPart);
            }
            else
            {
                if (historyList.Count > 0)
                {
                    ActivateEntry(historyList[0]);
                }
            }

            if (SmartPartClosing != null)
            {
                SmartPartClosing(this, e);
            }
        }
Beispiel #26
0
        public void Close(object smartPart)
        {
            UIElement element = smartPart as UIElement;

            if ((element != null) && (children.Contains(element)))
            {
                WorkspaceCancelEventArgs eventArgs = new WorkspaceCancelEventArgs(element);

                RaiseSmartPartClosing(eventArgs);

                if (!eventArgs.Cancel)
                {
                    int index = children.IndexOf(element);

                    if (index > -1)
                    {
                        while (children.Count > index)
                        {
                            UIElement child = children[children.Count - 1];
                            children.Remove(child);

                            RaiseSmartPartClosed(new WorkspaceEventArgs(child));
                        }

                        if (children.Count > 0)
                        {
                            Activate(children[children.Count - 1]);
                        }
                        else
                        {
                            this.Content = null;
                        }
                    }
                }
            }
        }
 void OnSmartPartClosingEvent(object sender, WorkspaceCancelEventArgs e)
 {
     composedWorkspace.RaiseSmartPartClosing(e);
 }
 /// <summary>
 /// See <see cref="IComposableWorkspace{TSmartPart, TSmartPartInfo}.RaiseSmartPartClosing"/> for more information.
 /// </summary>
 void IComposableWorkspace <Control, ZoneSmartPartInfo> .RaiseSmartPartClosing(WorkspaceCancelEventArgs e)
 {
     OnSmartPartClosing(e);
 }
Beispiel #29
0
 void IComposableWorkspace <UIElement, TabSmartPartInfo> .RaiseSmartPartClosing(WorkspaceCancelEventArgs e)
 {
     OnSmartPartClosing(e);
 }
Beispiel #30
0
 private void WindowFormClosing(object sender, WorkspaceCancelEventArgs e)
 {
     RaiseSmartPartClosing(e);
 }