Example #1
0
        event_DocumentToBeDestroyed(object sender, AcApp.DocumentCollectionEventArgs e)
        {
            // if the reactor instance exists and if the relevant checkbox is ticked in the Reactors UI
            if (MgdDbg.Reactors.Forms.EventsForm.m_dbEvents.AreEventsEnabled)
            {
                MgdDbg.Reactors.Forms.EventsForm.m_dbEvents.DisableEvents(e.Document.Database); // will turn off just for this new document
            }

            if (MgdDbg.Reactors.Forms.EventsForm.m_dbObjEvents.AreEventsEnabled)
            {
                MgdDbg.Reactors.Forms.EventsForm.m_dbObjEvents.DisableEvents(e.Document.Database); // will turn off just for this new document
            }

            if (MgdDbg.Reactors.Forms.EventsForm.m_docEvents.AreEventsEnabled)
            {
                MgdDbg.Reactors.Forms.EventsForm.m_docEvents.DisableEvents(e.Document);         // will turn off just for this new document
            }

            if (MgdDbg.Reactors.Forms.EventsForm.m_edEvents.AreEventsEnabled)
            {
                MgdDbg.Reactors.Forms.EventsForm.m_edEvents.DisableEvents(e.Document.Editor);   // will turn off just for this new document
            }

            if (MgdDbg.Reactors.Forms.EventsForm.m_gsEvents.AreEventsEnabled)
            {
                MgdDbg.Reactors.Forms.EventsForm.m_gsEvents.DisableEvents(e.Document.GraphicsManager);   // will turn off just for this new document
            }
        }
Example #2
0
        //每个Document被创建的时候,我们需要注册Event监控命令的执行
        //例如PxImportSHPToPipeNetwork,这些命令创建的 通信 管道,我们需要开始监控他的Size,Size变化需要自动刷新Module孔数
        private void DocumentManager_DocumentCreated(object sender, Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs e)
        {
            var doc = e.Document;

            Assertion.Assert(doc != null);
            var db = doc.Database;

            doc.CommandWillStart += Doc_CommandWillStart;
            doc.CommandEnded     += Doc_CommandEnded;
            doc.CommandCancelled += Doc_CommandCancelled;
            doc.CommandFailed    += Doc_CommandFailed;

            var TXPipeIds = new List <ObjectId>();

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var networkIds = Utils.FindEntities <Network>(db);
                if (!networkIds.Any())
                {
                    return;
                }

                //规划通信 和 现状通信
                var plIds_GHTX = NetworkUtils.GetPartListInformation()[(int)GHPipeType.TXG].GetPartListObjectIds();
                var plIds_XZTX = NetworkUtils.GetPartListInformation()[(int)XZPipeType.TXG].GetPartListObjectIds();
                //取不到这些PartList,说明这个图不符合我们的要求,就不用继续处理了
                if (plIds_GHTX == null || plIds_XZTX == null)
                {
                    return;
                }

                var TXPartListIds = new List <ObjectId> {
                    plIds_GHTX.PartListId, plIds_GHTX.PartListId
                };

                foreach (ObjectId networkId in networkIds)
                {
                    var network = tr.GetObject(networkId, OpenMode.ForRead) as Network;
                    if (!TXPartListIds.Contains(network.PartsListId))
                    {
                        continue;                                               //不是通信管就不管了
                    }
                    var pipeIds = network.GetPipeIds();
                    TXPipeIds.AddRange(pipeIds.ToList());
                }
                tr.Commit();
            }

            var pipeSizeMonitor = PipeSizeMonitorManager.GetInstance(doc);

            TXPipeIds.ForEach(i => pipeSizeMonitor.StartMonitor(i, false));
        }
Example #3
0
        public static void DrawingChanged(object sender, Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs e)
        {
            try {
                if (AcadIO.World.AcadIoLoaded == true)
                {
                    if (AcadIO.World.AcadIoDockVisible == true)
                    {
                        if (Application.DocumentManager.MdiActiveDocument != null)
                        {
                            World.Docu = Application.DocumentManager.MdiActiveDocument;    //setting the global active document

                            //unable to check whether the drawing that is activated already has a handler, remove if it exists (or doesnt, it wont error), then re-add
                            World.Docu.Editor.SelectionAdded -= new Autodesk.AutoCAD.EditorInput.SelectionAddedEventHandler(ObjectSelected);
                            World.Docu.Editor.SelectionAdded += new Autodesk.AutoCAD.EditorInput.SelectionAddedEventHandler(ObjectSelected);
                        }
                    }
                }
            }
            catch (System.Exception ex) { Err.Log(ex); }
        }
Example #4
0
 event_DocumentToBeActivated(object sender, AcApp.DocumentCollectionEventArgs e)
 {
     PrintEventMessage("Document To Be Activated", e.Document);
 }
Example #5
0
 event_DocumentBecameCurrent(object sender, AcApp.DocumentCollectionEventArgs e)
 {
     PrintEventMessage("Document Became Current", e.Document);
 }
Example #6
0
 event_DocumentCreationCanceled(object sender, AcApp.DocumentCollectionEventArgs e)
 {
     PrintEventMessage("Document Creation Canceled", e.Document);
 }
Example #7
0
 private void DocumentManager_DocumentToBeDeactivated(object sender, Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs e)
 {
     //store the current contents
     MyDocData.Current.Stuff = this.textBox1.Text;
 }
Example #8
0
 private void DocumentManager_DocumentActivated(object sender, Autodesk.AutoCAD.ApplicationServices.DocumentCollectionEventArgs e)
 {
     this.textBox1.Text = MyDocData.Current.Stuff;
 }
Example #9
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }

            // branch to all types we are concerned with
            System.Type type = e.ObjToSnoop as System.Type;
            if (type != null)
            {
                Stream(snoopCollector.Data(), type);
                return;
            }

            System.Version ver = e.ObjToSnoop as System.Version;
            if (ver != null)
            {
                Stream(snoopCollector.Data(), ver);
                return;
            }

            System.Collections.Specialized.StringCollection strCol = e.ObjToSnoop as System.Collections.Specialized.StringCollection;
            if (strCol != null)
            {
                Stream(snoopCollector.Data(), strCol);
                return;
            }

            AcAp.Document doc = e.ObjToSnoop as AcAp.Document;
            if (doc != null)
            {
                Stream(snoopCollector.Data(), doc);
                return;
            }

            AcAp.DocumentCollectionEventArgs docCollectEventArgs = e.ObjToSnoop as AcAp.DocumentCollectionEventArgs;
            if (docCollectEventArgs != null)
            {
                Stream(snoopCollector.Data(), docCollectEventArgs);
                return;
            }

            AcAp.DocumentLockModeWillChangeEventArgs docLockModeEventArgs = e.ObjToSnoop as AcAp.DocumentLockModeWillChangeEventArgs;
            if (docLockModeEventArgs != null)
            {
                Stream(snoopCollector.Data(), docLockModeEventArgs);
                return;
            }

            AcAp.DocumentLockModeChangedEventArgs docLockModeChangedEventArgs = e.ObjToSnoop as AcAp.DocumentLockModeChangedEventArgs;
            if (docLockModeChangedEventArgs != null)
            {
                Stream(snoopCollector.Data(), docLockModeChangedEventArgs);
                return;
            }

            AcAp.DocumentLockModeChangeVetoedEventArgs docLockModeVetoedEventArgs = e.ObjToSnoop as AcAp.DocumentLockModeChangeVetoedEventArgs;
            if (docLockModeVetoedEventArgs != null)
            {
                Stream(snoopCollector.Data(), docLockModeVetoedEventArgs);
                return;
            }

            AcAp.DocumentDestroyedEventArgs docDestroyedEventArgs = e.ObjToSnoop as AcAp.DocumentDestroyedEventArgs;
            if (docDestroyedEventArgs != null)
            {
                Stream(snoopCollector.Data(), docDestroyedEventArgs);
                return;
            }

            AcAp.DocumentCollection docCollection = e.ObjToSnoop as AcAp.DocumentCollection;
            if (docCollection != null)
            {
                Stream(snoopCollector.Data(), docCollection);
                return;
            }

            AcAp.XrefFileLock xrefFileLock = e.ObjToSnoop as AcAp.XrefFileLock;
            if (xrefFileLock != null)
            {
                Stream(snoopCollector.Data(), xrefFileLock);
                return;
            }

            Autodesk.AutoCAD.Windows.Window win = e.ObjToSnoop as Autodesk.AutoCAD.Windows.Window;
            if (win != null)
            {
                Stream(snoopCollector.Data(), win);
                return;
            }

            Autodesk.AutoCAD.Windows.StatusBar statusBar = e.ObjToSnoop as Autodesk.AutoCAD.Windows.StatusBar;
            if (statusBar != null)
            {
                Stream(snoopCollector.Data(), statusBar);
                return;
            }

            Autodesk.AutoCAD.Windows.StatusBarItem statusBarItem = e.ObjToSnoop as Autodesk.AutoCAD.Windows.StatusBarItem;
            if (statusBarItem != null)
            {
                Stream(snoopCollector.Data(), statusBarItem);
                return;
            }
        }
Example #10
0
        Stream(ArrayList data, AcAp.DocumentCollectionEventArgs args)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(AcAp.DocumentCollectionEventArgs)));

            data.Add(new Snoop.Data.Object("Document", args.Document));
        }