219 lines
6.3 KiB
C#
219 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AIMS.OremrUserControl
|
|
{
|
|
|
|
public class UText : TextBox
|
|
{
|
|
private const int WM_PAINT = 15;
|
|
|
|
private const int WM_CTLCOLOREDIT = 307;
|
|
|
|
private const int WM_SETFOCUS = 7;
|
|
|
|
private IContainer components = null;
|
|
|
|
private CheckedListBox checkedListBox1 = null;
|
|
|
|
private TextBox textBox1;
|
|
|
|
private Button button1;
|
|
|
|
private Button button2;
|
|
|
|
private string dictionaryKey = "";
|
|
|
|
private bool isUpdateDictionary = false;
|
|
|
|
private bool isFindDictionray = false;
|
|
|
|
public bool IsFindDictionray
|
|
{
|
|
get
|
|
{
|
|
return isFindDictionray;
|
|
}
|
|
set
|
|
{
|
|
isFindDictionray = value;
|
|
}
|
|
}
|
|
|
|
public string DictionaryKey
|
|
{
|
|
get
|
|
{
|
|
return dictionaryKey;
|
|
}
|
|
set
|
|
{
|
|
dictionaryKey = value;
|
|
}
|
|
}
|
|
|
|
public bool IsUpdateDictionary
|
|
{
|
|
get
|
|
{
|
|
return isUpdateDictionary;
|
|
}
|
|
set
|
|
{
|
|
isUpdateDictionary = value;
|
|
}
|
|
}
|
|
|
|
|
|
public CheckedListBox GetListBox()
|
|
{
|
|
return checkedListBox1;
|
|
}
|
|
|
|
public TextBox GetTestBox()
|
|
{
|
|
return textBox1;
|
|
}
|
|
|
|
[DllImport("User32.dll")]
|
|
public static extern IntPtr GetWindowDC(IntPtr hWnd);
|
|
|
|
[DllImport("User32.dll")]
|
|
public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
|
|
|
public UText()
|
|
{
|
|
InitializeComponent();
|
|
base.BorderStyle = BorderStyle.None;
|
|
BackColor = SystemColors.Control;
|
|
base.DoubleClick += this_DoubleClick;
|
|
checkedListBox1 = new CheckedListBox();
|
|
checkedListBox1.FormattingEnabled = true;
|
|
checkedListBox1.HorizontalScrollbar = true;
|
|
checkedListBox1.ScrollAlwaysVisible = true;
|
|
checkedListBox1.Items.AddRange(new object[0]);
|
|
checkedListBox1.Name = "checkedListBox1";
|
|
checkedListBox1.TabIndex = 6;
|
|
checkedListBox1.CheckOnClick = true;
|
|
textBox1 = new TextBox();
|
|
textBox1.Name = "textBox1";
|
|
textBox1.TabIndex = 7;
|
|
button2 = new Button();
|
|
button2.Name = "button1";
|
|
button2.TabIndex = 8;
|
|
button2.Text = "确定";
|
|
button2.UseVisualStyleBackColor = true;
|
|
button2.Font = new Font("宋体", 9f);
|
|
button2.Click += button2_Click;
|
|
button1 = new Button();
|
|
button1.Name = "button1";
|
|
button1.TabIndex = 8;
|
|
button1.Text = "+";
|
|
button1.UseVisualStyleBackColor = true;
|
|
button1.Font = new Font("宋体", 13f);
|
|
button1.Click += button_Click;
|
|
contVisible(isVisible: false);
|
|
}
|
|
|
|
private void button_Click(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
base.WndProc(ref m);
|
|
int msg = m.Msg;
|
|
if (msg != 15 && msg != 307)
|
|
{
|
|
return;
|
|
}
|
|
|
|
IntPtr windowDC = GetWindowDC(base.Handle);
|
|
if (windowDC.ToInt32() != 0)
|
|
{
|
|
Graphics g = Graphics.FromHdc(windowDC);
|
|
drawBottomLine(g);
|
|
}
|
|
|
|
m.Result = IntPtr.Zero;
|
|
ReleaseDC(m.HWnd, windowDC);
|
|
}
|
|
|
|
private void drawBottomLine(Graphics g)
|
|
{
|
|
Pen pen = new Pen(BackColor, 2f);
|
|
g.DrawRectangle(pen, -1, -1, base.Width, base.Height);
|
|
pen = new Pen(Color.FromArgb(0, 0, 0), 1f);
|
|
g.DrawLine(pen, 0, base.Height - 1, base.Width, base.Height - 1);
|
|
base.Parent.Controls.Add(button2);
|
|
button2.Location = new Point(base.Left + base.Width - 46, base.Top + base.Height + 2);
|
|
button2.Size = new Size(47, 26);
|
|
button2.BringToFront();
|
|
base.Parent.Controls.Add(checkedListBox1);
|
|
checkedListBox1.Size = new Size(base.Width, 176);
|
|
checkedListBox1.Location = new Point(base.Left, base.Top + base.Height + textBox1.Height + 2);
|
|
checkedListBox1.BringToFront();
|
|
base.Parent.Controls.Add(textBox1);
|
|
textBox1.Location = new Point(base.Left, base.Top + base.Height + 2);
|
|
textBox1.Size = new Size(base.Width - 67, 21);
|
|
textBox1.BringToFront();
|
|
base.Parent.Controls.Add(button1);
|
|
button1.Location = new Point(textBox1.Left + textBox1.Width, base.Top + base.Height + 2);
|
|
button1.Size = new Size(23, 26);
|
|
button1.BringToFront();
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
components = new System.ComponentModel.Container();
|
|
}
|
|
|
|
private void this_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (IsFindDictionray && !checkedListBox1.Visible)
|
|
{
|
|
contVisible(isVisible: true);
|
|
}
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
string text = "";
|
|
for (int i = 0; i < checkedListBox1.Items.Count; i++)
|
|
{
|
|
if (checkedListBox1.GetItemChecked(i))
|
|
{
|
|
text = text + checkedListBox1.GetItemText(checkedListBox1.Items[i]) + "\u3000";
|
|
}
|
|
}
|
|
|
|
base.Text += text;
|
|
contVisible(isVisible: false);
|
|
}
|
|
|
|
private void contVisible(bool isVisible)
|
|
{
|
|
checkedListBox1.Visible = isVisible;
|
|
textBox1.Visible = isVisible;
|
|
button1.Visible = isVisible;
|
|
button2.Visible = isVisible;
|
|
}
|
|
}
|
|
}
|