123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775 |
- using PaintDotNet.CustomControl;
- 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.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Web.UI;
- using System.Windows.Forms;
- namespace PaintDotNet
- {
- /// <summary>
- /// 通用书签配置页
- /// </summary>
- internal class BookmarkConfigDialog : PdnBaseForm
- {
- private Label label1;
- private TextBox textBox1;
- private TextBox textBox2;
- private Label label2;
- private GroupBox groupBox2;
- private Button button2;
- private Button button1;
- private DataGridView dataGridView1;
- private Button button3;
- private GroupBox groupBox1;
- /// <summary>
- /// 当前分类下的书签数据集合
- /// </summary>
- private List<mic_module_infos> mic_module_infos;
- private GroupBox groupBox3;
- private TextBox textBox10;
- private TextBox textBox9;
- private TextBox textBox8;
- private TextBox textBox7;
- private TextBox textBox6;
- private TextBox textBox5;
- private TextBox textBox4;
- private TextBox textBox3;
- private Label label10;
- private Label label9;
- private Label label8;
- private Label label7;
- private Label label6;
- private Label label5;
- private Label label4;
- private Label label3;
- /// <summary>
- /// 书签分类名
- /// </summary>
- private string analyzeClassify;
- public BookmarkConfigDialog(string analyzeClassify,string languageName)
- {
- this.analyzeClassify = analyzeClassify;
- this.Text = this.analyzeClassify + "-"+ PdnResources.GetString("Menu.Bookmarksconfiguration.Text");
- //查询当前分类下的所有书签信息
- if (!string.IsNullOrEmpty(this.analyzeClassify))
- {
- mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeClassify);
- mic_module_infos.Reverse();
- }
-
- InitializeComponent();
- InitializeLanguageText();
- InitGridHeader();
- InitDataGridView();
- this.textBox3.Text = "itemNumber";
- this.textBox7.Text = "ratingDate";
- this.textBox4.Text = "inspectionPerson";
- this.textBox8.Text = "contact";
- this.textBox5.Text = "inspectionDepartment";
- this.textBox9.Text = "inspectionDate";
- this.textBox6.Text = "other";
- this.textBox10.Text = "picture";
- if (languageName == "Template.Manager.item2.AtlasComparison")
- {
- groupBox3.Enabled = false;
- groupBox1.Enabled = false;
- button1.Enabled = false;
- dataGridView1.Visible = false;
- }
-
- }
- private void InitializeLanguageText()
- {
- this.groupBox1.Text = PdnResources.GetString("Menu.Advancedbookmarkconfiguration.Text");
- this.button3.Text = PdnResources.GetString("Menu.Addto.text");
- this.label2.Text = PdnResources.GetString("Menu.Formposition.Text") + ":";
- this.label1.Text = PdnResources.GetString("Menu.Thename.Text") + ":";
- this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
- this.button1.Text = PdnResources.GetString("Menu.File.Save.Text");
- this.button2.Text = PdnResources.GetString("Menu.cancel.text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Basedhebookmarks.Text");
- this.label10.Text = PdnResources.GetString("Menu.picture.Text") + ":";
- this.label8.Text = PdnResources.GetString("Menu.Contactperson.text") + ":";
- this.label9.Text = PdnResources.GetString("Menu.Inspectiondate.text") + ":";
- this.label7.Text = PdnResources.GetString("Menu.Ratingdate.text") + ":";
- this.label6.Text = PdnResources.GetString("Menu.other.text") + PdnResources.GetString("Menu.information.text") + ":";
- this.label5.Text = PdnResources.GetString("Menu.inspectiondepartment.text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Sender.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.projectnumber.text") + ":";
- }
- /// <summary>
- /// 初始化基础控件
- /// </summary>
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button3 = new System.Windows.Forms.Button();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.textBox10 = new System.Windows.Forms.TextBox();
- this.textBox9 = new System.Windows.Forms.TextBox();
- this.textBox8 = new System.Windows.Forms.TextBox();
- this.textBox7 = new System.Windows.Forms.TextBox();
- this.textBox6 = new System.Windows.Forms.TextBox();
- this.textBox5 = new System.Windows.Forms.TextBox();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.label10 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.groupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- this.groupBox2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.button3);
- this.groupBox1.Controls.Add(this.dataGridView1);
- this.groupBox1.Controls.Add(this.textBox2);
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.textBox1);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Location = new System.Drawing.Point(12, 239);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(517, 241);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "高级书签配置";
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(425, 27);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 5;
- this.button3.Text = "添加";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.AllowUserToDeleteRows = false;
- this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
- this.dataGridView1.Location = new System.Drawing.Point(20, 56);
- this.dataGridView1.MultiSelect = false;
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
- this.dataGridView1.Size = new System.Drawing.Size(480, 179);
- this.dataGridView1.TabIndex = 4;
- this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(277, 29);
- this.textBox2.MaxLength = 10;
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(110, 21);
- this.textBox2.TabIndex = 3;
- this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(217, 32);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(65, 12);
- this.label2.TabIndex = 2;
- this.label2.Text = "表格位置:";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(78, 29);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(110, 21);
- this.textBox1.TabIndex = 1;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(18, 32);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(65, 12);
- this.label1.TabIndex = 0;
- this.label1.Text = "书签名称:";
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.button2);
- this.groupBox2.Controls.Add(this.button1);
- this.groupBox2.Location = new System.Drawing.Point(12, 13);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(517, 65);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "操作";
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(425, 25);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "取消";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(328, 25);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "保存";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.textBox10);
- this.groupBox3.Controls.Add(this.textBox9);
- this.groupBox3.Controls.Add(this.textBox8);
- this.groupBox3.Controls.Add(this.textBox7);
- this.groupBox3.Controls.Add(this.textBox6);
- this.groupBox3.Controls.Add(this.textBox5);
- this.groupBox3.Controls.Add(this.textBox4);
- this.groupBox3.Controls.Add(this.textBox3);
- this.groupBox3.Controls.Add(this.label10);
- this.groupBox3.Controls.Add(this.label9);
- this.groupBox3.Controls.Add(this.label8);
- this.groupBox3.Controls.Add(this.label7);
- this.groupBox3.Controls.Add(this.label6);
- this.groupBox3.Controls.Add(this.label5);
- this.groupBox3.Controls.Add(this.label4);
- this.groupBox3.Controls.Add(this.label3);
- this.groupBox3.Location = new System.Drawing.Point(13, 85);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(516, 137);
- this.groupBox3.TabIndex = 2;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "基础书签";
- //
- // textBox10
- //
- this.textBox10.Location = new System.Drawing.Point(349, 108);
- this.textBox10.Name = "textBox10";
- this.textBox10.ReadOnly = true;
- this.textBox10.Size = new System.Drawing.Size(128, 21);
- this.textBox10.TabIndex = 15;
- //
- // textBox9
- //
- this.textBox9.Location = new System.Drawing.Point(349, 82);
- this.textBox9.Name = "textBox9";
- this.textBox9.ReadOnly = true;
- this.textBox9.Size = new System.Drawing.Size(128, 21);
- this.textBox9.TabIndex = 14;
- //
- // textBox8
- //
- this.textBox8.Location = new System.Drawing.Point(349, 52);
- this.textBox8.Name = "textBox8";
- this.textBox8.ReadOnly = true;
- this.textBox8.Size = new System.Drawing.Size(128, 21);
- this.textBox8.TabIndex = 13;
- //
- // textBox7
- //
- this.textBox7.Location = new System.Drawing.Point(349, 26);
- this.textBox7.Name = "textBox7";
- this.textBox7.ReadOnly = true;
- this.textBox7.Size = new System.Drawing.Size(128, 21);
- this.textBox7.TabIndex = 12;
- //
- // textBox6
- //
- this.textBox6.Location = new System.Drawing.Point(101, 108);
- this.textBox6.Name = "textBox6";
- this.textBox6.ReadOnly = true;
- this.textBox6.Size = new System.Drawing.Size(128, 21);
- this.textBox6.TabIndex = 11;
- //
- // textBox5
- //
- this.textBox5.Location = new System.Drawing.Point(101, 80);
- this.textBox5.Name = "textBox5";
- this.textBox5.ReadOnly = true;
- this.textBox5.Size = new System.Drawing.Size(128, 21);
- this.textBox5.TabIndex = 10;
- //
- // textBox4
- //
- this.textBox4.Location = new System.Drawing.Point(101, 52);
- this.textBox4.Name = "textBox4";
- this.textBox4.ReadOnly = true;
- this.textBox4.Size = new System.Drawing.Size(128, 21);
- this.textBox4.TabIndex = 9;
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(101, 24);
- this.textBox3.Name = "textBox3";
- this.textBox3.ReadOnly = true;
- this.textBox3.Size = new System.Drawing.Size(128, 21);
- this.textBox3.TabIndex = 8;
- //
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(274, 113);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(41, 12);
- this.label10.TabIndex = 7;
- this.label10.Text = "图片:";
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(274, 85);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(65, 12);
- this.label9.TabIndex = 6;
- this.label9.Text = "送检日期:";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(274, 57);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(53, 12);
- this.label8.TabIndex = 5;
- this.label8.Text = "联系人:";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(274, 29);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(65, 12);
- this.label7.TabIndex = 4;
- this.label7.Text = "评级日期:";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(30, 113);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(65, 12);
- this.label6.TabIndex = 3;
- this.label6.Text = "其他信息:";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(30, 85);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(65, 12);
- this.label5.TabIndex = 2;
- this.label5.Text = "送检单位:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(30, 57);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(53, 12);
- this.label4.TabIndex = 1;
- this.label4.Text = "送检人:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(30, 29);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(65, 12);
- this.label3.TabIndex = 0;
- this.label3.Text = "项目编号:";
- //
- // BookmarkConfigDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(541, 492);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "BookmarkConfigDialog";
- this.Text = "书签配置";
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- this.groupBox2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 初始化表头
- /// </summary>
- private void InitGridHeader()
- {
- DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
- h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h1.Width = 190;
- DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
- h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h2.Width = 190;
- DataGridViewButtonColumn h3 = new DataGridViewButtonColumn();
- h3.Width = 80;
- this.dataGridView1.Columns.Add(h1);
- this.dataGridView1.Columns.Add(h2);
- this.dataGridView1.Columns.Add(h3);
- DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
- helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.Booksigning.Text")));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Celllocation.Text")));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.operation.text")));
- this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.AllowUserToResizeRows = false;
- this.dataGridView1.AllowUserToResizeColumns = false;
- }
- /// <summary>
- /// 初始化表格信息
- /// </summary>
- private void InitDataGridView()
- {
- this.dataGridView1.Rows.Clear();
- if(mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach(mic_module_infos info in mic_module_infos)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Cells.Add(CreateTextBoxCell(info.tag_name, "tagName"));
- row.Cells.Add(CreateTextBoxCell(info.cell_position, "cellPosition"));
- row.Cells.Add(CreateButtonCell(PdnResources.GetString("Menu.Edit.Delete.Text"), "delete"));
- this.dataGridView1.Rows.Add(row);
- }
-
- this.dataGridView1.ClearSelection();
- }
- }
- /// <summary>
- /// 添加内容单元格
- /// </summary>
- /// <param name="text"></param>
- /// <param name="tag"></param>
- /// <returns></returns>
- private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
- {
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = text;
- textboxcell.Tag = tag;
- return textboxcell;
- }
- /// <summary>
- /// 添加按钮单元格
- /// </summary>
- /// <param name="text"></param>
- /// <param name="tag"></param>
- /// <returns></returns>
- public DataGridViewButtonCell CreateButtonCell(string text, object tag)
- {
- DataGridViewButtonCell buttonCell = new DataGridViewButtonCell();
- buttonCell.Value = text;
- buttonCell.Tag = tag;
- return buttonCell;
- }
- /// <summary>
- /// 取消按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (mic_module_infos.Count > 0)
- {
- mic_module_infos_BLL.Del(this.analyzeClassify);
- }
- foreach (DataGridViewRow row in this.dataGridView1.Rows)//重新添加到数据库
- {
- mic_module_infos newInfo = new mic_module_infos();
- newInfo.analyze_classify = this.analyzeClassify;
- newInfo.tag_name = row.Cells[0].Value.ToString().Replace(" ","");
- newInfo.cell_position = row.Cells[1].Value.ToString().Replace(" ", "");
- mic_module_infos_BLL.Add(newInfo);
- }
- this.Close();
- }
- catch(Exception)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Failedtosavebookmark.text"));
- }
- }
- /// <summary>
- /// 添加书签按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterbookmarkname.text"));
- return;
- }
- if (string.IsNullOrEmpty(this.textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseentertheformlocation.text"));
- return;
- }
- if (!Regex.IsMatch(this.textBox2.Text, "[0-9]"))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Thetableter.text"));
- return;
- }
- DataGridViewRow row = new DataGridViewRow();
- row.Cells.Add(CreateTextBoxCell(this.textBox1.Text.Replace(" ",""), "tagName"));
- row.Cells.Add(CreateTextBoxCell(this.textBox2.Text.Replace(" ", ""), "cellPosition"));
- row.Cells.Add(CreateButtonCell(PdnResources.GetString("Menu.Edit.Delete.Text"), "delete"));
- this.dataGridView1.Rows.Add(row);
- //选中最新添加的那一条
- this.dataGridView1.ClearSelection();
- this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[0].Selected = true;
- //清空输入框
- this.textBox1.Text = "";
- this.textBox2.Text = "";
- }
- /// <summary>
- /// 点击删除按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- var senderGrid = (DataGridView)sender;
- if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
- e.RowIndex >= 0)
- {
- this.dataGridView1.Rows[e.RowIndex].Cells[0].Selected = true;
- if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretoedbookmark.text")+"?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
- this.dataGridView1.Rows.Remove(this.dataGridView1.Rows[e.RowIndex]);
- }
-
- }
- /// <summary>
- /// 对单元格位置输入做限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- //如果不是字符,数字,退格键
- if (!char.IsDigit(e.KeyChar) && !char.IsLetter(e.KeyChar) && (int)e.KeyChar != 8)
- {
- e.Handled = true;
- }
- //数字不能在第一位
- if (char.IsDigit(e.KeyChar))
- {
- if (this.textBox2.Text.Length <= 0)
- e.Handled = true;
- }
- //有数字后不允许再输入字符
- if (char.IsLetter(e.KeyChar))
- {
- if (Regex.IsMatch(this.textBox2.Text, "[0-9]"))
- e.Handled = true;
- }
- }
- /// <summary>
- /// 编辑gatagridview的单元格,未完成
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
- {
- if(this.dataGridView1.CurrentCell.ColumnIndex == 1)
- {
- (this.dataGridView1.CurrentCell as DataGridViewTextBoxCell).MaxInputLength = 10;
- e.Control.KeyPress -= girdTextbox_KeyPress;
- e.Control.KeyPress += new KeyPressEventHandler(girdTextbox_KeyPress);
- }
- }
- /// <summary>
- /// 添加编辑时的事件控制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void girdTextbox_KeyPress(object sender, KeyPressEventArgs e)
- {
- //如果不是字符,数字,退格键
- if (!char.IsDigit(e.KeyChar) && !char.IsLetter(e.KeyChar) && (int)e.KeyChar != 8)
- {
- e.Handled = true;
- }
- TextBox gridTextBox = (TextBox)sender;
- string strMatchValue = gridTextBox.Text;
- //判断是否为退格键
- if(e.KeyChar == 8)
- {
- //判断输入控件选择文本的长度
- if (gridTextBox.SelectionLength == 0)
- {//未选中时
-
- }
- else
- {
- }
- }
- else
- {
- //判断输入控件选择文本的长度
- if (gridTextBox.SelectionLength == 0)
- {//未选中时
- //将当前输入的字符插入到原来的字符串中
- strMatchValue = strMatchValue.Insert(gridTextBox.SelectionStart, e.KeyChar.ToString());
- }
- else
- {
- //用当前输入的字符替换选中的字符串
- strMatchValue = strMatchValue.Replace(strMatchValue.Substring(gridTextBox.SelectionStart, gridTextBox.SelectionLength), e.KeyChar.ToString());
- }
- }
- if (!Regex.IsMatch(strMatchValue, "^[a-zA-Z]+[0-9]+$"))
- e.Handled = true;
- //string strMathchValue = tb.Text;
- ////判断是否为退格键
- //if (kc == 8)
- //{
- // ///判断输入控件选择文本的长度
- // if (tb.SelectionLength == 0)
- // {//未选文本中时处理
- // if (tb.SelectionStart > 0)
- // {//选择的开始位置大于0时处理
- // //strMathchValue.Remove(tb.SelectionStart, 1);
- // strMathchValue.Remove(tb.SelectionStart - 1, 1);
- // }
- // }
- // else
- // {//有选中文本时处理
- // strMathchValue.Remove(tb.SelectionStart, tb.SelectionLength);
- // }
- //}
- //else
- //{
- // //将当前输入的字符号插入到原来的字符串中
- // strMathchValue = strMathchValue.Insert(((TextBox)sender).SelectionStart, e.KeyChar.ToString());
- //}
- //Regex rx = new Regex(@"^\+?[1-9][0-9]*$", RegexOptions.IgnoreCase);
- //if (rx.IsMatch(strMathchValue) == false)
- //{
- // e.Handled = true;
- //}
- ////数字不能在第一位
- //if (char.IsDigit(e.KeyChar))
- //{
- // if (gridTextBox.Text.Length <= 0)
- // e.Handled = true;
- //}
- ////有数字后不允许再输入字符
- //if (char.IsLetter(e.KeyChar))
- //{
- // if (Regex.IsMatch(gridTextBox.Text, "[0-9]"))
- // e.Handled = true;
- //}
- }
- }
- }
|