/src/M2008/csharp/UMAListView/MainForm.cs
C# | 387 lines | 360 code | 27 blank | 0 comment | 5 complexity | 1d2a06a431c889848938d3f86eeb1848 MD5 | raw file
Possible License(s): LGPL-3.0
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Collections;
- using System.Linq;
-
- namespace UMAListView
- {
- public partial class MainForm : Form
- {
- private ListViewItemComparer listView1_Sorter;
-
- private enum HorseType {
- CHILD,
- RACE,
- DAM,
- SIRE,
- UNKNOWN,
- }
-
- public MainForm()
- {
- this.InitializeComponent();
- this.ControlsSetup();
- }
-
- private void ControlsSetup()
- {
- this.listView1_Setup();
-
- foreach( var _column in this.listView1.Columns )
- {
- var column = (_column as ColumnHeader);
- var text = column.Text;
- var button = new ToolStripMenuItem() {
- Text = text,
- Checked = true,
- Tag = column.Name,
- };
-
- button.Click += ( obj, e )=> {
- var b = ( obj as ToolStripMenuItem );
- var c = this.listView1.Columns[ (String)b.Tag ];
- if( b.Checked ) {
- c.Width = 0;
- b.Checked = false;
- } else {
- c.Width = (int)c.Tag;
- b.Checked = true;
- }
- };
- contextMenuStrip1.Items.Add( button );
- column.Tag = column.Width;
- }
-
- this.radioButton1.Tag = HorseType.CHILD;
- this.radioButton2.Tag = HorseType.RACE;
- this.radioButton3.Tag = HorseType.DAM;
- this.radioButton4.Tag = HorseType.SIRE;
-
- this.checkBox1.Checked = true;
- this.checkBox2.Checked = true;
- this.checkBox3.Checked = true;
- this.checkBox4.Checked = true;
- this.checkBox5.Checked = true;
-
- this.checkBox6.Checked = true;
- this.checkBox7.Checked = true;
- this.checkBox8.Checked = true;
-
- this.checkBox9.Checked = true;
- this.checkBox10.Checked = true;
-
- this.radioButton2.Checked = true;
-
- this.toolStripStatusLabel1.Text = "";
- this.toolStripStatusLabel2.Text = "";
- this.toolStripStatusLabel3.Text = "";
-
- this.timer1.Tick += ( obj, e )=> {
- Invoke( (MethodInvoker)delegate {
- this.toolStripStatusLabel1.Text =
- String.Format( "{0:f2}(MB)", GC.GetTotalMemory( false ) / 1024.0 / 1024.0 );
- });
- };
- this.timer1.Interval = 1000;
- this.timer1.Start();
- }
-
- private void listView1_Setup()
- {
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "name",
- TextAlign = HorizontalAlignment.Left,
- Width = 200,
- Tag = ListViewItemComparer.ComparerMode.STRING,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "age",
- TextAlign = HorizontalAlignment.Right,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "gender",
- TextAlign = HorizontalAlignment.Right,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "SP",
- Name = "speed",
- TextAlign = HorizontalAlignment.Right,
- Width = 60,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "ST",
- Name = "stamina",
- TextAlign = HorizontalAlignment.Right,
- Width = 35,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "power",
- TextAlign = HorizontalAlignment.Right,
- Width = 45,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "syunpatsu",
- TextAlign = HorizontalAlignment.Right,
- Width = 45,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "konzyou",
- TextAlign = HorizontalAlignment.Right,
- Width = 45,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "zyuunan",
- TextAlign = HorizontalAlignment.Right,
- Width = 45,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "seishin",
- TextAlign = HorizontalAlignment.Right,
- Width = 45,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "kashikosa",
- TextAlign = HorizontalAlignment.Right,
- Width = 45,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "health",
- TextAlign = HorizontalAlignment.Right,
- Width = 45,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "subpara",
- TextAlign = HorizontalAlignment.Right,
- Width = 40,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "babatekisei",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "seichougata",
- TextAlign = HorizontalAlignment.Left,
- Width = 40,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "seichouryoku",
- TextAlign = HorizontalAlignment.Left,
- Width = 40,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "seichou",
- TextAlign = HorizontalAlignment.Right,
- Width = 40,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "seigen",
- TextAlign = HorizontalAlignment.Right,
- Width = 40,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "zyumyou",
- TextAlign = HorizontalAlignment.Right,
- Width = 40,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "kodashi",
- TextAlign = HorizontalAlignment.Right,
- Width = 40,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "kisyou",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "keiro",
- TextAlign = HorizontalAlignment.Left,
- Width = 60,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "komawari_X",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "hidarimawari_X",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "migimawari_X",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "migimawari_X",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "migimawari_X",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "migimawari_X",
- TextAlign = HorizontalAlignment.Left,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
-
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "father",
- TextAlign = HorizontalAlignment.Left,
- Width = 200,
- Tag = ListViewItemComparer.ComparerMode.STRING,
- });
-
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "family_line",
- TextAlign = HorizontalAlignment.Left,
- Width = 200,
- Tag = ListViewItemComparer.ComparerMode.STRING,
- });
-
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "??",
- Name = "mother",
- TextAlign = HorizontalAlignment.Left,
- Width = 200,
- Tag = ListViewItemComparer.ComparerMode.STRING,
- });
-
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "?",
- Name = "sizitsu_num",
- TextAlign = HorizontalAlignment.Right,
- Width = 30,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "????",
- Name = "abl_num",
- TextAlign = HorizontalAlignment.Right,
- Width = 80,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
- this.listView1.Columns.Add( new ColumnHeader() {
- Text = "???",
- Name = "id",
- TextAlign = HorizontalAlignment.Right,
- Width = 80,
- Tag = ListViewItemComparer.ComparerMode.TAG_NUMERIC,
- });
-
- var list = new ListViewItemComparer.ComparerMode[ this.listView1.Columns.Count ];
- for( var i=0; i<list.Length; ++i ) {
- list[i] = (ListViewItemComparer.ComparerMode)this.listView1.Columns[i].Tag;
- }
- this.listView1_Sorter = new ListViewItemComparer() {
- ColumnModes = list,
- };
- this.listView1.ListViewItemSorter = this.listView1_Sorter;
- }
-
-
- private void button1_Click(object sender, EventArgs e)
- {
- var sw = new System.Diagnostics.Stopwatch();
- sw.Start();
-
- #if DEBUG
- this.CreateHorseList();
- #else
- try {
- this.CreateHorseList();
- } catch( Exception ex ) {
- MessageBox.Show( "?????????? - " + ex.Message );
- }
- #endif
- sw.Stop();
-
- this.toolStripStatusLabel2.Text = String.Format( "{0}(ms)", sw.ElapsedMilliseconds );
- this.toolStripStatusLabel3.Text = String.Format( "{0}(line)", this.listView1.Items.Count );
-
- GC.Collect();
- }
-
- private void listView1_OddColor()
- {
- for( var i=0; i<this.listView1.Items.Count; ++i ) {
- this.listView1.Items[i].BackColor = ( i % 2 == 1 )
- ? System.Drawing.Color.FromArgb( 0xef, 0xef, 0xff )
- : System.Drawing.Color.White;
- }
- }
-
- private void listView1_ColumnClick( object sender, ColumnClickEventArgs e )
- {
- this.listView1_ExecSort( e.Column );
- this.listView1_OddColor();
- }
-
- private void listView1_MouseClick(object sender, MouseEventArgs e)
- {
- }
- }
- }