123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PaintDotNet.Setting
- {
- /// <summary>
- /// 新增/编辑点距
- /// </summary>
- public partial class PointDataDialog : PdnBaseForm
- {
- private string pointId = string.Empty;
- private ListView fatherListView;
- private int listIndex = 0;
- public PointDataDialog(string id, ListView listView,int index = 0)
- {
- StartPosition = FormStartPosition.CenterScreen;
- InitializeComponent();
- InitializeLanguageText();
- #region [展示控件]
- pointId = id;
- fatherListView = listView;
- listIndex = index;
- if (!string.IsNullOrEmpty(pointId))
- {
- var point = mic_screen_rules_BLL.FindDefault(Convert.ToInt32(pointId));
- if (point == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Abnormalinformatio.Text"));
- }
- textBox1.MaxLength = 10;
- textBox2.MaxLength = 10;
- textBox3.MaxLength = 10;
- textBox4.MaxLength = 10;
- textBox5.MaxLength = 10;
- textBox1.Text = point.size;
- textBox4.Text = point.point_pitch;
- textBox5.Text = point.screen_width;
- string[] ls = point.max_resolution.Split('×');
- textBox2.Text = ls[0];
- textBox3.Text = ls[1];
- }
- #endregion
- }
- #region [控件相关]
- private TextBox textBox1;
- private Label label13;
- private TextBox textBox2;
- private Label label1;
- private Label label2;
- private TextBox textBox3;
- private Label label3;
- private TextBox textBox4;
- private Label label4;
- private TextBox textBox5;
- private Label label5;
- private Label label6;
- private Label label7;
- private Button button1;
- private Button button2;
- private void InitializeLanguageText()
- {
- label13.Text = PdnResources.GetString("Menu.sizeed.text") + ":";
- label1.Text = PdnResources.GetString("Menu.Set.Generalsettings.Maximumresolution.text") + ":";
- label3.Text = PdnResources.GetString("Menu.Set.Generalsettings.dotspacing.text") + ":";
- label5.Text = PdnResources.GetString("Menu.Set.Generalsettings.Screenwidth.text") + ":";
- label6.Text = PdnResources.GetString("Menu.Mm.text");
- label7.Text = PdnResources.GetString("Menu.Mm.text");
- button1.Text = PdnResources.GetString("Menu.ensure.text");
- button2.Text = PdnResources.GetString("Menu.cancel.text");
- }
- private void InitializeComponent()
- {
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label13 = new System.Windows.Forms.Label();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.textBox5 = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(111, 23);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(172, 21);
- this.textBox1.TabIndex = 4;
- //
- // label13
- //
- this.label13.AutoSize = true;
- this.label13.Location = new System.Drawing.Point(47, 26);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(41, 12);
- this.label13.TabIndex = 3;
- this.label13.Text = "尺寸:";
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(111, 73);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(73, 21);
- this.textBox2.TabIndex = 6;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(11, 73);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(77, 12);
- this.label1.TabIndex = 5;
- this.label1.Text = "最大分辨率:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(193, 76);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(11, 12);
- this.label2.TabIndex = 7;
- this.label2.Text = "*";
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(210, 73);
- this.textBox3.Name = "textBox3";
- this.textBox3.Size = new System.Drawing.Size(73, 21);
- this.textBox3.TabIndex = 8;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(47, 113);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(41, 12);
- this.label3.TabIndex = 9;
- this.label3.Text = "点距:";
- //
- // textBox4
- //
- this.textBox4.Location = new System.Drawing.Point(111, 113);
- this.textBox4.Name = "textBox4";
- this.textBox4.Size = new System.Drawing.Size(172, 21);
- this.textBox4.TabIndex = 10;
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(284, 76);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(17, 12);
- this.label4.TabIndex = 11;
- this.label4.Text = "PX";
- //
- // textBox5
- //
- this.textBox5.Location = new System.Drawing.Point(111, 147);
- this.textBox5.Name = "textBox5";
- this.textBox5.Size = new System.Drawing.Size(172, 21);
- this.textBox5.TabIndex = 13;
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(23, 150);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(65, 12);
- this.label5.TabIndex = 12;
- this.label5.Text = "屏幕宽度:";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(285, 116);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(0, 12);
- this.label6.TabIndex = 14;
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(285, 150);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(0, 12);
- this.label7.TabIndex = 15;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(113, 209);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 16;
- this.button1.Text = "确定";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(210, 209);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 17;
- this.button2.Text = "取消";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // PointDataDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(364, 261);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.label7);
- this.Controls.Add(this.label6);
- this.Controls.Add(this.textBox5);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.textBox4);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.textBox3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label13);
- this.Name = "PointDataDialog";
- this.Text = "新增点距";
- this.Controls.SetChildIndex(this.label13, 0);
- this.Controls.SetChildIndex(this.textBox1, 0);
- this.Controls.SetChildIndex(this.label1, 0);
- this.Controls.SetChildIndex(this.textBox2, 0);
- this.Controls.SetChildIndex(this.label2, 0);
- this.Controls.SetChildIndex(this.textBox3, 0);
- this.Controls.SetChildIndex(this.label3, 0);
- this.Controls.SetChildIndex(this.textBox4, 0);
- this.Controls.SetChildIndex(this.label4, 0);
- this.Controls.SetChildIndex(this.label5, 0);
- this.Controls.SetChildIndex(this.textBox5, 0);
- this.Controls.SetChildIndex(this.label6, 0);
- this.Controls.SetChildIndex(this.label7, 0);
- this.Controls.SetChildIndex(this.button1, 0);
- this.Controls.SetChildIndex(this.button2, 0);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private void button1_Click(object sender, EventArgs e)
- {
- var id = pointId;
- if (string.IsNullOrEmpty(textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.leaseentersiz.Text"));
- return;
- }
- else if (string.IsNullOrEmpty(textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.seenterthemaximumres.Text"));
- return;
- }
- else if (string.IsNullOrEmpty(textBox3.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.seenterthemaximumres.Text"));
- return;
- }
- else if (string.IsNullOrEmpty(textBox4.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.aseenterthedotsp.Text"));
- return;
- }
- else if (string.IsNullOrEmpty(textBox5.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.aseenterthescreenwi.Text"));
- return;
- }
- if (string.IsNullOrEmpty(id))
- {
- var point = new mic_screen_rules();
- point.delete_flag = 2;
- point.size = textBox1.Text;
- point.max_resolution = $"{textBox2.Text}×{textBox3.Text}";
- point.point_pitch = textBox4.Text;
- point.screen_width = textBox5.Text;
- mic_screen_rules_BLL.Add(point);
- fatherListView.BeginUpdate();
- var lv = new ListViewItem();
- lv.Text = "2";
- lv.SubItems.Add("×");
- lv.SubItems.Add(point.size);
- lv.SubItems.Add(point.max_resolution);
- lv.SubItems.Add(point.point_pitch);
- lv.SubItems.Add(point.screen_width);
- lv.SubItems.Add(point.id.ToString());
- fatherListView.Items.Add(lv);
- fatherListView.EndUpdate();
- }
- else {
- var point = mic_screen_rules_BLL.FindDefault(Convert.ToInt32(pointId));
- if (point == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Abnormalinformatio.Text"));
- }
- point.size = textBox1.Text;
- point.max_resolution = $"{textBox2.Text}×{textBox3.Text}";
- point.point_pitch = textBox4.Text;
- point.screen_width = textBox5.Text;
- mic_screen_rules_BLL.Update(point);
- fatherListView.BeginUpdate();
- var lv = fatherListView.Items[listIndex];
- lv.SubItems[2].Text = point.size;
- lv.SubItems[3].Text = point.max_resolution;
- lv.SubItems[4].Text = point.point_pitch;
- lv.SubItems[5].Text = point.screen_width;
- fatherListView.EndUpdate();
- }
- Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Hide();
- }
- }
- }
|