using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Globalization;
using RR.Windows.Forms;
namespace ExtenderTest
{
/// <summary>
/// Summary description for FormExtenderTest.
/// </summary>
public class FormExtenderTest : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panelCenter;
private System.Windows.Forms.ListView listView;
private System.Windows.Forms.Panel panelRight;
private System.Windows.Forms.Panel panelBottom;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.ColumnHeader columnHeaderString;
private System.Windows.Forms.ColumnHeader columnHeaderInt32;
private System.Windows.Forms.ColumnHeader columnHeaderDateTime;
private System.Windows.Forms.ColumnHeader columnHeaderNoCase;
private RR.Windows.Forms.ListViewExEdit listViewExEdit1;
private RR.Windows.Forms.ColumnSetting columnSetting1;
private RR.Windows.Forms.ColumnSetting columnSetting2;
private RR.Windows.Forms.ColumnSetting columnSetting3;
private RR.Windows.Forms.ColumnSetting columnSetting4;
private RR.Windows.Forms.ListViewExSort listViewExSort1;
private RR.Windows.Forms.ListBoxExEdit listBoxExEdit1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Panel panelRigthTop;
private System.Windows.Forms.Panel panelRigtBottom;
private System.Windows.Forms.ImageList imageList;
private System.Windows.Forms.Button buttonNewLine;
private System.Windows.Forms.Button buttonCutLine;
private System.Windows.Forms.Button buttonDown;
private System.Windows.Forms.Button buttonUp;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ToolTip toolTip;
private System.ComponentModel.IContainer components;
public FormExtenderTest()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
listView.Items.Add("ABc" ).SubItems.AddRange(new string[]{"ABc", 003.ToString(), (new DateTime(1971, 1, 24)).ToString("d")});
listView.Items.Add("ABC" ).SubItems.AddRange(new string[]{"ABC", 030.ToString(), (new DateTime(1982, 2, 24)).ToString("d")});
listView.Items.Add("Abc" ).SubItems.AddRange(new string[]{"Abc", 300.ToString(), (new DateTime(2001, 3, 22)).ToString("d")});
listView.Items.Add("aBC" ).SubItems.AddRange(new string[]{"aBC", 002.ToString(), (new DateTime(2001, 9, 22)).ToString("d")});
listView.Items.Add("abC" ).SubItems.AddRange(new string[]{"abC", 020.ToString(), (new DateTime(2001, 3, 21)).ToString("d")});
listView.Items.Add("abc" ).SubItems.AddRange(new string[]{"abc", 200.ToString(), (new DateTime(1983, 3, 24)).ToString("d")});
listViewExSort1.Comparer=new IListViewComparer[] {
null, // text, case sensitive (default)
new TextComparer(), // text, case insensitive
new Int32Comparer(), // number
new DateTimeComparer(), // DateTime
};
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormExtenderTest));
this.listView = new System.Windows.Forms.ListView();
this.columnHeaderString = new System.Windows.Forms.ColumnHeader();
this.columnHeaderNoCase = new System.Windows.Forms.ColumnHeader();
this.columnHeaderInt32 = new System.Windows.Forms.ColumnHeader();
this.columnHeaderDateTime = new System.Windows.Forms.ColumnHeader();
this.listViewExEdit1 = new RR.Windows.Forms.ListViewExEdit(this.components);
this.columnSetting1 = new RR.Windows.Forms.ColumnSetting();
this.columnSetting2 = new RR.Windows.Forms.ColumnSetting();
this.columnSetting3 = new RR.Windows.Forms.ColumnSetting();
this.columnSetting4 = new RR.Windows.Forms.ColumnSetting();
this.panelCenter = new System.Windows.Forms.Panel();
this.panelRight = new System.Windows.Forms.Panel();
this.panelRigtBottom = new System.Windows.Forms.Panel();
this.listBox1 = new System.Windows.Forms.ListBox();
this.listBoxExEdit1 = new RR.Windows.Forms.ListBoxExEdit(this.components);
this.panelRigthTop = new System.Windows.Forms.Panel();
this.buttonNewLine = new System.Windows.Forms.Button();
this.imageList = new System.Windows.Forms.ImageList(this.components);
this.buttonCutLine = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.panelBottom = new System.Windows.Forms.Panel();
this.textBox1 = new System.Windows.Forms.TextBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.listViewExSort1 = new RR.Windows.Forms.ListViewExSort(this.components);
this.splitter1 = new System.Windows.Forms.Splitter();
this.button1 = new System.Windows.Forms.Button();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.panelCenter.SuspendLayout();
this.panelRight.SuspendLayout();
this.panelRigtBottom.SuspendLayout();
this.panelRigthTop.SuspendLayout();
this.panelBottom.SuspendLayout();
this.SuspendLayout();
//
// listView
//
this.listView.AllowColumnReorder = true;
this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeaderString,
this.columnHeaderNoCase,
this.columnHeaderInt32,
this.columnHeaderDateTime});
this.listView.Controls.Add(this.listViewExEdit1.TextBox);
this.listView.Controls.Add(this.listViewExEdit1.Button);
this.listView.Cursor = System.Windows.Forms.Cursors.Default;
this.listView.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView.FullRowSelect = true;
this.listView.GridLines = true;
this.listView.Location = new System.Drawing.Point(8, 8);
this.listView.MultiSelect = false;
this.listView.Name = "listView";
this.listView.Size = new System.Drawing.Size(432, 242);
this.listView.TabIndex = 0;
this.listView.View = System.Windows.Forms.View.Details;
//
// columnHeaderString
//
this.columnHeaderString.Text = "string";
this.columnHeaderString.Width = 92;
//
// columnHeaderNoCase
//
this.columnHeaderNoCase.Text = "text (no-case)";
this.columnHeaderNoCase.Width = 110;
//
// columnHeaderInt32
//
this.columnHeaderInt32.Text = "int";
this.columnHeaderInt32.Width = 92;
//
// columnHeaderDateTime
//
this.columnHeaderDateTime.Text = "date";
this.columnHeaderDateTime.Width = 117;
//
// listViewExEdit1
//
//
// listViewExEdit1.Button
//
this.listViewExEdit1.Button.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.listViewExEdit1.Button.Location = new System.Drawing.Point(116, 17);
this.listViewExEdit1.Button.Name = "button";
this.listViewExEdit1.Button.Size = new System.Drawing.Size(30, 23);
this.listViewExEdit1.Button.TabIndex = 0;
this.listViewExEdit1.Button.Text = "...";
this.listViewExEdit1.Button.Visible = false;
this.listViewExEdit1.ColumnSettings.AddRange(new RR.Windows.Forms.ColumnSetting[] {
this.columnSetting1,
this.columnSetting2,
this.columnSetting3,
this.columnSetting4});
this.listViewExEdit1.EditableCursor = System.Windows.Forms.Cursors.Hand;
this.listViewExEdit1.ListView = this.listView;
this.listViewExEdit1.SelectedCursor = System.Windows.Forms.Cursors.IBeam;
//
// listViewExEdit1.TextBox
//
this.listViewExEdit1.TextBox.Location = new System.Drawing.Point(17, 17);
this.listViewExEdit1.TextBox.Name = "textBox";
this.listViewExEdit1.TextBox.TabIndex = 0;
this.listViewExEdit1.TextBox.Visible = false;
this.listViewExEdit1.ModifiedChanged += new RR.Windows.Forms.ListViewExEdit.ModifiedChangedEventHandler(this.listViewExEdit1_ModifiedChanged);
this.listViewExEdit1.ButtonClick += new RR.Windows.Forms.ListViewExEdit.ButtonClickedEventHandler(this.listViewExEdit1_ButtonClick);
//
// columnSetting1
//
this.columnSetting1.IsEditable = false;
//
// columnSetting3
//
this.columnSetting3.ButtonText = "++";
this.columnSetting3.HasButton = true;
//
// columnSetting4
//
this.columnSetting4.HasButton = true;
//
// panelCenter
//
this.panelCenter.Controls.Add(this.listView);
this.panelCenter.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelCenter.DockPadding.All = 8;
this.panelCenter.Location = new System.Drawing.Point(0, 0);
this.panelCenter.Name = "panelCenter";
this.panelCenter.Size = new System.Drawing.Size(448, 258);
this.panelCenter.TabIndex = 0;
//
// panelRight
//
this.panelRight.Controls.Add(this.panelRigtBottom);
this.panelRight.Controls.Add(this.panelRigthTop);
this.panelRight.Dock = System.Windows.Forms.DockStyle.Right;
this.panelRight.Location = new System.Drawing.Point(448, 0);
this.panelRight.Name = "panelRight";
this.panelRight.Size = new System.Drawing.Size(144, 258);
this.panelRight.TabIndex = 4;
//
// panelRigtBottom
//
this.panelRigtBottom.Controls.Add(this.listBox1);
this.panelRigtBottom.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelRigtBottom.DockPadding.All = 8;
this.panelRigtBottom.Location = new System.Drawing.Point(0, 32);
this.panelRigtBottom.Name = "panelRigtBottom";
this.panelRigtBottom.Size = new System.Drawing.Size(144, 226);
this.panelRigtBottom.TabIndex = 0;
//
// listBox1
//
this.listBox1.Controls.Add(this.listBoxExEdit1.TextBox);
this.listBox1.Controls.Add(this.listBoxExEdit1.Button);
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.ItemHeight = 16;
this.listBox1.Items.AddRange(new object[] {
"Z�rich",
"Bern",
"Luzern",
"Zug",
"Cham",
"Alpnach",
"Altdorf"});
this.listBox1.Location = new System.Drawing.Point(8, 8);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(128, 196);
this.listBox1.TabIndex = 0;
//
// listBoxExEdit1
//
//
// listBoxExEdit1.Button
//
this.listBoxExEdit1.Button.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.listBoxExEdit1.Button.Location = new System.Drawing.Point(116, 17);
this.listBoxExEdit1.Button.Name = "button";
this.listBoxExEdit1.Button.Size = new System.Drawing.Size(30, 20);
this.listBoxExEdit1.Button.TabIndex = 0;
this.listBoxExEdit1.Button.TabStop = false;
this.listBoxExEdit1.Button.Text = "...";
this.listBoxExEdit1.Button.Visible = false;
this.listBoxExEdit1.DisplayButton = true;
this.listBoxExEdit1.KeyNavigation = true;
this.listBoxExEdit1.ListBox = this.listBox1;
//
// listBoxExEdit1.TextBox
//
this.listBoxExEdit1.TextBox.Location = new System.Drawing.Point(13, 11);
this.listBoxExEdit1.TextBox.Name = "textBox";
this.listBoxExEdit1.TextBox.TabIndex = 0;
this.listBoxExEdit1.TextBox.Visible = false;
this.listBoxExEdit1.ModifiedChanged += new RR.Windows.Forms.ListBoxExEdit.ModifiedChangedEventHandler(this.listBoxExEdit1_ModifiedChanged);
//
// panelRigthTop
//
this.panelRigthTop.Controls.Add(this.buttonNewLine);
this.panelRigthTop.Controls.Add(this.buttonCutLine);
this.panelRigthTop.Controls.Add(this.buttonDown);
this.panelRigthTop.Controls.Add(this.buttonUp);
this.panelRigthTop.Dock = System.Windows.Forms.DockStyle.Top;
this.panelRigthTop.DockPadding.All = 8;
this.panelRigthTop.Location = new System.Drawing.Point(0, 0);
this.panelRigthTop.Name = "panelRigthTop";
this.panelRigthTop.Size = new System.Drawing.Size(144, 32);
this.panelRigthTop.TabIndex = 1;
//
// buttonNewLine
//
this.buttonNewLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonNewLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonNewLine.ImageIndex = 4;
this.buttonNewLine.ImageList = this.imageList;
this.buttonNewLine.Location = new System.Drawing.Point(40, 8);
this.buttonNewLine.Name = "buttonNewLine";
this.buttonNewLine.Size = new System.Drawing.Size(24, 24);
this.buttonNewLine.TabIndex = 0;
this.toolTip.SetToolTip(this.buttonNewLine, "New Line (Ctrl-Insert)");
this.buttonNewLine.Click += new System.EventHandler(this.buttonNewLine_Click);
//
// imageList
//
this.imageList.ImageSize = new System.Drawing.Size(16, 16);
this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
this.imageList.TransparentColor = System.Drawing.Color.Transparent;
//
// buttonCutLine
//
this.buttonCutLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCutLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonCutLine.ImageIndex = 1;
this.buttonCutLine.ImageList = this.imageList;
this.buttonCutLine.Location = new System.Drawing.Point(64, 8);
this.buttonCutLine.Name = "buttonCutLine";
this.buttonCutLine.Size = new System.Drawing.Size(24, 24);
this.buttonCutLine.TabIndex = 1;
this.toolTip.SetToolTip(this.buttonCutLine, "Cut Line (Ctrl-Delete)");
this.buttonCutLine.Click += new System.EventHandler(this.buttonCutLine_Click);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonDown.ImageIndex = 2;
this.buttonDown.ImageList = this.imageList;
this.buttonDown.Location = new System.Drawing.Point(88, 8);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(24, 24);
this.buttonDown.TabIndex = 2;
this.toolTip.SetToolTip(this.buttonDown, "Line Down (Ctrl-Down)");
this.buttonDown.Click += new System.EventHandler(this.buttonDown_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonUp.ImageIndex = 3;
this.buttonUp.ImageList = this.imageList;
this.buttonUp.Location = new System.Drawing.Point(112, 8);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(24, 24);
this.buttonUp.TabIndex = 3;
this.toolTip.SetToolTip(this.buttonUp, "Line Up (Ctrl-Up)");
this.buttonUp.Click += new System.EventHandler(this.buttonUp_Click);
//
// panelBottom
//
this.panelBottom.Controls.Add(this.textBox1);
this.panelBottom.Controls.Add(this.buttonCancel);
this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panelBottom.Location = new System.Drawing.Point(0, 258);
this.panelBottom.Name = "panelBottom";
this.panelBottom.Size = new System.Drawing.Size(592, 40);
this.panelBottom.TabIndex = 2;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(8, 8);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(224, 22);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.buttonCancel.Location = new System.Drawing.Point(504, 8);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(80, 24);
this.buttonCancel.TabIndex = 1;
this.buttonCancel.Text = "&Close";
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// listViewExSort1
//
this.listViewExSort1.Comparer = null;
this.listViewExSort1.ListView = this.listView;
this.listViewExSort1.ShadeColor = System.Drawing.Color.WhiteSmoke;
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.SystemColors.ControlDark;
this.splitter1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
this.splitter1.Location = new System.Drawing.Point(445, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 258);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
//
// FormExtenderTest
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(592, 298);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panelCenter);
this.Controls.Add(this.panelRight);
this.Controls.Add(this.panelBottom);
this.Name = "FormExtenderTest";
this.Text = "Control Extender Test";
this.panelCenter.ResumeLayout(false);
this.panelRight.ResumeLayout(false);
this.panelRigtBottom.ResumeLayout(false);
this.panelRigthTop.ResumeLayout(false);
this.panelBottom.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles(); // .NET 1.1 only (broken?)
Application.DoEvents();
Application.Run(new FormExtenderTest());
}
private void buttonCancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void listViewExEdit1_ButtonClick(object sender, RR.Windows.Forms.ListViewExEdit.ButtonClickedEventArgs e)
{
if (e.ColIndex==2)
{
int number=int.Parse(e.Text, NumberStyles.Number);
((ListViewExEdit)sender).SetFieldData((++number).ToString() , e.RowIndex, e.ColIndex);
}
else if (e.ColIndex==3)
{
// insert todays data if on date column
((ListViewExEdit)sender).SetFieldData(DateTime.Now.ToString("d"), e.RowIndex, e.ColIndex);
}
}
private void listViewExEdit1_ModifiedChanged(object sender, RR.Windows.Forms.ListViewExEdit.ModifiedChangedEventArgs e)
{
textBox1.Text=string.Format("[{1},{2}] = {0}", e.Text , e.RowIndex, e.ColIndex);
}
private void listBoxExEdit1_ModifiedChanged(object sender, RR.Windows.Forms.ListBoxExEdit.ModifiedChangedEventArgs e)
{
textBox1.Text=string.Format("[{1}] = {0}", e.NewText, e.Index);
}
private void buttonNewLine_Click(object sender, System.EventArgs e)
{
listBoxExEdit1.NewLine();
}
private void buttonCutLine_Click(object sender, System.EventArgs e)
{
listBoxExEdit1.CutLine();
}
private void buttonDown_Click(object sender, System.EventArgs e)
{
listBoxExEdit1.MoveLineDown();
}
private void buttonUp_Click(object sender, System.EventArgs e)
{
listBoxExEdit1.MoveLineUp();
}
class Int32Comparer : IListViewComparer
{
public int OnCompare(string x, string y)
{
try
{
return int.Parse(x, NumberStyles.Number) - int.Parse(y, NumberStyles.Number);
}
catch (System.Exception)
{
return -1;
}
}
}
class DateTimeComparer : IListViewComparer
{
public int OnCompare(string x, string y)
{
try
{
return DateTime.Parse(x).CompareTo(DateTime.Parse(y));
}
catch (System.Exception)
{
return -1;
}
}
}
class TextComparer : IListViewComparer
{
public int OnCompare(string x, string y)
{
return string.Compare(x, y, true);
}
}
}
}