|
using System;
using System.Windows.Forms;
using dwf.tool;
using System.Drawing;
namespace dwf.gui.test
{
public class DiffTest : UserControl
{
private Label textALabel = new Label();
private Label textBLabel = new Label();
private TextBox textA = new TextBox();
private TextBox textB = new TextBox();
private Button test = new Button();
private PList result = new PList();
private GroupBoxItem itemParam = new GroupBoxItem();
private GroupBoxItem itemResult = new GroupBoxItem();
private GroupBoxMap map = new GroupBoxMap();
private TableLayoutPanel panel = new TableLayoutPanel();
public DiffTest()
{
this.textALabel.Text = "Param1:";
this.textALabel.TextAlign = ContentAlignment.BottomCenter;
this.textBLabel.Text = "Param2:";
this.textBLabel.TextAlign = ContentAlignment.BottomCenter;
this.textA.Text = "Sequential Read: Up to 550 MB/s ";
this.textA.Dock = DockStyle.Fill;
this.textB.Text = "Sequential Write: Up to 510 MB/s ";
this.textB.Dock = DockStyle.Fill;
this.test.Text = "Test";
this.test.Click += TestOnClick;
this.result.Dock = DockStyle.Fill;
this.result.GenerateToString = false;
this.result.SelectionChanged += result_SelectionChanged;
this.panel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 60));
this.panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
this.panel.Controls.Add(textALabel, 0, 0);
this.panel.Controls.Add(textA, 1, 0);
this.panel.Controls.Add(textBLabel, 0, 1);
this.panel.Controls.Add(textB, 1, 1);
this.panel.Controls.Add(test);
//test.RowSpan =
this.itemParam.Control = panel;
this.itemParam.FillWidth = true;
this.itemParam.Text = "Params";
this.itemResult.Control = result;
this.itemResult.Row = 1;
this.itemResult.FillHeight = true;
this.itemResult.Text = "Result";
this.map.Add(this.itemParam);
this.map.Add(this.itemResult);
this.map.Dock = DockStyle.Fill;
this.Controls.Add(map);
this.BackColor = SystemColors.Control;
this.Text = "Diff Test";
}
private void result_SelectionChanged(object sender, PListSelectionArgs e)
{
if (result.SelectedItem != null)
{
var rez = (ListTool.DiffRez)result.SelectedItem;
var box = rez.Type == ListTool.DiffType.Deleted ? textA : textB;
box.SelectionStart = rez.Index;
box.SelectionLength = rez.Length;
box.Focus();
}
}
private void TestOnClick(object sender, EventArgs e)
{
result.ListSource = ListTool.Diff(textA.Text, textB.Text, false);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.