///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoView view = RhUtil.RhinoApp().ActiveView(); if (view == null) return IRhinoCommand.result.nothing; MRhinoGetOption go = new MRhinoGetOption(); go.SetCommandPrompt("Capture Method"); go.SetCommandPromptDefault("ViewCapture"); int viewcap = go.AddCommandOption(new MRhinoCommandOptionName("ViewCapture")); int screencap = go.AddCommandOption(new MRhinoCommandOptionName("ScreenCapture")); go.GetOption(); if (go.CommandResult() != IRhinoCommand.result.success) return go.CommandResult(); System.Drawing.Bitmap bmp = null; if (go.Option().m_option_index == viewcap) { MRhinoDisplayPipeline pipeline = view.DisplayPipeline(); int left = 0, right = 0, bot = 0, top = 0; view.MainViewport().VP().GetScreenPort(ref left, ref right, ref bot, ref top); int w = right - left; int h = bot - top; bmp = new System.Drawing.Bitmap(w, h); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp); MDisplayPipelineAttributes attr = new MDisplayPipelineAttributes(pipeline.DisplayAttrs()); bool rc = pipeline.DrawToDC(g, w, h, attr); g.Dispose(); if (!rc) bmp = null; } else { bmp = new System.Drawing.Bitmap(1, 1); bool rc = view.ScreenCaptureToBitmap(ref bmp, true, false); if (!rc) bmp = null; } if (bmp != null) { string mydir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); string path = System.IO.Path.Combine(mydir, "capture.png"); bmp.Save(path); return IRhinoCommand.result.success; } return IRhinoCommand.result.failure; }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { System.Guid id = CsDockingDialogDockBar.ID(); bool bVisible = RMA.UI.MRhinoDockBarManager.IsDockBarVisible(id); string prompt; if (bVisible) prompt = string.Format("{0} window is visible. New value", EnglishCommandName()); else prompt = string.Format("{0} window is hidden. New value", EnglishCommandName()); MRhinoGetOption go = new MRhinoGetOption(); go.SetCommandPrompt(prompt); int h_option = go.AddCommandOption(new MRhinoCommandOptionName("Hide")); int s_option = go.AddCommandOption(new MRhinoCommandOptionName("Show")); int t_option = go.AddCommandOption(new MRhinoCommandOptionName("Toggle")); go.GetOption(); if (go.CommandResult() != IRhinoCommand.result.success) return go.CommandResult(); IRhinoCommandOption opt = go.Option(); if (opt == null) return IRhinoCommand.result.failure; int option_index = opt.m_option_index; if (h_option == option_index) { if (bVisible) RMA.UI.MRhinoDockBarManager.ShowDockBar(id, false, false); } else if (s_option == option_index) { if (!bVisible) RMA.UI.MRhinoDockBarManager.ShowDockBar(id, true, false); } else if (t_option == option_index) { if (bVisible) RMA.UI.MRhinoDockBarManager.ShowDockBar(id, false, false); else RMA.UI.MRhinoDockBarManager.ShowDockBar(id, true, false); } return IRhinoCommand.result.success; }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoView view = RhUtil.RhinoApp().ActiveView(); if (view == null) { return(IRhinoCommand.result.nothing); } MRhinoGetOption go = new MRhinoGetOption(); go.SetCommandPrompt("Capture Method"); go.SetCommandPromptDefault("ViewCapture"); int viewcap = go.AddCommandOption(new MRhinoCommandOptionName("ViewCapture")); int screencap = go.AddCommandOption(new MRhinoCommandOptionName("ScreenCapture")); go.GetOption(); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } System.Drawing.Bitmap bmp = null; if (go.Option().m_option_index == viewcap) { MRhinoDisplayPipeline pipeline = view.DisplayPipeline(); int left = 0, right = 0, bot = 0, top = 0; view.MainViewport().VP().GetScreenPort(ref left, ref right, ref bot, ref top); int w = right - left; int h = bot - top; bmp = new System.Drawing.Bitmap(w, h); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp); MDisplayPipelineAttributes attr = new MDisplayPipelineAttributes(pipeline.DisplayAttrs()); bool rc = pipeline.DrawToDC(g, w, h, attr); g.Dispose(); if (!rc) { bmp = null; } } else { bmp = new System.Drawing.Bitmap(1, 1); bool rc = view.ScreenCaptureToBitmap(ref bmp, true, false); if (!rc) { bmp = null; } } if (bmp != null) { string mydir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); string path = System.IO.Path.Combine(mydir, "capture.png"); bmp.Save(path); return(IRhinoCommand.result.success); } return(IRhinoCommand.result.failure); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { Guid id = SampleCsObjectManagerDockBar.ID(); bool bVisible = MRhinoDockBarManager.IsDockBarVisible(id); string prompt; if (bVisible) { prompt = string.Format("{0} window is visible. New value", EnglishCommandName()); } else { prompt = string.Format("{0} window is hidden. New value", EnglishCommandName()); } MRhinoGetOption go = new MRhinoGetOption(); go.SetCommandPrompt(prompt); int h_option = go.AddCommandOption(new MRhinoCommandOptionName("Hide")); int s_option = go.AddCommandOption(new MRhinoCommandOptionName("Show")); int t_option = go.AddCommandOption(new MRhinoCommandOptionName("Toggle")); go.GetOption(); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } IRhinoCommandOption opt = go.Option(); if (opt == null) { return(IRhinoCommand.result.failure); } int option_index = opt.m_option_index; if (h_option == option_index) { if (bVisible) { MRhinoDockBarManager.ShowDockBar(id, false, false); } } else if (s_option == option_index) { if (!bVisible) { MRhinoDockBarManager.ShowDockBar(id, true, false); } } else if (t_option == option_index) { if (bVisible) { MRhinoDockBarManager.ShowDockBar(id, false, false); } else { MRhinoDockBarManager.ShowDockBar(id, true, false); } } return(IRhinoCommand.result.success); }