Пример #1
0
        public void DoIt()
        {
            // Get the tool GUID;
            Type          t        = typeof(SimpleTool);
            GuidAttribute guidAttr = (GuidAttribute)t.GetCustomAttributes(typeof(GuidAttribute), false)[0];
            Guid          guid     = new Guid(guidAttr.Value);

            // don't redefine the stock tool if it's already in the catalog
            ToolPaletteManager mgr = ToolPaletteManager.Manager;

            if (mgr.StockToolCatalogs.Find(guid) != null)
            {
                return;
            }

            SimpleTool tool = new SimpleTool();

            tool.New();

            Catalog catalog = tool.CreateStockTool("SimpleCatalog");
            Palette palette = tool.CreatePalette(catalog, "SimplePalette");
            Package package = tool.CreateShapeCatalog("*AutoCADShapes");

            tool.CreateFlyoutTool(palette, package, null);
            ImageInfo imageInfo = new ImageInfo();

            imageInfo.ResourceFile = "TOOL1.bmp";
            imageInfo.Size         = new System.Drawing.Size(65, 65);

            tool.CreateCommandTool(palette, "Line", imageInfo, tool.CmdName);
            tool.CreateTool(palette, "Custom Line", imageInfo);
            mgr.LoadCatalogs();
        }
        public void DoIt()
        {
            // Get the tool GUID;
            Type t = typeof(SimpleTool);
            GuidAttribute guidAttr = (GuidAttribute)t.GetCustomAttributes(typeof(GuidAttribute), false)[0];
            Guid guid = new Guid(guidAttr.Value);

            // don't redefine the stock tool if it's already in the catalog
            ToolPaletteManager mgr = ToolPaletteManager.Manager;
            if (mgr.StockToolCatalogs.Find(guid) != null)
                return;

            SimpleTool tool = new SimpleTool();
            tool.New();

            Catalog catalog = tool.CreateStockTool("SimpleCatalog");
            Palette palette = tool.CreatePalette(catalog, "SimplePalette");
            Package package = tool.CreateShapeCatalog("*AutoCADShapes");
            tool.CreateFlyoutTool(palette, package, null);
            ImageInfo imageInfo = new ImageInfo();
            imageInfo.ResourceFile = "TOOL1.bmp";
            imageInfo.Size=new System.Drawing.Size(65,65);

            tool.CreateCommandTool(palette, "Line", imageInfo, tool.CmdName);
            tool.CreateTool(palette, "Custom Line",imageInfo);
            mgr.LoadCatalogs();
        }