using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using App_8dam; namespace WindowsApplication1 { /// <summary> /// Summary description for _8damWin. /// </summary> public class _8damWin : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label ReseniCelkem; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label ReseniUnikatniCelkem; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label4; private System.Windows.Forms.ComboBox comboBox1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; private System.Windows.Forms.ComboBox comboBox2; private System.Windows.Forms.Label label5; App_8dam._8dam o8dam; [STAThread] static void Main() { Application.Run(new _8damWin()); } public _8damWin() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // o8dam = new _8dam(); this.ReseniCelkem.Text = o8dam.POCET_RESENI.ToString(); this.ReseniUnikatniCelkem.Text = o8dam.UNIKATNICH_RESENI.ToString(); GeneratePictures(); for (int i=0; i<o8dam.POCET_RESENI; i++) { comboBox1.Items.Add("Řešení " + (i+1)); } // inicializuj selekt box s unikátními řešeními for (int i=0; i<o8dam.UNIKATNICH_RESENI; i++) { comboBox2.Items.Add("UNI Řešení: " + (i+1)); } comboBox1.SelectedIndex = 0; zobrazReseni(0); } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } void GeneratePictures() { PictureBox Horni = new PictureBox(); PictureBox Levy = new PictureBox(); Horni.Image = Image.FromFile("img\desk_d.gif"@); Horni.Width = 480; Horni.Height = 26; Horni.Top = 480; Horni.Left = 27; this.Controls.Add(Horni); Levy.Image = System.Drawing.Bitmap.FromFile("img\desk_l.gif"@); Levy.Width = 27; Levy.Height = 506; Levy.Top = 0; this.Controls.Add(Levy); for (int i=0; i<8; i++) { for (int j=0; j<8; j++) { PictureBox novy = new PictureBox(); novy.Name = "c"+i.ToString()+j.ToString(); novy.Image = Image.FromFile("img\cel"@ + ((7*i+j) % 2).ToString() + ".gif"); novy.Width = 60; novy.Height = 60; novy.Top = i*60; novy.Left = Levy.Width + j*60; this.Controls.Add(novy); } } } #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.label1 = new System.Windows.Forms.Label(); this.ReseniCelkem = new System.Windows.Forms.Label(); this.ReseniUnikatniCelkem = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.comboBox2 = new System.Windows.Forms.ComboBox(); this.label5 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.Location = new System.Drawing.Point(528, 24); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(104, 24); this.label1.TabIndex = 0; this.label1.Text = "Nalezených řešení:"; // // ReseniCelkem // this.ReseniCelkem.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238))); this.ReseniCelkem.Location = new System.Drawing.Point(560, 48); this.ReseniCelkem.Name = "ReseniCelkem"; this.ReseniCelkem.TabIndex = 1; // // ReseniUnikatniCelkem // this.ReseniUnikatniCelkem.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238))); this.ReseniUnikatniCelkem.Location = new System.Drawing.Point(560, 96); this.ReseniUnikatniCelkem.Name = "ReseniUnikatniCelkem"; this.ReseniUnikatniCelkem.TabIndex = 3; // // label3 // this.label3.Location = new System.Drawing.Point(528, 72); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(104, 24); this.label3.TabIndex = 2; this.label3.Text = "Unikatnich řešení:"; // // label2 // this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238))); this.label2.Location = new System.Drawing.Point(536, 144); this.label2.Name = "label2"; this.label2.TabIndex = 5; // // label4 // this.label4.Location = new System.Drawing.Point(528, 120); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(104, 24); this.label4.TabIndex = 4; this.label4.Text = "Aktuální řešení:"; // // comboBox1 // this.comboBox1.ImeMode = System.Windows.Forms.ImeMode.NoControl; this.comboBox1.Location = new System.Drawing.Point(520, 192); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(121, 21); this.comboBox1.TabIndex = 6; this.comboBox1.Text = "comboBox1"; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // // comboBox2 // this.comboBox2.ImeMode = System.Windows.Forms.ImeMode.NoControl; this.comboBox2.Location = new System.Drawing.Point(520, 264); this.comboBox2.Name = "comboBox2"; this.comboBox2.Size = new System.Drawing.Size(121, 21); this.comboBox2.TabIndex = 7; this.comboBox2.Text = "comboBox2"; this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); // // label5 // this.label5.Location = new System.Drawing.Point(520, 232); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(104, 24); this.label5.TabIndex = 8; this.label5.Text = "Unikatní řešení:"; // // _8damWin // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(645, 506); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.label5, this.comboBox2, this.comboBox1, this.label2, this.label4, this.ReseniUnikatniCelkem, this.label3, this.ReseniCelkem, this.label1}); this.Name = "_8damWin"; this.Text = "_8damWin"; this.ResumeLayout(false); } #endregion private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e) { label2.Text = comboBox1.SelectedItem.ToString(); zobrazReseni(comboBox1.SelectedIndex); } void zobrazReseni(int idx) { PictureBox obj; for (int i=0; i<8; i++) { for (int j=0; j<8; j++) { for (int k=0; k<Controls.Count; k++) { if (Controls[k].Name == "c"+i.ToString()+j.ToString()) { obj = (PictureBox) Controls[k]; if ((int) o8dam.SACHOVNICE.Tables[idx].Rows[j].ItemArray[7-i] == 1) { obj.Image = Image.FromFile("img\dama"@ + ((7*i+j) % 2).ToString() + ".gif"); } else { obj.Image = Image.FromFile("img\cel"@ + ((7*i+j) % 2).ToString() + ".gif"); } } } } } } // vybrano unikatni rešení private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e) { label2.Text = comboBox2.SelectedItem.ToString(); zobrazReseni(o8dam.getUNI(comboBox2.SelectedIndex)); } } }