protected override Result RunCommand(RhinoDoc doc, RunMode mode) { this.widthOpt = new OptionInteger(Properties.Settings.Default.Width); this.heightOpt = new OptionInteger(Properties.Settings.Default.Height); this.dpiOpt = new OptionInteger(Properties.Settings.Default.DPI); this.ratioToggle = new OptionToggle(Properties.Settings.Default.KeepRatio, "Yes", "No"); this.gridAxesToggle = new OptionToggle(Properties.Settings.Default.GridAndAxes, "Hide", "Show"); this.portraitToggle = new OptionToggle(Properties.Settings.Default.Portrait, "Landscape", "Portrait"); GetOption go = new GetOption(); go.AcceptNothing(true); int selectedResolution = Properties.Settings.Default.Resolution; this.RestoreOptions(ref go, selectedResolution); GetResult res = go.Get(); while (res == GetResult.Option) { if (go.Option().CurrentListOptionIndex >= 0) { selectedResolution = go.Option().CurrentListOptionIndex; } this.RestoreOptions(ref go, selectedResolution); res = go.Get(); } if (res != GetResult.Nothing) { return(Result.Cancel); } Properties.Settings.Default.Resolution = selectedResolution; Properties.Settings.Default.Width = widthOpt.CurrentValue; Properties.Settings.Default.Height = heightOpt.CurrentValue; Properties.Settings.Default.KeepRatio = ratioToggle.CurrentValue; Properties.Settings.Default.GridAndAxes = gridAxesToggle.CurrentValue; Properties.Settings.Default.Portrait = portraitToggle.CurrentValue; Properties.Settings.Default.Save(); RhinoHelpers.CustomScreenshot(); return(Result.Success); }
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode < 0) { return(CallNextHookEx((IntPtr)0, nCode, wParam, lParam)); } if (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_KEYUP) { bool IsKeyDown = wParam == (IntPtr)WM_KEYDOWN; Keys key = (Keys)Marshal.ReadInt32(lParam); bool hideOverlay = true; if (key == Keys.Escape) { StopWASD(); } else if (key == Keys.Q) { Q = IsKeyDown; } else if (key == Keys.W || key == Keys.Up) { W = IsKeyDown; } else if (key == Keys.E) { E = IsKeyDown; } else if (key == Keys.A || key == Keys.Left) { A = IsKeyDown; } else if (key == Keys.S || key == Keys.Down) { S = IsKeyDown; } else if (key == Keys.D || key == Keys.Right) { D = IsKeyDown; } else if (key == Keys.LShiftKey || key == Keys.RShiftKey || key == Keys.Shift || key == Keys.ShiftKey) { Shift = IsKeyDown; } else if (key == Keys.F1 && IsKeyDown) { RhinoHelpers.PreviousNamedView(); } else if (key == Keys.F2 && IsKeyDown) { RhinoHelpers.NextNamedView(); } else if (key == Keys.F3 && IsKeyDown) { RhinoHelpers.SaveNamedView(); } else if (key == Keys.F12 && IsKeyDown) { RhinoHelpers.CustomScreenshot(); } else if (key == Keys.Escape) { Esc = IsKeyDown; } else if (key == Keys.Enter) { hideOverlay = false; if (IsKeyDown) { if (Overlay.ImageVisible) { Overlay.ShowImage(null); } else { Overlay.ShowImage(Properties.Resources.Info); } } } else if (key == Keys.PrintScreen) { return(CallNextHookEx((IntPtr)0, nCode, wParam, lParam)); // forward PrintScreen Key } else { hideOverlay = false; } if (hideOverlay && Overlay.ImageVisible) { Overlay.ShowImage(null); } //RhinoApp.WriteLine("KEY:" + key); } else if (wParam == (IntPtr)WM_MOUSEMOVE) { NativeMethods.MSLLHOOKSTRUCT data = NativeMethods.GetData((IntPtr)lParam); Rhino.Display.RhinoViewport vp = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport; MouseOffset = new System.Drawing.Point(data.pt.x - MidPoint.X, data.pt.y - MidPoint.Y); } else if (wParam == (IntPtr)WM_MOUSEWHEEL) { int delta = NativeMethods.GetDelta(lParam) / 120; if (Shift) { RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Camera35mmLensLength += delta; double llength = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Camera35mmLensLength; Overlay.ShowMessage("lens length " + (int)Math.Round(llength)); RhinoDoc.ActiveDoc.Views.Redraw(); } else { if (speed + delta / 10.0 >= 0.1 && speed + delta / 10.0 <= 1.0) { speed += delta / 10.0; } else if (speed + delta >= 1 && speed + delta <= 50) { speed += delta; } Properties.Settings.Default.Speed = speed; Properties.Settings.Default.Save(); Overlay.ShowMessage("speed " + Math.Round(speed, 1)); } } else if ((int)wParam >= WM_LBUTTONDOWN && (int)wParam <= WM_RBUTTONUP) { //RhinoApp.WriteLine("CLICK " + DateTime.Now.Ticks); } else { return(CallNextHookEx((IntPtr)0, nCode, wParam, lParam)); } return(new IntPtr(-1)); }