标签:
DGUI总体来说还是很不错,在使用过程中,据需求做了一部分修改。今天用它来做了一个小工具。
很是不错,哈哈….
缩小一点看看:
对DGUI做了以下修改:
一、给Event做了+=与-=操作符重载
三、给ListBox添加了removeAll方法
写起来很像在使用.net From ,哈哈,不错的东西,主要是想怎么改,就能怎么改。
module MainForm; import dgui.all; import dgui.layout.splitpanel; import std.conv; import StringExtend; class MainForm : Form { TextBox _regexpBox; TextBox _textBox; Button _findBtn; Button _findsBtn; Button _helpBtn; SplitPanel _splitPanel; ListBox _listView; this() { init(); layout(); bindEvent(); } ~this() { uninit(); } void init() { _regexpBox = new TextBox(); _textBox = new TextBox(); _findBtn = new Button(); _findsBtn = new Button(); _splitPanel = new SplitPanel(); _helpBtn = new Button(); _listView = new ListBox(); _findBtn.text = "查找"; _findsBtn.text = "多个查找"; _helpBtn.text = "帮助"; } void uninit() { delete _regexpBox; delete _textBox; delete _findBtn; delete _findsBtn; delete _splitPanel; delete _helpBtn; delete _listView; } void layout() { _splitPanel.parent = this; _splitPanel.splitOrientation = SplitOrientation.horizontal; _splitPanel.splitPosition = 180; _textBox.parent = _splitPanel.panel1; _regexpBox.parent = _splitPanel.panel2; _findBtn.parent = _splitPanel.panel2; _findsBtn.parent = _splitPanel.panel2; _helpBtn.parent = _splitPanel.panel2; _listView.parent = _splitPanel.panel2; _textBox.scrollBars = true; _textBox.multiline = true; _textBox.anchor = AnchorStyles.right | AnchorStyles.top | AnchorStyles.left | AnchorStyles.bottom; _regexpBox.anchor = AnchorStyles.right | AnchorStyles.top | AnchorStyles.left; _regexpBox.right = 85; _regexpBox.left = 1; _regexpBox.top = 2; _listView.anchor = AnchorStyles.right | AnchorStyles.top | AnchorStyles.left | AnchorStyles.bottom; _listView.right = 85; _listView.left = 1; _listView.top = 35; _listView.bottom = 2; _findBtn.anchor = AnchorStyles.right | AnchorStyles.top; _findBtn.right = 1; _findBtn.top = 1; _findsBtn.anchor = AnchorStyles.right | AnchorStyles.top; _findsBtn.right = 1; _findsBtn.top = 35; _helpBtn.anchor = AnchorStyles.right | AnchorStyles.top; _helpBtn.right = 1; _helpBtn.top = 70; } void bindEvent() { _findBtn.click += &findBtn_Proc; _findsBtn.click += &findsBtn_Proc; } void unBindEvent() { _findBtn.click -= &findBtn_Proc; _findsBtn.click -= &findsBtn_Proc; } void findBtn_Proc(Control control,EventArgs args) { auto text = _textBox.text.to!wstring(); auto rgx = _regexpBox.text.to!wstring(); auto item = text.Find(rgx); _listView.removeAll(); _listView.addItem(item.to!string()); } void findsBtn_Proc(Control control,EventArgs args) { auto text = _textBox.text.to!wstring(); auto rgx = _regexpBox.text.to!wstring(); auto items = text.Finds(rgx); _listView.removeAll(); foreach(item;items) { _listView.addItem(item.to!string()); } } }
标签:
原文地址:http://www.cnblogs.com/wanhongnan/p/5770580.html