コード例 #1
0
ファイル: CornerShape.cs プロジェクト: m309/fiddler-plus
 /// <summary>
 /// Assigns Values of supplied <see cref="CornerShape"/> to current object.
 /// </summary>
 /// <param name="shape"><see cref="CornerShape"/> object whose value is to be assigned.</param>
 public void Assign(CornerShape shape)
 {
     TopLeft     = shape.topLeft;
     TopRight    = shape.topRight;
     BottomLeft  = shape.bottomLeft;
     BottomRight = shape.bottomRight;
 }
コード例 #2
0
ファイル: AppearanceBorder.cs プロジェクト: m309/fiddler-plus
 /// <summary>
 /// Converts an object into its XML representation.
 /// </summary>
 /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"/> stream to which the object is serialized. </param>
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteElementString("BorderLineStyle", BorderLineStyle.ToString());
     writer.WriteElementString("BorderVisibility", BorderVisibility.ToString());
     writer.WriteStartElement("CornerShape");
     CornerShape.WriteXml(writer);
     writer.WriteEndElement();
 }
コード例 #3
0
ファイル: CornerShape.cs プロジェクト: m309/fiddler-plus
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public virtual object Clone()
        {
            var shape = new CornerShape();

            shape.TopLeft     = topLeft;
            shape.TopRight    = topRight;
            shape.BottomLeft  = bottomLeft;
            shape.BottomRight = bottomRight;
            return(shape);
        }
コード例 #4
0
ファイル: AppearanceBorder.cs プロジェクト: m309/fiddler-plus
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized. </param>
        public void ReadXml(XmlReader reader)
        {
            var doc = new XmlDocument();

            doc.Load(reader);
            if (doc.GetElementsByTagName("BorderLineStyle").Count > 0)
            {
                BorderLineStyle =
                    (DashStyle)Enum.Parse(typeof(DashStyle), doc.GetElementsByTagName("BorderLineStyle")[0].InnerText);
            }
            if (doc.GetElementsByTagName("BorderVisibility").Count > 0)
            {
                BorderVisibility =
                    (ToolStripStatusLabelBorderSides)
                    Enum.Parse(typeof(ToolStripStatusLabelBorderSides),
                               doc.GetElementsByTagName("BorderVisibility")[0].InnerText);
            }
            if (doc.GetElementsByTagName("CornerShape").Count > 0)
            {
                string xml = "<CornerShape>" + doc.GetElementsByTagName("CornerShape")[0].InnerXml + "</CornerShape>";
                CornerShape.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }
        }
コード例 #5
0
ファイル: AppearanceBorder.cs プロジェクト: m309/fiddler-plus
 /// <summary>
 /// Create new instance of <see cref="AppearanceBorder"/>
 /// </summary>
 public AppearanceBorder()
 {
     cornerShape = new CornerShape();
 }
コード例 #6
0
ファイル: AppearanceBorder.cs プロジェクト: m309/fiddler-plus
 /// <summary>
 /// Resets value of <see cref="CornerShape"/> to default value.
 /// </summary>
 protected void ResetCornerShape()
 {
     cornerShape = new CornerShape();
 }
コード例 #7
0
ファイル: AppearanceBorder.cs プロジェクト: m309/fiddler-plus
 /// <summary>
 /// Copies values of supplied <see cref="AppearanceBorder"/> to current object.
 /// </summary>
 /// <param name="appearanceBorder"><see cref="AppearanceBorder"/> object whose value is to be copied.</param>
 public void Assign(AppearanceBorder appearanceBorder)
 {
     CornerShape.Assign((CornerShape)appearanceBorder.cornerShape.Clone());
     BorderLineStyle  = appearanceBorder.borderLineStyle;
     BorderVisibility = appearanceBorder.borderVisibility;
 }
コード例 #8
0
ファイル: AppearanceBorder.cs プロジェクト: m309/fiddler-plus
 /// <summary>
 /// Resets current object to default values.
 /// </summary>
 public virtual void Reset()
 {
     cornerShape      = new CornerShape();
     borderLineStyle  = DashStyle.Solid;
     borderVisibility = ToolStripStatusLabelBorderSides.All;
 }
コード例 #9
0
        internal static void DrawBorder(Graphics g, RectangleF rect, CornerShape bShape,
            ToolStripStatusLabelBorderSides bVisibility, DashStyle bLineStyle,
            int cornerRadius, Color borderColor, Brush borderBrush, Region excRegion)
        {
            if (bVisibility == ToolStripStatusLabelBorderSides.None)
            {
                return;
            }
            if (excRegion != null)
            {
                g.ExcludeClip(excRegion);
            }
            var pen = borderBrush != null ? new Pen(borderBrush, 1f) : new Pen(borderColor, 1f);
            var smoothingMode = g.SmoothingMode;
            pen.DashStyle = bLineStyle;
            var num = 2*cornerRadius;
            if (bVisibility == ToolStripStatusLabelBorderSides.All)
            {
                var path = GetDrawingPath(rect, bShape, cornerRadius);
                g.DrawPath(pen, path);
                path.Dispose();
                g.SmoothingMode = smoothingMode;
                pen.Dispose();
                return;
            }
            if ((bVisibility & ToolStripStatusLabelBorderSides.Left) > ToolStripStatusLabelBorderSides.None)
            {
                g.DrawLine(pen, rect.X, rect.Y + cornerRadius, rect.X, (rect.Y + rect.Height) - cornerRadius);
            }
            if ((bVisibility & ToolStripStatusLabelBorderSides.Top) > ToolStripStatusLabelBorderSides.None)
            {
                g.DrawLine(pen, rect.X + cornerRadius, rect.Y, (rect.X + rect.Width) - cornerRadius, rect.Y);
            }
            if ((bVisibility & ToolStripStatusLabelBorderSides.Right) > ToolStripStatusLabelBorderSides.None)
            {
                g.DrawLine(pen, rect.X + rect.Width, rect.Y + cornerRadius, rect.X + rect.Width,
                           (rect.Y + rect.Height) - cornerRadius);
            }
            if ((bVisibility & ToolStripStatusLabelBorderSides.Bottom) > ToolStripStatusLabelBorderSides.None)
            {
                g.DrawLine(pen, rect.X + cornerRadius, rect.Y + rect.Height, (rect.X + rect.Width) - cornerRadius,
                           rect.Y + rect.Height);
            }
            if (((bVisibility & ToolStripStatusLabelBorderSides.Left) > ToolStripStatusLabelBorderSides.None) ||
                ((bVisibility & ToolStripStatusLabelBorderSides.Top) > ToolStripStatusLabelBorderSides.None))
            {
                switch (bShape.TopLeft)
                {
                    case CornerType.Sliced:
                        g.DrawLine(pen, rect.X, rect.Y + cornerRadius, rect.X + cornerRadius, rect.Y);
                        break;

                    case CornerType.Square:
                        if (((bVisibility & ToolStripStatusLabelBorderSides.Left) <=
                             ToolStripStatusLabelBorderSides.None) ||
                            ((bVisibility & ToolStripStatusLabelBorderSides.Top) > ToolStripStatusLabelBorderSides.None))
                        {
                            if (((bVisibility & ToolStripStatusLabelBorderSides.Left) <=
                                 ToolStripStatusLabelBorderSides.None) &&
                                ((bVisibility & ToolStripStatusLabelBorderSides.Top) >
                                 ToolStripStatusLabelBorderSides.None))
                            {
                                g.DrawLine(pen, rect.X, rect.Y, rect.X + cornerRadius, rect.Y);
                            }
                            else
                            {
                                g.DrawLine(pen, rect.X, rect.Y + cornerRadius, rect.X, rect.Y);
                                g.DrawLine(pen, rect.X, rect.Y, rect.X + cornerRadius, rect.Y);
                            }
                        }
                        else
                        {
                            g.DrawLine(pen, rect.X, rect.Y + cornerRadius, rect.X, rect.Y);
                        }
                        break;
                }
                if (((bVisibility & ToolStripStatusLabelBorderSides.Top) > ToolStripStatusLabelBorderSides.None) ||
                    ((bVisibility & ToolStripStatusLabelBorderSides.Right) > ToolStripStatusLabelBorderSides.None))
                {
                    switch (bShape.TopRight)
                    {
                        case CornerType.Sliced:
                            g.DrawLine(pen, (rect.X + rect.Width) - cornerRadius, rect.Y, rect.X + rect.Width,
                                       rect.Y + cornerRadius);
                            break;
                        case CornerType.Square:
                            if (((bVisibility & ToolStripStatusLabelBorderSides.Right) >
                                 ToolStripStatusLabelBorderSides.None) ||
                                ((bVisibility & ToolStripStatusLabelBorderSides.Top) <=
                                 ToolStripStatusLabelBorderSides.None))
                            {
                                if (((bVisibility & ToolStripStatusLabelBorderSides.Right) >
                                     ToolStripStatusLabelBorderSides.None) &&
                                    ((bVisibility & ToolStripStatusLabelBorderSides.Top) <=
                                     ToolStripStatusLabelBorderSides.None))
                                {
                                    g.DrawLine(pen, rect.X + rect.Width, rect.Y, rect.X + rect.Width,
                                               rect.Y + cornerRadius);
                                }
                                else
                                {
                                    g.DrawLine(pen, (rect.X + rect.Width) - cornerRadius, rect.Y, rect.X + rect.Width,
                                               rect.Y);
                                    g.DrawLine(pen, rect.X + rect.Width, rect.Y, rect.X + rect.Width,
                                               rect.Y + cornerRadius);
                                }
                            }
                            else
                            {
                                g.DrawLine(pen, (rect.X + rect.Width) - cornerRadius, rect.Y, rect.X + rect.Width,
                                           rect.Y);
                            }
                            break;
                    }
                    if (((bVisibility & ToolStripStatusLabelBorderSides.Right) > ToolStripStatusLabelBorderSides.None) ||
                        ((bVisibility & ToolStripStatusLabelBorderSides.Bottom) > ToolStripStatusLabelBorderSides.None))
                    {
                        switch (bShape.BottomRight)
                        {
                            case CornerType.Sliced:
                                g.DrawLine(pen, rect.X + rect.Width, (rect.Y + rect.Height) - cornerRadius,
                                           (rect.X + rect.Width) - cornerRadius, rect.Y + rect.Height);
                                break;

                            case CornerType.Square:
                                if (((bVisibility & ToolStripStatusLabelBorderSides.Right) <=
                                     ToolStripStatusLabelBorderSides.None) ||
                                    ((bVisibility & ToolStripStatusLabelBorderSides.Bottom) >
                                     ToolStripStatusLabelBorderSides.None))
                                {
                                    if (((bVisibility & ToolStripStatusLabelBorderSides.Right) <=
                                         ToolStripStatusLabelBorderSides.None) &&
                                        ((bVisibility & ToolStripStatusLabelBorderSides.Bottom) >
                                         ToolStripStatusLabelBorderSides.None))
                                    {
                                        g.DrawLine(pen, (rect.X + rect.Width), (rect.Y + rect.Height),
                                                   (rect.X + rect.Width) - cornerRadius, (rect.Y + rect.Height));
                                    }
                                    else
                                    {
                                        g.DrawLine(pen, (rect.X + rect.Width), ((rect.Y + rect.Height) - cornerRadius),
                                                   rect.X + rect.Width, (rect.Y + rect.Height));
                                        g.DrawLine(pen, (rect.X + rect.Width), (rect.Y + rect.Height),
                                                   (rect.X + rect.Width) - cornerRadius, (rect.Y + rect.Height));
                                    }
                                }
                                else
                                {
                                    g.DrawLine(pen, rect.X + rect.Width, (rect.Y + rect.Height) - cornerRadius,
                                               rect.X + rect.Width, rect.Y + rect.Height);
                                }
                                break;
                        }
                        if (((bVisibility & ToolStripStatusLabelBorderSides.Bottom) >
                             ToolStripStatusLabelBorderSides.None) ||
                            ((bVisibility & ToolStripStatusLabelBorderSides.Left) > ToolStripStatusLabelBorderSides.None))
                        {
                            switch (bShape.BottomLeft)
                            {
                                case CornerType.Sliced:
                                    g.DrawLine(pen, rect.X + cornerRadius, rect.Y + rect.Height, rect.X,
                                               (rect.Y + rect.Height) - cornerRadius);
                                    g.SmoothingMode = smoothingMode;
                                    pen.Dispose();
                                    return;

                                case CornerType.Square:
                                    if (((bVisibility & ToolStripStatusLabelBorderSides.Left) >
                                         ToolStripStatusLabelBorderSides.None) ||
                                        ((bVisibility & ToolStripStatusLabelBorderSides.Bottom) <=
                                         ToolStripStatusLabelBorderSides.None))
                                    {
                                        if (((bVisibility & ToolStripStatusLabelBorderSides.Left) >
                                             ToolStripStatusLabelBorderSides.None) &&
                                            ((bVisibility & ToolStripStatusLabelBorderSides.Bottom) <=
                                             ToolStripStatusLabelBorderSides.None))
                                        {
                                            g.DrawLine(pen, rect.X, rect.Y + rect.Height, rect.X,
                                                       (rect.Y + rect.Height) - cornerRadius);
                                        }
                                        else
                                        {
                                            g.DrawLine(pen, rect.X + cornerRadius, rect.Y + rect.Height, rect.X,
                                                       rect.Y + rect.Height);
                                            g.DrawLine(pen, rect.X, rect.Y + rect.Height, rect.X,
                                                       (rect.Y + rect.Height) - cornerRadius);
                                        }
                                    }
                                    else
                                    {
                                        g.DrawLine(pen, rect.X + cornerRadius, rect.Y + rect.Height, rect.X,
                                                   rect.Y + rect.Height);
                                    }
                                    g.SmoothingMode = smoothingMode;
                                    pen.Dispose();
                                    return;
                            }
                            g.DrawArc(pen, rect.X, (rect.Y + rect.Height) - num, num, num, 90f, 90f);
                        }
                        g.DrawArc(pen, (rect.X + rect.Width) - num, (rect.Y + rect.Height) - num, num, num, 0f, 90f);
                    }
                    g.DrawArc(pen, (rect.X + rect.Width) - num, rect.Y, num, num, 270f, 90f);
                }
                g.DrawArc(pen, rect.X, rect.Y, num, num, 180f, 90f);
            }
        }
コード例 #10
0
 /// <summary>
 /// Resets value of <see cref="CornerShape"/> to default value.
 /// </summary>
 protected void ResetCornerShape()
 {
     cornerShape = new CornerShape();
 }
コード例 #11
0
 /// <summary>
 /// Create new instance of <see cref="AppearanceBorder"/>
 /// </summary>
 public AppearanceBorder()
 {
     cornerShape = new CornerShape();
 }
コード例 #12
0
 /// <summary>
 /// Resets current object to default values.
 /// </summary>
 public virtual void Reset()
 {
     cornerShape = new CornerShape();
     borderLineStyle = DashStyle.Solid;
     borderVisibility = ToolStripStatusLabelBorderSides.All;
 }
コード例 #13
0
 internal static void DrawBackground(Graphics g, RectangleF rect, Brush fillBrush, CornerShape bShape,
     int cornerRadius, Region excRegion)
 {
     if (excRegion != null)
     {
         g.ExcludeClip(excRegion);
     }
     var path = GetDrawingPath(rect, bShape, cornerRadius);
     g.FillPath(fillBrush, path);
     fillBrush.Dispose();
     path.Dispose();
 }
コード例 #14
0
 internal static GraphicsPath GetDrawingPath(RectangleF rect, CornerShape bShape, int cornerRadius)
 {
     var path = new GraphicsPath();
     int num = 2*cornerRadius;
     if (bShape.TopLeft == CornerType.Square)
     {
         if (bShape.TopRight == CornerType.Square)
         {
             path.AddLine(rect.X, rect.Y, rect.X + rect.Width, rect.Y);
         }
         else
         {
             path.AddLine(rect.X, rect.Y, (rect.X + rect.Width) - cornerRadius, rect.Y);
             if (bShape.TopRight == CornerType.Round && cornerRadius > 0)
             {
                 path.AddArc((rect.X + rect.Width) - num, rect.Y, num, num, 270f, 90f);
             }
             else
             {
                 path.AddLine((rect.X + rect.Width) - cornerRadius, rect.Y, rect.X + rect.Width,
                              rect.Y + cornerRadius);
             }
         }
     }
     else if (bShape.TopRight == CornerType.Square)
     {
         path.AddLine(rect.X + cornerRadius, rect.Y, rect.X + rect.Width, rect.Y);
     }
     else
     {
         path.AddLine(rect.X + cornerRadius, rect.Y, (rect.X + rect.Width) - cornerRadius, rect.Y);
         if (bShape.TopRight == CornerType.Round && cornerRadius > 0)
         {
             path.AddArc((rect.X + rect.Width) - num, rect.Y, num, num, 270f, 90f);
         }
         else
         {
             path.AddLine((rect.X + rect.Width) - cornerRadius, rect.Y, rect.X + rect.Width,
                          rect.Y + cornerRadius);
         }
     }
     if (bShape.TopRight == CornerType.Square)
     {
         if (bShape.BottomRight == CornerType.Square)
         {
             path.AddLine(rect.X + rect.Width, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
         }
         else
         {
             path.AddLine(rect.X + rect.Width, rect.Y, rect.X + rect.Width, (rect.Y + rect.Height) - cornerRadius);
             if (bShape.BottomRight == CornerType.Round && cornerRadius > 0)
             {
                 path.AddArc((rect.X + rect.Width) - num, (rect.Y + rect.Height) - num, num, num, 0f, 90f);
             }
             else
             {
                 path.AddLine(rect.X + rect.Width, (rect.Y + rect.Height) - cornerRadius,
                              (rect.X + rect.Width) - cornerRadius, rect.Y + rect.Height);
             }
         }
     }
     else if (bShape.BottomRight == CornerType.Square)
     {
         path.AddLine(rect.X + rect.Width, rect.Y + cornerRadius, (rect.X + rect.Width), (rect.Y + rect.Height));
     }
     else
     {
         path.AddLine(rect.X + rect.Width, rect.Y + cornerRadius, (rect.X + rect.Width),
                      ((rect.Y + rect.Height) - cornerRadius));
         if (bShape.BottomRight == CornerType.Round && cornerRadius > 0)
         {
             path.AddArc((rect.X + rect.Width) - num, (rect.Y + rect.Height) - num, num, num, 0f, 90f);
         }
         else
         {
             path.AddLine(rect.X + rect.Width, (rect.Y + rect.Height) - cornerRadius,
                          (rect.X + rect.Width) - cornerRadius, rect.Y + rect.Height);
         }
     }
     if (bShape.BottomRight == CornerType.Square)
     {
         if (bShape.BottomLeft == CornerType.Square)
         {
             path.AddLine(rect.X + rect.Width, rect.Y + rect.Height, rect.X, rect.Y + rect.Height);
         }
         else
         {
             path.AddLine(rect.X + rect.Width, rect.Y + rect.Height, rect.X + cornerRadius, rect.Y + rect.Height);
             if (bShape.BottomLeft == CornerType.Round && cornerRadius > 0)
             {
                 path.AddArc(rect.X, (rect.Y + rect.Height) - num, num, num, 90f, 90f);
             }
             else
             {
                 path.AddLine(rect.X + cornerRadius, rect.Y + rect.Height, rect.X,
                              (rect.Y + rect.Height) - cornerRadius);
             }
         }
     }
     else if (bShape.BottomLeft == CornerType.Square)
     {
         path.AddLine((rect.X + rect.Width) - cornerRadius, rect.Y + rect.Height, rect.X, rect.Y + rect.Height);
     }
     else
     {
         path.AddLine((rect.X + rect.Width) - cornerRadius, rect.Y + rect.Height, rect.X + cornerRadius,
                      rect.Y + rect.Height);
         if (bShape.BottomLeft == CornerType.Round && cornerRadius > 0)
         {
             path.AddArc(rect.X, (rect.Y + rect.Height) - num, num, num, 90f, 90f);
         }
         else
         {
             path.AddLine(rect.X + cornerRadius, rect.Y + rect.Height, rect.X,
                          (rect.Y + rect.Height) - cornerRadius);
         }
     }
     if (bShape.BottomLeft == CornerType.Square)
     {
         if (bShape.TopLeft == CornerType.Square)
         {
             path.AddLine(rect.X, rect.Y + rect.Height, rect.X, rect.Y);
             return path;
         }
         path.AddLine(rect.X, rect.Y + rect.Height, rect.X, rect.Y + cornerRadius);
         if (bShape.TopLeft == CornerType.Round && cornerRadius > 0)
         {
             path.AddArc(rect.X, rect.Y, num, num, 180f, 90f);
             return path;
         }
         path.AddLine(rect.X, rect.Y + cornerRadius, rect.X + cornerRadius, rect.Y);
         return path;
     }
     if (bShape.TopLeft == CornerType.Square)
     {
         path.AddLine(rect.X, (rect.Y + rect.Height) - cornerRadius, rect.X, rect.Y);
         return path;
     }
     path.AddLine(rect.X, (rect.Y + rect.Height) - cornerRadius, rect.X, rect.Y + cornerRadius);
     if (bShape.TopLeft == CornerType.Round && cornerRadius > 0)
     {
         path.AddArc(rect.X, rect.Y, num, num, 180f, 90f);
         return path;
     }
     path.AddLine(rect.X, rect.Y + cornerRadius, rect.X + cornerRadius, rect.Y);
     return path;
 }
コード例 #15
0
 /// <summary>
 /// Assigns Values of supplied <see cref="CornerShape"/> to current object.
 /// </summary>
 /// <param name="shape"><see cref="CornerShape"/> object whose value is to be assigned.</param>
 public void Assign(CornerShape shape)
 {
     TopLeft = shape.topLeft;
     TopRight = shape.topRight;
     BottomLeft = shape.bottomLeft;
     BottomRight = shape.bottomRight;
 }
コード例 #16
0
ファイル: AppearanceBorder.cs プロジェクト: m309/fiddler-plus
 /// <summary>
 /// Get wether default values of the object has been modified.
 /// </summary>
 /// <returns>Returns true if default values has been modified for current object.</returns>
 public virtual bool DefaultChanged()
 {
     return(borderLineStyle != DashStyle.Solid || borderVisibility != ToolStripStatusLabelBorderSides.All ||
            CornerShape.DefaultChanged());
 }
コード例 #17
0
 /// <summary>
 /// Creates a new object that is a copy of the current instance.
 /// </summary>
 /// <returns>
 /// A new object that is a copy of this instance.
 /// </returns>
 /// <filterpriority>2</filterpriority>
 public virtual object Clone()
 {
     var shape = new CornerShape();
     shape.TopLeft = topLeft;
     shape.TopRight = topRight;
     shape.BottomLeft = bottomLeft;
     shape.BottomRight = bottomRight;
     return shape;
 }
コード例 #18
0
 internal static void DrawBorder(Graphics g, RectangleF rect, CornerShape bShape,
     ToolStripStatusLabelBorderSides bVisibility, DashStyle bLineStyle,
     int cornerRadius, Brush borderBrush, Region excRegion)
 {
     DrawBorder(g, rect, bShape, bVisibility, bLineStyle, cornerRadius, Color.Empty, borderBrush, excRegion);
 }