/// <summary> /// Обработка двойного клика по блоку /// </summary> private static void AcApp_BeginDoubleClick(object sender, BeginDoubleClickEventArgs e) { var psr = AcadUtils.Editor.SelectImplied(); if (psr.Status != PromptStatus.OK) { return; } var ids = psr.Value.GetObjectIds(); if (ids.Length != 1) { return; } using (AcadUtils.Document.LockDocument()) { using (var tr = AcadUtils.Document.TransactionManager.StartTransaction()) { var obj = tr.GetObject(ids[0], OpenMode.ForWrite, true, true); if (obj is BlockReference blockReference) { var applicableAppName = ExtendedDataUtils.ApplicableAppName(blockReference); if (string.IsNullOrEmpty(applicableAppName)) { BeditCommandWatcher.UseBedit = true; } else if (applicableAppName == AxisDescriptor.Instance.Name) { EntityUtils.DoubleClickEdit(blockReference, entity => new AxisValueEditor(entity)); } else if (applicableAppName == SectionDescriptor.Instance.Name) { EntityUtils.DoubleClickEdit(blockReference, entity => new SectionValueEditor(entity)); } else if (applicableAppName == LevelMarkDescriptor.Instance.Name) { EntityUtils.DoubleClickEdit(blockReference, entity => new LevelMarkValueEditor(entity)); } else { BeditCommandWatcher.UseBedit = true; } } else { BeditCommandWatcher.UseBedit = true; } tr.Commit(); } } }
private void Application_BeginDoubleClick(object sender, BeginDoubleClickEventArgs e) { _customCommand = null; _customFound = false; //Get entity which user double-clicked on Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; //PromptSelectionResult res = ed.SelectAtPickBox(e.Location); PromptSelectionResult res = ed.GetSelection(); if (res.Status == PromptStatus.OK) { ObjectId[] ids = res.Value.GetObjectIds(); //Only when there is one entity selected, we go ahead to see //if there is a custom command supposed to target at this entity if (ids.Length == 1) { using (Transaction tr = ids[0].Database.TransactionManager.StartTransaction()) { foreach (IClickOverrideInstance oci in Overrides) { if (oci.CanHandle(tr.GetObject(ids[0], OpenMode.ForRead))) { _customCommand = oci.CommandName(); _customFound = true; _selected = ids[0]; } } if (_customFound) { //Check if an overriden type exists if ((int)Application.GetSystemVariable("DBLCLKEDIT") == 0) { //Not enabled so launch custom Launch(); } else { //block custom command in the event handlers return; } } } } } }
private static void Application_BeginDoubleClick(object sender, [NotNull] BeginDoubleClickEventArgs e) { UseBedit = true; var doc = AcadHelper.Doc; var sel = ed.SelectAtPickBox(e.Location); if (sel.Status == PromptStatus.OK) { var selIds = sel.Value.GetObjectIds(); if (selIds.All(a => a.ObjectClass != RXObject.GetClass(typeof(BlockReference)))) { return; } var db = doc.Database; using (doc.LockDocument()) using (var t = db.TransactionManager.StartTransaction()) { foreach (var blRef in selIds.GetObjects <BlockReference>()) { var dynBtr = blRef.DynamicBlockTableRecord.GetObject <BlockTableRecord>() ?? throw new InvalidOperationException(); if (dynBtr.Name.StartsWith("КПП")) { UseBedit = false; var btr = blRef.BlockTableRecord.GetObject <BlockTableRecord>(); var section = GetSection(btr, e.Location.TransformBy(blRef.BlockTransform.Inverse())); if (section == null) { ed.WriteMessage("\nНе определена секция в блоке КПП по двойному клику."); return; } IndexerElevation(section); t.Commit(); doc.Editor.Regen(); return; } } } } }
public void DoubleClick(object sender, BeginDoubleClickEventArgs e) { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; PromptSelectionResult res = ed.SelectImplied(); if (res.Status != PromptStatus.Error) { if ((lastDoubleClickModel is SubStation || lastDoubleClickModel is HeatProducer) && currentSolution != null) { currentSolution.CancelHighLightPipeLine(); } SelectionSet set = res.Value; if (set.Count > 0) { List <ObjectId> vals = new List <ObjectId>(); for (int i = 0; i < set.Count; i++) { if (set[i].SelectionMethod != SelectionMethod.Unavailable) { vals.Add(set[i].ObjectId); } } if (vals.Count == 0) { return; } ObjectId lastId = vals.Last(); //从选择的项目中移除除最后的选择外的其他选择 ObjectId[] newids = { lastId }; ed.SetImpliedSelection(newids); if (HeatSourceLayoutApp.buildings.ContainsKey(lastId)) { Building b = buildings[lastId]; lastDoubleClickModel = b; showBuildingAttrsEditor(); buildingAttrEditor.SetBuilding(b); return; } if (currentSolution == null) { return; } HeatProducer producer = HeatSourceLayoutApp.currentSolution.GetHeatProducer(lastId); if (producer != null) { lastDoubleClickModel = producer; showHeatproducerAttrsEditor(); heatProducerAttrEditor.SetHeatProducer(producer); currentSolution.HighLight(producer); return; } SubStation substation = HeatSourceLayoutApp.currentSolution.GetSubStation(lastId); if (substation != null) { lastDoubleClickModel = substation; showSubstationAttrsEditor(); substationAttrEditor.SetSubstation(substation); currentSolution.HighLight(substation); return; } } } }