123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using PaintDotNet.Annotation.Enum;
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace PaintDotNet.Annotation.Label
- {
- /// <summary>
- /// 标注->文本
- /// </summary>
- public class ToolTextString : ToolObject
- {
- private static DrawTextString newTextString;
- private static ISurfaceBox areaNow;
- private static bool isTextBoxAlive = false;
- private static RichTextBox lab;
- private static Point p;
- private static Cursor cursor = new Cursor(PdnResources.GetResourceStream("Cursors.AnnotationRectangle.cur"));
- public static void OnMouseDown(ISurfaceBox drawArea, MouseEventArgs e)
- {
- areaNow = drawArea;
- if (e.Button == MouseButtons.Left)
- {
- if (newTextString == null && !isTextBoxAlive)
- {
- Point temp = drawArea.GetCalcOriginPoint();
- p = GetEventPointInArea(drawArea, e.Location);
- lab = new RichTextBox();
- lab.LostFocus += new EventHandler(OnTextBoxLostFocus);
- lab.Width = 100;
- lab.Height = 40;
- lab.BackColor = Color.White;
- lab.Cursor = Cursors.Default;
- lab.Location = new Point(temp.X + (int)(p.X * drawArea.ScaleRatio) + 16, temp.Y+ (int)(p.Y * drawArea.ScaleRatio) + 16);
- drawArea.Controls.Add(lab);
- lab.Focus();
- lab.BringToFront();
- isTextBoxAlive = true;
- drawArea.Refresh();
- }
- }
- if (e.Button == MouseButtons.Right)
- {
- if (newTextString == null && isTextBoxAlive)
- {
- string textStr = lab.Text;
- drawArea.Controls.Remove(lab);
- newTextString = new DrawTextString(drawArea, p.X, p.Y, textStr);
- newTextString.ISurfaceBox = drawArea;
- AddNewObject(drawArea, newTextString);
- drawArea.Refresh();
- //OnMouseNotLeftDown(drawArea, newTextString);
- newTextString = null;
- isTextBoxAlive = false;
- if (!drawArea.ContinuousDrawingLabel())
- {
- drawArea.ActiveTool = DrawToolType.Pointer;
- }
- OnMouseUpTwo(drawArea, e);
- }
- }
- }
- private static void OnTextBoxLostFocus(object sender, EventArgs e)
- {
- if(areaNow != null && lab != null)
- {
- areaNow.Controls.Remove(lab);
- newTextString = null;
- isTextBoxAlive = false;
- if (!areaNow.ContinuousDrawingLabel())
- {
- OnMouseUpTwo(areaNow, null);
- }
- }
- }
- public static void OnMouseMove(ISurfaceBox drawArea, MouseEventArgs e)
- {
-
- }
- public static void OnMouseUp(ISurfaceBox drawArea, MouseEventArgs e)
- {
-
- }
- public static void OnMouseClick(ISurfaceBox surfacebox, MouseEventArgs e)
- {
- }
- /// <summary>
- /// 鼠标左键双击
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
- {
- }
- /// <summary>
- /// 删除按键
- /// </summary>
- /// <param name="surfacebox"></param>
- /// <param name="e"></param>
- public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
- {
- }
- /// <summary>
- /// 删除划痕处理&污迹处理选择区域的痕迹
- /// </summary>
- /// <param name="surfacebox"></param>
- /// <param name="e"></param>
- public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
- {
-
- }
- public static void beginWithNewObject()
- {
-
- }
- }
- }
|