public void PreViewSymbol(string imgPath, bool bl) { try { var name = Path.GetFileNameWithoutExtension(imgPath); imgPath = string.Format("{0}\\自定义模版图片\\{1}.jpg", DBEntityFinder.Instance.SymbolPicturePath, name); if (File.Exists(imgPath)) { if (ps == null) { if (bl) { ps = new PreviewSymbol(imgPath); Application.ShowModelessDialog(ps); } } else { ps.pictureBox1.Load(imgPath); } } } catch (Exception ex) { PublicMethod.Instance.ShowMessage(ex.Message); } }
private void frmGridLabelEdit_Load(object sender, System.EventArgs e) { Point3d pnt3dPick = Pub.pnt3dO; try { Entity ent = Base_Tools45.Select.selectEntity(typeof(Line), "Select Grid Line for Label Edit:", "", out pnt3dPick); if (ent == null) { return; } idLine = ent.ObjectId; } catch { Application.ShowAlertDialog("Retry and make sure to elect the Grid Line not the text"); return; } ResultBuffer rb = idLine.getXData("GRID"); TypedValue[] tvs = rb.AsArray(); tv = tvs; this.lblGridLabel.Text = tvs[1].Value.ToString(); }
/// <summary> /// 户表管理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void mouse_SHBManager(object sender, EventArgs e) { var ee = (selectEntityArgs)e; var shb = new SHBMap(ee); Application.ShowModelessDialog(shb); }
private Microsoft.Win32.RegistryKey GetAcadAppKey(bool forWrite) { string User = Environment.UserDomainName + "\\" + Environment.UserName; string RootKey = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.Current.UserRegistryProductRootKey; Microsoft.Win32.RegistryKey AcadKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(RootKey); RegistryAccessRule Role = new RegistryAccessRule(User, RegistryRights.WriteKey | RegistryRights.Delete | RegistryRights.ReadKey, AccessControlType.Allow); RegistrySecurity Rs = new RegistrySecurity(); Rs.AddAccessRule(Role); Microsoft.Win32.RegistryKey AppKey = AcadKey.OpenSubKey("Applications", forWrite); if (AppKey == null) { try { Microsoft.Win32.RegistryKey Key = AcadKey.CreateSubKey("Applications", RegistryKeyPermissionCheck.ReadWriteSubTree, Rs); return(Key); } catch (System.Exception Ex) { AcadApp.ShowAlertDialog(Ex.Message + "注册失败。详情请查看软件的帮助文档"); return(AppKey); } } else { return(AppKey); } }
public void TabView() { Editor editor = AfaDocData.ActiveDocData.DocDataset.ParentDocument.Editor; try { try { int arg_25_0 = editor.SelectAll().Value.Count; } catch { editor.WriteMessage("\n" + AfaStrings.NoFeaturesFound); return; } MSCFeatureClass activeFeatureClassOrSubtype = AfaDocData.ActiveDocData.GetActiveFeatureClassOrSubtype(); if (activeFeatureClassOrSubtype == null) { editor.WriteMessage("\n" + AfaStrings.NoCurrentFeatureClassFound); } else { TableView tableView = new TableView(activeFeatureClassOrSubtype); Application.ShowModalDialog(Application.MainWindow.Handle, tableView, true); tableView.Uninitialize(); tableView.Dispose(); } } catch { editor.WriteMessage("\nError"); } }
/// <summary> /// Shows a multi-inputs window. /// </summary> /// <param name="title">The title.</param> /// <param name="entries">The input entries.</param> public static void MultiInputs(string title, Dictionary <string, string> entries) { var mi = new MultiInputs(); mi.Ready(entries, title); AcadApplication.ShowModalWindow(mi); }
private void MoveJLBItem_Click(object sender, EventArgs e) { try { var isLock = DBEntityFinder.Instance.VerifyLTTID(detail_fid); if (!isLock) { PublicMethod.Instance.AlertDialog("详图没有被工单锁定,不能迁移计量表!"); Show(); return; } var movept = dddMap.screen2geo(mouseLocation.X, mouseLocation.Y); var detail = DBManager.Instance.GetEntities <Detailreference_n>( o => o.G3E_FID == detail_fid && o.EntityState != EntityState.Delete).FirstOrDefault(); if (detail != null) { if (detail.G3E_DETAILID == null) { return; } var tt = new JLBMove((long)detail.G3E_DETAILID, movept); var res = Application.ShowModalDialog(tt); if (res == DialogResult.OK) { // 加一个计量表,刷新窗口 var pb = new JlbPB(); pb.Height = picWheight; pb.Width = picWwidth; pb.Location = new System.Drawing.Point((int)mouseLocation.X - picWwidth / 2, (int)mouseLocation.Y - picWheight / 2); if (tt.SBLX == "高供高计") { pb.Image = imageList1.Images[0]; } else { pb.Image = imageList1.Images[1]; } pb.Tag = tt.g3e_Fid; pb.ContextMenuStrip = contextMenuStrip2; pb.JlbPBPosition = new Point3d(movept[1], movept[0], 0); pb.JlbPBFid = tt.g3e_Fid; pb.JlbSBLX = tt.SBLX; pb.SizeMode = PictureBoxSizeMode.StretchImage; pb.MouseDoubleClick += pb_MouseDoubleClick; pb.MouseDown += pb_MouseDown; pb.MouseHover += pb_MouseHover; pb.MouseUp += pb_MouseUp; pb.MouseMove += pb_MouseMove; pbs.Add(pb); Controls.Add(pb); } } } catch (Exception ex) { LogManager.Instance.Error(ex); } }
insertCurve(ObjectId idAlign) { Alignment align = (Alignment)idAlign.getEnt(); AlignmentEntityCollection ents = align.Entities; PromptStatus ps; Point3d pnt3dPick = UserInput.getPoint("Select Curve PI", out ps, osMode: 1); AlignmentEntity lineBefore = null; AlignmentEntity lineAfter = null; for (int i = 0; i < ents.Count; i++) { AlignmentEntity ent = ents[i]; if (ent.EntityType == AlignmentEntityType.Line) { AlignmentLine line = (AlignmentLine)ent; if (line.EndPoint.IsEqualTo(pnt3dPick.Convert2d(BaseObjs.xyPlane), new Tolerance(.01, .01))) { lineBefore = line; } if (line.StartPoint.IsEqualTo(pnt3dPick.Convert2d(BaseObjs.xyPlane), new Tolerance(.01, .01))) { lineAfter = line; } } } AlignmentArc arc = ents.AddFreeCurve(lineBefore.EntityId, lineAfter.EntityId, 200.0, CurveParamType.Radius, false, CurveType.Compound); List <AlgnEntData> algnEntData = sortAlignEnts(align); fAlignEnts.updateForm(algnEntData); fAlignEnts.AlignHandle = align.Handle; Application.ShowModelessDialog(Application.MainWindow.Handle, fAlignEnts, false); }
private AGSExportOptions InitExportOptions(object srcObject) { AGSExportOptions aGSExportOptions = new AGSExportOptions(); aGSExportOptions.AcadDocument = AfaDocData.ActiveDocData.Document; Extent extent = this.spProps.ctrlBoundingBoxExtent.Content as Extent; aGSExportOptions.BoundingBox = extent; aGSExportOptions.OutputWKT = AfaDocData.ActiveDocData.DocPRJ.WKT; aGSExportOptions.WhereClause = ""; System.Drawing.Size size = Application.ToSystemDrawingSize(AfaDocData.ActiveDocData.Document.Window.DeviceIndependentSize); aGSExportOptions.Width = size.Width; aGSExportOptions.Height = size.Height; aGSExportOptions.DPI = 96; aGSExportOptions.Transparency = this.spProps.ExportOptions.Transparency; aGSExportOptions.Format = this.spProps.ExportOptions.Format; aGSExportOptions.Dynamic = this.spProps.ExportOptions.Dynamic; if (aGSExportOptions.Format == null) { aGSExportOptions.Format = "PNG24"; } AGSService aGSService = srcObject as AGSService; AGSLayer aGSLayer = srcObject as AGSLayer; string text = ""; if (aGSService != null) { text = aGSService.GetWKT(); } else if (aGSLayer != null) { text = aGSLayer.GetWKT(); } if (string.IsNullOrEmpty(text)) { text = "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0],AUTHORITY[\"EPSG\",3857]]"; } if (string.IsNullOrEmpty(extent.SpatialReference)) { extent.SpatialReference = text; } aGSExportOptions.OutputWKT = MSCPrj.CurrentWKT(AfaDocData.ActiveDocData.Document, text); try { aGSExportOptions.Interpolation = this.spProps.ExportOptions.Interpolation; aGSExportOptions.Quality = this.spProps.ExportOptions.Quality; aGSExportOptions.TransCompression = this.spProps.ExportOptions.TransCompression; aGSExportOptions.MosaicMethod = this.spProps.ExportOptions.MosaicMethod; aGSExportOptions.OrderField = this.spProps.ExportOptions.OrderField; aGSExportOptions.OrderBaseValue = this.spProps.ExportOptions.OrderBaseValue; aGSExportOptions.MosaicOperator = this.spProps.ExportOptions.MosaicOperator; aGSExportOptions.LockRasterID = this.spProps.ExportOptions.LockRasterID; aGSExportOptions.Ascending = this.spProps.ExportOptions.Ascending; } catch { return(aGSExportOptions); } return(aGSExportOptions); }
private void AnalyzeImpl() { var logWindow = new LogWindow(); AcApplication.ShowModelessWindow(logWindow); var log = ""; foreach (var part in ViewModel.Parts) { var e = _acad.CheckBlockExists(part.ReferenceName); var l = _acad.CheckLayerExists(part.Layer); log += $"{part.ReferenceName}\n"; if (e && l) { log += "OK"; } else { if (!e) { log += "\tReferência Inexistente\n"; } if (!l) { log += "\tCamada Inexistente"; } } log += "\n"; logWindow.SetLogMessage(log); } logWindow.SetResultTitle($"{ViewModel.Parts.Count} peças analizadas."); }
/// <summary> /// 生成表单 /// </summary> public static void AddCarTable() { Database db = HostApplicationServices.WorkingDatabase; using (var tr = db.TransactionManager.StartTransaction()) { //选择车 var cars = db.GetSelectionOfBlockRefs("\n选择车", false, carBlockName); if (cars.Count != 0) { //车类型、数量字典 var gCar = cars.GroupBy(d => d.ObjectId.GetDynBlockValue("类型")) .ToDictionary(d => d.Key, d => d.Count()); //文字样式 var tsId = db.AddTextStyle("index", "sceic.shx", "sceic.shx", 0.7); //设置表样式 var tableStyleId = db.AddTableStyle("Summary", "index", 350, CellAlignment.BottomCenter, 100); //表单 Table table = new Table(); table.TableStyle = tableStyleId; //表单大小 table.SetSize(2 + gCar.Count, 2); //设置列宽 foreach (var col in table.Columns) { col.Width = 2000; } //表头行 int row = 0; table.Cells[row, 0].Value = "车位统计"; //标题行 row++; table.Cells[row, 0].Value = "名称"; table.Cells[row, 1].Value = "数量"; //表单内容 for (int i = row + 1; i <= gCar.Count + row; i++) { var gc = gCar.ElementAt(i); table.Cells[i, 0].Value = gc.Key; table.Cells[i, 1].Value = gc.Value; } Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor; //插入点 var ppr = ed.GetPoint(new PromptPointOptions("\n指定点")); //添加表单 if (ppr.Status == PromptStatus.OK) { table.Position = ppr.Value; db.AddToCurrentSpace(table); } } else { AcadApp.ShowAlertDialog("选中数量为0"); } tr.Commit(); } }
private void cmdStakeSta_Click(object sender, EventArgs e) { this.Hide(); fStaRange = Forms.Stake_Forms.sForms.fStaRange; Application.ShowModelessDialog(Application.MainWindow.Handle, fStaRange, false); }
makePointEnt(Point3d pt, int colorIndex, Database db) { int mode = (int)AcadApp.GetSystemVariable("pdmode"); if (mode == 0) { AcadApp.SetSystemVariable("pdmode", 99); } try { using (Transaction tr = BaseObjs.startTransactionDb()) { using (DBPoint dbPt = new DBPoint(pt)) { dbPt.ColorIndex = colorIndex; SymTbl.AddToCurrentSpace(dbPt, db); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Db.cs: line: 431"); } }
public void ShowProcessingDialog() { ThumnailProcessDlg thumnailProcessDlg = new ThumnailProcessDlg(0, false, ""); thumnailProcessDlg.RootPath.Text = "这里显示CAD文件夹路径"; AcadApp.ShowModalDialog(AcadApp.MainWindow.Handle, thumnailProcessDlg); }
private void cmdDone_Click(object sender, EventArgs e) { fStake = Forms.Stake_Forms.sForms.fStake; fStake.optMISC.Checked = false; Application.ShowModelessDialog(Application.MainWindow.Handle, fStake, false); this.Hide(); }
private void ToolSMI_UploadCADToGIS_Click(object sender, EventArgs e) { if (!PublicMethod.Instance.IsExecuteSystemCMD("")) { var upload = new Upload.UploadCAD(fileName); Application.ShowModalDialog(upload); } }
private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (System.Windows.Forms.Control.MouseButtons == System.Windows.Forms.MouseButtons.Left) { //start dragDrop operation, MyDropTarget will be called when the cursor enters the AutoCAD view area. AcadApp.DoDragDrop(this, "Drag & drop successful!!!", System.Windows.Forms.DragDropEffects.All, new MyDropTarget()); } }
/// <summary> /// Starts new command. /// </summary> /// <param name="command">The command.</param> public static void StartCommand(string command) { var existingCommands = Application.GetSystemVariable("CMDNAMES").ToString(); var escapes = existingCommands.Length > 0 ? string.Join(string.Empty, Enumerable.Repeat('\x03', existingCommands.Split('\'').Length)) : string.Empty; Application.DocumentManager.MdiActiveDocument.SendStringToExecute(escapes + command, true, false, true); }
/// <summary> /// 计量表管理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void mouse_JLBManager(object sender, EventArgs e) { var ee = (selectEntityArgs)e; var jlb = new JLBMap(ee); Application.ShowModelessDialog(jlb); jlb.WindowState = FormWindowState.Normal; jlb.Visible = true; }
private void optBLDG_Click(object sender, EventArgs e) { if (optBLDG.Checked) { ClassObj = "BLDG"; this.Hide(); Application.ShowModelessDialog(Application.MainWindow.Handle, Stake_Forms.sForms.fGrid, false); } }
static public void bview() // This method can have any name { // create a new instance of the dialog using (BlockViewDialog blockViewDlg = new BlockViewDialog()) { // now show it as a model form in AutoCAD AcadApp.ShowModalDialog(blockViewDlg); } }
//create an tabpage private bool CreateDWGThumnailCollection(ref TabPage Page) { string PathStr = Page.Tag as string; FlowLayoutPanel FlowPanel = new FlowLayoutPanel(); if (Directory.Exists(PathStr)) { List <string> DwgFiles = Directory.GetFiles(PathStr, "*.dwg", SearchOption.AllDirectories).ToList(); BlockingCollection <DwgThumnail> DwgItemList = new BlockingCollection <DwgThumnail>(); FlowPanel.Dock = DockStyle.Fill; FlowPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight; FlowPanel.AutoScroll = true; int type = 0; if (Regex.Match(PathStr, @"StdBlock").Success) { type = 0; } else { type = 1; } Parallel.ForEach(DwgFiles, item => { DwgThumnail DwgItem = new DwgThumnail(item, type); DwgItemList.Add(DwgItem); }); if (DwgItemList.Count == 0) { Label lb = new Label(); lb.Text = "该路径下不包含任何DWG文件"; lb.Dock = DockStyle.Top; lb.AutoSize = true; FlowPanel.Padding = new Padding(30); FlowPanel.Controls.Add(lb); Page.Controls.Add(FlowPanel); return(false); } else { FlowPanel.SuspendLayout(); List <DwgThumnail> DwgList = DwgItemList.ToList(); DwgList.Sort(); FlowPanel.Controls.AddRange(DwgList.ToArray()); FlowPanel.ResumeLayout(); Page.Controls.Add(FlowPanel); return(true); } } else { AcadApp.ShowAlertDialog(string.Format("路径:{0} 不存在", PathStr)); return(false); } }
private void btn_selectViewport_Click(object sender, RoutedEventArgs e) { try { //check if defnition and note list are selected if (checkifDefnitionsSelected()) { //rest progressbar proBar.Value = 0; using (GV.Doc.LockDocument()) { short val = (short)AcAp.GetSystemVariable("CVPORT"); if (val != 1) { GV.processStatus = false; UIH.toastIT("This option works only in Paperspace (Layouts), please swtich to paperspace and try again!", "Viewport Not Preset", NotificationType.Error); } else { Helper.ViewportExtensions.getvPortCoordinatesADV(); if (GV.processStatus == true && GV.selObjects_forProcessing != null) { bw.WorkerSupportsCancellation = true; bw.WorkerReportsProgress = true; //bw.ProgressChanged += bw_ProgressChanged; bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar); //start work if (bw.IsBusy != true) { bw.RunWorkerAsync(); } ProcessLabels(); updateUIdata(); UIH.toastIT("All selected labels processed successfully!", "Status", NotificationType.Success); } } } } } catch (Autodesk.Civil.CivilException ex) { GH.errorBox(ex.ToString()); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { GH.errorBox(ex.ToString()); } catch (System.Exception ee) { GH.errorBox(ee.ToString()); } }
public void Execute() { // Get the current document var acDocument = Application.DocumentManager.MdiActiveDocument; // Get the PickFirst selection set PromptSelectionResult acSSPrompt; acSSPrompt = acDocument.Editor.SelectImplied(); SelectionSet acSSet; // If the prompt status is OK, objects were selected before // the command was started if (acSSPrompt.Status == PromptStatus.OK) { acSSet = acSSPrompt.Value; // Get the current document and database, and start a transaction Database acCurDb = acDocument.Database; double totalArea = default; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { int nCnt = 0; // Step through each object in Model space and // display the type of object found foreach (var acObjId in acSSet.GetObjectIds()) { var pline = acTrans.GetObject(acObjId, OpenMode.ForRead) as Polyline; if (!(pline is null)) { totalArea += pline.Area; nCnt++; } } string userInfoContetnt = $"\nSummed polylines: {nCnt}" + $"\nTotal Area: {totalArea}" + $"\nTotal area is copied to clipboard." + $"\nUse Paste command (Ctrl+V) to place vale."; Application.ShowAlertDialog(userInfoContetnt); acDocument.Editor.WriteMessage(userInfoContetnt); System.Windows.Clipboard.SetText(totalArea.ToString(CultureInfo.InvariantCulture)); } } else { Application.ShowAlertDialog("Select polylines first"); } }
/*受电馈线管理*/ private void ToolSMI_Sdkxgl_Click(object sender, EventArgs e) { if (!IsLoadDataSource()) { return; } var SDKXForm = new SDKXView(); Application.ShowModelessDialog(SDKXForm); }
private void cmdDone_Click(object sender, EventArgs e) { double staBeg = double.Parse(tbxStaStart.Text); double staEnd = double.Parse(tbxStaEnd.Text); this.Hide(); Stake_Calc.stakePoints(staBeg, staEnd); Application.ShowModelessDialog(Application.MainWindow.Handle, Forms.Stake_Forms.sForms.fStake, false); }
/// <summary> /// Shows an input box. /// </summary> /// <param name="tip">The tip.</param> /// <param name="defaultValue">The default value.</param> /// <returns>The input.</returns> public static string InputBox(string tip, string defaultValue = "") { var input = new InputBox(tip, defaultValue); if (AcadApplication.ShowModalWindow(input) == true) { return(input.Value); } return(string.Empty); }
public void ListAttributes() { var dlg = new AttributeSyncForm(); dlg.BlockName = "Old"; if (AcAp.ShowModalDialog(dlg) == DialogResult.OK) { AcAp.ShowAlertDialog(dlg.BlockName); } }
/*工单锁定设备管理*/ private void ToolSMI_Gdsd_Click(object sender, EventArgs e) { if (!IsLoadDataSource()) { return; } var woroe = new WorkOrderRangeOfEntity(); Application.ShowModelessDialog(woroe); }
public void openHelpFolder() { try { System.Diagnostics.Process.Start(HelpFile); }catch (System.Exception ex) { AcadApp.ShowAlertDialog(ex.Message); } }