using PaintDotNet.Base.SettingModel; using PaintDotNet.Base.CommTool; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PaintDotNet.Setting { public partial class WorkTypeSettingDialog : PdnBaseForm { #region 控件 private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label4; private System.Windows.Forms.RadioButton fzxRBF; private System.Windows.Forms.RadioButton fzxRBT; private System.Windows.Forms.Label label3; private System.Windows.Forms.PictureBox pictureBox; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label5; private System.Windows.Forms.RadioButton ljxRBF; private System.Windows.Forms.RadioButton ljxRBT; private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label8; private System.Windows.Forms.RadioButton clxRangeRBF; private System.Windows.Forms.RadioButton clxRangeRBT; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label11; private System.Windows.Forms.Label label14; private System.Windows.Forms.Label label13; private System.Windows.Forms.RadioButton clxLenRBF; private System.Windows.Forms.RadioButton clxLenRBT; private System.Windows.Forms.Label label12; private System.Windows.Forms.Panel fzxColourPanel; private System.Windows.Forms.Panel ljxColourPanel; private System.Windows.Forms.Panel clxColourPanel; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button2; private ComboBox fontComboBox; private NumericUpDown fontSizeNumeric; private ComboBox styleComboBox; private Label label1; private Button button4; private Button button3; private System.Windows.Forms.Button button1; private Panel fontColourPanel; private NumericUpDown ljxLineWidthNumeric; private NumericUpDown fzxLineWidthNumeric; private NumericUpDown clxLineWidthNumeric; /// /// 字体列表 /// ArrayList fontsItems = new ArrayList(); /// /// 调色板测量线 /// PaintDotNet.ColorsForm colorsFormclx; /// /// 调色板辅助线 /// PaintDotNet.ColorsForm colorsFormfzx; /// /// 调色板连接线 /// PaintDotNet.ColorsForm colorsFormljx; /// /// 调色板字体 /// PaintDotNet.ColorsForm colorsFormfont; /// /// 与xml对应得映射类 /// private WorkTypeStyleModel workTypeStyleModel; /// /// 另存为弹出框显示 /// private CreateNameDialog dialog; /// /// 操作样式下拉数据 /// private List files = new List(); /// /// 另存为文件名 /// private string newName; private Panel panel1; /// /// 初始化标识 /// private int initflag = 0; #endregion public WorkTypeSettingDialog() { InitializeComponent(); InitializeLanguageText(); InitializeComponent2(); InitializeControl(); InitializeData(); // 测量出最大的字符大小 int maxSize = 0; System.Drawing.Graphics g = CreateGraphics(); for (int i = 0; i < fontComboBox.Items.Count; i++) { fontComboBox.SelectedIndex = i; SizeF size = g.MeasureString(fontComboBox.Text, fontComboBox.Font); if (maxSize < (int)size.Width) { maxSize = (int)size.Width; } } fontComboBox.DropDownWidth = fontComboBox.Width; if (fontComboBox.DropDownWidth < maxSize) { fontComboBox.DropDownWidth = maxSize + 15; //comboBox1.Width = maxSize; } } #region 初始化控件 private void InitializeLanguageText() { this.groupBox2.Text = PdnResources.GetString("Menu.Auxiliarylinesettings.text"); this.label4.Text = PdnResources.GetString("Menu.display.text") + ":"; this.fzxRBF.Text = PdnResources.GetString("Menu.no.text"); this.fzxRBT.Text = PdnResources.GetString("Menu.Yes.text"); this.label3.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label2.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox3.Text = PdnResources.GetString("Menu.Set.typesettings.the communicationscablesetting.text"); this.ljxRBF.Text = PdnResources.GetString("Menu.no.text"); this.ljxRBT.Text = PdnResources.GetString("Menu.Yes.text"); this.label7.Text = PdnResources.GetString("Menu.display.text") + ":"; this.label6.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label5.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox4.Text = PdnResources.GetString("Menu.Measuringlinesetting.text"); this.clxRangeRBF.Text = PdnResources.GetString("Menu.no.text"); this.clxRangeRBT.Text = PdnResources.GetString("Menu.Yes.text"); this.label10.Text = PdnResources.GetString("Menu.Set.typesettings.Displaymeasuringlinedistance.text") + ":"; this.label14.Text = PdnResources.GetString("Menu.Fontsize.text") + ":"; this.label13.Text = PdnResources.GetString("Menu.Font.text") + ":"; this.clxLenRBF.Text = PdnResources.GetString("Menu.no.text"); this.clxLenRBT.Text = PdnResources.GetString("Menu.Yes.text"); this.label12.Text = PdnResources.GetString("Menu.Set.typesettings.Displaythelengthofmeasuringline.text") + ":"; this.label11.Text = PdnResources.GetString("Menu.fontcolor.text") + ":"; this.label9.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label8.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox5.Text = PdnResources.GetString("Menu.Preview.text"); this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.label1.Text = PdnResources.GetString("Menu.Currentoperationstyle.text") + ":"; this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.button3.Text = PdnResources.GetString("Menu.File.SaveAs.Text"); this.button2.Text = PdnResources.GetString("Menu.application.text"); this.button1.Text = PdnResources.GetString("Menu.File.Save.Text"); this.Text = PdnResources.GetString("Menu.Setting.WorkTypeSetting.Text"); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.groupBox2 = new System.Windows.Forms.GroupBox(); this.fzxLineWidthNumeric = new System.Windows.Forms.NumericUpDown(); this.fzxColourPanel = new System.Windows.Forms.Panel(); this.label4 = new System.Windows.Forms.Label(); this.fzxRBF = new System.Windows.Forms.RadioButton(); this.fzxRBT = new System.Windows.Forms.RadioButton(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.ljxLineWidthNumeric = new System.Windows.Forms.NumericUpDown(); this.ljxColourPanel = new System.Windows.Forms.Panel(); this.ljxRBF = new System.Windows.Forms.RadioButton(); this.ljxRBT = new System.Windows.Forms.RadioButton(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.panel1 = new System.Windows.Forms.Panel(); this.clxRangeRBF = new System.Windows.Forms.RadioButton(); this.clxRangeRBT = new System.Windows.Forms.RadioButton(); this.label10 = new System.Windows.Forms.Label(); this.clxLineWidthNumeric = new System.Windows.Forms.NumericUpDown(); this.fontColourPanel = new System.Windows.Forms.Panel(); this.fontSizeNumeric = new System.Windows.Forms.NumericUpDown(); this.fontComboBox = new System.Windows.Forms.ComboBox(); this.clxColourPanel = new System.Windows.Forms.Panel(); this.label14 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label(); this.clxLenRBF = new System.Windows.Forms.RadioButton(); this.clxLenRBT = new System.Windows.Forms.RadioButton(); this.label12 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.pictureBox = new System.Windows.Forms.PictureBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.styleComboBox = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.fzxLineWidthNumeric)).BeginInit(); this.groupBox3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.ljxLineWidthNumeric)).BeginInit(); this.groupBox4.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.clxLineWidthNumeric)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.fontSizeNumeric)).BeginInit(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // groupBox2 // this.groupBox2.Controls.Add(this.fzxLineWidthNumeric); this.groupBox2.Controls.Add(this.fzxColourPanel); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.fzxRBF); this.groupBox2.Controls.Add(this.fzxRBT); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Location = new System.Drawing.Point(12, 76); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(509, 79); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "辅助线设置"; // // fzxLineWidthNumeric // this.fzxLineWidthNumeric.Location = new System.Drawing.Point(333, 17); this.fzxLineWidthNumeric.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.fzxLineWidthNumeric.Name = "fzxLineWidthNumeric"; this.fzxLineWidthNumeric.Size = new System.Drawing.Size(161, 21); this.fzxLineWidthNumeric.TabIndex = 23; this.fzxLineWidthNumeric.Value = new decimal(new int[] { 1, 0, 0, 0}); // // fzxColourPanel // this.fzxColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.fzxColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.fzxColourPanel.Location = new System.Drawing.Point(70, 17); this.fzxColourPanel.Name = "fzxColourPanel"; this.fzxColourPanel.Size = new System.Drawing.Size(161, 21); this.fzxColourPanel.TabIndex = 8; this.fzxColourPanel.Click += new System.EventHandler(this.fzxColorPanel_Click); // // label4 // this.label4.Location = new System.Drawing.Point(18, 50); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(46, 23); this.label4.TabIndex = 7; this.label4.Text = "显示:"; // // fzxRBF // this.fzxRBF.AutoSize = true; this.fzxRBF.Location = new System.Drawing.Point(164, 48); this.fzxRBF.Name = "fzxRBF"; this.fzxRBF.Size = new System.Drawing.Size(35, 16); this.fzxRBF.TabIndex = 6; this.fzxRBF.TabStop = true; this.fzxRBF.Text = "否"; this.fzxRBF.UseVisualStyleBackColor = true; // // fzxRBT // this.fzxRBT.AutoSize = true; this.fzxRBT.Checked = true; this.fzxRBT.Location = new System.Drawing.Point(70, 48); this.fzxRBT.Name = "fzxRBT"; this.fzxRBT.Size = new System.Drawing.Size(35, 16); this.fzxRBT.TabIndex = 5; this.fzxRBT.TabStop = true; this.fzxRBT.Text = "是"; this.fzxRBT.UseVisualStyleBackColor = true; // // label3 // this.label3.Location = new System.Drawing.Point(281, 20); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(46, 23); this.label3.TabIndex = 4; this.label3.Text = "线宽:"; // // label2 // this.label2.Location = new System.Drawing.Point(18, 17); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(46, 23); this.label2.TabIndex = 1; this.label2.Text = "颜色:"; // // groupBox3 // this.groupBox3.Controls.Add(this.ljxLineWidthNumeric); this.groupBox3.Controls.Add(this.ljxColourPanel); this.groupBox3.Controls.Add(this.ljxRBF); this.groupBox3.Controls.Add(this.ljxRBT); this.groupBox3.Controls.Add(this.label7); this.groupBox3.Controls.Add(this.label6); this.groupBox3.Controls.Add(this.label5); this.groupBox3.Location = new System.Drawing.Point(12, 161); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(509, 79); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; this.groupBox3.Text = "连接线设置"; // // ljxLineWidthNumeric // this.ljxLineWidthNumeric.Location = new System.Drawing.Point(335, 20); this.ljxLineWidthNumeric.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.ljxLineWidthNumeric.Name = "ljxLineWidthNumeric"; this.ljxLineWidthNumeric.Size = new System.Drawing.Size(161, 21); this.ljxLineWidthNumeric.TabIndex = 22; this.ljxLineWidthNumeric.Value = new decimal(new int[] { 1, 0, 0, 0}); // // ljxColourPanel // this.ljxColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.ljxColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.ljxColourPanel.Location = new System.Drawing.Point(70, 20); this.ljxColourPanel.Name = "ljxColourPanel"; this.ljxColourPanel.Size = new System.Drawing.Size(161, 21); this.ljxColourPanel.TabIndex = 11; this.ljxColourPanel.Click += new System.EventHandler(this.ljxColorPanel_Click); // // ljxRBF // this.ljxRBF.AutoSize = true; this.ljxRBF.Location = new System.Drawing.Point(164, 49); this.ljxRBF.Name = "ljxRBF"; this.ljxRBF.Size = new System.Drawing.Size(35, 16); this.ljxRBF.TabIndex = 10; this.ljxRBF.TabStop = true; this.ljxRBF.Text = "否"; this.ljxRBF.UseVisualStyleBackColor = true; // // ljxRBT // this.ljxRBT.AutoSize = true; this.ljxRBT.Checked = true; this.ljxRBT.Location = new System.Drawing.Point(70, 47); this.ljxRBT.Name = "ljxRBT"; this.ljxRBT.Size = new System.Drawing.Size(35, 16); this.ljxRBT.TabIndex = 9; this.ljxRBT.TabStop = true; this.ljxRBT.Text = "是"; this.ljxRBT.UseVisualStyleBackColor = true; // // label7 // this.label7.Location = new System.Drawing.Point(18, 49); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(46, 23); this.label7.TabIndex = 8; this.label7.Text = "显示:"; // // label6 // this.label6.Location = new System.Drawing.Point(281, 23); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(46, 23); this.label6.TabIndex = 5; this.label6.Text = "线宽:"; // // label5 // this.label5.Location = new System.Drawing.Point(18, 20); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(46, 23); this.label5.TabIndex = 2; this.label5.Text = "颜色:"; // // groupBox4 // this.groupBox4.Controls.Add(this.panel1); this.groupBox4.Controls.Add(this.clxLineWidthNumeric); this.groupBox4.Controls.Add(this.fontColourPanel); this.groupBox4.Controls.Add(this.fontSizeNumeric); this.groupBox4.Controls.Add(this.fontComboBox); this.groupBox4.Controls.Add(this.clxColourPanel); this.groupBox4.Controls.Add(this.label14); this.groupBox4.Controls.Add(this.label13); this.groupBox4.Controls.Add(this.clxLenRBF); this.groupBox4.Controls.Add(this.clxLenRBT); this.groupBox4.Controls.Add(this.label12); this.groupBox4.Controls.Add(this.label11); this.groupBox4.Controls.Add(this.label9); this.groupBox4.Controls.Add(this.label8); this.groupBox4.Location = new System.Drawing.Point(12, 246); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(509, 100); this.groupBox4.TabIndex = 4; this.groupBox4.TabStop = false; this.groupBox4.Text = "测量线设置"; // // panel1 // this.panel1.Controls.Add(this.clxRangeRBF); this.panel1.Controls.Add(this.clxRangeRBT); this.panel1.Controls.Add(this.label10); this.panel1.Location = new System.Drawing.Point(16, 41); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(211, 28); this.panel1.TabIndex = 24; // // clxRangeRBF // this.clxRangeRBF.AutoSize = true; this.clxRangeRBF.Location = new System.Drawing.Point(150, 5); this.clxRangeRBF.Name = "clxRangeRBF"; this.clxRangeRBF.Size = new System.Drawing.Size(14, 13); this.clxRangeRBF.TabIndex = 11; this.clxRangeRBF.TabStop = true; this.clxRangeRBF.UseVisualStyleBackColor = true; // // clxRangeRBT // this.clxRangeRBT.AutoSize = true; this.clxRangeRBT.Checked = true; this.clxRangeRBT.Location = new System.Drawing.Point(109, 5); this.clxRangeRBT.Name = "clxRangeRBT"; this.clxRangeRBT.Size = new System.Drawing.Size(14, 13); this.clxRangeRBT.TabIndex = 10; this.clxRangeRBT.TabStop = true; this.clxRangeRBT.UseVisualStyleBackColor = true; // // label10 // this.label10.Location = new System.Drawing.Point(3, 5); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(112, 19); this.label10.TabIndex = 9; this.label10.Text = "显示测量线距离:"; // // clxLineWidthNumeric // this.clxLineWidthNumeric.Location = new System.Drawing.Point(335, 14); this.clxLineWidthNumeric.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.clxLineWidthNumeric.Name = "clxLineWidthNumeric"; this.clxLineWidthNumeric.Size = new System.Drawing.Size(161, 21); this.clxLineWidthNumeric.TabIndex = 23; this.clxLineWidthNumeric.Value = new decimal(new int[] { 1, 0, 0, 0}); // // fontColourPanel // this.fontColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.fontColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.fontColourPanel.Location = new System.Drawing.Point(335, 41); this.fontColourPanel.Name = "fontColourPanel"; this.fontColourPanel.Size = new System.Drawing.Size(161, 23); this.fontColourPanel.TabIndex = 22; this.fontColourPanel.Click += new System.EventHandler(this.fontColorPanel_Click); // // fontSizeNumeric // this.fontSizeNumeric.Location = new System.Drawing.Point(441, 69); this.fontSizeNumeric.Maximum = new decimal(new int[] { 49000, 0, 0, 0}); this.fontSizeNumeric.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.fontSizeNumeric.Name = "fontSizeNumeric"; this.fontSizeNumeric.Size = new System.Drawing.Size(55, 21); this.fontSizeNumeric.TabIndex = 21; this.fontSizeNumeric.Value = new decimal(new int[] { 12, 0, 0, 0}); // // fontComboBox // this.fontComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.fontComboBox.FormattingEnabled = true; this.fontComboBox.Location = new System.Drawing.Point(335, 70); this.fontComboBox.Name = "fontComboBox"; this.fontComboBox.Size = new System.Drawing.Size(57, 20); this.fontComboBox.TabIndex = 20; // // clxColourPanel // this.clxColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.clxColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.clxColourPanel.Location = new System.Drawing.Point(70, 14); this.clxColourPanel.Name = "clxColourPanel"; this.clxColourPanel.Size = new System.Drawing.Size(161, 21); this.clxColourPanel.TabIndex = 19; this.clxColourPanel.Click += new System.EventHandler(this.clxColorPanel_Click); // // label14 // this.label14.Location = new System.Drawing.Point(398, 71); this.label14.Name = "label14"; this.label14.Size = new System.Drawing.Size(45, 23); this.label14.TabIndex = 18; this.label14.Text = "字号:"; // // label13 // this.label13.Location = new System.Drawing.Point(281, 74); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(45, 23); this.label13.TabIndex = 17; this.label13.Text = "字体:"; // // clxLenRBF // this.clxLenRBF.AutoSize = true; this.clxLenRBF.Location = new System.Drawing.Point(166, 71); this.clxLenRBF.Name = "clxLenRBF"; this.clxLenRBF.Size = new System.Drawing.Size(14, 13); this.clxLenRBF.TabIndex = 16; this.clxLenRBF.TabStop = true; this.clxLenRBF.UseVisualStyleBackColor = true; this.clxLenRBF.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged); // // clxLenRBT // this.clxLenRBT.AutoSize = true; this.clxLenRBT.Checked = true; this.clxLenRBT.Location = new System.Drawing.Point(125, 71); this.clxLenRBT.Name = "clxLenRBT"; this.clxLenRBT.Size = new System.Drawing.Size(14, 13); this.clxLenRBT.TabIndex = 15; this.clxLenRBT.TabStop = true; this.clxLenRBT.UseVisualStyleBackColor = true; // // label12 // this.label12.Location = new System.Drawing.Point(18, 73); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(113, 23); this.label12.TabIndex = 14; this.label12.Text = "显示测量线长度:"; // // label11 // this.label11.Location = new System.Drawing.Point(258, 46); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(117, 23); this.label11.TabIndex = 12; this.label11.Text = "字体颜色:"; // // label9 // this.label9.Location = new System.Drawing.Point(282, 18); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(46, 23); this.label9.TabIndex = 6; this.label9.Text = "线宽:"; // // label8 // this.label8.Location = new System.Drawing.Point(18, 17); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(46, 23); this.label8.TabIndex = 3; this.label8.Text = "颜色:"; // // groupBox5 // this.groupBox5.Controls.Add(this.pictureBox); this.groupBox5.Location = new System.Drawing.Point(12, 352); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(509, 148); this.groupBox5.TabIndex = 5; this.groupBox5.TabStop = false; this.groupBox5.Text = "预览"; // // pictureBox // this.pictureBox.Location = new System.Drawing.Point(99, 20); this.pictureBox.Name = "pictureBox"; this.pictureBox.Size = new System.Drawing.Size(306, 122); this.pictureBox.TabIndex = 0; this.pictureBox.TabStop = false; // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.styleComboBox); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.button4); this.groupBox1.Controls.Add(this.button3); this.groupBox1.Controls.Add(this.button2); 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(509, 58); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // styleComboBox // this.styleComboBox.FormattingEnabled = true; this.styleComboBox.Location = new System.Drawing.Point(99, 21); this.styleComboBox.Name = "styleComboBox"; this.styleComboBox.Size = new System.Drawing.Size(80, 20); this.styleComboBox.TabIndex = 22; // // label1 // this.label1.Location = new System.Drawing.Point(8, 24); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(101, 23); this.label1.TabIndex = 9; this.label1.Text = "当前操作样式:"; // // button4 // this.button4.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button4.Location = new System.Drawing.Point(185, 20); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(75, 23); this.button4.TabIndex = 3; this.button4.Text = "删除"; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.Button4_Click); // // button3 // this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button3.Location = new System.Drawing.Point(266, 21); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(75, 23); this.button3.TabIndex = 2; this.button3.Text = "另存为"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.Button3_Click); // // button2 // this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button2.Location = new System.Drawing.Point(428, 21); 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.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button1.Location = new System.Drawing.Point(347, 21); 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); // // WorkTypeSettingDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(533, 512); this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Name = "WorkTypeSettingDialog"; this.Text = "工型设置"; 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.Controls.SetChildIndex(this.groupBox1, 0); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.fzxLineWidthNumeric)).EndInit(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.ljxLineWidthNumeric)).EndInit(); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.clxLineWidthNumeric)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.fontSizeNumeric)).EndInit(); this.groupBox5.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); } #endregion #region InitializeComponent2 /// /// 初始化组件 /// private void InitializeComponent2() { this.colorsFormljx = new ColorsForm(); this.colorsFormljx.StartPosition = FormStartPosition.CenterScreen; this.colorsFormljx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsFormfzx = new ColorsForm(); this.colorsFormfzx.StartPosition = FormStartPosition.CenterScreen; this.colorsFormfzx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsFormclx = new ColorsForm(); this.colorsFormclx.StartPosition = FormStartPosition.CenterScreen; this.colorsFormclx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsFormfont = new ColorsForm(); this.colorsFormfont.StartPosition = FormStartPosition.CenterScreen; this.colorsFormfont.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); } #endregion /// /// 连接线Panel被点击 /// /// /// private void ljxColorPanel_Click(object sender, EventArgs e) { this.colorsFormljx.UserPrimaryColor = ColorBgra.FromColor(this.ljxColourPanel.BackColor); this.colorsFormljx.setSaveBtn_Click(new System.EventHandler(this.ljxColorChanged)); this.colorsFormljx.ShowDialog(); } /// /// 连接线Panel的调色板颜色改变 /// /// /// private void ljxColorChanged(object sender, EventArgs e) { this.ljxColourPanel.BackColor = this.colorsFormljx.UserPrimaryColor.ToColor(); // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb(); this.colorsFormljx.Close(); } private void radioButton8_CheckedChanged(object sender, EventArgs e) { } /// /// 测量线Panel被点击 /// /// /// private void clxColorPanel_Click(object sender, EventArgs e) { this.colorsFormclx.UserPrimaryColor = ColorBgra.FromColor(this.clxColourPanel.BackColor); this.colorsFormclx.setSaveBtn_Click(new System.EventHandler(this.clxColorChanged)); this.colorsFormclx.ShowDialog(); } /// /// 测量线Panel的调色板颜色改变 /// /// /// private void clxColorChanged(object sender, EventArgs e) { this.clxColourPanel.BackColor = this.colorsFormclx.UserPrimaryColor.ToColor(); // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb(); this.colorsFormclx.Close(); } /// /// 处理控件 /// private void InitializeControl() { this.pictureBox.Paint += new PaintEventHandler(this.pictureBox_Paint); } /// /// pictureBox的绘制事件 /// /// /// private void pictureBox_Paint(object sender, PaintEventArgs e) { WorkTypeStyleModel model = this.workTypeStyleModel; Graphics gps = e.Graphics; Pen measurePen = new Pen(this.clxColourPanel.BackColor, Convert.ToInt32(this.clxLineWidthNumeric.Value)); gps.DrawLine(measurePen, 150, 20 + model.guideLineWidth / 2, 150, 80 - model.connectLineWidth / 2); if (model.guideShowFlag == 1) { Pen guidePen = new Pen(Color.FromArgb(model.guideColour), Convert.ToInt32(model.guideLineWidth)); gps.DrawLine(guidePen, 50, 20, 250, 20); } if (model.connectShowFlag == 1) { Pen connectPen = new Pen(Color.FromArgb(model.connectColour), model.connectLineWidth); gps.DrawLine(connectPen, 50, 80, 250, 80); } } /// /// 应用按钮被点击 /// /// /// private void Button2_Click(object sender, EventArgs e) { /*//预览展示 Graphics gps = pictureBox.CreateGraphics(); // gps.Clear(Color.Empty); Pen guidePen = new Pen(this.fzxColourPanel.BackColor , Convert.ToInt32(this.fzxLineWidthNumeric.Value)); Pen measurePen = new Pen(this.clxColourPanel.BackColor, Convert.ToInt32(this.clxLineWidthNumeric.Value)); Pen connectPen = new Pen(this.ljxColourPanel.BackColor, Convert.ToInt32(this.ljxLineWidthNumeric.Value)); gps.DrawLine(measurePen, 150, 20 + Convert.ToInt32(this.fzxLineWidthNumeric.Value)/2, 150, 80 - Convert.ToInt32(this.ljxLineWidthNumeric.Value)/2); gps.DrawLine(guidePen, 50, 20, 250, 20); gps.DrawLine(connectPen, 50, 80, 250, 80);*/ //检查数据 this.checkData(); this.pictureBox.Invalidate(); Startup.instance.workTypeStyleModel = this.workTypeStyleModel; } /// /// 检查数据并且赋值到model中 /// private void checkData() { UpDownBase fzxLineWidthup = (UpDownBase)this.fzxLineWidthNumeric; if (string.IsNullOrEmpty(fzxLineWidthup.Text)) { this.fzxLineWidthNumeric.Value = 1; } UpDownBase ljxLineWidthup = (UpDownBase)this.ljxLineWidthNumeric; if (string.IsNullOrEmpty(ljxLineWidthup.Text)) { this.ljxLineWidthNumeric.Value = 1; } UpDownBase clxLineWidthup = (UpDownBase)this.clxLineWidthNumeric; if (string.IsNullOrEmpty(clxLineWidthup.Text)) { this.clxLineWidthNumeric.Value = 1; } UpDownBase fontSizeWidthup = (UpDownBase)this.fontSizeNumeric; if (string.IsNullOrEmpty(fontSizeWidthup.Text)) { this.fontSizeNumeric.Value = 1; } /* if (string.IsNullOrEmpty(fontComboBox.Text)) { fontComboBox.Text = this.workTypeStyleModel.font; }*/ //辅助线设置赋值 this.workTypeStyleModel.guideColour = Convert.ToInt32(this.fzxColourPanel.BackColor.ToArgb()); this.workTypeStyleModel.guideLineWidth = Convert.ToInt32(this.fzxLineWidthNumeric.Value); if (this.fzxRBF.Checked) { this.workTypeStyleModel.guideShowFlag = 0; } else { this.workTypeStyleModel.guideShowFlag = 1; } //连接线设置赋值 this.workTypeStyleModel.connectColour = Convert.ToInt32(this.ljxColourPanel.BackColor.ToArgb()); this.workTypeStyleModel.connectLineWidth = Convert.ToInt32(this.ljxLineWidthNumeric.Value); if (this.ljxRBF.Checked) { this.workTypeStyleModel.connectShowFlag = 0; } else { this.workTypeStyleModel.connectShowFlag = 1; } //测量线设置 this.workTypeStyleModel.measureColour = Convert.ToInt32(this.clxColourPanel.BackColor.ToArgb()); this.workTypeStyleModel.measureLineWidth = Convert.ToInt32(this.clxLineWidthNumeric.Value); if (this.clxRangeRBF.Checked) { this.workTypeStyleModel.measureRangeShowFlag = 0; } else { this.workTypeStyleModel.measureRangeShowFlag = 1; } if (this.clxLenRBF.Checked) { this.workTypeStyleModel.measureLengthShowFlag = 0; } else { this.workTypeStyleModel.measureLengthShowFlag = 1; } this.workTypeStyleModel.fontColour = Convert.ToInt32(this.fontColourPanel.BackColor.ToArgb()); this.workTypeStyleModel.font = this.fontComboBox.Text; this.workTypeStyleModel.fontSize = Convert.ToInt32(this.fontSizeNumeric.Value); } /// /// 保存按钮被点击 /// /// /// private void Button1_Click(object sender, EventArgs e) { //调用检查方法 this.checkData(); //以下保存xml文件信息 string workTypeStyleModelXml = XmlSerializeHelper.XmlSerialize(this.workTypeStyleModel); string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.Text + ".xml"; FileOperationHelper.WriteStringToFile(workTypeStyleModelXml, filePath, FileMode.Create); } /// /// 另存为 /// /// /// private void Button3_Click(object sender, EventArgs e) { dialog = new CreateNameDialog(this); dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text"); dialog.StartPosition = FormStartPosition.CenterParent; dialog.ShowDialog(); } /// /// 初始化数据 /// private void InitializeData() { this.fontsItems.Clear(); //绑定字体数据 System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection(); foreach (FontFamily fontFamily in fonts.Families) { fontsItems.Add(fontFamily.Name); } this.fontComboBox.DataSource = fontsItems; //绑定样式默认数据 /*this.comboBox11.Text = this.measureStyleModel.measureLine.font; this.numericUpDown21.Value = this.measureStyleModel.measureLine.fontSize; this.textPanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.textColor); this.linePanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.lineColor); this.numericUpDown11.Value = this.measureStyleModel.measureLine.lineWidth; this.comboBox21.Text = this.measureStyleModel.measureLine.lineStyle;*/ //绑定样式下拉 todo if (initflag++ == 0) { InitializeStyleName(); } //辅助线设置赋值 this.fzxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.guideColour); this.fzxLineWidthNumeric.Value = this.workTypeStyleModel.guideLineWidth; if (this.workTypeStyleModel.guideShowFlag == 0) { this.fzxRBF.Checked = true; } else { this.fzxRBT.Checked = true; } //连接线设置赋值 this.ljxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.connectColour); this.ljxLineWidthNumeric.Value = this.workTypeStyleModel.connectLineWidth; if (this.workTypeStyleModel.connectShowFlag == 0) { this.ljxRBF.Checked = true; } else { this.ljxRBT.Checked = true; } //测量线设置 this.clxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.measureColour); this.clxLineWidthNumeric.Value = this.workTypeStyleModel.measureLineWidth; if (this.workTypeStyleModel.measureRangeShowFlag == 0) { this.clxRangeRBF.Checked = true; } else { this.clxRangeRBT.Checked = true; } if (this.workTypeStyleModel.measureLengthShowFlag == 0) { this.clxLenRBF.Checked = true; } else { this.clxLenRBT.Checked = true; } this.fontColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.fontColour); this.fontComboBox.Text = this.workTypeStyleModel.font; this.fontSizeNumeric.Value = this.workTypeStyleModel.fontSize; } /// /// 调色板回调函数 /// /// /// private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce) { } /// /// 辅助线Panel被点击 /// /// /// private void fzxColorPanel_Click(object sender, EventArgs e) { this.colorsFormfzx.UserPrimaryColor = ColorBgra.FromColor(this.fzxColourPanel.BackColor); this.colorsFormfzx.setSaveBtn_Click(new System.EventHandler(this.fzxColorChanged)); this.colorsFormfzx.ShowDialog(); } /// /// 辅助线Panel的调色板颜色改变 /// /// /// private void fzxColorChanged(object sender, EventArgs e) { this.fzxColourPanel.BackColor = this.colorsFormfzx.UserPrimaryColor.ToColor(); // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb(); this.colorsFormfzx.Close(); } /// /// 字体颜色Panel被点击 /// /// /// private void fontColorPanel_Click(object sender, EventArgs e) { this.colorsFormfont.UserPrimaryColor = ColorBgra.FromColor(this.fontColourPanel.BackColor); this.colorsFormfont.setSaveBtn_Click(new System.EventHandler(this.fontColorChanged)); this.colorsFormfont.ShowDialog(); } /// /// 字体颜色Panel的调色板颜色改变 /// /// /// private void fontColorChanged(object sender, EventArgs e) { this.fontColourPanel.BackColor = this.colorsFormfont.UserPrimaryColor.ToColor(); // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb(); this.colorsFormfont.Close(); } /// /// 绑定样式下拉 /// private void InitializeStyleName() { List fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\"); files.Clear(); foreach (string fileName in fileNames) { string name = fileName.Substring(0, fileName.LastIndexOf(".")); files.Add(name); } this.styleComboBox.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged; this.styleComboBox.DataSource = null; this.styleComboBox.DataSource = files; string nowModelName = Startup.instance.configModel.Watermark.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf(".")); this.styleComboBox.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName)); this.workTypeStyleModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open)); // InitializeData(); this.styleComboBox.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged); } /// /// 删除按钮 /// /// /// private void Button4_Click(object sender, EventArgs e) { if ("Default".Equals(this.styleComboBox.Text)) { MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (dr == DialogResult.OK) { int newIndex = 0; int selectIndex = this.styleComboBox.SelectedIndex; int tall = files.Count - 1; if (selectIndex < tall) { newIndex = selectIndex; } string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.Text + ".xml"; FileInfo fileInfo = new FileInfo(filePath); fileInfo.Delete(); InitializeStyleName(); this.styleComboBox.SelectedIndex = newIndex; workTypeStyleModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open)); InitializeData(); } else if (dr == DialogResult.Cancel) { } } /// /// 弹出另存为框点击保存效果 /// /// public override void GetCreateName(string name) { string currentcomboBox = this.styleComboBox.Text; this.newName = name; if (files.Contains(this.newName)) { MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } CopyConfigAndRename(); InitializeStyleName(); this.styleComboBox.Text = currentcomboBox; dialog.Close(); } /// /// 另存配置文件 /// private void CopyConfigAndRename() { /*if (this.checkBox1.Checked) { this.watermarkModel.bold = 1; } else { this.watermarkModel.bold = 2; } if (this.checkBox2.Checked) { this.watermarkModel.italic = 1; } else { this.watermarkModel.italic = 2; } this.watermarkModel.position = this.comboBox2.SelectedIndex + 1; this.watermarkModel.typeface = this.comboBox3.Text; this.watermarkModel.fontSize = Int32.Parse(this.comboBox4.Text);*/ //检查保存类型 // this.checkSaveModel(); //另存为 //调用检查方法 this.checkData(); string stageModelXml = XmlSerializeHelper.XmlSerialize(this.workTypeStyleModel); string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.newName + ".xml"; FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create); } /// /// 当前操作样式 /// /// /// private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { workTypeStyleModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open)); InitializeData(); } private void ClxRangeRBT_CheckedChanged(object sender, EventArgs e) { } } }