Beispiel #1
0
 /// <summary>
 /// Show a windows form that is modal in the sense that this function does not return until
 /// the form is closed, but also allows for interaction with other elements of the Rhino
 /// user interface.
 /// </summary>
 /// <param name="form">
 /// The form must have buttons that are assigned to the "AcceptButton" and "CancelButton".
 /// </param>
 /// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
 public static System.Windows.Forms.DialogResult ShowSemiModal(System.Windows.Forms.Form form)
 {
     if (Rhino.Runtime.HostUtils.RunningOnWindows)
     {
         form.Load += SemiModalFormLoad;
     }
     return(form.ShowDialog(RhinoApp.MainWindow()));
 }
Beispiel #2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var form = new Form1();
            var type = form.GetType();

            form.Show(RhinoApp.MainWindow());
            return(Result.Success);
        }
Beispiel #3
0
        // EXIT Button
        private void button1_Click(object sender, EventArgs e)
        {
            form2 = new PCCDMainEntrance(doc);
            //form2.FormClosed += OnFormClosed2;
            this.Close();

            form2.Show(RhinoApp.MainWindow());
            //Form.Show();
        }
        protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            var sprite_mode  = new Rhino.Input.Custom.OptionToggle(m_draw_single_sprite, "SpriteList", "SingleSprite");
            var size_option  = new Rhino.Input.Custom.OptionDouble(m_sprite_size);
            var space_option = new Rhino.Input.Custom.OptionToggle(m_draw_world_location, "Screen", "World");
            var go           = new Rhino.Input.Custom.GetOption();

            go.SetCommandPrompt("Sprite drawing mode");
            go.AddOptionToggle("Mode", ref sprite_mode);
            go.AddOptionDouble("Size", ref size_option);
            go.AddOptionToggle("DrawSpace", ref space_option);
            int option_go   = go.AddOption("Spin");
            int option_file = go.AddOption("FileSprite");

            Rhino.Display.DisplayPipeline.PostDrawObjects      += DisplayPipeline_PostDrawObjects;
            Rhino.Display.DisplayPipeline.CalculateBoundingBox += DisplayPipeline_CalculateBoundingBox;

            doc.Views.Redraw();
            while (go.Get() == Rhino.Input.GetResult.Option)
            {
                m_draw_single_sprite  = sprite_mode.CurrentValue;
                m_sprite_size         = (float)size_option.CurrentValue;
                m_draw_world_location = space_option.CurrentValue;
                if (go.OptionIndex() == option_go)
                {
                    var gs = new Rhino.Input.Custom.GetOption();
                    gs.SetCommandPrompt("press enter/escape to end");
                    gs.SetWaitDuration(1);

                    var vp = doc.Views.ActiveView.MainViewport;
                    while (gs.Get() == Rhino.Input.GetResult.Timeout)
                    {
                        vp.Rotate(0.1, Vector3d.ZAxis, Point3d.Origin);
                        doc.Views.Redraw();
                    }
                }
                else if (go.OptionIndex() == option_file)
                {
                    System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
                    if (dlg.ShowDialog(RhinoApp.MainWindow()) == System.Windows.Forms.DialogResult.OK)
                    {
                        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(dlg.FileName);
                        m_sprite = new Rhino.Display.DisplayBitmap(bmp);
                    }
                    doc.Views.Redraw();
                }
                else
                {
                    doc.Views.Redraw();
                }
            }

            Rhino.Display.DisplayPipeline.PostDrawObjects      -= DisplayPipeline_PostDrawObjects;
            Rhino.Display.DisplayPipeline.CalculateBoundingBox -= DisplayPipeline_CalculateBoundingBox;
            return(Rhino.Commands.Result.Success);
        }
Beispiel #5
0
        // add new printers
        private void button2_Click(object sender, EventArgs e)
        {
            if (null == form)
            {
                form             = new PCCDPrinter();
                form.FormClosed += OnFormClosed;

                form.Show(RhinoApp.MainWindow());
                //Form.Show();
            }
        }
Beispiel #6
0
 // extract all information from the beginning
 private void startANewSessionToolStripMenuItem_Click(object sender1, EventArgs e1)
 {
     if (null == Form)
     {
         Form             = new PCCDInfoSetup_New(doc);
         Form.FormClosed += OnFormClosed2;
         this.Close();
         Form.Show(RhinoApp.MainWindow());
         //Form.Show();
     }
 }
Beispiel #7
0
 // edit existing xml file
 private void editAnExistingSessionToolStripMenuItem_Click_1(object sender, EventArgs e)
 {
     if (null == Form2)
     {
         Form2             = new PCCDInfoSetup_Edit();
         Form2.FormClosed += OnFormClosed;
         this.Close();
         Form2.Show(RhinoApp.MainWindow());
         //Form.Show();
     }
 }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            if (null == Form)
            {
                Form             = new PCCDMainEntrance(doc);
                Form.FormClosed += OnFormClosed;
                Form.Show(RhinoApp.MainWindow());
            }

            return(Result.Success);
        }
Beispiel #9
0
 private void findFeasibleGroupsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (null == Form3)
     {
         Form3             = new PCCDSolve(doc);
         Form3.FormClosed += OnFormClosed3;
         this.Close();
         Form3.Show(RhinoApp.MainWindow());
         //Form.Show();
     }
 }
Beispiel #10
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            if (null == Form)
            {
                Form             = new SampleCsModelessForm();
                Form.FormClosed += OnFormClosed;
                Form.Show(RhinoApp.MainWindow());
            }

            return(Result.Success);
        }
Beispiel #11
0
 private void redesignToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (null == Form5)
     {
         Form5             = new PCCDConsolidation(doc);
         Form5.FormClosed += OnFormClosed5;
         this.Close();
         Form5.Show(RhinoApp.MainWindow());
         //Form.Show();
     }
 }
Beispiel #12
0
        /// <summary>
        /// Runs the command
        /// </summary>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            SampleCsModelessTextForm.setRhinoDoc(doc);
            if (null == Form)
            {
                Form             = new SampleCsModelessTextForm();
                Form.FormClosed += new System.Windows.Forms.FormClosedEventHandler(Form_FormClosed);
                Form.Show(RhinoApp.MainWindow());
            }

            return(Result.Success);
        }
Beispiel #13
0
 /// <summary>
 /// Displays Rhino's check list box.
 /// </summary>
 /// <param name="title">The dialog title.</param>
 /// <param name="message">The dialog message.</param>
 /// <param name="items">A list of items to show.</param>
 /// <param name="checkState">A list of true/false boolean values.</param>
 /// <returns>An array or boolean values determining if the user checked the corresponding box. On error, null.</returns>
 public static bool[] ShowCheckListBox(string title, string message, System.Collections.IList items, System.Collections.Generic.IList <bool> checkState)
 {
     bool[] rc = null;
     if (items != null && items.Count > 0 && checkState != null && checkState.Count == items.Count)
     {
         ListBoxForm dlg = new ListBoxForm(title, message, items, checkState);
         if (dlg.ShowDialog(RhinoApp.MainWindow()) == System.Windows.Forms.DialogResult.OK)
         {
             rc = dlg.GetCheckedItemStates();
         }
     }
     return(rc);
 }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Check the selected dot
            GetObject go = new GetObject();

            go.GroupSelect     = true;
            go.SubObjectSelect = false;
            go.EnableClearObjectsOnEntry(false);
            go.EnableUnselectObjectsOnExit(false);
            go.DeselectAllBeforePostSelect = false;
            go.EnableSelPrevious(true);
            go.EnablePreSelect(true, false);
            go.GeometryFilter = Rhino.DocObjects.ObjectType.Annotation;

            go.SetCommandPrompt("Select Text to replace:");
            GetResult result = go.GetMultiple(1, -1);

            if (go.CommandResult() != Rhino.Commands.Result.Success)
            {
                return(go.CommandResult());
            }

            RhinoApp.WriteLine("Object selection counter = {0}", go.ObjectCount);

            List <TextEntity>  textEntityList  = new List <TextEntity>();
            List <RhinoObject> rhinoObjectList = new List <RhinoObject>();

            // Loop through all the objects to find Text
            for (int i = 0; i < go.ObjectCount; i++)
            {
                RhinoObject rhinoObject = go.Object(i).Object();

                if (rhinoObject.ObjectType == ObjectType.Annotation)
                {
                    TextEntity textEntity = rhinoObject.Geometry as TextEntity;

                    if (textEntity != null)
                    {
                        rhinoObjectList.Add(rhinoObject);
                    }
                }
            }

            FindAndReplaceForm findForm = new FindAndReplaceForm(rhinoObjectList);

            findForm.ShowDialog(RhinoApp.MainWindow());

            doc.Views.Redraw();

            return(Result.Success);
        }
Beispiel #15
0
            public static object ShowListBox(string title, string message, System.Collections.IList items, object selectedItem)
            {
                object rc = null;

                if (items != null && items.Count > 0)
                {
                    ListBoxForm dlg = new ListBoxForm(title, message, items, selectedItem);
                    if (dlg.ShowDialog(RhinoApp.MainWindow()) == System.Windows.Forms.DialogResult.OK)
                    {
                        rc = dlg.SelectedItem();
                    }
                }
                return(rc);
            }
Beispiel #16
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Check the selected curve
            GetObject go = new GetObject();

            go.GroupSelect     = true;
            go.SubObjectSelect = false;
            go.EnableClearObjectsOnEntry(false);
            go.EnableUnselectObjectsOnExit(false);
            go.DeselectAllBeforePostSelect = false;
            go.EnableSelPrevious(true);
            go.EnablePreSelect(true, false);
            go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;

            GetResult result = go.Get();

            if (go.CommandResult() != Rhino.Commands.Result.Success)
            {
                return(go.CommandResult());
            }

            if (go.ObjectCount != 1)
            {
                RhinoApp.WriteLine("Error: {0} curve is selected.", go.ObjectCount);
                return(Rhino.Commands.Result.Failure);
            }

            RhinoApp.WriteLine("{0} curve is selected.", go.ObjectCount);

            Curve curve = go.Object(0).Curve();

            // If curve is null
            if (curve == null)
            {
                return(Rhino.Commands.Result.Failure);
            }

            // If curve is Closed Curve Orientation
            if (curve.IsClosed == false)
            {
                RhinoApp.WriteLine("The curve is open");
                return(Rhino.Commands.Result.Failure);
            }
            RhinoUtilities.SetActiveLayer(Properties.Settings.Default.PerforationLayerName, System.Drawing.Color.Green);
            PerforationForm perforationForm = new PerforationForm(curve);

            perforationForm.ShowDialog(RhinoApp.MainWindow());
            RhinoDoc.ActiveDoc.Views.Redraw();
            return(Result.Success);
        }
Beispiel #17
0
            public static System.Windows.Forms.DialogResult ShowNumberBox(string title, string message, ref double number, double minimum, double maximum)
            {
                string defaultText = String.Empty;

                if (number != RhinoMath.UnsetValue)
                {
                    defaultText = number.ToString();
                }
                StringBoxForm dlg = new StringBoxForm(title, message, defaultText);

                dlg.SetAsNumberInput(minimum, maximum);
                System.Windows.Forms.DialogResult rc = dlg.ShowDialog(RhinoApp.MainWindow());
                if (rc == System.Windows.Forms.DialogResult.OK)
                {
                    string text = dlg.GetText();
                    double.TryParse(text, out number);
                }
                return(rc);
            }
Beispiel #18
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // launch Unify window
            var result = Result.Cancel;

            if (mode == RunMode.Interactive)
            {
                InputData inputData = new InputData(doc);
                var       form      = new UnifyForm(inputData)
                {
                    StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
                };
                var dialog_result = form.ShowDialog(RhinoApp.MainWindow());
                if (dialog_result == System.Windows.Forms.DialogResult.OK)
                {
                    result = Result.Success;
                }
            }
            return(result);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var rc = Result.Cancel;

            if (mode == RunMode.Interactive)
            {
                var form = new SampleCsModalForm {
                    StartPosition = FormStartPosition.CenterParent
                };
                var dialog_result = form.ShowDialog(RhinoApp.MainWindow());
                if (dialog_result == DialogResult.OK)
                {
                    rc = Result.Success;
                }
            }
            else
            {
                var msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName);
                RhinoApp.WriteLine(msg);
            }

            return(rc);
        }
Beispiel #20
0
 public static System.Windows.Forms.DialogResult ShowEditBox(string title, string message, string defaultText, bool multiline, out string text)
 {
     text = String.Empty;
     System.Windows.Forms.DialogResult rc;
     if (multiline)
     {
         EditBoxForm dlg = new EditBoxForm(title, message, defaultText);
         rc = dlg.ShowDialog(RhinoApp.MainWindow());
         if (rc == System.Windows.Forms.DialogResult.OK)
         {
             text = dlg.GetText();
         }
     }
     else
     {
         StringBoxForm dlg = new StringBoxForm(title, message, defaultText);
         rc = dlg.ShowDialog(RhinoApp.MainWindow());
         if (rc == System.Windows.Forms.DialogResult.OK)
         {
             text = dlg.GetText();
         }
     }
     return(rc);
 }
Beispiel #21
0
            /// <summary>
            /// Displays the standard modal color picker dialog for floating point colors.
            /// </summary>
            /// <param name="parent">Parent window for this dialog, should always pass this if calling from a form or user control.</param>
            /// <param name="color">The initial color to set the picker to and also accepts the user's choice.</param>
            /// <param name="allowAlpha">Specifies if the color picker should allow changes to the alpha channel or not.</param>
            /// <returns>true if a color was picked, false if the user canceled the picker dialog.</returns>
            public static bool ShowColorDialog(System.Windows.Forms.IWin32Window parent, ref Rhino.Display.Color4f color, bool allowAlpha)
            {
                if (null == parent)
                {
                    parent = RhinoApp.MainWindow();
                }

                IntPtr hWnd = IntPtr.Zero;

                if (null != parent)
                {
                    hWnd = parent.Handle;
                }

                Rhino.Display.Color4f c = Rhino.Display.Color4f.Empty;

                bool rc = (1 == UnsafeNativeMethods.Rdk_Globals_ShowColorPicker(hWnd, color, allowAlpha, ref c));

                if (rc)
                {
                    color = c;
                }
                return(rc);
            }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Check the selected curve
            GetObject go = new GetObject();

            go.GroupSelect     = true;
            go.SubObjectSelect = false;
            go.EnableClearObjectsOnEntry(false);
            go.EnableUnselectObjectsOnExit(false);
            go.DeselectAllBeforePostSelect = false;
            go.EnableSelPrevious(true);
            go.EnablePreSelect(true, false);
            go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;

            GetResult result = go.GetMultiple(1, -1);

            if (go.CommandResult() != Rhino.Commands.Result.Success)
            {
                return(go.CommandResult());
            }

            RhinoApp.WriteLine("{0} curve is selected.", go.ObjectCount);

            // Process the curveList and put it in a data structure
            List <Circle> circleList = new List <Circle>();

            double diameter = -1;
            Circle circle;

            for (int i = 0; i < go.ObjectCount; i++)
            {
                Curve currentCurve = go.Object(i).Curve();
                bool  converted    = currentCurve.TryGetCircle(out circle);

                if (converted == true)
                {
                    if (diameter == -1)
                    {
                        diameter = circle.Diameter;
                    }
                    else if (Math.Abs(diameter - circle.Diameter) > Properties.Settings.Default.Tolerance)
                    {
                        RhinoApp.WriteLine("Not all the curves are the same size. {0}", currentCurve.ToString());
                        return(Rhino.Commands.Result.Failure);
                    }
                }

                circleList.Add(circle);
            }

            ClusterToolSearcherForm clusterToolSearcherForm = new ClusterToolSearcherForm(circleList);

            clusterToolSearcherForm.ShowDialog(RhinoApp.MainWindow());

            //Curve curve = go.Object(0).Curve();

            //// If curve is null
            //if (curve == null)
            //{
            //   return Rhino.Commands.Result.Failure;
            //}

            //// If curve is Closed Curve Orientation
            //if (curve.IsClosed == false)
            //{
            //   RhinoApp.WriteLine("The curve is open");
            //   return Rhino.Commands.Result.Failure;
            //}

            //PerforationForm perforationForm = new PerforationForm(curve);

            //perforationForm.ShowDialog(RhinoApp.MainWindow());

            return(Result.Success);
        }
Beispiel #23
0
        public static ForeachParallelResultEnum ExecuteParallelMethodInDialogWindow(string progressCaption, Func <ForeachParallelResultEnum> foreachFunc, bool wait150millisecondsBeforeShowAnyProgress = true)
        {
            //return foreachFunc();
            //if (Shared.FILEGROUPOPERATIONS_ENABLED)
            //{
            //    return foreachFunc();
            //}
            //log.temp("Progress: " + progressCaption);

            //
            // allocate window
            //
            AlocateOrReuseWindow();

            //
            // Add progress item
            //
            var addProgress = !String.IsNullOrEmpty(progressCaption);

            if (addProgress)
            {
                Window.AddProgress(progressCaption);
                //log.temp("added");
            }

            //
            // run foreach method
            //
            try
            {
                if (!Window.Visible) // if ColoredProgress window is not opened - open if as dialog and execute method inside dialog itself
                {
                    if (!wait150millisecondsBeforeShowAnyProgress)
                    {
                        DisableWait150millisecondsBeforeShowAnyProgress();
                    }
                    using (new WaitCursor())
                    {
                        Window.ForeachFuncSavedBeforeShowModal = foreachFunc;
                        lock (Shared.RhinoLock)
                        {
                            RhinoApp.Wait();
                        }
                        var h   = RhinoApp.MainWindow();
                        var res = Window.ShowDialog(h); // here we will execute 'ForeachFuncSavedBeforeShowModal'
                        return(res == DialogResult.OK ? ForeachParallelResultEnum.Ok : ForeachParallelResultEnum.Terminated);
                    }
                }
                else
                {
                    return(foreachFunc());
                }
            }
            finally
            {
                if (addProgress)
                {
                    Window.CurrentProgress.Status = StatusItem.CurrentStatus.Complete;
                }
            }
        }
Beispiel #24
0
 // exit
 private void button6_Click(object sender, EventArgs e)
 {
     this.Dispose();
     form = new PCCDMainEntrance(doc);
     form.Show(RhinoApp.MainWindow());
 }