예제 #1
0
        public static void CustomizeUI()
        {
            if (_customized)
            {
                return;
            }
            _customized = true;

            if (Instances.DocumentEditor.Controls[4] is Grasshopper.GUI.GH_MenuStrip menuStrip)
            {
                var items = menuStrip.Items.Find("mnuSpecialFolders", true);
                if (items.Length != 0 && items[0] is ToolStripMenuItem specFold)
                {
                    var samplesItem = new ToolStripMenuItem("Grasshopper-BricsCAD Connection");
                    samplesItem.Image  = specFold.DropDownItems[0].Image;
                    samplesItem.Click += (s, e) =>
                    {
                        try
                        {
                            string directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                            System.Diagnostics.Process.Start(@Path.Combine(directory, "Samples"));
                        }
                        catch (System.Exception) { }
                    };
                    specFold.DropDownItems.Add(samplesItem);
                }
            }

            if (Instances.DocumentEditor.Controls[0].Controls[1] is ToolStrip toolbar)
            {
                var linkButton = new ToolStripButton(Properties.Resources.link)
                {
                    ToolTipText = "Link with current BricsCAD document"
                };
                linkButton.Click += (s, e) => { PlugIn.RelinkToDoc(Bricscad.ApplicationServices.Application.DocumentManager.MdiActiveDocument); };
                toolbar.Items.Add(linkButton);

                var bakeSelectedButton = new ToolStripButton(Properties.Resources.bake)
                {
                    ToolTipText = "Bakes the geometry from the selected Bake Geometry and Building Element components"
                };
                bakeSelectedButton.Click += (s, e) => { BakeComponent.BakeSelectedComponents(); };
                toolbar.Items.Add(bakeSelectedButton);
            }
        }
예제 #2
0
        public static void StartGrasshopper()
        {
            PlugIn.LoadGrasshopperComponents();
            var ghDocEditor = Grasshopper.Instances.DocumentEditor;

            if (ghDocEditor == null || !ghDocEditor.Visible)
            {
                if (System.Convert.ToInt16(Application.GetSystemVariable("DWGTITLED")) == 0)
                {
                    System.Windows.Forms.MessageBox.Show("Bricscad drawing must be saved before using Grasshopper");
                    return;
                }
            }
            Rhino.RhinoApp.RunScript("!_-Grasshopper _W _T ENTER", false);
            if (Grasshopper.Instances.DocumentEditor.Visible)
            {
                PlugIn.RelinkToDoc(Application.DocumentManager.MdiActiveDocument);
            }
            GhUI.CustomizeUI();
        }
        public bool Init()
        {
            var editor     = Instances.DocumentEditor;
            var canvas     = Instances.ActiveCanvas;
            var definition = canvas?.Document;

            if (definition != ActiveDefinition)
            {
                PlugIn.SetNeetRedraw();
                UnhighlightBcData();
                if (ActiveDefinition != null)
                {
                    if (editor != null)
                    {
                        editor.VisibleChanged -= Editor_VisibleChanged;
                    }
                    ActiveDefinition.SolutionEnd     -= ActiveDefinition_SolutionEnd;
                    ActiveDefinition.SettingsChanged -= ActiveDefinition_SettingsChanged;
                    GH_Document.DefaultSelectedPreviewColourChanged -= Document_DefaultPreviewColourChanged;
                    GH_Document.DefaultPreviewColourChanged         -= Document_DefaultPreviewColourChanged;
                }

                ActiveDefinition = definition;

                if (ActiveDefinition != null)
                {
                    GH_Document.DefaultPreviewColourChanged         += Document_DefaultPreviewColourChanged;
                    GH_Document.DefaultSelectedPreviewColourChanged += Document_DefaultPreviewColourChanged;
                    ActiveDefinition.SettingsChanged += ActiveDefinition_SettingsChanged;
                    ActiveDefinition.SolutionEnd     += ActiveDefinition_SolutionEnd;
                    if (editor != null)
                    {
                        editor.VisibleChanged += Editor_VisibleChanged;
                    }
                }
            }
            return(ActiveDefinition != null);
        }
 private static void Editor_VisibleChanged(object sender, EventArgs e)
 {
     PlugIn.SetNeetRedraw();
 }
 private static void Document_DefaultPreviewColourChanged(System.Drawing.Color colour)
 {
     PlugIn.SetNeetRedraw();
 }
 private void ActiveDefinition_SolutionEnd(object sender, GH_SolutionEventArgs e)
 {
     PlugIn.SetNeetRedraw();
 }
 private void ActiveDefinition_ModifiedChanged(object sender, GH_DocModifiedEventArgs e)
 {
     PlugIn.SetNeetRedraw();
 }
 private void ActiveDefinition_SettingsChanged(object sender, GH_DocSettingsEventArgs e)
 {
     PlugIn.SetNeetRedraw();
 }