///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select surface or polysurface for direction display"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object | IRhinoGetObject.GEOMETRY_TYPE_FILTER.polysrf_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) return go.CommandResult(); MRhinoObjRef obj_ref = go.Object(0); IOnBrep brep = obj_ref.Brep(); if (null == brep) return IRhinoCommand.result.failure; bool bIsSolid = brep.IsSolid(); bool bFlip = false; SampleCsSurfaceDirectionConduit conduit = new SampleCsSurfaceDirectionConduit(); conduit.SetBrep(brep); conduit.Enable(); context.m_doc.Redraw(); MRhinoGetOption gf = new MRhinoGetOption(); gf.SetCommandPrompt("Press Enter when done"); gf.AcceptNothing(); if (!bIsSolid) gf.AddCommandOption(new MRhinoCommandOptionName("Flip")); for (; ; ) { IRhinoGet.result res = gf.GetOption(); if (res == IRhinoGet.result.option) { bFlip = !bFlip; conduit.SetFlip(bFlip); context.m_doc.Redraw(); continue; } if (res == IRhinoGet.result.nothing) { if (!bIsSolid && bFlip) { OnBrep flipped_brep = new OnBrep(brep); flipped_brep.Flip(); context.m_doc.ReplaceObject(obj_ref, flipped_brep); } } break; } conduit.Disable(); context.m_doc.Redraw(); 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) { 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) { MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select surface or polysurface for direction display"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object | IRhinoGetObject.GEOMETRY_TYPE_FILTER.polysrf_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } MRhinoObjRef obj_ref = go.Object(0); IOnBrep brep = obj_ref.Brep(); if (null == brep) { return(IRhinoCommand.result.failure); } bool bIsSolid = brep.IsSolid(); bool bFlip = false; SampleCsSurfaceDirectionConduit conduit = new SampleCsSurfaceDirectionConduit(); conduit.SetBrep(brep); conduit.Enable(); context.m_doc.Redraw(); MRhinoGetOption gf = new MRhinoGetOption(); gf.SetCommandPrompt("Press Enter when done"); gf.AcceptNothing(); if (!bIsSolid) { gf.AddCommandOption(new MRhinoCommandOptionName("Flip")); } for (; ;) { IRhinoGet.result res = gf.GetOption(); if (res == IRhinoGet.result.option) { bFlip = !bFlip; conduit.SetFlip(bFlip); context.m_doc.Redraw(); continue; } if (res == IRhinoGet.result.nothing) { if (!bIsSolid && bFlip) { OnBrep flipped_brep = new OnBrep(brep); flipped_brep.Flip(); context.m_doc.ReplaceObject(obj_ref, flipped_brep); } } break; } conduit.Disable(); context.m_doc.Redraw(); 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); }