Esempio n. 1
0
        private void callback_ObjectErased(object sender, ObjectErasedEventArgs e)
        {
            // if the object was erased
            if (e.Erased)
            {
                // find the object in the treeview control so we can remove it
                foreach (System.Windows.Forms.TreeNode node in myPalette.treeView1.Nodes)
                {
                    // is this the one we want
                    if (node.Tag.ToString() == e.DBObject.ObjectId.ToString())
                    {
                        node.Remove();
                        break;
                    }
                }
            }
            else
            {
                // if the object was unerased
                // add the class name of the object to the tree view
                System.Windows.Forms.TreeNode newNode = myPalette.treeView1.Nodes.Add(e.DBObject.GetType().ToString());

                // we need to record its id for recognition later
                newNode.Tag = e.DBObject.ObjectId.ToString();
            }
        }
 private void WorkingDatabase_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     if (e.DBObject is DBPoint)
     {
         _pointIds.Remove(e.DBObject.ObjectId);
     }
 }
Esempio n. 3
0
 // Define callback for Database.ObjectErased event
 private void OnObjectErased(object sender, ObjectErasedEventArgs e)
 {
     if (e.Erased)
     {
         m_linkManager.RemoveLinks(e.DBObject.ObjectId);
     }
 }
Esempio n. 4
0
 private static void Database_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     MessageBox.Show(
         "FireObjectErased: " + e.ToString() + "\n"
         + "该侦听在数据库对象删除之后被触发,删除的对象的类型是: " + e.DBObject.GetType().ToString() + "\n"
         + "是否删除: " + e.Erased.ToString()
         );
 }
Esempio n. 5
0
 private void DbPoint_Erased(object sender, ObjectErasedEventArgs e)
 {
     // Удаление точки из расчета. Проверка есть ли такая точка в расчете (если нет, то она уже удалена через палитру)
     if (Model.Tree.HasPoint(e.DBObject.Id))
     {
         Delete();
     }
 }
Esempio n. 6
0
        private void ActiveObject_Erased(object sender, ObjectErasedEventArgs e)
        {
            Erased = e.Erased;
            ObjectErased(sender, e);

            //TODO: Review once dirty system implemented
            DirtyRemoved = e.Erased;
            DirtyAdded   = !e.Erased;
        }
Esempio n. 7
0
 event_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     if (e.Erased)
     {
         PrintEventMessage((Database)sender, "Object Erased", e.DBObject);
     }
     else
     {
         PrintEventMessage((Database)sender, "Object Un-Erased", e.DBObject);
     }
 }
Esempio n. 8
0
        public void ObjectErased(ObjectErasedEventArgs e)
        {
            try
            {
                var       objectId  = e.DBObject.Id;
                var       isErased  = e.Erased;
                G3EObject g3eObject = null;
                if (DBEntityFinder.Instance.GetG3EIds(objectId, ref g3eObject))
                {
                    var dbSymbolEntry = SimpleDBSymbolsConfig.Instance.DBSymbol.SingleOrDefault(o => o.G3E_FNO == g3eObject.G3E_FNO);
                    if (dbSymbolEntry != null)
                    {
                        if (isErased)
                        {
                            //存储备份实体
                            var backupEntity = new List <DBEntity>();
                            if (e.DBObject is DBText || e.DBObject is MText)
                            {
                                //删除标注坐标数据
                                backupEntity = ErasedPointSymbolTable(objectId, backupEntity);
                                //杂项标注属性删除
                                if (g3eObject.G3E_FNO == 250)
                                {
                                    backupEntity = EraseZxbzDBEntity(g3eObject.G3E_FID, backupEntity);
                                }
                                //删除标注lb
                                backupEntity = ErasedLabelLB(objectId, g3eObject, backupEntity);
                                ObjectHistoryManagerAdd(objectId, backupEntity);
                            }
                            else
                            {
                                //删除设备数据
                                backupEntity = ObjectErased(dbSymbolEntry, objectId, g3eObject, backupEntity);
                                ObjectHistoryManagerAdd(objectId, backupEntity);

                                //删除标注
                                DeleteLinkageLabel(g3eObject.G3E_FID);
                            }
                        }
                        else
                        {
                            Redo(objectId);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error("删除设备错误!\n" + ex);
            }
        }
        private void OnObjectErased(object sender, ObjectErasedEventArgs e)
        {
            // Very simple: we just add our ObjectId to the list
            // for later processing
            if (e.DBObject.ObjectId.IsErased)
            {
                //String msg = e.DBObject.ObjectId.ToString();
                ObjectId oId = e.DBObject.ObjectId;

                Dictionary <ObjectId, Building> bui = buildings;
                Solution sln = currentSolution;
                if (bui.Keys.Contains(oId))
                {
                    //楼房
                    Building buiTmp = buildings[oId];
                    buiTmp.Delete();
                    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
                    .WriteMessage("删除了楼房\n");
                    return;
                }
                else if (sln == null)
                {
                }
                else if (sln.HeatProducers.Keys.Contains(oId))
                {
                    //删除了热源
                    currentSolution.HeatProducers[oId].Delete();
                    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
                    .WriteMessage("删除了热源\n");
                }
                else if (sln.SubStations.Keys.Contains(oId))
                {
                    currentSolution.SubStations[oId].Delete();
                    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
                    .WriteMessage("删除了热力站\n");
                }
                else if (sln.Districts.Keys.Contains(oId))
                {
                    //删除了云线
                    currentSolution.Districts[oId].Delete();
                }
                if (sln != null)
                {
                    sln.TryDeleteObjectInSolution(oId);
                }
            }
        }
Esempio n. 10
0
        // 24. Create a private function named callback_ObjectErased. (returns void)
        // This is the function that will be called when an Object is erased from the
        // Database. (The name needs to be the name used in the Delegate parameter of
        // step 18). The first parameter is an object. (use sender as the name of the
        // Object). The second parameter is an ObjectErasedEventArgs.
        // Use e as the name of the ObjectErasedEventArgs)
        // Note: Put the closing curly brace before step 32
        private void callback_ObjectErased(object sender, ObjectErasedEventArgs e)
        {
            // 25. use an "if else"  statement and check the Erased property of the
            // ObjectErasedEventArgs passed into the function. (e.Erased)
            // Note: Put the closing curly brace and "else" stament before step 30.
            // put the closing curly brace for the "else after step 31
            if (e.Erased)
            {
                // 26. Here we will search for an object in the treeview control so it can be removed.
                // Create a foreach statement. Use node for the element name and the type is
                // System.Windows.Forms.Treenode. The group paramater is the Nodes in the TreeView.
                // (myPalette.treeView1.Nodes)
                // Note: put the closing curly brace below step 29.
                foreach (System.Windows.Forms.TreeNode node in myPalette.treeView1.Nodes)
                {
                    // 27. Use an "if" statement. Test to see if the node Tag is the ObjectId
                    // of the erased Object. Use the DBObject property of the of the
                    // ObjectErasedEventArgs passed into the event. (e.DBObject.ObjectId.ToString())
                    // Note: put the closing curly brace above the closing curley brace for the for loop
                    if (node.Tag.ToString() == e.DBObject.ObjectId.ToString())
                    {
                        // 28. Remove the node by calling the Remove method. (The entity was
                        // erased from the drawing).
                        node.Remove();

                        // 29. Exit the For loop by adding a break statement.
                        break;
                    }
                }
            }
            else
            {
                // 30. If this is processed it means that the object was unerased. (e.Erased was false)
                // Declare a System.Windows.Forms.TreeNode use newNode as the name. Instantiate it by
                // using the Add method of the Nodes collection of the TreeView created in previous steps.
                // Use the Type of the object for the parameter.
                // e.DBObject.GetType().ToString()
                System.Windows.Forms.TreeNode newNode = myPalette.treeView1.Nodes.Add(e.DBObject.GetType().ToString());

                // 31. Make the Tag property of the node created in step 30 equal to the ObjectId of
                // the unerased object. This will allow us to record it's ObjectId for recognition in
                // other events. Use e.DBObject.ObjectId.ToString()
                newNode.Tag = e.DBObject.ObjectId.ToString();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Удаление здания
        /// </summary>
        private void Building_Erased(object sender, ObjectErasedEventArgs e)
        {
            // Определение удаленного здания
            var building = FindBuildingByEnt(e.DBObject.Id);

            if (building != null)
            {
                Buildings.Remove(building);
                building.Dispose();
                var r = GetBuildingRectangle(building);
                treeBuildings.Delete(r, building);

                if (IsEventsOn)
                {
                    BuildingErased?.Invoke(this, building);
                }
            }
        }
Esempio n. 12
0
 public static void db_ObjectErased(ObjectErasedEventArgs e)
 {
     try
     {
         if (DBEntityFinder.Instance.HasG3EIDS(e.DBObject.Id))
         {
             if (!DCadApi.isEraseRollback)
             {
                 DBEntityErased.Instance.ObjectErased(e);
                 mouse._selectedObjectIds = null;
                 mouse.selectedEntityId   = ObjectId.Null;
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.Instance.Error(ex);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// 删除事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void db_ObjectErased(object sender, ObjectErasedEventArgs e)
        {
            if (!(e.DBObject is BaseTunnel) && !(e.DBObject is Node))
            {
                return;
            }

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            if (e.Erased == true)   //这时候是删除触发的
            {
                DBEntityControl dbControl = Project.Instance.GetTmpEntCol(doc);

                dbControl.Delete(Query.EQ("HandleValue", e.DBObject.ObjectId.Handle.Value), db);

                if (e.DBObject is BaseTunnel)
                {
                    Global.EraseSelectedTunnel(sender, e.DBObject.ObjectId.Handle.Value);
                }
            }
            else             //这时候是删除后的撤销动作触发的
            {
                Entity entity = e.DBObject as Entity;
                if (entity is BaseTunnel)
                {
                    DBEntityControl dbControl = Project.Instance.GetTmpEntCol(doc);

                    DBTunnel dbTunnel = new DBTunnel();
                    dbTunnel.SetProperty(entity);
                    dbControl.Insert(dbTunnel, db);
                }
                else if (entity is Node)
                {
                    DBEntityControl dbControl = Project.Instance.GetTmpEntCol(doc);
                    DBNode          dbNode    = new DBNode();
                    dbNode.SetProperty(entity);
                    dbControl.Insert(dbNode, db);
                }
            }
        }
 private void db_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     try
     {
         if (e.DBObject.Id == this.RasterObjectId)
         {
             if (base.GetType() == typeof(MSCMapService))
             {
                 MSCMapService mSCMapService = this as MSCMapService;
                 mSCMapService.DeleteService();
             }
             else if (base.GetType() == typeof(MSCImageService))
             {
                 MSCImageService mSCImageService = this as MSCImageService;
                 mSCImageService.DeleteService();
             }
         }
         this.CheckForUpdates();
     }
     catch
     {
         System.Windows.MessageBox.Show("DEBUG:  Catch in MSCRasterService.db_ObjectErased");
     }
 }
Esempio n. 15
0
        /// <summary>
        /// 当阀门删除时,接上被打断的管道。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void ValveRemoved(object sender, ObjectErasedEventArgs e)
        {
            var valve = e.DBObject as BlockReference;

            if (e.Erased == true && valve != null)
            {
                if (valve.Name == Valve.kValve1BlkName)
                {
                    DBHelper.ForEach(ent =>
                    {
                        var poly = ent as Polyline;
                        if (poly != null)
                        {
                            var xdata = poly.GetXData(PipeSample.kAppName);
                            if (xdata == null || xdata.Length == 0)
                            {
                                return;
                            }
                            ConnectPipeWithValveType1(poly, valve.Position);
                        }
                    });
                }
            }
        }
 protected override void ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     throw new NotImplementedException();
 }
Esempio n. 17
0
 private void callback_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     WriteLine(String.Format("ObjectErased - {0} {1} {2}", e.DBObject.ToString(), e.DBObject.Id.ToString(), e.Erased));
 }
Esempio n. 18
0
 protected abstract void ObjectErased(object sender, ObjectErasedEventArgs e);
Esempio n. 19
0
 void ActiveObject_Erased(object sender, ObjectErasedEventArgs e)
 {
     Erased = true;
 }
Esempio n. 20
0
 /// <summary>
 /// 对象删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void db_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     ObjectOperate.db_ObjectErased(e);
 }
Esempio n. 21
0
 private void callback_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     WriteLine(String.Format("ObjectErased - {0} {1} {2}", e.DBObject.ToString(), e.DBObject.Id.ToString(), e.Erased));
 }
Esempio n. 22
0
        public void DbEvent_ObjectErased_Handler_RoadPavenment(object sender, ObjectErasedEventArgs e)
        {
            try
            {
                if (e.DBObject is Alignment)
                {
                    AcadUtils.CbAutocadItem obj = new AcadUtils.CbAutocadItem((e.DBObject as Alignment).Name,
                                                    (e.DBObject as Alignment).ObjectId);
                    if (obj == null)
                    {
                        return;
                    }
                    for (int i = 0; i < cbAlignment.Items.Count; i++)
                    {
                        if ((cbAlignment.Items[i] as AcadUtils.CbAutocadItem).ID == obj.ID)
                        {
                            if (cbAlignment.Text == obj.Name)
                            {
                                cbAlignment.Items.RemoveAt(i);
                                if (cbAlignment.Items.Count != 0)
                                {
                                    cbAlignment.SelectedIndex = 0;
                                    cbAlignment.SelectedItem = cbAlignment.Items[0];
                                }
                            }
                            else
                            {
                                cbAlignment.Items.RemoveAt(i);
                            }
                            break; //for i
                        }
                    }
                }
                else if (e.DBObject is TinSurface)
                {
                    AcadUtils.CbAutocadItem obj = new AcadUtils.CbAutocadItem((e.DBObject as TinSurface).Name,
                                                    (e.DBObject as TinSurface).ObjectId);
                    if (obj == null)
                    {
                        return;
                    }
                    for (int i = 0; i < cbSurfEx.Items.Count; i++)
                    {
                        if ((cbSurfEx.Items[i] as AcadUtils.CbAutocadItem).ID == obj.ID)
                        {
                            if (cbSurfEx.Text == obj.Name)
                            {
                                cbSurfEx.Items.RemoveAt(i);

                                if (cbSurfEx.Items.Count != 0)
                                {
                                    cbSurfEx.SelectedIndex = 0;
                                    cbSurfEx.SelectedItem = cbSurfPr.Items[0];
                                }
                            }
                            else
                            {
                                cbSurfEx.Items.RemoveAt(i);
                            }
                            break; //for
                        }
                    }

                    for (int i = 0; i < cbSurfPr.Items.Count; i++)
                    {
                        if ((cbSurfPr.Items[i] as AcadUtils.CbAutocadItem).ID == obj.ID)
                        {
                            if (cbSurfPr.Text == obj.Name)
                            {
                                cbSurfPr.Items.RemoveAt(i);

                                if (cbSurfPr.Items.Count != 0)
                                {
                                    cbSurfPr.SelectedIndex = 0;
                                    cbSurfPr.SelectedItem = cbSurfPr.Items[0];
                                }
                            }
                            else
                            {
                                cbSurfPr.Items.RemoveAt(i);
                            }
                            break; //for
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LufsGenplan.AcadApp.AcaEd.WriteMessage("\nERROR: RoadPavenment.DbEvent_ObjectErased_Handler() " + ex + "\n");
            }
        }
Esempio n. 23
0
 void BaseDBObject_Erased(object sender, ObjectErasedEventArgs e)
 {
     Erased(sender, e);
 }
Esempio n. 24
0
 private static void Database_ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     GoatMessageUtil.msg("FireObjectErased: " + e + "该侦听在数据库对象删除之后被触发,删除的对象的类型是: " + e.DBObject.GetType() + "是否删除: " + e.Erased);
     GoatMessageUtil.msg("\n你删除的对象ObjectId为: " + e.DBObject.ObjectId);
 }
Esempio n. 25
0
 protected override void ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     //Nothing to do on erase
 }
Esempio n. 26
0
 void BaseDBObject_Erased(object sender, ObjectErasedEventArgs e)
 {
     Erased(sender, e);
 }
Esempio n. 27
0
 protected override void ObjectErased(object sender, ObjectErasedEventArgs e)
 {
 }
Esempio n. 28
0
 protected override void ObjectErased(object sender, ObjectErasedEventArgs e)
 {
     //Do nothing...
 }