Esempio n. 1
0
 /// <summary>
 /// Draws a tree-control style expander, which looks like a square with
 /// a dash (expanded) or a cross (unexpanded)</summary>
 /// <param name="g">The Direct2D graphics object</param>
 /// <param name="x">X coordinate of expander top left corner</param>
 /// <param name="y">Y coordinate of expander top left corner</param>
 /// <param name="size">Size of expander, in pixels</param>
 /// <param name="brush">Brush</param>
 /// <param name="expanded">Whether or not expander should appear "expanded"</param>
 public static void DrawExpander(this D2dGraphics g, float x, float y, float size, D2dBrush brush, bool expanded)
 {
     s_expanderPoints[0] = new PointF(x, y + size);
     if (expanded)
     {
         s_expanderPoints[1] = new PointF(x + size, y + size);
         s_expanderPoints[2] = new PointF(x + size, y);
         g.FillPolygon(s_expanderPoints, brush);
     }
     else
     {
         s_expanderPoints[1] = new PointF(x + size, y + size / 2);
         s_expanderPoints[2] = new PointF(x, y);
         g.DrawPolygon(s_expanderPoints, brush, 1.0f);
     }
 }
Esempio n. 2
0
File: D2dUtil.cs Progetto: zparr/ATF
        /// <summary>
        /// Draws a tree-control style expander, which looks like a square with
        /// a dash (expanded) or a cross (unexpanded)</summary>
        /// <param name="g">The Direct2D graphics object</param>
        /// <param name="x">X coordinate of expander top left corner</param>
        /// <param name="y">Y coordinate of expander top left corner</param>
        /// <param name="size">Size of expander, in pixels</param>
        /// <param name="brush">Brush</param>
        /// <param name="expanded">Whether or not expander should appear "expanded"</param>
        public static void DrawExpander(this D2dGraphics g, float x, float y, float size, D2dBrush brush, bool expanded)
        {
            s_expanderPoints[0] = new PointF(x, y + size);
            if (expanded)
            {
                s_expanderPoints[1] = new PointF(x + size, y + size);
                s_expanderPoints[2] = new PointF(x + size, y);
                g.FillPolygon(s_expanderPoints, brush);
            }
            else
            {
                s_expanderPoints[1] = new PointF(x + size, y + size / 2);
                s_expanderPoints[2] = new PointF(x, y);
                g.DrawPolygon(s_expanderPoints, brush, 1.0f);
            }

            //g.DrawRectangle(new RectangleF(x, y, size, size), brush);
            //float lineLength = size - 4;
            //float center = size / 2;
            //g.DrawLine(x + 2, y + center, x + 2 + lineLength, y + center, brush);
            //if (!expanded)
            //    g.DrawLine(x + center, y + 2, x + center, y + 2 + lineLength, brush);
        }