private void control_DrawingD2d(object sender, EventArgs e)
        {
            if (Selector.IsSelecting)
            {
                var         d2dControl = (D2dAdaptableControl)sender;
                D2dGraphics g          = d2dControl.D2dGraphics;

                // Replace transform and anti-aliasing setting.
                Matrix3x2F xform = d2dControl.D2dGraphics.Transform;
                d2dControl.D2dGraphics.Transform = Matrix3x2F.Identity;
                D2dAntialiasMode oldAA = d2dControl.D2dGraphics.AntialiasMode;
                d2dControl.D2dGraphics.AntialiasMode = D2dAntialiasMode.Aliased;

                // Draw the selection rectangle.
                Rectangle rect = MakeSelectionRect(
                    ClientToCanvas(Selector.CurrentPoint), ClientToCanvas(Selector.FirstPoint));
                rect.Intersect(AdaptedControl.ClientRectangle);
                var rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
                g.DrawRectangle(rectF, SelectionBorderColor, 1.0f, null);
                g.FillRectangle(rectF, SelectionFillColor);

                // Restore D2dGraphics settings.
                d2dControl.D2dGraphics.Transform     = xform;
                d2dControl.D2dGraphics.AntialiasMode = oldAA;
            }
        }
Example #2
0
        /// <summary>
        /// Draws a key</summary>
        /// <param name="key">Key</param>
        /// <param name="bounds">Bounding rectangle, computed during layout phase</param>
        /// <param name="drawMode">Drawing mode</param>
        /// <param name="c">Drawing context</param>
        protected override void Draw(IKey key, RectangleF bounds, DrawMode drawMode, Context c)
        {
            Color color = key.Color;

            bounds.Width = bounds.Height = KeySize; // key is always square, fixed size

            switch (drawMode & DrawMode.States)
            {
            case DrawMode.Normal:
                c.Graphics.FillEllipse(bounds, color);

                if ((drawMode & DrawMode.Selected) != 0)
                {
                    D2dAntialiasMode originalAntiAliasMode = c.Graphics.AntialiasMode;
                    c.Graphics.AntialiasMode = D2dAntialiasMode.PerPrimitive;
                    c.Graphics.DrawEllipse(
                        new D2dEllipse(
                            new PointF(bounds.X + bounds.Width * 0.5f, bounds.Y + bounds.Height * 0.5f),
                            bounds.Width * 0.5f, bounds.Height * 0.5f),
                        SelectedBrush, 3.0f);
                    c.Graphics.AntialiasMode = originalAntiAliasMode;
                }
                break;

            case DrawMode.Collapsed:
                c.Graphics.FillEllipse(bounds, CollapsedBrush);
                break;

            case DrawMode.Ghost:
                c.Graphics.FillEllipse(bounds, Color.FromArgb(128, color));
                c.Graphics.DrawText(
                    GetXPositionString(bounds.Left + KeySize * 0.5f, c),
                    c.TextFormat,
                    new PointF(bounds.Right + 16, bounds.Y),
                    TextBrush);
                break;

            case DrawMode.Invalid:
                c.Graphics.FillEllipse(bounds, InvalidBrush);
                break;
            }
        }
        // draw dragged events
        private void control_DrawingD2d(object sender, EventArgs e)
        {
            if (m_visible)
            {
                var        d2dControl = AdaptedControl as D2dAdaptableControl;
                Matrix3x2F xform      = d2dControl.D2dGraphics.Transform;
                d2dControl.D2dGraphics.Transform = Matrix3x2F.Identity;
                Matrix     transform  = m_transformAdapter.Transform;
                RectangleF clientRect = AdaptedControl.ClientRectangle;
                RectangleF canvasRect = GdiUtil.InverseTransform(transform, clientRect);

                D2dAntialiasMode oldAA = d2dControl.D2dGraphics.AntialiasMode;
                d2dControl.D2dGraphics.AntialiasMode = D2dAntialiasMode.Aliased;
                // draw horizontal lines
                ChartUtil.DrawHorizontalGrid(transform, canvasRect, m_verticalGridSpacing, m_gridColor, d2dControl.D2dGraphics);

                // draw vertical lines
                ChartUtil.DrawVerticalGrid(transform, canvasRect, m_horizontalGridSpacing, m_gridColor, d2dControl.D2dGraphics);

                d2dControl.D2dGraphics.Transform     = xform;
                d2dControl.D2dGraphics.AntialiasMode = oldAA;
            }
        }
Example #4
0
 /// <summary>    
 /// Specifies a rectangle to which all subsequent drawing operations are clipped</summary>
 /// <remarks>The clipRect is transformed by the current world transform set on the render target.
 /// After the transform is applied to the clipRect that is passed in, the axis-aligned 
 /// bounding box for the clipRect is computed. For efficiency, the contents are clipped 
 /// to this axis-aligned bounding box and not to the original clipRect that is passed in.</remarks>    
 /// <param name="clipRect">The size and position of the clipping area, in pixels</param>
 /// <param name="antialiasMode">The antialiasing mode that is used to draw the edges of clip rects that have subpixel 
 /// boundaries, and to blend the clip with the scene contents. The blending is performed 
 /// once when the PopAxisAlignedClip method is called, and does not apply to each 
 /// primitive within the layer.</param>        
 public void PushAxisAlignedClip(RectangleF clipRect, D2dAntialiasMode antialiasMode)
 {
     m_clipStack.Push(clipRect);
     m_renderTarget.PushAxisAlignedClip(clipRect.ToSharpDX(), (AntialiasMode)antialiasMode);
 }
Example #5
0
 /// <summary>    
 /// Specifies a rectangle to which all subsequent drawing operations are clipped</summary>
 /// <remarks>The clipRect is transformed by the current world transform set on the render target.
 /// After the transform is applied to the clipRect that is passed in, the axis-aligned 
 /// bounding box for the clipRect is computed. For efficiency, the contents are clipped 
 /// to this axis-aligned bounding box and not to the original clipRect that is passed in.</remarks>    
 /// <param name="clipRect">The size and position of the clipping area, in pixels</param>
 /// <param name="antialiasMode">The antialiasing mode that is used to draw the edges of clip rects that have subpixel 
 /// boundaries, and to blend the clip with the scene contents. The blending is performed 
 /// once when the PopAxisAlignedClip method is called, and does not apply to each 
 /// primitive within the layer.</param>        
 public void PushAxisAlignedClip(RectangleF clipRect, D2dAntialiasMode antialiasMode)
 {
     m_clipStack.Push(clipRect);
     var rect = new SharpDX.RectangleF(clipRect.Left, clipRect.Top, clipRect.Right, clipRect.Bottom);
     m_renderTarget.PushAxisAlignedClip(rect, (AntialiasMode)antialiasMode);
 }