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.DedicatedAnalysis { public partial class SurveyPointStyleSettingDialog : Form { #region 控件 private Button button2; private Button button1; private GroupBox groupBox2; private Label label6; private Label label5; private Label label3; private Label label2; private Label label1; private Label label4; private RadioButton radioButton2; private RadioButton radioButton1; private CheckBox checkBox1; private GroupBox groupBox3; private Panel panel1; private Panel panel2; private GroupBox groupBox1; private NumericUpDown numericUpDown3; private NumericUpDown numericUpDown2; private NumericUpDown numericUpDown1; private ComboBox comboBox1; #endregion /// /// 图像显示数量下拉选项 /// int[] imgCount = new int[] { 2, 3, 4, 6, 8, 9 }; /// /// 字体列表 /// ArrayList fontsItems = new ArrayList(); /// /// 调色板 /// PaintDotNet.ColorsForm colorsForm; public SurveyPointStyleSettingDialog() { InitializeComponent(); InitializeLanguageText(); InitializeData(); //调色板 this.colorsForm = new ColorsForm(); this.colorsForm.StartPosition = FormStartPosition.CenterScreen; this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); } #region 初始化 private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.button2.Text = PdnResources.GetString("CommonAction.Save"); this.button1.Text = PdnResources.GetString("Menu.File.Close.Text"); this.groupBox2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Measuringpoint.text"); this.checkBox1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Displaypointmarkersymbol.text"); this.radioButton2.Text = PdnResources.GetString("Menu.solid.text"); this.radioButton1.Text = PdnResources.GetString("Menu.Hollow.text"); this.label4.Text = PdnResources.GetString("Menu.style.text") + ":"; this.label6.Text = PdnResources.GetString("Menu.size.text") + ":"; this.label5.Text = PdnResources.GetString("Menu.Font.text") + ":"; this.label3.Text = PdnResources.GetString("Menu.diameter.text") + ":"; this.label2.Text = PdnResources.GetString("Menu.width.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text"); this.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Measurinsetting.text"); } private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.numericUpDown3 = new System.Windows.Forms.NumericUpDown(); this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.panel2 = new System.Windows.Forms.Panel(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.radioButton2 = new System.Windows.Forms.RadioButton(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.label4 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.panel1 = new System.Windows.Forms.Panel(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.groupBox3.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(11, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(320, 54); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; // // button2 // this.button2.Location = new System.Drawing.Point(228, 15); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(70, 28); this.button2.TabIndex = 3; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // button1 // this.button1.Location = new System.Drawing.Point(139, 15); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(70, 28); this.button1.TabIndex = 2; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox2 // this.groupBox2.Controls.Add(this.comboBox1); this.groupBox2.Controls.Add(this.numericUpDown3); this.groupBox2.Controls.Add(this.numericUpDown2); this.groupBox2.Controls.Add(this.numericUpDown1); this.groupBox2.Controls.Add(this.panel2); this.groupBox2.Controls.Add(this.checkBox1); this.groupBox2.Controls.Add(this.radioButton2); this.groupBox2.Controls.Add(this.radioButton1); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new System.Drawing.Point(12, 72); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(319, 145); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; // // comboBox1 // this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox1.FormattingEnabled = true; this.comboBox1.Location = new System.Drawing.Point(216, 29); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(81, 20); this.comboBox1.TabIndex = 19; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // // numericUpDown3 // this.numericUpDown3.Location = new System.Drawing.Point(46, 112); this.numericUpDown3.Maximum = new decimal(new int[] { 100000, 0, 0, 0}); this.numericUpDown3.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown3.Name = "numericUpDown3"; this.numericUpDown3.Size = new System.Drawing.Size(95, 21); this.numericUpDown3.TabIndex = 18; this.numericUpDown3.Value = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged); // // numericUpDown2 // this.numericUpDown2.Location = new System.Drawing.Point(46, 84); this.numericUpDown2.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown2.Name = "numericUpDown2"; this.numericUpDown2.Size = new System.Drawing.Size(95, 21); this.numericUpDown2.TabIndex = 17; this.numericUpDown2.Value = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged); // // numericUpDown1 // this.numericUpDown1.Location = new System.Drawing.Point(216, 60); this.numericUpDown1.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Size = new System.Drawing.Size(81, 21); this.numericUpDown1.TabIndex = 14; this.numericUpDown1.Value = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); // // panel2 // this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel2.Location = new System.Drawing.Point(46, 28); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(95, 21); this.panel2.TabIndex = 16; this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged); this.panel2.Click += new System.EventHandler(this.panel2_Click); // // checkBox1 // this.checkBox1.AutoSize = true; this.checkBox1.Location = new System.Drawing.Point(183, 110); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(108, 16); this.checkBox1.TabIndex = 15; this.checkBox1.UseVisualStyleBackColor = true; // // radioButton2 // this.radioButton2.AutoSize = true; this.radioButton2.Location = new System.Drawing.Point(99, 59); this.radioButton2.Name = "radioButton2"; this.radioButton2.Size = new System.Drawing.Size(47, 16); this.radioButton2.TabIndex = 14; this.radioButton2.TabStop = true; this.radioButton2.UseVisualStyleBackColor = true; // // radioButton1 // this.radioButton1.AutoSize = true; this.radioButton1.Location = new System.Drawing.Point(46, 59); this.radioButton1.Name = "radioButton1"; this.radioButton1.Size = new System.Drawing.Size(47, 16); this.radioButton1.TabIndex = 13; this.radioButton1.TabStop = true; this.radioButton1.UseVisualStyleBackColor = true; this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(6, 59); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(41, 12); this.label4.TabIndex = 12; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(181, 63); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(41, 12); this.label6.TabIndex = 5; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(181, 32); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(41, 12); this.label5.TabIndex = 4; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 114); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(41, 12); this.label3.TabIndex = 2; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 88); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 12); this.label2.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 32); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(41, 12); this.label1.TabIndex = 0; // // groupBox3 // this.groupBox3.Controls.Add(this.panel1); this.groupBox3.Location = new System.Drawing.Point(12, 223); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(319, 116); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; // // panel1 // this.panel1.Location = new System.Drawing.Point(27, 17); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(270, 88); this.panel1.TabIndex = 0; this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); // // SurveyPointStyleSettingDialog // this.ClientSize = new System.Drawing.Size(343, 351); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.MaximizeBox = false; this.MaximumSize = new System.Drawing.Size(359, 390); this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(359, 390); this.Name = "SurveyPointStyleSettingDialog"; this.ShowInTaskbar = false; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); this.groupBox3.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// /// 初始化数据 /// 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.comboBox1.DataSource = fontsItems; CompoundRatioStyleModel compoundRatioStyleModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\SurvePointStyle.xml", FileMode.Open)); if (compoundRatioStyleModel.survePointStyle != null) { this.panel2.BackColor = Color.FromArgb(compoundRatioStyleModel.survePointStyle.pointColor); if (compoundRatioStyleModel.survePointStyle.pointStyle == 0) this.radioButton1.Checked = true; else this.radioButton2.Checked = true; this.numericUpDown2.Value = compoundRatioStyleModel.survePointStyle.pointWidth; this.numericUpDown3.Value = compoundRatioStyleModel.survePointStyle.pointDiameter; this.comboBox1.Text = compoundRatioStyleModel.survePointStyle.font; this.numericUpDown1.Value = compoundRatioStyleModel.survePointStyle.fontSize; if (compoundRatioStyleModel.survePointStyle.pointMarkerSymbol) this.checkBox1.Checked = true; else this.checkBox1.Checked = false; } } /// /// 页面关闭 /// /// /// private void button1_Click(object sender, EventArgs e) { this.Close(); } private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce) { } private void panel2_Click(object sender, EventArgs e) { this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor); this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel2Changed)); this.colorsForm.ShowDialog(); } private void panel2Changed(object sender, EventArgs e) { this.panel2.BackColor = this.colorsForm.UserPrimaryColor.ToColor(); this.colorsForm.Close(); } /// /// 保存按钮 /// /// /// private void button2_Click(object sender, EventArgs e) { CompoundRatioStyleModel compoundRatioStyleModel = new CompoundRatioStyleModel(); compoundRatioStyleModel.survePointStyle = new CompoundRatioStyleModel.SurvePointStyle(); compoundRatioStyleModel.survePointStyle.pointColor = Convert.ToInt32(this.panel2.BackColor.ToArgb()); if(this.radioButton1.Checked) compoundRatioStyleModel.survePointStyle.pointStyle = 0; else compoundRatioStyleModel.survePointStyle.pointStyle = 1; compoundRatioStyleModel.survePointStyle.pointWidth = Convert.ToInt32(numericUpDown2.Value); compoundRatioStyleModel.survePointStyle.pointDiameter = Convert.ToInt32(numericUpDown3.Value); compoundRatioStyleModel.survePointStyle.font = this.comboBox1.Text; compoundRatioStyleModel.survePointStyle.fontSize = Convert.ToInt32(numericUpDown1.Value); if(this.checkBox1.Checked) compoundRatioStyleModel.survePointStyle.pointMarkerSymbol = true; else compoundRatioStyleModel.survePointStyle.pointMarkerSymbol = false; //以下保存xml文件信息 string stageModelXml = XmlSerializeHelper.XmlSerialize(compoundRatioStyleModel); string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\SurvePointStyle.xml"; FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create); RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner; recombinationRateDialog.RefreshPanel(); } /// /// 绘制预览图形 /// /// /// private void panel1_Paint(object sender, PaintEventArgs e) { DrawPreviewGraphics(e.Graphics); } /// /// 绘制预览图形 /// private void DrawPreviewGraphics(Graphics g) { Pen pointPen = new Pen(this.panel2.BackColor, Convert.ToInt32(numericUpDown2.Value)); SolidBrush brush = new SolidBrush(this.panel2.BackColor); Font textfont = new Font(this.comboBox1.Text, Convert.ToInt32(numericUpDown1.Value)); this.panel1.BackColor = Color.Black; if (this.radioButton1.Checked) g.DrawEllipse(pointPen, this.panel1.Width / 2 - Convert.ToInt32(numericUpDown3.Value) / 2, this.panel1.Height / 2 - Convert.ToInt32(numericUpDown3.Value) / 2, Convert.ToInt32(numericUpDown3.Value), Convert.ToInt32(numericUpDown3.Value)); else g.FillEllipse(brush, this.panel1.Width / 2 - Convert.ToInt32(numericUpDown3.Value) / 2, this.panel1.Height / 2 - Convert.ToInt32(numericUpDown3.Value) / 2, Convert.ToInt32(numericUpDown3.Value), Convert.ToInt32(numericUpDown3.Value)); g.DrawString("文字预览", textfont, new SolidBrush(Color.Red), new PointF(0, 0)); } /// /// 更改文字 /// /// /// private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { this.panel1.Refresh(); } /// /// 空实心样式改变 /// /// /// private void radioButton1_CheckedChanged(object sender, EventArgs e) { this.panel1.Refresh(); } /// /// 字体大小改变 /// /// /// private void numericUpDown1_ValueChanged(object sender, EventArgs e) { this.panel1.Refresh(); } /// /// 空心点线宽改变 /// /// /// private void numericUpDown2_ValueChanged(object sender, EventArgs e) { this.panel1.Refresh(); } /// /// 点直径改变 /// /// /// private void numericUpDown3_ValueChanged(object sender, EventArgs e) { this.panel1.Refresh(); } /// /// 点颜色改变 /// /// /// private void panel2_BackColorChanged(object sender, EventArgs e) { this.panel1.Refresh(); } } }