Ostatecznie zdecydowałem się na WinForms. Ja to robię w oddzielnej klasie, z poziomu C# o tak:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing; //font
namespace AppNote
{
public class TextField : TextBox
{
int border = 15;
Point previousposition;
public static bool ismousedown = false;
TextField()
{
Multiline = true;
ShortcutsEnabled = true;
TextAlign = HorizontalAlignment.Center;
}
protected void ModifyTextPosition(int bgpositionx, int bgpositiony, int endpositionx, int endpositiony)
{
if (bgpositionx < endpositionx && bgpositiony < endpositiony)
{
this.Left = bgpositionx;
this.Top = bgpositiony;
this.Size = new System.Drawing.Size(endpositionx - bgpositionx, endpositiony - bgpositiony);
}
if (bgpositionx < endpositionx && bgpositiony > endpositiony)
{
this.Left = bgpositionx;
this.Top = endpositiony;
this.Size = new System.Drawing.Size(endpositionx - bgpositionx, bgpositiony - endpositiony);
}
if (bgpositionx > endpositionx && bgpositiony < endpositiony)
{
this.Left = endpositionx;
this.Top = bgpositiony;
this.Size = new System.Drawing.Size(bgpositionx - endpositionx, endpositiony - bgpositiony);
}
if (bgpositionx > endpositionx && bgpositiony > endpositiony)
{
this.Left = endpositionx;
this.Top = endpositiony;
this.Size = new System.Drawing.Size(bgpositionx - endpositionx, bgpositiony - endpositiony);
}
}
public static void AddNewTextField(Panel panel, int bgpositionx, int bgpositiony, int endpositionx, int endpositiony)
{
try
{
TextField txt = new TextField();
panel.Controls.Add(txt);
txt.ModifyTextPosition(bgpositionx, bgpositiony, endpositionx, endpositiony);
txt.Font = new Font(txt.Font.FontFamily, txt.Size.Height / 5);
}
catch (Exception e)
{
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (e.Button == MouseButtons.Middle)
{
this.Cursor = Cursors.SizeAll;
this.Top += e.Y - previousposition.Y;
this.Left += e.X - previousposition.X;
}
ResizeTextField(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
ismousedown = false;
}
protected void ResizeTextField(MouseEventArgs e)
{
int msg = -1; //if (msg == -1) at the end of this, then the mousedown is not a drag.
if (e.Y < border)
{
if (e.X < border)
{
this.Cursor = Cursors.SizeNWSE;
}
else if (e.X > Width - border)
{
this.Cursor = Cursors.SizeNESW;
}
else
{
this.Cursor = Cursors.SizeNS;
}
if (e.Button == MouseButtons.Left)
{
msg = 12; //Top
if (e.X < 25) msg = 13; //Top Left
if (e.X > Width - 25) msg = 14; //Top Right
}
}
else if (e.Y > Height - border)
{
if (e.X < border)
{
this.Cursor = Cursors.SizeNESW;
}
else if (e.X > Width - border)
{
this.Cursor = Cursors.SizeNWSE;
}
else
{
this.Cursor = Cursors.SizeNS;
}
if (e.Button == MouseButtons.Left)
{
msg = 15; //Bottom
if (e.X < 25) msg = 16;
if (e.X > Width - 25) msg = 17;
}
}
else if (e.X < border)
{
this.Cursor = Cursors.SizeWE;
if (e.Button == MouseButtons.Left)
{
msg = 10; //Left
if (e.Y < 17) msg = 13;
if (e.Y > Height - 17) msg = 16;
}
}
else if (e.X > Width - border)
{
this.Cursor = Cursors.SizeWE;
if (e.Button == MouseButtons.Left)
{
msg = 11; //Right
if (e.Y < 17) msg = 14;
if (e.Y > Height - 17) msg = 17;
}
}
else
{
this.Cursor = Cursors.Default;
}
if (msg != -1)
{
UnsafeNativeMethods.ReleaseCapture(); //Release current mouse capture
UnsafeNativeMethods.SendMessage(Handle, 0xA1, new IntPtr(msg), IntPtr.Zero);
//Tell the OS that you want to drag the window.
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
this.BringToFront();
if(e.Button == MouseButtons.Middle) previousposition = e.Location;
if (e.Button == MouseButtons.Left)
{
ismousedown = true;
ResizeTextField(e);
}
}
protected override void OnGotFocus(EventArgs e)
{
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
}
protected override void OnLostFocus(EventArgs e)
{
this.BorderStyle = BorderStyle.Fixed3D;
}
}
}