コード例 #1
0
        /// <summary>
        /// Save graph as
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">Event arguments</param>
        private void saveGraphToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SaveGraphDialog.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileStream fs = (System.IO.FileStream)SaveGraphDialog.OpenFile();

                Bitmap bt = new Bitmap(GraphControl.Width, GraphControl.Height);
                GraphControl.DrawToBitmap(bt, new Rectangle(0, 0, bt.Width, bt.Height));

                bt.Save(fs, ImageFormat.Png);
                fs.Dispose();
            }
        }
コード例 #2
0
            public void Paint([NotNull] IRenderContext context, [NotNull] Graphics g)
            {
                if (!inputMode.mouseInside || !inputMode.Enabled)
                {
                    return;
                }

                if (currentSize != inputMode.Size)
                {
                    bitmap?.Dispose();
                    bitmap = new Bitmap(inputMode.Size.Width, inputMode.Size.Height);

                    // Update GraphControl size
                    lensGraphControl.Width  = inputMode.Size.Width;
                    lensGraphControl.Height = inputMode.Size.Height;

                    // Update clipping region
                    clippingPath.Reset();
                    clippingPath.AddEllipse(new Rectangle(new Point(), inputMode.Size));
                    region?.Dispose();
                    region = new Region(clippingPath);

                    currentSize = inputMode.Size;
                }
                // Update the GraphControl with all relevant information
                var canvasControl = context.CanvasControl as GraphControl;

                lensGraphControl.Center     = canvasControl.LastEventLocation;
                lensGraphControl.Zoom       = inputMode.ZoomFactor * context.Zoom;
                lensGraphControl.Projection = context.Projection;

                // Draw to the bitmap
                lensGraphControl.DrawToBitmap(bitmap, new Rectangle(0, 0, inputMode.Size.Width, inputMode.Size.Height));
                // Draw the bitmap to the screen
                var drawingLocation = context.ToViewCoordinates(canvasControl.LastEventLocation).ToFloorPoint();
                var state           = g.Save();

                g.Transform = context.ViewTransform;
                g.TranslateTransform(drawingLocation.X, drawingLocation.Y);
                g.Clip = region;
                g.DrawImageUnscaled(bitmap, new Point());
                g.ResetClip();
                g.DrawEllipse(outlinePen, new Rectangle(new Point(), inputMode.Size));
                g.Restore(state);
            }