|
@@ -0,0 +1,532 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.ComponentModel;
|
|
|
+using System.Data;
|
|
|
+using System.Drawing;
|
|
|
+using System.Drawing.Drawing2D;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows.Forms;
|
|
|
+
|
|
|
+namespace monitor_main_windows
|
|
|
+{
|
|
|
+ public partial class Arrow : UserControl
|
|
|
+ {
|
|
|
+ public Arrow()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
+ this.SetStyle(ControlStyles.DoubleBuffer, true);
|
|
|
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
|
|
|
+ this.SetStyle(ControlStyles.Selectable, true);
|
|
|
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
|
|
+ this.SetStyle(ControlStyles.UserPaint, true);
|
|
|
+ this.ForeColor = Color.White;
|
|
|
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
|
|
+ this.SizeChanged += Arrow_SizeChanged;
|
|
|
+ this.Size = new Size(100, 50);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// The arrow color
|
|
|
+ /// </summary>
|
|
|
+ private Color arrowColor = Color.FromArgb(255, 77, 59);
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Gets or sets the color of the arrow.
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The color of the arrow.</value>
|
|
|
+ [Description("箭头颜色"), Category("自定义")]
|
|
|
+ public Color ArrowColor
|
|
|
+ {
|
|
|
+ get { return arrowColor; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ arrowColor = value;
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// The border color
|
|
|
+ /// </summary>
|
|
|
+ private Color? borderColor = null;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Gets or sets the color of the border.
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The color of the border.</value>
|
|
|
+ [Description("箭头边框颜色,为空则无边框"), Category("自定义")]
|
|
|
+ public Color? BorderColor
|
|
|
+ {
|
|
|
+ get { return borderColor; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ borderColor = value;
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// The direction
|
|
|
+ /// </summary>
|
|
|
+ private ArrowDirection direction = monitor_main_windows.ArrowDirection.Right;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Gets or sets the direction.
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The direction.</value>
|
|
|
+ [Description("箭头方向"), Category("自定义")]
|
|
|
+ public ArrowDirection Direction
|
|
|
+ {
|
|
|
+ get { return direction; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ direction = value;
|
|
|
+ ResetPath();
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 获取或设置控件显示的文字的字体。
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The font.</value>
|
|
|
+ /// <PermissionSet>
|
|
|
+ /// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
|
+ /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
|
+ /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
|
|
+ /// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
|
+ /// </PermissionSet>
|
|
|
+ public override Font Font
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return base.Font;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ base.Font = value;
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 获取或设置控件的前景色。
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The color of the fore.</value>
|
|
|
+ /// <PermissionSet>
|
|
|
+ /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
|
+ /// </PermissionSet>
|
|
|
+ public override Color ForeColor
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return base.ForeColor;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ base.ForeColor = value;
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// The text
|
|
|
+ /// </summary>
|
|
|
+ private string text;
|
|
|
+ /// <summary>
|
|
|
+ /// Gets or sets the text.
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The text.</value>
|
|
|
+ [Bindable(true)]
|
|
|
+ [Browsable(true)]
|
|
|
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
|
|
+ [EditorBrowsable(EditorBrowsableState.Always)]
|
|
|
+ [Localizable(true)]
|
|
|
+ [Description("箭头文字"), Category("自定义")]
|
|
|
+ public override string Text
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return text;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ text = value;
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// The m path
|
|
|
+ /// </summary>
|
|
|
+ GraphicsPath m_path;
|
|
|
+ /// <summary>
|
|
|
+ /// Initializes a new instance of the <see cref="UCArrow" /> class.
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Handles the SizeChanged event of the UCArrow control.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender">The source of the event.</param>
|
|
|
+ /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
|
|
+ void Arrow_SizeChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ ResetPath();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Resets the path.
|
|
|
+ /// </summary>
|
|
|
+ private void ResetPath()
|
|
|
+ {
|
|
|
+ Point[] ps = null;
|
|
|
+ int arrow_h = 20;
|
|
|
+ switch (direction)
|
|
|
+ {
|
|
|
+ case ArrowDirection.Left:
|
|
|
+ arrow_h = Width / 3+1;
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(0,this.Height/2),
|
|
|
+ new Point(arrow_h,0),
|
|
|
+ new Point(arrow_h,this.Height/4),
|
|
|
+ new Point(this.Width-1,this.Height/4),
|
|
|
+ new Point(this.Width-1,this.Height-this.Height/4),
|
|
|
+ new Point(arrow_h,this.Height-this.Height/4),
|
|
|
+ new Point(arrow_h,this.Height),
|
|
|
+ new Point(0,this.Height/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Right:
|
|
|
+ arrow_h = Width / 3 + 1;
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(0,this.Height/4),
|
|
|
+ new Point(this.Width-arrow_h,this.Height/4),
|
|
|
+ new Point(this.Width-arrow_h,0),
|
|
|
+ new Point(this.Width-1,this.Height/2),
|
|
|
+ new Point(this.Width-arrow_h,this.Height),
|
|
|
+ new Point(this.Width-arrow_h,this.Height-this.Height/4),
|
|
|
+ new Point(0,this.Height-this.Height/4),
|
|
|
+ new Point(0,this.Height/4)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Top:
|
|
|
+ arrow_h = Height / 3 + 1;
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(this.Width/2,0),
|
|
|
+ new Point(this.Width,arrow_h),
|
|
|
+ new Point(this.Width-this.Width/4,arrow_h),
|
|
|
+ new Point(this.Width-this.Width/4,this.Height-1),
|
|
|
+ new Point(this.Width/4,this.Height-1),
|
|
|
+ new Point(this.Width/4,arrow_h),
|
|
|
+ new Point(0,arrow_h),
|
|
|
+ new Point(this.Width/2,0),
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Bottom:
|
|
|
+ arrow_h = Height / 3 + 1;
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(this.Width-this.Width/4,0),
|
|
|
+ new Point(this.Width-this.Width/4,this.Height-arrow_h),
|
|
|
+ new Point(this.Width,this.Height-arrow_h),
|
|
|
+ new Point(this.Width/2,this.Height-1),
|
|
|
+ new Point(0,this.Height-arrow_h),
|
|
|
+ new Point(this.Width/4,this.Height-arrow_h),
|
|
|
+ new Point(this.Width/4,0),
|
|
|
+ new Point(this.Width-this.Width/4,0),
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Left_Right:
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(0,this.Height/2),
|
|
|
+ new Point(arrow_h,0),
|
|
|
+ new Point(arrow_h,this.Height/4),
|
|
|
+ new Point(this.Width-arrow_h,this.Height/4),
|
|
|
+ new Point(this.Width-arrow_h,0),
|
|
|
+ new Point(this.Width-1,this.Height/2),
|
|
|
+ new Point(this.Width-arrow_h,this.Height),
|
|
|
+ new Point(this.Width-arrow_h,this.Height-this.Height/4),
|
|
|
+ new Point(arrow_h,this.Height-this.Height/4),
|
|
|
+ new Point(arrow_h,this.Height),
|
|
|
+ new Point(0,this.Height/2),
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Top_Bottom:
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(this.Width/2,0),
|
|
|
+ new Point(this.Width,arrow_h),
|
|
|
+ new Point(this.Width-this.Width/4,arrow_h),
|
|
|
+ new Point(this.Width-this.Width/4,this.Height-arrow_h),
|
|
|
+ new Point(this.Width,this.Height-arrow_h),
|
|
|
+ new Point(this.Width/2,this.Height-1),
|
|
|
+ new Point(0,this.Height-arrow_h),
|
|
|
+ new Point(this.Width/4,this.Height-arrow_h),
|
|
|
+ new Point(this.Width/4,arrow_h),
|
|
|
+ new Point(0,arrow_h),
|
|
|
+ new Point(this.Width/2,0),
|
|
|
+ };
|
|
|
+ break;
|
|
|
+
|
|
|
+ case ArrowDirection.TopRight:
|
|
|
+ arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2+5*arrow_h/2,Height/2-arrow_h/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2-arrow_h),
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2-arrow_h),
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2+arrow_h/2),
|
|
|
+ new Point(Width/2+5*arrow_h/2,Height/2-arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.TopLeft:
|
|
|
+ arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2-5*arrow_h/2,Height/2-arrow_h/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2-arrow_h),
|
|
|
+ new Point(Width/2-arrow_h/2+1,Height/2-arrow_h),
|
|
|
+ new Point(Width/2-arrow_h/2+1,Height/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2+arrow_h/2),
|
|
|
+ new Point(Width/2-5*arrow_h/2,Height/2-arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+
|
|
|
+ case ArrowDirection.LeftTop:
|
|
|
+ arrow_h = Math.Min(Width /3, Height /5);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2-arrow_h/2,Height/2-5*arrow_h/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h,Height/2-arrow_h/2+1),
|
|
|
+ new Point(Width/2,Height/2-arrow_h/2+1),
|
|
|
+ new Point(Width/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h/2,Height/2-5*arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.LeftDown:
|
|
|
+ arrow_h = Math.Min(Width / 3, Height / 5);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2-arrow_h/2,Height/2+5*arrow_h/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h,Height/2+arrow_h/2-1),
|
|
|
+ new Point(Width/2,Height/2+arrow_h/2-1),
|
|
|
+ new Point(Width/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h/2,Height/2+5*arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+
|
|
|
+ case ArrowDirection.RightTop:
|
|
|
+ arrow_h = Math.Min(Width / 3, Height / 5);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2-5*arrow_h/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h,Height/2-arrow_h/2+1),
|
|
|
+ new Point(Width/2,Height/2-arrow_h/2+1),
|
|
|
+ new Point(Width/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h/2,Height/2-3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2-5*arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.RightDown:
|
|
|
+ arrow_h = Math.Min(Width / 3, Height / 5);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2+5*arrow_h/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h,Height/2+arrow_h/2-1),
|
|
|
+ new Point(Width/2,Height/2+arrow_h/2-1),
|
|
|
+ new Point(Width/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2-arrow_h/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2+arrow_h/2,Height/2+5*arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.DownLeft:
|
|
|
+ arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2-5*arrow_h/2,Height/2+arrow_h/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2+arrow_h),
|
|
|
+ new Point(Width/2-arrow_h/2+1,Height/2+arrow_h),
|
|
|
+ new Point(Width/2-arrow_h/2+1,Height/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2),
|
|
|
+ new Point(Width/2-3*arrow_h/2,Height/2-arrow_h/2),
|
|
|
+ new Point(Width/2-5*arrow_h/2,Height/2+arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case ArrowDirection.DownRight:
|
|
|
+ arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ ps = new Point[]
|
|
|
+ {
|
|
|
+ new Point(Width/2+5*arrow_h/2,Height/2+arrow_h/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2+3*arrow_h/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2+arrow_h),
|
|
|
+ new Point(Width/2+arrow_h/2-1,Height/2+arrow_h),
|
|
|
+ new Point(Width/2+arrow_h/2-1,Height/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2),
|
|
|
+ new Point(Width/2+3*arrow_h/2,Height/2-arrow_h/2),
|
|
|
+ new Point(Width/2+5*arrow_h/2,Height/2+arrow_h/2)
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ m_path = new GraphicsPath();
|
|
|
+ m_path.AddLines(ps);
|
|
|
+ m_path.CloseAllFigures();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
|
|
|
+ protected override void OnPaint(PaintEventArgs e)
|
|
|
+ {
|
|
|
+ base.OnPaint(e);
|
|
|
+ var g = e.Graphics;
|
|
|
+
|
|
|
+ g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
|
|
|
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
|
+ g.CompositingQuality = CompositingQuality.HighQuality;
|
|
|
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
|
|
|
+ //base.Region = new Region(m_path);
|
|
|
+
|
|
|
+
|
|
|
+ g.FillPath(new SolidBrush(arrowColor), m_path);
|
|
|
+
|
|
|
+ if (borderColor != null && borderColor != Color.Empty)
|
|
|
+ g.DrawPath(new Pen(new SolidBrush(borderColor.Value)), m_path);
|
|
|
+
|
|
|
+
|
|
|
+ if (direction == ArrowDirection.TopRight)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle((Width - arrow_h)/ 2, Height / 2 - arrow_h, arrow_h * 2+1, arrow_h * 2+1), 180,90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF((Width - arrow_h) / 2, Height / 2),new SizeF(arrow_h, Height / 2)));
|
|
|
+ }
|
|
|
+ if (direction == ArrowDirection.TopLeft)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle((Width - 3*arrow_h) / 2, Height / 2 - arrow_h, arrow_h * 2, arrow_h * 2 + 1), 270, 90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF((Width - arrow_h) / 2, Height / 2), new SizeF(arrow_h, Height / 2)));
|
|
|
+ }
|
|
|
+ if (direction == ArrowDirection.LeftTop)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width /3, Height / 5);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle(Width / 2 - arrow_h,(Height - 3 * arrow_h) / 2, arrow_h * 2+1, arrow_h * 2), 90, 90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF(Width / 2,(Height - arrow_h) / 2), new SizeF(Width / 2,arrow_h)));
|
|
|
+ }
|
|
|
+ if (direction == ArrowDirection.LeftDown)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width / 3, Height / 5);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle(Width / 2 - arrow_h, (Height - arrow_h) / 2, arrow_h * 2+1 , arrow_h * 2), 180, 90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF(Width / 2, (Height - arrow_h) / 2), new SizeF(Width / 2, arrow_h)));
|
|
|
+ }
|
|
|
+ if (direction == ArrowDirection.RightTop)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width / 3, Height / 5);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle(Width / 2 - arrow_h, (Height - 3 * arrow_h) / 2, arrow_h * 2 , arrow_h * 2), 0, 90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF(0, (Height - arrow_h) / 2), new SizeF(Width / 2+1, arrow_h)));
|
|
|
+ }
|
|
|
+ if (direction == ArrowDirection.RightDown)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width / 3, Height / 5);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle(Width / 2 - arrow_h, (Height - arrow_h+1) / 2, arrow_h * 2, arrow_h * 2), 270, 90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF(0, (Height - arrow_h) / 2), new SizeF(Width / 2 + 1, arrow_h)));
|
|
|
+ }
|
|
|
+ if (direction == ArrowDirection.DownLeft)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle((Width - 3 * arrow_h) / 2, Height / 2 - arrow_h, arrow_h * 2, arrow_h * 2 ), 0, 90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF((Width - arrow_h) / 2, 0), new SizeF(arrow_h, Height / 2+1)));
|
|
|
+ }
|
|
|
+ if (direction == ArrowDirection.DownRight)
|
|
|
+ {
|
|
|
+ int arrow_h = Math.Min(Width / 5, Height / 3);
|
|
|
+ g.FillPie(new SolidBrush(arrowColor),
|
|
|
+ new Rectangle((Width - arrow_h) / 2, Height / 2 - arrow_h, arrow_h * 2, arrow_h * 2), 90, 90);
|
|
|
+ g.FillRectangle(new SolidBrush(arrowColor),
|
|
|
+ new RectangleF(new PointF((Width - arrow_h) / 2, 0), new SizeF(arrow_h, Height / 2 + 1)));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(text))
|
|
|
+ {
|
|
|
+ var size = g.MeasureString(Text, Font);
|
|
|
+ g.DrawString(Text, Font, new SolidBrush(ForeColor), new PointF((this.Width - size.Width) / 2, (this.Height - size.Height) / 2));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Enum ArrowDirection
|
|
|
+ /// </summary>
|
|
|
+ public enum ArrowDirection
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// The left
|
|
|
+ /// </summary>
|
|
|
+ Left,
|
|
|
+ /// <summary>
|
|
|
+ /// The right
|
|
|
+ /// </summary>
|
|
|
+ Right,
|
|
|
+ /// <summary>
|
|
|
+ /// The top
|
|
|
+ /// </summary>
|
|
|
+ Top,
|
|
|
+ /// <summary>
|
|
|
+ /// The bottom
|
|
|
+ /// </summary>
|
|
|
+ Bottom,
|
|
|
+ /// <summary>
|
|
|
+ /// The left right
|
|
|
+ /// </summary>
|
|
|
+ Left_Right,
|
|
|
+ /// <summary>
|
|
|
+ /// The top bottom
|
|
|
+ /// </summary>
|
|
|
+ Top_Bottom,
|
|
|
+
|
|
|
+ LeftTop,
|
|
|
+ LeftDown,
|
|
|
+ RightTop,
|
|
|
+ RightDown,
|
|
|
+ TopLeft,
|
|
|
+ TopRight,
|
|
|
+ DownLeft,
|
|
|
+ DownRight
|
|
|
+ }
|
|
|
+}
|