Example #1
0
 private void _window_Closed(object sender, EventArgs e)
 {
     this._window = null;
 }
Example #2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            #region Default command
            // TODO: start here modifying the behaviour of your command.
            // ---
            //RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName);

            //Point3d pt0;
            //using (GetPoint getPointAction = new GetPoint())
            //{
            //    getPointAction.SetCommandPrompt("Please select the start point");
            //    if (getPointAction.Get() != GetResult.Point)
            //    {
            //        RhinoApp.WriteLine("No start point was selected.");
            //        return getPointAction.CommandResult();
            //    }
            //    pt0 = getPointAction.Point();
            //}

            //Point3d pt1;
            //using (GetPoint getPointAction = new GetPoint())
            //{
            //    getPointAction.SetCommandPrompt("Please select the end point");
            //    getPointAction.SetBasePoint(pt0, true);
            //    getPointAction.DynamicDraw +=
            //      (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed);
            //    if (getPointAction.Get() != GetResult.Point)
            //    {
            //        RhinoApp.WriteLine("No end point was selected.");
            //        return getPointAction.CommandResult();
            //    }
            //    pt1 = getPointAction.Point();
            //}

            //doc.Objects.AddLine(pt0, pt1);
            //doc.Views.Redraw();
            //RhinoApp.WriteLine("The {0} command added one line to the document.", EnglishName);

            // ---
            #endregion

            if (!_handlerIsAttached)
            {
                Frixel.UI.MainWindow.ReferenceFromClient += MainWindow_ReferenceFromClient;
                Frixel.UI.MainWindow.UpdateClient        += MainWindow_UpdateClient;
                Frixel.UI.MainWindow.BakeStructure       += MainWindow_BakeStructure;
                _handlerIsAttached = true;
            }

            // Create a FrixelWindow
            if (_window == null)
            {
                _window         = new Frixel.UI.MainWindow();
                _window.Closed += _window_Closed;
                RhinoApp.WriteLine("Launching Frixel Window", EnglishName);
                new System.Windows.Interop.WindowInteropHelper(_window).Owner = Rhino.RhinoApp.MainWindowHandle();
                this._doc = doc;
            }

            // Show theFrixelWindow
            _window.ShowWindow();

            return(Result.Success);
        }