/// <summary>
 /// Virtual MRhinoDisplayConduit.ExecConduit override
 /// </summary>
 public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate)
 {
     if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX)
     {
         m_pChannelAttrs.m_BoundingBox.Union(m_line.BoundingBox());
     }
     else if (nChannel == MSupportChannels.SC_DRAWOVERLAY)
     {
         dp.DrawLine(m_line.from, m_line.to, m_pDisplayAttrs.m_ObjectColor | 0xFF000000, m_pDisplayAttrs.m_nLineThickness);
         if (m_bDraw)
         {
             dp.DrawPolygon(m_arrowhead, dp.DisplayAttrs().m_ObjectColor | 0xFF000000, true);
         }
     }
     return(true);
 }
 /// <summary>
 /// Virtual MRhinoDisplayConduit.ExecConduit override
 /// </summary>
 public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate)
 {
     if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX)
       {
     m_pChannelAttrs.m_BoundingBox.Union(m_line.BoundingBox());
       }
       else if (nChannel == MSupportChannels.SC_DRAWOVERLAY)
       {
     dp.DrawLine(m_line.from, m_line.to, m_pDisplayAttrs.m_ObjectColor | 0xFF000000, m_pDisplayAttrs.m_nLineThickness);
     if (m_bDraw)
       dp.DrawPolygon(m_arrowhead, dp.DisplayAttrs().m_ObjectColor | 0xFF000000, true);
       }
       return true;
 }
Esempio n. 3
0
        ///<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);
        }