using PaintDotNet.Annotation.Enum;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace PaintDotNet.Annotation.Label
{
///
/// 标注->文本
///
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)
{
}
///
/// 鼠标左键双击
///
///
///
public static void OnMouseLeftDoubleClick(ISurfaceBox surfacebox, MouseEventArgs e)
{
}
///
/// 删除按键
///
///
///
public static void OnDelKeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
{
}
///
/// 删除划痕处理&污迹处理选择区域的痕迹
///
///
///
public static void OnDel2KeyDown(ISurfaceBox surfacebox, MouseEventArgs e)
{
}
public static void beginWithNewObject()
{
}
}
}