//CONSTRUCTOR //default values obtained from original Grasshopper component variables public VarVM(IVariable dvar, Design d) { DesignVar = dvar; this.Design = d; //value trackers this.OriginalValue = DesignVar.CurrentValue; this.BestSolutionValue = DesignVar.CurrentValue; this._name = DesignVar.Parameter.NickName; this._value = DesignVar.CurrentValue; this._min = DesignVar.Min; this._max = DesignVar.Max; this.IsActive = true; this.OptRunning = false; }
//[STAThread] public override Grasshopper.GUI.Canvas.GH_ObjectResponse RespondToMouseDoubleClick(Grasshopper.GUI.Canvas.GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { //Prevent opening of multiple windows at once if (!MyComponent.IsWindowOpen && MyComponent.InputsSatisfied) { MyComponent.IsWindowOpen = true; Design design = new Design(MyComponent); Thread viewerThread = new Thread(delegate() { RadicalVM radVM = new RadicalVM(design, this.MyComponent); Window viewer = new RadicalWindow(radVM); viewer.Show(); System.Windows.Threading.Dispatcher.Run(); }); viewerThread.SetApartmentState(ApartmentState.STA); // needs to be STA or throws exception viewerThread.Start(); } return(base.RespondToMouseDoubleClick(sender, e)); }