using PaintDotNet.Base.CommTool; using PaintDotNet.CustomControl; using PaintDotNet.Base.SettingModel; using System; using System.Drawing; using System.IO; using System.Windows.Forms; using System.Collections.Generic; namespace PaintDotNet.Setting { /// /// 设置->网格设置 ///已弃用 /// internal partial class GridSettingDialog : PdnBaseForm { private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.ComboBox comboBox2; private System.Windows.Forms.Label label7; private System.Windows.Forms.Panel gridPanel; private System.Windows.Forms.Panel rectPanel; private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label9; private System.Windows.Forms.ComboBox comboBox4; private System.Windows.Forms.ComboBox comboBox3; private System.Windows.Forms.Panel circularPanel; private System.Windows.Forms.Label label11; private System.Windows.Forms.Label label12; private System.Windows.Forms.ComboBox comboBox5; private System.Windows.Forms.ComboBox comboBox6; private System.Windows.Forms.Label label13; private System.Windows.Forms.ColorDialog colorDialog1; private UserTextBox userTextBox1; private UserTextBox userTextBox2; private UserTextBox userTextBox3; /// /// 主控件 /// private AppWorkspace appWorkspace; /// /// 网格设置的model /// private GridModel gridModel = Startup.instance.gridModel; /// /// 单位标尺 /// private double unitLength = 1; /// /// 网格调色板 /// PaintDotNet.ColorsForm colorsFormGrid; /// /// 矩形调色板 /// PaintDotNet.ColorsForm colorsFormRect; private ComboBox comboBox7; private ColorDialog colorDialog2; private GroupBox groupBox5; private Button button5; private Button button4; private Button button3; private DataGridView dataGridView1; private DataGridViewTextBoxColumn Column1; private Label label2; private TextBox textBox1; /// /// 圆形调色板 /// PaintDotNet.ColorsForm colorsFormCircular; private Button btnSaveAs; private Button btnSave; private Button btnDel; /// /// 网格样式的增改删,0-添加、1-修改、2-删除 /// private int operation = -1; public GridSettingDialog(AppWorkspace appWorkspace) { this.appWorkspace = appWorkspace; InitializeComponent(); InitializeLanguageText(); InitializeButtonBackgroudImage(); InitParameterData(); InitializationDataGridView(); InitializeComponent2(); UnitData(); } #region Windows Form Designer generated code private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); //this.button2.Text = PdnResources.GetString("Menu.cancel.text"); this.button1.Text = PdnResources.GetString("Menu.application.text"); this.groupBox2.Text = PdnResources.GetString("Menu.Setting.GridSetting.Text"); this.label7.Text = PdnResources.GetString("Menu.color.text") + ":"; this.label6.Text = PdnResources.GetString("Menu.Set.Gridsettings.grist.text") + ":"; this.label5.Text = PdnResources.GetString("Menu.Set.Gridsettings.Linear.text") + ":"; this.label4.Text = PdnResources.GetString("Menu.Set.Gridsettings.Numberofverticalgrids.text") + ":"; this.label3.Text = PdnResources.GetString("Menu.Set.Gridsettings.Numberofhorizontalgrids.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.Set.Gridsettings.Gridsidelength.text") + ":"; this.groupBox3.Text = PdnResources.GetString("Menu.Set.Gridsettings.Rectsettings.text"); this.label8.Text = PdnResources.GetString("Menu.color.text") + ":"; this.label10.Text = PdnResources.GetString("Menu.Set.Gridsettings.Linear.text") + ":"; this.label9.Text = PdnResources.GetString("Menu.Set.Gridsettings.grist.text") + ":"; this.groupBox4.Text = PdnResources.GetString("Menu.Set.Gridsettings.roundsetting.text"); this.label11.Text = PdnResources.GetString("Menu.color.text") + ":"; this.label12.Text = PdnResources.GetString("Menu.Set.Gridsettings.grist.text") + ":"; this.label13.Text = PdnResources.GetString("Menu.Set.Gridsettings.Linear.text") + ":"; this.Text = PdnResources.GetString("Menu.Setting.GridSetting.Text"); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.btnSaveAs = new System.Windows.Forms.Button(); this.btnSave = new System.Windows.Forms.Button(); this.btnDel = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.comboBox7 = new System.Windows.Forms.ComboBox(); this.userTextBox3 = new PaintDotNet.CustomControl.UserTextBox(); this.userTextBox2 = new PaintDotNet.CustomControl.UserTextBox(); this.userTextBox1 = new PaintDotNet.CustomControl.UserTextBox(); this.gridPanel = new System.Windows.Forms.Panel(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.comboBox2 = new System.Windows.Forms.ComboBox(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.label5 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.rectPanel = new System.Windows.Forms.Panel(); this.label8 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.comboBox4 = new System.Windows.Forms.ComboBox(); this.comboBox3 = new System.Windows.Forms.ComboBox(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.circularPanel = new System.Windows.Forms.Panel(); this.label11 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.comboBox5 = new System.Windows.Forms.ComboBox(); this.comboBox6 = new System.Windows.Forms.ComboBox(); this.label13 = new System.Windows.Forms.Label(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.colorDialog2 = new System.Windows.Forms.ColorDialog(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.button5 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.btnSaveAs); this.groupBox1.Controls.Add(this.btnSave); this.groupBox1.Controls.Add(this.btnDel); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(691, 58); this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // btnSaveAs // this.btnSaveAs.Anchor = System.Windows.Forms.AnchorStyles.Right; this.btnSaveAs.Location = new System.Drawing.Point(520, 20); this.btnSaveAs.Name = "btnSaveAs"; this.btnSaveAs.Size = new System.Drawing.Size(75, 23); this.btnSaveAs.TabIndex = 3; this.btnSaveAs.Text = "另存为"; this.btnSaveAs.UseVisualStyleBackColor = true; this.btnSaveAs.Click += new System.EventHandler(this.btnSaveAs_Click); // // btnSave // this.btnSave.Anchor = System.Windows.Forms.AnchorStyles.Right; this.btnSave.Location = new System.Drawing.Point(439, 20); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(75, 23); this.btnSave.TabIndex = 2; this.btnSave.Text = "保存"; this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // btnDel // this.btnDel.Anchor = System.Windows.Forms.AnchorStyles.Right; this.btnDel.Location = new System.Drawing.Point(358, 20); this.btnDel.Name = "btnDel"; this.btnDel.Size = new System.Drawing.Size(75, 23); this.btnDel.TabIndex = 1; this.btnDel.Text = "删除"; this.btnDel.UseVisualStyleBackColor = true; this.btnDel.Click += new System.EventHandler(this.btnDel_Click); // // button1 // this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button1.Location = new System.Drawing.Point(601, 20); 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); // // groupBox2 // this.groupBox2.Controls.Add(this.textBox1); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Controls.Add(this.comboBox7); this.groupBox2.Controls.Add(this.userTextBox3); this.groupBox2.Controls.Add(this.userTextBox2); this.groupBox2.Controls.Add(this.userTextBox1); this.groupBox2.Controls.Add(this.gridPanel); this.groupBox2.Controls.Add(this.label7); this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.comboBox2); this.groupBox2.Controls.Add(this.comboBox1); this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new System.Drawing.Point(195, 77); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(508, 207); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "网格设置"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(107, 13); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(342, 21); this.textBox1.TabIndex = 20; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(59, 18); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 12); this.label2.TabIndex = 16; this.label2.Text = "名称:"; // // comboBox7 // this.comboBox7.FormattingEnabled = true; this.comboBox7.Items.AddRange(new object[] { "px", "μm"}); this.comboBox7.Location = new System.Drawing.Point(400, 42); this.comboBox7.Name = "comboBox7"; this.comboBox7.Size = new System.Drawing.Size(49, 20); this.comboBox7.TabIndex = 2; // // userTextBox3 // this.userTextBox3.Location = new System.Drawing.Point(107, 100); this.userTextBox3.Name = "userTextBox3"; this.userTextBox3.Size = new System.Drawing.Size(342, 21); this.userTextBox3.TabIndex = 15; // // userTextBox2 // this.userTextBox2.Location = new System.Drawing.Point(107, 72); this.userTextBox2.Name = "userTextBox2"; this.userTextBox2.Size = new System.Drawing.Size(342, 21); this.userTextBox2.TabIndex = 14; // // userTextBox1 // this.userTextBox1.Location = new System.Drawing.Point(107, 42); this.userTextBox1.Name = "userTextBox1"; this.userTextBox1.Size = new System.Drawing.Size(287, 21); this.userTextBox1.TabIndex = 13; // // gridPanel // this.gridPanel.BackColor = System.Drawing.Color.Transparent; this.gridPanel.Location = new System.Drawing.Point(107, 182); this.gridPanel.Name = "gridPanel"; this.gridPanel.Size = new System.Drawing.Size(72, 21); this.gridPanel.TabIndex = 12; this.gridPanel.Click += new System.EventHandler(this.gridColorPanel_Click); // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(59, 186); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(41, 12); this.label7.TabIndex = 11; this.label7.Text = "颜色:"; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(59, 159); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(41, 12); this.label6.TabIndex = 10; this.label6.Text = "粗细:"; // // comboBox2 // this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox2.FormattingEnabled = true; this.comboBox2.Location = new System.Drawing.Point(107, 155); this.comboBox2.Name = "comboBox2"; this.comboBox2.Size = new System.Drawing.Size(341, 20); this.comboBox2.TabIndex = 9; // // comboBox1 // this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox1.FormattingEnabled = true; this.comboBox1.Location = new System.Drawing.Point(107, 128); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(341, 20); this.comboBox1.TabIndex = 8; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(59, 132); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(41, 12); this.label5.TabIndex = 7; this.label5.Text = "线形:"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(11, 104); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(89, 12); this.label4.TabIndex = 6; this.label4.Text = "垂直网格数量:"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(11, 76); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(89, 12); this.label3.TabIndex = 3; this.label3.Text = "水平网格数量:"; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(35, 46); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(65, 12); this.label1.TabIndex = 0; this.label1.Text = "网格边长:"; // // groupBox3 // this.groupBox3.Controls.Add(this.rectPanel); this.groupBox3.Controls.Add(this.label8); this.groupBox3.Controls.Add(this.label10); this.groupBox3.Controls.Add(this.label9); this.groupBox3.Controls.Add(this.comboBox4); this.groupBox3.Controls.Add(this.comboBox3); this.groupBox3.Location = new System.Drawing.Point(195, 290); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(508, 100); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; this.groupBox3.Text = "矩形设置"; // // rectPanel // this.rectPanel.BackColor = System.Drawing.Color.Transparent; this.rectPanel.Location = new System.Drawing.Point(107, 73); this.rectPanel.Name = "rectPanel"; this.rectPanel.Size = new System.Drawing.Size(72, 21); this.rectPanel.TabIndex = 18; this.rectPanel.Click += new System.EventHandler(this.rectColorPanel_Click); // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(59, 77); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(41, 12); this.label8.TabIndex = 17; this.label8.Text = "颜色:"; // // label10 // this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(59, 23); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(41, 12); this.label10.TabIndex = 13; this.label10.Text = "线形:"; // // label9 // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(59, 50); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(41, 12); this.label9.TabIndex = 16; this.label9.Text = "粗细:"; // // comboBox4 // this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox4.FormattingEnabled = true; this.comboBox4.Location = new System.Drawing.Point(107, 46); this.comboBox4.Name = "comboBox4"; this.comboBox4.Size = new System.Drawing.Size(341, 20); this.comboBox4.TabIndex = 14; // // comboBox3 // this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox3.FormattingEnabled = true; this.comboBox3.Location = new System.Drawing.Point(107, 19); this.comboBox3.Name = "comboBox3"; this.comboBox3.Size = new System.Drawing.Size(341, 20); this.comboBox3.TabIndex = 15; // // groupBox4 // this.groupBox4.Controls.Add(this.circularPanel); this.groupBox4.Controls.Add(this.label11); this.groupBox4.Controls.Add(this.label12); this.groupBox4.Controls.Add(this.comboBox5); this.groupBox4.Controls.Add(this.comboBox6); this.groupBox4.Controls.Add(this.label13); this.groupBox4.Location = new System.Drawing.Point(195, 397); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(508, 100); this.groupBox4.TabIndex = 4; this.groupBox4.TabStop = false; this.groupBox4.Text = "圆形设置"; // // circularPanel // this.circularPanel.BackColor = System.Drawing.Color.Transparent; this.circularPanel.Location = new System.Drawing.Point(105, 72); this.circularPanel.Name = "circularPanel"; this.circularPanel.Size = new System.Drawing.Size(72, 21); this.circularPanel.TabIndex = 18; this.circularPanel.Click += new System.EventHandler(this.circularColorPanel_Click); // // label11 // this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(57, 76); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(41, 12); this.label11.TabIndex = 17; this.label11.Text = "颜色:"; // // label12 // this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(57, 49); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(41, 12); this.label12.TabIndex = 16; this.label12.Text = "粗细:"; // // comboBox5 // this.comboBox5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox5.FormattingEnabled = true; this.comboBox5.Location = new System.Drawing.Point(105, 18); this.comboBox5.Name = "comboBox5"; this.comboBox5.Size = new System.Drawing.Size(341, 20); this.comboBox5.TabIndex = 15; // // comboBox6 // this.comboBox6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox6.FormattingEnabled = true; this.comboBox6.Location = new System.Drawing.Point(105, 44); this.comboBox6.Name = "comboBox6"; this.comboBox6.Size = new System.Drawing.Size(341, 20); this.comboBox6.TabIndex = 14; // // label13 // this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(57, 22); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(41, 12); this.label13.TabIndex = 13; this.label13.Text = "线形:"; // // groupBox5 // this.groupBox5.Controls.Add(this.dataGridView1); this.groupBox5.Controls.Add(this.button5); this.groupBox5.Controls.Add(this.button4); this.groupBox5.Controls.Add(this.button3); this.groupBox5.Location = new System.Drawing.Point(12, 77); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(175, 420); this.groupBox5.TabIndex = 5; this.groupBox5.TabStop = false; this.groupBox5.Text = "预览"; // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.ColumnHeadersVisible = false; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column1}); this.dataGridView1.Location = new System.Drawing.Point(7, 49); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new System.Drawing.Size(162, 364); this.dataGridView1.TabIndex = 5; this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged); // // Column1 // this.Column1.HeaderText = "Column1"; this.Column1.Name = "Column1"; // // button5 // this.button5.Location = new System.Drawing.Point(138, 18); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(30, 25); this.button5.TabIndex = 3; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // // button4 // this.button4.Location = new System.Drawing.Point(104, 18); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(30, 25); this.button4.TabIndex = 2; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // // button3 // this.button3.Location = new System.Drawing.Point(70, 18); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(30, 25); this.button3.TabIndex = 1; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // GridSettingDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(712, 512); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "GridSettingDialog"; this.Text = "网格设置"; this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox3, 0); this.Controls.SetChildIndex(this.groupBox4, 0); this.Controls.SetChildIndex(this.groupBox5, 0); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); this.groupBox5.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #endregion #region InitializeComponent2 /// /// 初始化组件 /// private void InitializeComponent2() { //this.textBox1.Text = gridModel.gridName; this.userTextBox1.Text = gridModel.grid.ActualLength.ToString(); this.userTextBox2.Text = gridModel.grid.HorizontalNum.ToString(); this.userTextBox3.Text = gridModel.grid.VerticalNum.ToString(); this.comboBox1.SelectedIndex = gridModel.grid.DashStyle; this.comboBox2.SelectedIndex = gridModel.grid.Thickness - 1; this.gridPanel.BackColor = Color.FromArgb(gridModel.grid.Color); this.comboBox3.SelectedIndex = gridModel.rectangle.DashStyle; this.comboBox4.SelectedIndex = gridModel.rectangle.Thickness - 1; this.rectPanel.BackColor = Color.FromArgb(gridModel.rectangle.Color); this.comboBox5.SelectedIndex = gridModel.round.DashStyle; this.comboBox6.SelectedIndex = gridModel.round.Thickness - 1; this.circularPanel.BackColor = Color.FromArgb(gridModel.round.Color); this.colorsFormGrid = new ColorsForm(); this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen; this.colorsFormGrid.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsFormRect = new ColorsForm(); this.colorsFormRect.StartPosition = FormStartPosition.CenterScreen; this.colorsFormRect.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsFormCircular = new ColorsForm(); this.colorsFormCircular.StartPosition = FormStartPosition.CenterScreen; this.colorsFormCircular.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); //this.groupBox2.Enabled = false; //this.groupBox3.Enabled = false; //this.groupBox4.Enabled = false; } #endregion /// /// 给下拉集合赋值 /// private void InitParameterData() { this.comboBox1.Items.AddRange(InvariantData.dashStyles); this.comboBox2.Items.AddRange(InvariantData.thinkness); this.comboBox3.Items.AddRange(InvariantData.dashStyles); this.comboBox4.Items.AddRange(InvariantData.thinkness); this.comboBox5.Items.AddRange(InvariantData.dashStyles); this.comboBox6.Items.AddRange(InvariantData.thinkness); } private void InitializeButtonBackgroudImage() { this.button3.FlatStyle = FlatStyle.Flat; this.button3.FlatAppearance.BorderSize = 0; this.button3.BackgroundImageLayout = ImageLayout.Center; this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListAddIcon.png").Reference; this.button4.FlatStyle = FlatStyle.Flat; this.button4.FlatAppearance.BorderSize = 0; this.button4.BackgroundImageLayout = ImageLayout.Center; this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListEditIcon.png").Reference; this.button5.FlatStyle = FlatStyle.Flat; this.button5.FlatAppearance.BorderSize = 0; this.button5.BackgroundImageLayout = ImageLayout.Center; this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListDeleteIcon.png").Reference; } /// /// 网格样式列表初始化 /// private void InitializationDataGridView() { this.dataGridView1.Rows.Clear(); //keyValuePairs.Clear(); int serveNameID = 0; this.dataGridView1.ReadOnly = true; List fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\"); if (fileNames.Count > 0) { for (int i = 0; i < fileNames.Count; i++) { GridModel gselectRidModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + fileNames[i], FileMode.Open)); DataGridViewRow row = new DataGridViewRow(); foreach (DataGridViewColumn c in this.dataGridView1.Columns) { row.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell); } row.Cells[0].Value = gselectRidModel.gridName; if (gselectRidModel.gridName.Equals(Startup.instance.configModel.GridName)) { serveNameID = i; } this.dataGridView1.Rows.Add(row); } if (operation != 2) { this.dataGridView1.CurrentCell = this.dataGridView1[0, serveNameID]; } else { this.dataGridView1.CurrentCell = this.dataGridView1[0, 0]; } RefreshDataGridView(); } } /// /// 单位设置初始化 /// private void UnitData() { // //获取系统标尺-微米 // this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength); if (gridModel.grid.Unit == 6) { comboBox7.Text = "px"; } else if (gridModel.grid.Unit == 4) { comboBox7.Text = "μm"; } } private void button1_Click(object sender, EventArgs e) { if (this.userTextBox1.Text.Equals("")) { MessageBox.Show(PdnResources.GetString("Menu.eedgelengthofthegridcannotbeemptw.Text")); return; } if (this.userTextBox2.Text.Equals("")) { MessageBox.Show(PdnResources.GetString("Menu.henumberofhorizontalgridscanno.Text")); return; } if (this.userTextBox3.Text.Equals("")) { MessageBox.Show(PdnResources.GetString("Menu.henumberofverticalgridscannotbenu.Text")); return; } //临时model,根据应用场景运用 GridModel temporarygridModel = new GridModel(); temporarygridModel.grid = new GridModel.Grid(); temporarygridModel.rectangle = new GridModel.Rectangle(); temporarygridModel.round = new GridModel.Round(); temporarygridModel.gridName = this.textBox1.Text; if ("px".Equals(comboBox7.Text)) { temporarygridModel.grid.SideLength = int.Parse(this.userTextBox1.Text); } else if ("μm".Equals(comboBox7.Text)) { temporarygridModel.grid.SideLength = int.Parse((double.Parse(this.userTextBox1.Text) / unitLength).ToString("F0")); } temporarygridModel.grid.HorizontalNum = int.Parse(this.userTextBox2.Text); temporarygridModel.grid.VerticalNum = int.Parse(this.userTextBox3.Text); temporarygridModel.grid.DashStyle = this.comboBox1.SelectedIndex; temporarygridModel.grid.Thickness = this.comboBox2.SelectedIndex + 1; temporarygridModel.grid.Color = this.gridPanel.BackColor.ToArgb(); if ("px".Equals(comboBox7.Text)) { temporarygridModel.grid.Unit = (int)MeasurementUnit.Pixel; } else if ("μm".Equals(comboBox7.Text)) { temporarygridModel.grid.Unit = (int)MeasurementUnit.Micron; } temporarygridModel.rectangle.DashStyle = this.comboBox3.SelectedIndex; temporarygridModel.rectangle.Thickness = this.comboBox4.SelectedIndex + 1; temporarygridModel.rectangle.Color = this.rectPanel.BackColor.ToArgb(); temporarygridModel.round.DashStyle = this.comboBox5.SelectedIndex; temporarygridModel.round.Thickness = this.comboBox6.SelectedIndex + 1; temporarygridModel.round.Color = this.circularPanel.BackColor.ToArgb(); temporarygridModel.grid.ActualLength = int.Parse(this.userTextBox1.Text); //if (operation == 0) //{ // gridModel.xmlName = "Grid" + (maxValue + 1).ToString(); //} //if (operation == 1) //{ // gridModel.xmlName = keyValuePairs[this.dataGridView1.CurrentCell.Value.ToString()]; //} string userInfoXml = XmlSerializeHelper.XmlSerialize(temporarygridModel); //选中标尺保存到默认标尺(网格样式列表为空时用) if (operation == -1) { Startup.instance.gridModel = temporarygridModel; Startup.instance.configModel.GridName = this.textBox1.Text; string configXml = XmlSerializeHelper.XmlSerialize(Startup.instance.configModel); string configPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml"; FileOperationHelper.WriteStringToFile(configXml, configPath, FileMode.Create); string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Grid.xml"; if (!FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create)) { MessageBox.Show(PdnResources.GetString("Menu.idinformationsavin.Text")); } if (appWorkspace.ActiveDocumentWorkspace != null) { appWorkspace.ActiveDocumentWorkspace.Refresh(); } } //添加 if (operation == 0) { //保存到xml string gridFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.textBox1.Text + ".xml"; if (System.IO.File.Exists(gridFilePath)) { MessageBox.Show(PdnResources.GetString("Menu.Thefilenandmodify.text")); return; } else { if (!FileOperationHelper.WriteStringToFile(userInfoXml, gridFilePath, FileMode.Create)) { MessageBox.Show(PdnResources.GetString("Menu.idinformationsavin.Text")); } InitializationDataGridView(); } this.button1.Text = PdnResources.GetString("Menu.application.text"); } //修改 if (operation == 1) { string updateName = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.dataGridView1.CurrentCell.Value + ".xml"; System.IO.File.Delete(updateName); //FileOperationHelper.DeleteFolder(updateName); //保存到xml string gridFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.textBox1.Text + ".xml"; if (System.IO.File.Exists(gridFilePath)) { MessageBox.Show(PdnResources.GetString("Menu.Thefilenandmodify.text")); return; } if (!FileOperationHelper.WriteStringToFile(userInfoXml, gridFilePath, FileMode.Create)) { MessageBox.Show(PdnResources.GetString("Menu.idinformationsavin.Text")); } InitializationDataGridView(); //this.dataGridView1.CurrentCell.Value = this.textBox1.Text; this.groupBox2.Enabled = false; this.groupBox3.Enabled = false; this.groupBox4.Enabled = false; this.button1.Text = PdnResources.GetString("Menu.application.text"); } operation = -1; } /// /// 调色板回调函数 /// /// /// private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce) { } /// /// 网格Panel被点击 /// /// /// private void gridColorPanel_Click(object sender, EventArgs e) { this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.gridPanel.BackColor); this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged)); this.colorsFormGrid.ShowDialog(); } /// /// 网格Panel的调色板颜色改变 /// /// /// private void gridColorChanged(object sender, EventArgs e) { this.gridPanel.BackColor = this.colorsFormGrid.UserPrimaryColor.ToColor(); // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb(); this.colorsFormGrid.Close(); } /// /// 矩形Panel被点击 /// /// /// private void rectColorPanel_Click(object sender, EventArgs e) { this.colorsFormRect.UserPrimaryColor = ColorBgra.FromColor(this.rectPanel.BackColor); this.colorsFormRect.setSaveBtn_Click(new System.EventHandler(this.rectColorChanged)); this.colorsFormRect.ShowDialog(); } /// /// 矩形Panel的调色板颜色改变 /// /// /// private void rectColorChanged(object sender, EventArgs e) { this.rectPanel.BackColor = this.colorsFormRect.UserPrimaryColor.ToColor(); // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb(); this.colorsFormRect.Close(); } /// /// 圆形Panel被点击 /// /// /// private void circularColorPanel_Click(object sender, EventArgs e) { this.colorsFormCircular.UserPrimaryColor = ColorBgra.FromColor(this.circularPanel.BackColor); this.colorsFormCircular.setSaveBtn_Click(new System.EventHandler(this.circularColorChanged)); this.colorsFormCircular.ShowDialog(); } /// /// 圆形Panel的调色板颜色改变 /// /// /// private void circularColorChanged(object sender, EventArgs e) { this.circularPanel.BackColor = this.colorsFormCircular.UserPrimaryColor.ToColor(); // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb(); this.colorsFormCircular.Close(); } private string serveName = string.Empty; private void dataGridView1_SelectionChanged(object sender, EventArgs e) { RefreshDataGridView(); } /// /// 刷新网格样式列表 /// private void RefreshDataGridView() { if (this.dataGridView1.SelectedRows.Count > 0 && this.dataGridView1.CurrentCell != null) { serveName = this.dataGridView1.CurrentCell.Value.ToString(); //string selectName = this.dataGridView1.CurrentCell.Value.ToString() + ".xml"; GridModel gselectRidModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + serveName + ".xml", FileMode.Open)); this.textBox1.Text = serveName; //网格 this.userTextBox1.Text = gselectRidModel.grid.ActualLength.ToString(); this.userTextBox2.Text = gselectRidModel.grid.HorizontalNum.ToString(); this.userTextBox3.Text = gselectRidModel.grid.VerticalNum.ToString(); this.comboBox1.SelectedIndex = gselectRidModel.grid.DashStyle; this.comboBox1.Text = gselectRidModel.grid.Thickness.ToString(); this.gridPanel.BackColor = Color.FromArgb(gselectRidModel.grid.Color); //矩形 this.comboBox3.SelectedIndex = gselectRidModel.rectangle.DashStyle; this.comboBox4.Text = gselectRidModel.rectangle.Thickness.ToString(); this.rectPanel.BackColor = Color.FromArgb(gselectRidModel.rectangle.Color); //圆形 this.comboBox5.SelectedIndex = gselectRidModel.round.DashStyle; this.comboBox6.Text = gselectRidModel.round.Thickness.ToString(); this.circularPanel.BackColor = Color.FromArgb(gselectRidModel.round.Color); if (gselectRidModel.grid.Unit == 6) { comboBox7.Text = "px"; } else if (gselectRidModel.grid.Unit == 4) { comboBox7.Text = "μm"; } this.groupBox2.Enabled = false; this.groupBox3.Enabled = false; this.groupBox4.Enabled = false; } } //添加网格样式 private void button3_Click(object sender, EventArgs e) { this.button1.Text = PdnResources.GetString("CloseWorkspaceAction.SaveButton.ActionText"); this.textBox1.Text = "Grid"; this.textBox1.Focus(); //this.userTextBox2.Focus(); //this.userTextBox3.Focus(); this.dataGridView1.ClearSelection(); operation = 0; this.groupBox2.Enabled = true; this.groupBox3.Enabled = true; this.groupBox4.Enabled = true; } //修改网格样式 private void button4_Click(object sender, EventArgs e) { if (this.dataGridView1.Rows.Count > 0) { this.button1.Text = PdnResources.GetString("CloseWorkspaceAction.SaveButton.ActionText"); this.textBox1.Focus(); operation = 1; this.groupBox2.Enabled = true; this.groupBox3.Enabled = true; this.groupBox4.Enabled = true; } } //删除网格样式 private void button5_Click(object sender, EventArgs e) { if (this.dataGridView1.Rows.Count > 1) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text") + "?", PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (dr == DialogResult.OK) { operation = 2; string updateName = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.dataGridView1.CurrentCell.Value.ToString() + ".xml"; System.IO.File.Delete(updateName); InitializationDataGridView(); operation = -1; } } } /// /// 删除网格样式 /// /// /// private void btnDel_Click(object sender, EventArgs e) { if (this.dataGridView1.Rows.Count > 1) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text") + "?", PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (dr == DialogResult.OK) { operation = 2; string updateName = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.dataGridView1.CurrentCell.Value.ToString() + ".xml"; System.IO.File.Delete(updateName); InitializationDataGridView(); operation = -1; } } } /// /// 保存 /// /// /// private void btnSave_Click(object sender, EventArgs e) { } /// /// 另存为、新增 /// /// /// private void btnSaveAs_Click(object sender, EventArgs e) { } } }