示例#1
0
 /// <summary>
 /// Handler for Revit's DocumentClosing event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void OnApplicationDocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     if (revitDynamoModel != null)
     {
         revitDynamoModel.HandleApplicationDocumentClosing(e.Document);
     }
 }
示例#2
0
        private void dockManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            bool savedialogfunc(Dialog.Result r)
            {
                switch (r)
                {
                case Dialog.Result.Cancel:
                    e.Cancel = true;
                    break;

                case Dialog.Result.No:
                    //not call SaveActiveDocument() and close
                    break;

                case Dialog.Result.Yes:
                    SaveActiveDocument();
                    //Boot.Core.Workspace.RemoveDocument(GetActiveDocument());
                    break;

                default:
                    e.Cancel = true;
                    break;
                }
                return(true);
            }

            Dialog.Open(I18N.__("Save And close?"), "DSTEd", Dialog.Buttons.YesNoCancel, Dialog.Icon.Warning, savedialogfunc);
        }
示例#3
0
        /// <summary>
        /// Handles removal of updaters when Document closes.
        /// </summary>
        public void DocumentClosing(object sender, DocumentClosingEventArgs args)
        {
            try
            {
                var doc = args.Document;
                if (null == doc)
                {
                    return;
                }

                var centralPath = RevitUtil.GetCentralFilePath(doc);
                if (!configDictionary.ContainsKey(centralPath))
                {
                    return;
                }

                var config = configDictionary[centralPath];
                UpdaterUtil.UnregisterUpdaters(doc, config);
                configDictionary.Remove(centralPath);
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
示例#4
0
 private void DockingManager_OnDocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to close the document?", "Tips",
                         MessageBoxButton.YesNo) == MessageBoxResult.No)
     {
         e.Cancel = true;
     }
     else
     {
         foreach (var item in App.Locator.Main.ProgrammeFiles)
         {
             if (item.Des == e.Document.Title)
             {
                 item.IsActived = false;
                 var edi = App.Locator.TextModal.AllFileEditor;
                 for (int i = 0; i < edi.Count; i++)
                 {
                     if (edi[i].FileName.Equals(item.Des))
                     {
                         App.Locator.TextModal.AllFileEditor.Remove(edi[i]);
                         if (!App.Locator.TextModal.AllFileEditor.Any())
                         {
                             App.Locator.Main.CurProgmFile = string.Empty;
                             App.Locator.Main.CurEditor    = null;
                         }
                         break;
                     }
                 }
                 break;
             }
         }
     }
 }
示例#5
0
        private static void OnDocumentClosing(object source, DocumentClosingEventArgs args)
        {
            try
            {
                var doc = args.Document;
                if (doc == null || args.IsCancelled() || doc.IsFamilyDocument)
                {
                    return;
                }

                // (Konrad) Cleanup updaters.
                Tools.MissionControl.MissionControl.UnregisterUpdaters(doc);

                // (Konrad) Disconnect from Sockets.
                Socket?.Kill();

                // (Konrad) If any task windows are still open, let's shut them down.
                Messenger.Default.Send(new DocumentClosed {
                    CloseWindow = true
                });
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }
        }
示例#6
0
 private void DocumentClosingAction(object sender, DocumentClosingEventArgs even)
 {
     isThresholdChanged  = true;
     color_blue          = null;
     color_gray          = null;
     color_red           = null;
     settings            = null;
     keyNameToElementMap = null;
     current_doc         = null;
     m_uiApp.Idling     -= SettingIdlingHandler;
     m_uiApp.Idling     -= IdlingHandler;
     m_uiApp.Idling     -= ImageControlIdlingHandler;
     if (even.Document.IsModified)
     {
         even.Document.Save();
     }
     //关闭设置框
     if (this.SettingsForm != null && !this.SettingsForm.IsDisposed)
     {
         this.SettingsForm.Dispose();
         this.SettingsForm = null;
     }
     if (this.FatherImageForm != null && !this.FatherImageForm.IsDisposed)
     {
         this.FatherImageForm.Child.Dispose();
         this.FatherImageForm.Dispose();
         this.FatherImageForm = null;
     }
 }
示例#7
0
        public static void DocClosed(object sender, DocumentClosingEventArgs args)
        {
            Document currentDoc = args.Document;

            Autodesk.Revit.ApplicationServices.Application uiApp = currentDoc.Application;

            if (!currentDoc.IsFamilyDocument)
            {
                EventData ptdata = new EventData("ProjectTime");
                ptdata.DirSetup();
                string        fp    = currentDoc.PathName;
                BasicFileInfo bfi   = BasicFileInfo.Extract(fp);
                string        fpath = bfi.CentralPath.Split('\\').Last().Split('.').First();
                string        pnum  = currentDoc.ProjectInformation.Number.ToString();

                EventData odata = new EventData(pnum);
                string[]  Open  = File.ReadAllLines(odata.FileName);

                DateTime dtin = DateTime.MinValue;
                DateTime.TryParse(Open.Last().Split(',')[3], out dtin);
                if (dtin != DateTime.MinValue)
                {
                    long     timedif = ptdata.Time.Ticks - dtin.Ticks;
                    double   hours   = TimeSpan.FromTicks(timedif).TotalHours;
                    string[] lines   = new string[1];
                    lines[0] = ptdata.User + "," + pnum + "," + fpath + "," + ptdata.Time + "," + hours.ToString() + "," + Open.Last().Split(',')[4];
                    File.AppendAllLines(ptdata.FileName, lines);
                    File.Delete(odata.FileName);
                }
            }
        }
 private void dockManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to close the document?", "AvalonDock Sample", MessageBoxButton.YesNo) == MessageBoxResult.No)
     {
         e.Cancel = true;
     }
 }
示例#9
0
 private void DockingManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     e.Document.CanClose = false;
     if (e.Document.Content is DocumentViewModel documentModel)
     {
         Application.Current.Dispatcher.BeginInvoke(new Action(() => RemoveDocumentFromCollection(documentModel)), DispatcherPriority.Background);
     }
 }
示例#10
0
        public void CloseDocument(DocumentClosingEventArgs e)
        {
            e.SaveDialogResult = MessageBoxResult.No;
            e.Handled          = true;

            DictionaryBookmarks.Clear();
            SaveRecentFile(CurrentDocumentPath);
        }
示例#11
0
 private void DockingManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     if (e.Document.Content is EditorElement element)
     {
         element.Close();
     }
     UpdateWindowTitle();
 }
示例#12
0
 private void UnregisterSectionUpdaterOnClose(object source, DocumentClosingEventArgs args)
 {
     if (m_sectionUpdater != null)
     {
         UpdaterRegistry.UnregisterUpdater(m_sectionUpdater.GetUpdaterId());
         m_sectionUpdater = null;
     }
 }
示例#13
0
文件: Application.cs 项目: AMEE/revit
 private void UnregisterSectionUpdaterOnClose(object source, DocumentClosingEventArgs args)
 {
     if (m_sectionUpdater != null)
        {
        UpdaterRegistry.UnregisterUpdater(m_sectionUpdater.GetUpdaterId());
        m_sectionUpdater = null;
        }
 }
示例#14
0
        private static void OnDocumentClosing(object source, DocumentClosingEventArgs args)
        {
            var docToRemove = ModelProvider.Models.Where(x => x.Title == args.Document.Title);

            if (docToRemove != null)
            {
                ModelProvider.Models.Remove(docToRemove.FirstOrDefault());
            }
        }
示例#15
0
        private void DockManager_OnDocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            if (!_initialized)
            {
                return;
            }

            //Trace.WriteLine("Document: " + e.Document);
        }
示例#16
0
        public void lodApp_DocumentClosing(object sender, DocumentClosingEventArgs args)
        {
            AddInId val = args.get_Document().get_Application().get_ActiveAddInId();

            foreach (UpdaterId registeredUpdater in registeredUpdaters)
            {
                UpdaterRegistry.UnregisterUpdater(registeredUpdater);
            }
        }
示例#17
0
        private void DockingManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            var vm = ((IView)e.Document.Content).DataContext as DocumentViewModel;

            if (vm != null)
            {
                e.Cancel = (vm.CanClose() == false);
            }
        }
示例#18
0
        /// <summary>
        /// Event raised when a document is being closed by clicking the 'X' button in AvalonDock.
        /// </summary>
        private void avalonDockHost_DocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            var document = (TextFileDocumentViewModel)e.Document;

            if (!this.ViewModel.QueryCanCloseFile(document))
            {
                e.Cancel = true;
            }
        }
示例#19
0
        // this is a workaround similar to that described in
        // http://stackoverflow.com/questions/17185780/prevent-document-from-closing-in-dockingmanager?rq=1
        // where the main view code directly calls this method handling the docking manager closing event.
        // The scenario is the following: AvalonDock has its document handling mechanism, which should be
        // synchronized with the Caliburn Micro's one. CM is based on a screen conductor; when a screen
        // needs to be closed, the method TryClose is used to close it if possible (i.e. unless a guard
        // method tells the framework that the screen cannot be closed, e.g. because the document is dirty).
        // I found no elegant alternative to this workaround: when AD is closing the document, call
        // the underlying VM guard method and cancel if required; if not cancelled, then AD goes on closing
        // thus firing the DocumentClosed event. Handling this event I can call TryClose on CM so that the
        // viewmodel representing the closed document screen is correctly removed. I can be sure that this
        // will be the case, as TryClose has just been called in handling OnDocumentClosing. I cannot directly
        // call TryClose in OnDocumentClosing, as this would cause null object reference errors in AD.

        private void OnDocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            DocumentBase document = e.Document.Content as DocumentBase;

            if (document == null)
            {
                return;
            }

            e.Cancel = !document.CanClose();
        }
示例#20
0
        private void UnregisterViewportUpdaterOnClose(object source, DocumentClosingEventArgs args)
        {
            //idsToWatch.Clear();
            //m_oldSectionId = ElementId.InvalidElementId;

            if (m_viewportUpdater != null)
            {
                UpdaterRegistry.UnregisterUpdater(m_viewportUpdater.GetUpdaterId());
                m_viewportUpdater = null;
            }
        }
示例#21
0
        private void DockManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            var doc = e.Document.Content as IDockDocument;

            if (doc != null)
            {
                bool cancel = e.Cancel;
                doc.DocumentClosing(ref cancel);
                e.Cancel = cancel;
            }
        }
示例#22
0
 internal void OnClosing(object sender, DocumentClosingEventArgs e)
 {
     if (docdict.ContainsKey(e.Document))
     {
         docdict.Remove(e.Document);
     }
     else if (doclist.Contains(e.Document))
     {
         doclist.Remove(e.Document);
     }
 }
示例#23
0
        public void ScreenClosing(DocumentClosingEventArgs e)
        {
            var screen = e.Document.Content as VMScreenBase;

            if (screen != null && !screen.CloseAble)
            {
                //e.Document.CanClose = screen.CloseAble;//F
                e.Cancel = true;
                MessageBox.Show("亲,暂时不能关闭!");
            }
        }
示例#24
0
        private void UnregisterSectionUpdaterOnClose(object sender, DocumentClosingEventArgs e)
        {
            idsToWatch.Clear();
            m_oldSectionId = ElementId.InvalidElementId;

            if (m_sectionUpdater != null)
            {
                UpdaterRegistry.UnregisterUpdater(m_sectionUpdater.GetUpdaterId());
                m_sectionUpdater = null;
            }
        }
示例#25
0
        private void OnDockingManagerDocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            var control = e.Document.Content as DockingControl;

            if (control == null)
            {
                return;
            }

            e.Cancel = !control.CanClose();
        }
示例#26
0
        /// <summary>
        /// Handler for Revit's DocumentClosing event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnApplicationDocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            // Invalidate the cached active document value if it is the closing document.
            var activeDocumentHashCode = DocumentManager.Instance.ActiveDocumentHashCode;

            if (e.Document != null && (e.Document.GetHashCode() == activeDocumentHashCode))
            {
                DocumentManager.Instance.HandleDocumentActivation(null);
            }

            HandleApplicationDocumentClosing(e.Document);
        }
示例#27
0
        public void TabClosing(object sender, DocumentClosingEventArgs args)
        {
            var doc = args.Document.Content as IScreen;

            if (doc == null)
            {
                return;
            }

            args.Cancel = true; // cancel the default tab close action as we want to call

            doc.TryClose();     // TryClose and give the document a chance to block the close
        }
        /// <summary>
        /// Called when the docking manager is about to close a document.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DocumentClosingEventArgs" /> instance containing the event data.</param>
        private static void OnDockingManagerDocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            var containerView = e.Document;
            var view          = containerView.Content as IDocumentView;

            if (view != null)
            {
                if (!view.CloseDocument())
                {
                    e.Cancel = true;
                }
            }
        }
示例#29
0
        /// <summary>
        /// When DocumentClosing, update list models and disconnect to projects if models is current models
        /// </summary>
        /// <param name="source">The source<see cref="object"/></param>
        /// <param name="args">The args<see cref="DocumentClosingEventArgs"/></param>
        private static void OnDocumentClosing(object source, DocumentClosingEventArgs args)
        {
            //if (args.Document.Title == ModelProvider.Instance.CurrentModel.Title) AuthProvider.Instance.Disconnect();
            if (ModelProvider.Instance.CurrentModel != null && args.Document.Title == ModelProvider.Instance.CurrentModel.Title)
            {
                AuthProvider.Instance.Logout();
            }
            var docToRemove = ModelProvider.Instance.Models.Where(x => x.Title == args.Document.Title);

            if (docToRemove != null)
            {
                ModelProvider.Instance.Models.Remove(docToRemove.FirstOrDefault());
            }
        }
示例#30
0
        private void UnregisterUpdaterOnClosing(object source, DocumentClosingEventArgs args)
        {
            try
            {
                Document doc = args.Document;
                if (doc.IsWorkshared)
                {
                    string centralPath = FileInfoUtil.GetCentralFilePath(doc);
                    if (!string.IsNullOrEmpty(centralPath))
                    {
                        SingleSessionMonitor.CloseFile(centralPath);

                        if (configDictionary.ContainsKey(centralPath))
                        {
                            Configuration configFound = configDictionary[centralPath];
                            foreach (ProjectUpdater updater in configFound.updaters)
                            {
                                if (!updater.isUpdaterOn)
                                {
                                    continue;
                                }
                                if (updater.updaterId.ToLower() == doorUpdater.UpdaterGuid.ToString().ToLower())
                                {
                                    doorUpdater.Unregister(doc);
                                }
                                else if (updater.updaterId.ToLower() == dtmUpdater.UpdaterGuid.ToString().ToLower())
                                {
                                    dtmUpdater.Unregister(doc);
                                }
                                else if (updater.updaterId.ToLower() == revisionUpdater.UpdaterGuid.ToString().ToLower())
                                {
                                    revisionUpdater.Unregister(doc);
                                }
                            }
                            configDictionary.Remove(centralPath);
                        }

                        if (SingleSessionMonitor.OpenedDocuments.Count == 0)
                        {
                            DisconnectSocket();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.AppendLog("UnregisterUpdaterOnClosing:" + ex.Message);
            }
        }
        private void DockingManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            var document = (DocumentVM)e.Document.Content;

            if (document != null)
            {
                this.ViewModel.CloseDocument(document);
            }

            if (this.ViewModel.Documents.Count == 0)
            {
                this.ViewModel.ActiveDocument = null;
            }

            e.Cancel = true;
        }
示例#32
0
 private void DocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     var doc = e.Document;
     _sessionManager.FinaliseSession(doc);
 }
示例#33
0
 /// <summary>
 /// Raises the <see cref="BeforeDocumentChanged"/> event.
 /// </summary>
 /// <param name="e">An System.EventArgs that contains the event data.</param>
 /// <returns>True if changing should be canceled, False otherwise</returns>
 protected virtual bool OnBeforeDocumentChanged(DocumentClosingEventArgs e)
 {
     if (BeforeDocumentChanged != null)
         BeforeDocumentChanged(this, e);
     return e.Cancel;
 }
示例#34
0
 /// <summary>
 /// Handler for Revit's DocumentClosing event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void OnApplicationDocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     if (revitDynamoModel != null)
     {
         revitDynamoModel.HandleApplicationDocumentClosing(e.Document);
     }
 }
示例#35
0
 private void dockManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to close the document?", "AvalonDock Sample", MessageBoxButton.YesNo) == MessageBoxResult.No)
         e.Cancel = true;
 }
示例#36
0
		private void ManagerLayoutPartClosing(object sender, DocumentClosingEventArgs e)
		{
			var layoutPartViewModel = e.Document.Content as LayoutPartViewModel;
			if (layoutPartViewModel != null)
			{
				LayoutParts.Remove(layoutPartViewModel);
				e.Cancel = true;
			}
		}
        void OnDocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            //serialize actual settings
            var xmlString = SerializationHelper.Serialize<ProjectSettingsData>(_data);

            //add resulting XML string to the entity
            var field = _schema.GetField(FieldNameData);
            _entity.Set(field, xmlString);

            //save actual settings
            _element.SetEntity(_entity);

            //remove this from the static cache
            Cache.Remove(_element.Document);
        }
        /// <summary>
        /// Event raised when an AvalonDock DocumentContent is being closed.
        /// </summary>
        private void documentContent_Closing(object sender, CancelEventArgs e)
        {
            var documentContent = (DocumentContent)sender;
            var document = documentContent.DataContext;

            if (!disableClosingEvent)
            {
                if (this.DocumentClosing != null)
                {
                    //
                    // Notify the application that the document is being closed.
                    //
                    var eventArgs = new DocumentClosingEventArgs(document);
                    this.DocumentClosing(this, eventArgs);

                    if (eventArgs.Cancel)
                    {
                        //
                        // Closing of the document is to be cancelled.
                        //
                        e.Cancel = true;
                        return;
                    }
                }
            }

            documentContent.Closing -= new EventHandler<CancelEventArgs>(documentContent_Closing);
        }
示例#39
0
 /// <summary>
 /// Raises the <see cref="DocumentClosing"/> event.
 /// </summary>
 /// <param name="e">An System.EventArgs that contains the event data.</param>
 /// <returns>True if closing should be canceled, False otherwise</returns>
 protected virtual bool OnDocumentClosing(DocumentClosingEventArgs e)
 {
     if (DocumentClosing != null)
         DocumentClosing(this, e);
     return e.Cancel;
 }