public void AddToolBar()
        {
            //获取当前运行的程序集
            System.Reflection.Module myModule = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0];
            //获取当前运行的程序集的完整路径(包含文件名)
            string modulePath = myModule.FullyQualifiedName;

            //获取去除文件名后程序集的路径,即程序集所在的文件夹
            modulePath = modulePath.Substring(0, modulePath.LastIndexOf("\\"));
            //COM方式获取AutoCAD应用程序对象
            AcadApplication acadApp = (AcadApplication)Application.AcadApplication;
            //获取当前菜单组,用于加入工具栏
            AcadMenuGroup currMenuGroup = acadApp.MenuGroups.Item(0);
            //为AutoCAD添加一个新的工具栏,并设置标题为"我的工具栏"
            AcadToolbar tbModify = currMenuGroup.Toolbars.Add("我的工具栏");
            //在新建的工具栏中添加一个"复制"按钮,以调用复制命令
            AcadToolbarItem button0 = tbModify.AddToolbarButton("", "复制", "复制对象", "_Copy ", Type.Missing);

            //设置复制按钮的图片
            button0.SetBitmaps(modulePath + "\\Resources\\Copy.bmp", modulePath + "\\Resources\\Copy.bmp");
            //'添加一个"删除"按钮,以调用删除命令
            AcadToolbarItem button1 = tbModify.AddToolbarButton("", "删除", "从图形删除对象", "_Erase ", Type.Missing);

            //设置删除按钮的图片
            button1.SetBitmaps(modulePath + "\\Resources\\Erase.bmp", modulePath + "\\Resources\\Erase.bmp");
            //添加一个"移动"按钮,以调用删除命令
            AcadToolbarItem button2 = tbModify.AddToolbarButton("", "移动", "移动对象", "_Move ", Type.Missing);

            //设置移动按钮的图片
            button2.SetBitmaps(modulePath + "\\Resources\\Move.bmp", modulePath + "\\Resources\\Move.bmp");
            //添加一个"旋转"按钮,以调用旋转命令
            AcadToolbarItem button3 = tbModify.AddToolbarButton("", "旋转", "绕基点旋转对象", "_Rotate ", Type.Missing);

            //设置旋转按钮的图片
            button3.SetBitmaps(modulePath + "\\Resources\\Rotate.bmp", modulePath + "\\Resources\\Rotate.bmp");

            //添加一个弹出按钮,该按钮只用来附着下面的画图工具栏
            AcadToolbarItem FlyoutButton = tbModify.AddToolbarButton("", "画图工具", "画图工具", " ", true);
            //创建第二个工具栏。该工具栏将通过弹出按钮附加到第一个工具栏。
            AcadToolbar tbDraw = currMenuGroup.Toolbars.Add("画图工具栏");
            //下面的语句分别在工具栏上设置绘制圆、直线、多段线、矩形的按钮
            AcadToolbarItem button4 = tbDraw.AddToolbarButton("", "圆", "用指定半径创建圆", "_Circle ", Type.Missing);

            button4.SetBitmaps(modulePath + "\\Resources\\Circle.bmp", modulePath + "\\Resources\\Circle.bmp");
            AcadToolbarItem button5 = tbDraw.AddToolbarButton("", "直线", "创建直线段", "_Line ", Type.Missing);

            button5.SetBitmaps(modulePath + "\\Resources\\Line.bmp", modulePath + "\\Resources\\Line.bmp");
            AcadToolbarItem button6 = tbDraw.AddToolbarButton("", "多段线", "创建二维多段线", "_Pline ", Type.Missing);

            button6.SetBitmaps(modulePath + "\\Resources\\Polyline.bmp", modulePath + "\\Resources\\Polyline.bmp");
            AcadToolbarItem button7 = tbDraw.AddToolbarButton("", "矩形", "创建矩形多段线", "_Rectangle ", Type.Missing);

            button7.SetBitmaps(modulePath + "\\Resources\\Rectangle.bmp", modulePath + "\\Resources\\Rectangle.bmp");
            //将第二个工具栏附着到第一个工具栏的弹出按钮上
            FlyoutButton.AttachToolbarToFlyout(currMenuGroup.Name, tbDraw.Name);
            //显示第一个工具栏
            tbModify.Visible = true;
            //隐藏第二个工具栏
            tbDraw.Visible = false;
        }
Exemple #2
0
        public static void TopologyManagerBar()
        {
            var acadApp = (AcadApplication)acApp.AcadApplication;

            TopologyTool = acadApp.MenuGroups.Item(0).Toolbars.Add("拓扑管理");
            var syzz = Path.Combine(dirPath, "Resource\\上游.bmp");

            TopologyTool.AddToolbarButton(0, "上游追踪", "", "SYZZ ", Type.Missing).SetBitmaps(syzz, syzz);
            var xyzz = Path.Combine(dirPath, "Resource\\下游.bmp");

            TopologyTool.AddToolbarButton(1, "下游追踪", "", "XYZZ ", Type.Missing).SetBitmaps(xyzz, xyzz);
            var qxzz = Path.Combine(dirPath, "Resource\\取消和打段.bmp");

            TopologyTool.AddToolbarButton(2, "取消追踪", "", "cls ", Type.Missing).SetBitmaps(qxzz, qxzz);

            var pldd = Path.Combine(dirPath, "Resource\\批量打段.bmp");

            TopologyTool.AddToolbarButton(3, "批量打断", "", "pldd ", Type.Missing).SetBitmaps(pldd, pldd);
            var zdlj = Path.Combine(dirPath, "Resource\\自动连接.bmp");

            TopologyTool.AddToolbarButton(4, "自动连接", "", "autoc ", Type.Missing).SetBitmaps(zdlj, zdlj);
            var lxlj = Path.Combine(dirPath, "Resource\\连选连接.bmp");

            TopologyTool.AddToolbarButton(5, "连选连接", "", "lxlj ", Type.Missing).SetBitmaps(lxlj, lxlj);
            var mxjl = Path.Combine(dirPath, "Resource\\母线建立.bmp");

            TopologyTool.AddToolbarButton(6, "母线建立", "", "mxjl ", Type.Missing).SetBitmaps(mxjl, mxjl);

            TopologyTool.Visible = true;
            //工具栏靠右边停靠
            TopologyTool.Dock(Autodesk.AutoCAD.Interop.Common.AcToolbarDockStatus.acToolbarDockLeft);
        }
Exemple #3
0
        public static void DrawManagerBar()
        {
            var acadApp = (AcadApplication)acApp.AcadApplication;

            DrawTool = acadApp.MenuGroups.Item(0).Toolbars.Add("绘图管理");
            var pan = Path.Combine(dirPath, "Resource\\漫游.bmp");

            DrawTool.AddToolbarButton(0, "漫游", "", "pan ", Type.Missing).SetBitmaps(pan, pan);

            var pldd = Path.Combine(dirPath, "Resource\\复制.bmp");

            DrawTool.AddToolbarButton(1, "复制", "", "COPY ", Type.Missing).SetBitmaps(pldd, pldd);
            var zdlj = Path.Combine(dirPath, "Resource\\移动.bmp");

            DrawTool.AddToolbarButton(2, "移动", "", "SBYD ", Type.Missing).SetBitmaps(zdlj, zdlj);
            var lxlj = Path.Combine(dirPath, "Resource\\旋转.bmp");

            DrawTool.AddToolbarButton(3, "旋转", "", "SBXZ ", Type.Missing).SetBitmaps(lxlj, lxlj);
            var sbjx = Path.Combine(dirPath, "Resource\\镜像.bmp");

            DrawTool.AddToolbarButton(4, "镜像", "", "mi ", Type.Missing).SetBitmaps(sbjx, sbjx);
            var ddyd = Path.Combine(dirPath, "Resource\\打断于点.bmp");

            DrawTool.AddToolbarButton(5, "打断于点", "", "ddyd ", Type.Missing).SetBitmaps(ddyd, ddyd);
            var lddd = Path.Combine(dirPath, "Resource\\两点打断.bmp");

            DrawTool.AddToolbarButton(6, "两点打断", "", "lddd ", Type.Missing).SetBitmaps(lddd, lddd);
            DrawTool.AddSeparator(7);

            var jdcz = Path.Combine(dirPath, "Resource\\节点操作.bmp");

            DrawTool.AddToolbarButton(8, "新增节点", "", "av ", Type.Missing).SetBitmaps(jdcz, jdcz);
            var scjd = Path.Combine(dirPath, "Resource\\删除节点.bmp");

            DrawTool.AddToolbarButton(9, "删除节点", "", "rv ", Type.Missing).SetBitmaps(scjd, scjd);

            var redraw = Path.Combine(dirPath, "Resource\\重新绘制.bmp");

            DrawTool.AddToolbarButton(10, "重绘设备", "", "ch ", Type.Missing).SetBitmaps(redraw, redraw);


            var fidcx = Path.Combine(dirPath, "Resource\\FID.bmp");

            DrawTool.AddToolbarButton(11, "FID查询", "", "fidcx ", Type.Missing).SetBitmaps(fidcx, fidcx);
            var sbdw = Path.Combine(dirPath, "Resource\\设备定位.bmp");

            DrawTool.AddToolbarButton(12, "设备定位", "", "sbdw ", Type.Missing).SetBitmaps(sbdw, sbdw);
            var zbdw = Path.Combine(dirPath, "Resource\\坐标定位.bmp");

            DrawTool.AddToolbarButton(13, "坐标定位", "", "zbdw ", Type.Missing).SetBitmaps(zbdw, zbdw);
            var gdsd = Path.Combine(dirPath, "Resource\\定位锁定框.bmp");

            DrawTool.AddToolbarButton(14, "定位锁定框", "", "zz ", Type.Missing).SetBitmaps(gdsd, gdsd);
            var re = Path.Combine(dirPath, "Resource\\刷新.bmp");

            DrawTool.AddToolbarButton(15, "刷新", "", "rec ", Type.Missing).SetBitmaps(re, re);


            DrawTool.Visible = true;
            DrawTool.top     = 100;
            DrawTool.left    = 400;
            //工具栏靠右边停靠
            //DrawTool.Dock(Autodesk.AutoCAD.Interop.Common.AcToolbarDockStatus.acToolbarDockLeft);
        }