123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533 |
- 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
- /// <summary>
- /// 图像显示数量下拉选项
- /// </summary>
- int[] imgCount = new int[] { 2, 3, 4, 6, 8, 9 };
- /// <summary>
- /// 字体列表
- /// </summary>
- ArrayList fontsItems = new ArrayList();
- /// <summary>
- /// 调色板
- /// </summary>
- 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
- /// <summary>
- /// 初始化数据
- /// </summary>
- 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<CompoundRatioStyleModel>(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;
- }
-
- }
- /// <summary>
- /// 页面关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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>(compoundRatioStyleModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\SurvePointStyle.xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
- recombinationRateDialog.RefreshPanel();
- }
- /// <summary>
- /// 绘制预览图形
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- DrawPreviewGraphics(e.Graphics);
- }
- /// <summary>
- /// 绘制预览图形
- /// </summary>
- 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));
- }
- /// <summary>
- /// 更改文字
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 空实心样式改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 字体大小改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 空心点线宽改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 点直径改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 点颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel2_BackColorChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- }
- }
|