1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297 |
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Annotation.relationModel;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Setting.LabelComponent;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Windows.Forms;
- using PaintDotNet.Base;
- using PaintDotNet.Annotation;
- namespace PaintDotNet.Setting
- {
- /// <summary>
- /// 设置->标注设置
- /// </summary>
- internal class LabelSettingDialog : PdnBaseForm
- {
- /// <summary>
- /// 标注一二级关系
- /// </summary>
- private static List<LabelRelationModel> list;
- /// <summary>
- /// 当前选中的二级标注
- /// </summary>
- private DrawToolType drawToolType;
- /// <summary>
- /// 标注的样式
- /// </summary>
- private LabelStyleModel labelStyleModel = Startup.instance.labelStyleModel;
- /// <summary>
- /// 主配置文件的model
- /// </summary>
- private ConfigModel configModel = Startup.instance.configModel;
- /// <summary>
- /// 操作样式下拉数据
- /// </summary>
- private List<string> files = new List<string>();
- /// <summary>
- /// 另存为弹出框显示
- /// </summary>
- private CreateNameDialog dialog;
- /// <summary>
- /// 另存为文件名
- /// </summary>
- private string newName;
- private int initflag = 0;
- //各页面组件
- private LabelTextControl textControl;
- private LabelMarkDateControl dateMarkControl;
- private LabelMarkTimeControl timeMarkControl;
- private LabelMarkPointControl pointMarkControl;
- private LabelMarkNumberControl numberMarkControl;
- private LabelMarkGainNumberControl gainNumberControl;
- private LabelStraightLineControl straightLineControl;
- private LabelStraightLineSegmentControl segmentLineControl;
- private LabelCurvePencilControl pencilControl;
- private LabelCurvePolylineControl polylineControl;
- private LabelCurveControl curveControl;
- private LabelCurveClosedControl closedCurveControl;
- private LabelArrowOneWayControl oneWayArrowControl;
- private LabelArrowTwoWayControl twoWayArrowControl;
- private LabelCircleControl circleControl;
- private LabelCircleOvalControl ovalControl;
- private LabelPolygonRectangleControl polygonRectangleControl;
- private LabelPolygonControl polygonControl;
- private LabelPolygonRoundedControl roundedRectangleControl;
- private GroupBox groupBox4;
- private System.Windows.Forms.Label label71;
- private NumericUpDown numericUpDown71;
- private ConfigModel config = Startup.instance.configModel;
- private AppWorkspace appWorkspace;
- PaintDotNet.ColorsForm colorsForm2;
- PaintDotNet.ColorsForm colorsForm3;
- PaintDotNet.ColorsForm colorsForm4;
- PaintDotNet.ColorsForm colorsForm5;
- #region 控件
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.ListBox listBox1;
- private Button button3;
- private Button button2;
- private Button button4;
- private ComboBox comboBox1;
- private Label label1;
- private CheckBox checkbox1;
- private Panel panel5;
- private Panel panel4;
- private NumericUpDown numericUpDown2;
- private ComboBox comboBox9;
- private Label label19;
- private Label label17;
- private Label label16;
- private Label label15;
- private Button button5;
- #endregion
- public LabelSettingDialog(AppWorkspace appWorkspace)
- {
- if (list == null)
- {
- list = InvariantData.GetLabelRelations();
- }
- this.appWorkspace = appWorkspace;
- InitializeComponent();
- InitializeLanguageText();
- InitializeData();
- }
- private void InitializeLanguageText()
- {
- 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.File.Save.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Type.text");
- this.button5.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
- this.Text = PdnResources.GetString("Menu.Setting.LabelSetting.Text");
- this.label71.Text = PdnResources.GetString("Markpointsize.Text") + ":";
- }
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.label1 = new System.Windows.Forms.Label();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.listBox1 = new System.Windows.Forms.ListBox();
- this.panel1 = new System.Windows.Forms.Panel();
- this.button5 = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.checkbox1 = new System.Windows.Forms.CheckBox();
- this.panel5 = new System.Windows.Forms.Panel();
- this.panel4 = new System.Windows.Forms.Panel();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.comboBox9 = new System.Windows.Forms.ComboBox();
- this.label19 = new System.Windows.Forms.Label();
- this.label17 = new System.Windows.Forms.Label();
- this.label16 = new System.Windows.Forms.Label();
- this.label15 = new System.Windows.Forms.Label();
- this.label71 = new System.Windows.Forms.Label();
- this.numericUpDown71 = new System.Windows.Forms.NumericUpDown();
- this.groupBox1.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown71)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.comboBox1);
- this.groupBox1.Controls.Add(this.button4);
- this.groupBox1.Controls.Add(this.button3);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Location = new System.Drawing.Point(134, 13);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(638, 58);
- this.groupBox1.TabIndex = 1;
- this.groupBox1.TabStop = false;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(176, 25);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(89, 12);
- this.label1.TabIndex = 5;
- this.label1.Text = "当前操作样式:";
- //
- // comboBox1
- //
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(271, 21);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(116, 20);
- this.comboBox1.TabIndex = 4;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(393, 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.Location = new System.Drawing.Point(474, 20);
- 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.Location = new System.Drawing.Point(555, 20);
- 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);
- //
- // groupBox2
- //
- this.groupBox2.Location = new System.Drawing.Point(137, 114);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(633, 235);
- this.groupBox2.TabIndex = 2;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "设置";
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.listBox1);
- this.groupBox3.Location = new System.Drawing.Point(13, 13);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(115, 340);
- this.groupBox3.TabIndex = 3;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "类型";
- //
- // listBox1
- //
- this.listBox1.FormattingEnabled = true;
- this.listBox1.ItemHeight = 12;
- this.listBox1.Location = new System.Drawing.Point(6, 20);
- this.listBox1.Name = "listBox1";
- this.listBox1.Size = new System.Drawing.Size(103, 316);
- this.listBox1.TabIndex = 0;
- this.listBox1.SelectedValueChanged += new System.EventHandler(this.listBox1_SelectedValueChanged);
- //
- // panel1
- //
- this.panel1.Location = new System.Drawing.Point(134, 78);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(556, 36);
- this.panel1.TabIndex = 5;
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(692, 78);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 4;
- this.button5.Text = "保存全部";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.checkbox1);
- this.groupBox4.Controls.Add(this.panel5);
- this.groupBox4.Controls.Add(this.panel4);
- this.groupBox4.Controls.Add(this.numericUpDown2);
- this.groupBox4.Controls.Add(this.comboBox9);
- this.groupBox4.Controls.Add(this.label19);
- this.groupBox4.Controls.Add(this.label17);
- this.groupBox4.Controls.Add(this.label16);
- this.groupBox4.Controls.Add(this.label15);
- this.groupBox4.Controls.Add(this.label71);
- this.groupBox4.Controls.Add(this.numericUpDown71);
- this.groupBox4.Location = new System.Drawing.Point(137, 76);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(716, 277);
- this.groupBox4.TabIndex = 6;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "设置";
- this.groupBox4.Visible = false;
- //
- // checkbox1
- //
- this.checkbox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.checkbox1.AutoSize = true;
- this.checkbox1.Location = new System.Drawing.Point(136, 238);
- this.checkbox1.Name = "checkbox1";
- this.checkbox1.Size = new System.Drawing.Size(78, 16);
- this.checkbox1.TabIndex = 42;
- this.checkbox1.Text = "跟随缩放 ";
- this.checkbox1.UseVisualStyleBackColor = true;
- //
- // panel5
- //
- this.panel5.BackColor = System.Drawing.SystemColors.Window;
- this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel5.Location = new System.Drawing.Point(137, 106);
- this.panel5.Name = "panel5";
- this.panel5.Size = new System.Drawing.Size(152, 20);
- this.panel5.TabIndex = 41;
- this.panel5.Click += new EventHandler(panel5Click);
- //
- // panel4
- //
- this.panel4.BackColor = System.Drawing.SystemColors.Window;
- this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel4.Location = new System.Drawing.Point(137, 192);
- this.panel4.Name = "panel4";
- this.panel4.Size = new System.Drawing.Size(152, 20);
- this.panel4.TabIndex = 40;
- this.panel4.Click += new EventHandler(panel4Click);
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(137, 147);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 100000,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(152, 21);
- this.numericUpDown2.TabIndex = 39;
- //
- // comboBox9
- //
- this.comboBox9.FormattingEnabled = true;
- this.comboBox9.Location = new System.Drawing.Point(137, 60);
- this.comboBox9.Name = "comboBox9";
- this.comboBox9.Size = new System.Drawing.Size(150, 20);
- this.comboBox9.TabIndex = 38;
- //
- // label19
- //
- this.label19.AutoSize = true;
- this.label19.Location = new System.Drawing.Point(64, 196);
- this.label19.Name = "label19";
- this.label19.Size = new System.Drawing.Size(65, 12);
- this.label19.TabIndex = 37;
- this.label19.Text = "填充颜色:";
- //
- // label17
- //
- this.label17.AutoSize = true;
- this.label17.Location = new System.Drawing.Point(64, 151);
- this.label17.Name = "label17";
- this.label17.Size = new System.Drawing.Size(65, 12);
- this.label17.TabIndex = 36;
- this.label17.Text = "线条宽度:";
- //
- // label16
- //
- this.label16.AutoSize = true;
- this.label16.Location = new System.Drawing.Point(66, 110);
- this.label16.Name = "label16";
- this.label16.Size = new System.Drawing.Size(65, 12);
- this.label16.TabIndex = 35;
- this.label16.Text = "线条颜色:";
- //
- // label15
- //
- this.label15.AutoSize = true;
- this.label15.Location = new System.Drawing.Point(54, 64);
- this.label15.Name = "label15";
- this.label15.Size = new System.Drawing.Size(77, 12);
- this.label15.TabIndex = 34;
- this.label15.Text = "标记点样式:";
- //
- // label71
- //
- this.label71.Location = new System.Drawing.Point(6, 27);
- this.label71.Name = "label71";
- this.label71.Size = new System.Drawing.Size(125, 13);
- this.label71.TabIndex = 0;
- this.label71.Text = "标记点大小:";
- this.label71.TextAlign = System.Drawing.ContentAlignment.TopRight;
- //
- // numericUpDown71
- //
- this.numericUpDown71.Location = new System.Drawing.Point(134, 23);
- this.numericUpDown71.Maximum = new decimal(new int[] {
- 100000,
- 0,
- 0,
- 0});
- this.numericUpDown71.Name = "numericUpDown71";
- this.numericUpDown71.Size = new System.Drawing.Size(152, 21);
- this.numericUpDown71.TabIndex = 14;
- //
- // LabelSettingDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(776, 359);
- this.Controls.Add(this.button5);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox2);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "LabelSettingDialog";
- this.Text = "标注设置";
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.panel1, 0);
- this.Controls.SetChildIndex(this.button5, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox3.ResumeLayout(false);
- this.groupBox4.ResumeLayout(false);
- this.groupBox4.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown71)).EndInit();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 初始化数据
- /// </summary>
- private void InitializeData()
- {
- this.colorsForm2 = new ColorsForm();
- this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- this.colorsForm3 = new ColorsForm();
- this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- this.colorsForm4 = new ColorsForm();
- this.colorsForm4.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm4.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- this.colorsForm5 = new ColorsForm();
- this.colorsForm5.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm5.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- //绑定左侧listbox数据
- this.listBox1.Items.Clear();
- foreach (LabelRelationModel model in list)
- {
- this.listBox1.Items.Add(model.name);
- }
- this.listBox1.SelectedIndex = 0;
- //绑定样式下拉
- if (initflag++ == 0)
- {
- InitializeStyleName();
- }
- //更新右侧设置界面
- UpdateRightSettingUI();
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- #region [标记点相关]
- this.comboBox9.Items.Add("正方形");
- this.comboBox9.Items.Add("圆形");
- this.comboBox9.Items.Add("三角形");
- this.numericUpDown71.Value = this.config.MarkpointWidth;
- this.comboBox9.SelectedIndex = this.config.MarkpointStyle;
- this.panel5.BackColor = Color.FromArgb(this.config.MarkpointLineColor);
- this.numericUpDown2.Value = this.config.MarkpointLineWidth;
- this.panel4.BackColor = Color.FromArgb(this.config.MarkpointAreaColor);
- this.checkbox1.Checked = this.config.isFollow;
- #endregion
- }
- /// <summary>
- /// 初始化样式下拉
- /// </summary>
- private void InitializeStyleName()
- {
- List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\");
- files.Clear();
- foreach (string fileName in fileNames)
- {
- string name = fileName.Substring(0, fileName.LastIndexOf("."));
- files.Add(name);
- }
- this.comboBox1.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
- this.comboBox1.DataSource = null;
- this.comboBox1.DataSource = files;
- string nowModelName = Startup.instance.configModel.Watermark.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
- this.comboBox1.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
- this.labelStyleModel = XmlSerializeHelper.DESerializer<LabelStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
- this.comboBox1.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
- }
- /// <summary>
- /// 当前操作样式 下拉选切换
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.labelStyleModel = XmlSerializeHelper.DESerializer<LabelStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
- InitializeData();
- }
- /// <summary>
- /// 左侧listbox选择事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listBox1_SelectedValueChanged(object sender, EventArgs e)
- {
- //首先更新右侧分类部分
- UpdateRightCatalog();
- //更新右侧设置界面
- UpdateRightSettingUI();
- //刷新右侧预览
- UpdateRightPreview();
- }
- /// <summary>
- /// 更新右侧分类
- /// </summary>
- private void UpdateRightCatalog()
- {
- this.panel1.Controls.Clear();
- LabelRelationModel model = list[this.listBox1.SelectedIndex];
- int postion = 0;
- if (model.id == 8)
- {
- groupBox2.Visible = false;
- panel1.Visible = false;
- button5.Visible = false;
- groupBox4.Visible = true;
- comboBox1.Visible = false;
- button4.Visible = false;
- button3.Visible = false;
- label1.Visible = false;
- }
- else {
- groupBox2.Visible = true;
- panel1.Visible = true;
- button5.Visible = true;
- groupBox4.Visible = false;
- comboBox1.Visible = true;
- button4.Visible = true;
- button3.Visible = true;
- label1.Visible = true;
- }
- foreach (LabelRelationModel.ChildLabel child in model.childLabel)
- {
- Button button = new Button();
- button.Size = new Size(75, 23);
- button.Location = new Point(postion * 75 + 5, 0);
- button.Text = child.name;
- button.Tag = child;
- button.Click += new EventHandler(ChildButton_Click);
- this.panel1.Controls.Add(button);
- if (postion == 0)
- {
- this.drawToolType = child.drawToolType;
- button.Focus();
- }
- postion++;
- }
- }
- /// <summary>
- /// 二级分类按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ChildButton_Click(object sender, EventArgs e)
- {
- Button button = (Button)sender;
- LabelRelationModel.ChildLabel child = (LabelRelationModel.ChildLabel)button.Tag;
- this.drawToolType = child.drawToolType;
- this.UpdateRightSettingUI();
- }
- /// <summary>
- /// 更新右侧设置
- /// </summary>
- private void UpdateRightSettingUI()
- {
- this.groupBox2.Controls.Clear();
- switch (this.drawToolType)
- {
- case DrawToolType.DrawTextString: //文本
- textControl = new LabelTextControl(this.labelStyleModel.text);
- textControl.Location = new Point(10, 15);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- this.groupBox2.Controls.Add(textControl);
- break;
- case DrawToolType.DrawDateMark: //标记-日期
- dateMarkControl = new LabelMarkDateControl(this.labelStyleModel.dateMark);
- dateMarkControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(dateMarkControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.dateMark.chooseStyle == null ? "" : this.labelStyleModel.dateMark.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.dateMark.chooseStyle == null ? 1 : this.labelStyleModel.dateMark.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.dateMark.chooseStyle == null ? 1 : this.labelStyleModel.dateMark.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.dateMark.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.dateMark.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.dateMark.chooseStyle == null ? 0 : this.labelStyleModel.dateMark.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.dateMark.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.dateMark.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.dateMark.chooseStyle == null ? 0 : this.labelStyleModel.dateMark.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawTimeMark: //标记-时间
- timeMarkControl = new LabelMarkTimeControl(this.labelStyleModel.timeMark);
- timeMarkControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(timeMarkControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.timeMark.chooseStyle == null ? "" : this.labelStyleModel.tetimeMarkxt.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.timeMark.chooseStyle == null ? 1 : this.labelStyleModel.timeMark.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.timeMark.chooseStyle == null ? 1 : this.labelStyleModel.timeMark.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.timeMark.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.timeMark.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.timeMark.chooseStyle == null ? 0 : this.labelStyleModel.timeMark.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.timeMark.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.timeMark.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.timeMark.chooseStyle == null ? 0 : this.labelStyleModel.timeMark.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawPointMark: //标记-点标记
- pointMarkControl = new LabelMarkPointControl(this.labelStyleModel.pointMark);
- pointMarkControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(pointMarkControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawNumberMark: //标记-数字标记
- numberMarkControl = new LabelMarkNumberControl(this.labelStyleModel.numberMark);
- numberMarkControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(numberMarkControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawGainNumber: //标记-放大倍数
- gainNumberControl = new LabelMarkGainNumberControl(this.labelStyleModel.gainNumber);
- gainNumberControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(gainNumberControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawLine: //直线->直线
- straightLineControl = new LabelStraightLineControl(this.labelStyleModel.lineChildLine);
- straightLineControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(straightLineControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawLineSegment: //直线->线段
- segmentLineControl = new LabelStraightLineSegmentControl(this.labelStyleModel.lineChildLineSegment);
- segmentLineControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(segmentLineControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawPencil: //曲线->铅笔
- pencilControl = new LabelCurvePencilControl(this.labelStyleModel.pencilModel);
- pencilControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(pencilControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawPolygonLine: //曲线->折线
- polylineControl = new LabelCurvePolylineControl(this.labelStyleModel.polylineModel);
- polylineControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(polylineControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawCurve: //曲线->曲线
- curveControl = new LabelCurveControl(this.labelStyleModel.curveModel);
- curveControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(curveControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawClosedCurve: //曲线->闭合曲线
- closedCurveControl = new LabelCurveClosedControl(this.labelStyleModel.closedCurveModel);
- closedCurveControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(closedCurveControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawOneArrowLine: //箭头->单向箭头
- oneWayArrowControl = new LabelArrowOneWayControl(this.labelStyleModel.oneWayArrowModel);
- oneWayArrowControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(oneWayArrowControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawTwoArrowLine: //箭头->双向箭头
- twoWayArrowControl = new LabelArrowTwoWayControl(this.labelStyleModel.twoWayArrowModel);
- twoWayArrowControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(twoWayArrowControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawCircle: //圆->圆
- circleControl = new LabelCircleControl(this.labelStyleModel.circleModel);
- circleControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(circleControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawEllipse: //圆->椭圆
- ovalControl = new LabelCircleOvalControl(this.labelStyleModel.ovalModel);
- ovalControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(ovalControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawRectangle: //多边形->矩形
- polygonRectangleControl = new LabelPolygonRectangleControl(this.labelStyleModel.polygonRectangle);
- polygonRectangleControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(polygonRectangleControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawPolygon: //多边形->多边形
- polygonControl = new LabelPolygonControl(this.labelStyleModel.polygonPolygon);
- polygonControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(polygonControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- case DrawToolType.DrawRoundRectangle: //多边形->圆角矩形
- roundedRectangleControl = new LabelPolygonRoundedControl(this.labelStyleModel.roundedRectangle);
- roundedRectangleControl.Location = new Point(10, 15);
- this.groupBox2.Controls.Add(roundedRectangleControl);
- #region [选中样式]
- //this.comboBox20.Text = this.labelStyleModel.text.chooseStyle == null ? "" : this.labelStyleModel.text.chooseStyle.font;
- //this.numericUpDown4.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.lineWidth;
- //this.numericUpDown5.Value = this.labelStyleModel.text.chooseStyle == null ? 1 : this.labelStyleModel.text.chooseStyle.fontSize;
- //this.panel9.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.textColor);
- //this.numericUpDown3.Value = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.vLineLength;
- //this.panel8.BackColor = this.labelStyleModel.text.chooseStyle == null ? Color.Black : Color.FromArgb(this.labelStyleModel.text.chooseStyle.lineColor);
- //this.comboBox18.SelectedIndex = this.labelStyleModel.text.chooseStyle == null ? 0 : this.labelStyleModel.text.chooseStyle.lineStyle;
- #endregion
- break;
- }
- }
- /// <summary>
- /// 刷新右侧预览图
- /// </summary>
- private void UpdateRightPreview()
- {
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if ("Default".Equals(this.comboBox1.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.comboBox1.SelectedIndex;
- int tall = files.Count - 1;
- if (selectIndex < tall)
- {
- newIndex = selectIndex;
- }
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.Text + ".xml";
- FileInfo fileInfo = new FileInfo(filePath);
- fileInfo.Delete();
- InitializeStyleName();
- this.comboBox1.SelectedIndex = newIndex;
- this.labelStyleModel = XmlSerializeHelper.DESerializer<LabelStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
- InitializeData();
- }
- else if (dr == DialogResult.Cancel)
- {
- }
- }
- /// <summary>
- /// 另存为 出弹窗
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 另存为弹窗 确定保存
- /// </summary>
- /// <param name="name"></param>
- public override void GetCreateName(string name)
- {
- string currentcomboBox = this.comboBox1.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;
- }
- LabelStyleModel newModel = this.labelStyleModel;
- modelSave(newModel);
- //另存为
- string stageModelXml = XmlSerializeHelper.XmlSerialize<LabelStyleModel>(newModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.newName + ".xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- InitializeStyleName();
- this.comboBox1.Text = currentcomboBox;
- dialog.Close();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- this.labelStyleModel = modelSave(this.labelStyleModel);
- //以下保存xml文件信息
- string stageModelXml = XmlSerializeHelper.XmlSerialize<LabelStyleModel>(this.labelStyleModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.Text + ".xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- this.config.MarkpointWidth = Convert.ToInt32(this.numericUpDown71.Value);
- this.config.MarkpointStyle = this.comboBox9.SelectedIndex;
- this.config.MarkpointLineColor = this.panel5.BackColor.ToArgb();
- this.config.MarkpointLineWidth = Convert.ToInt32(this.numericUpDown2.Value);
- this.config.MarkpointAreaColor = this.panel4.BackColor.ToArgb();
- this.config.isFollow = this.checkbox1.Checked;
- string configModelXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(config);
- FileOperationHelper.WriteStringToFile(configModelXml, Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml", FileMode.Create);
- MarkPointRect.markPointRectWidth = configModel.MarkpointWidth;
- //if (this.appWorkspace.DocumentWorkspaces != null)
- //{
- // foreach (var item in this.appWorkspace.DocumentWorkspaces)
- // {
- // if (item != null && item.GraphicsList != null)
- // foreach (var graObject in item.GraphicsList.graphicsList)
- // {
- // graObject.smallRectangleWidth = this.config.MarkpointWidth;
- // }
- // item.Refresh();
- // }
- //}
- DrawObject.smallRectangleWidth = this.config.MarkpointWidth;
- DrawObject.MarkpointStyle = this.config.MarkpointStyle;
- DrawObject.MarkpointLineColor = this.config.MarkpointLineColor;
- DrawObject.MarkpointLineWidth = this.config.MarkpointLineWidth;
- DrawObject.MarkpointAreaColor = this.config.MarkpointAreaColor;
- DrawObject.isFollow = this.checkbox1.Checked;
- ApplicationSetting();
- }
- /// <summary>
- /// 各个子页面的model保存方法
- /// </summary>
- private LabelStyleModel modelSave(LabelStyleModel model)
- {
- switch (this.drawToolType)
- {
- case DrawToolType.DrawTextString: //文本
- model.text = textControl.getNowModel(this.labelStyleModel.text);
- break;
- case DrawToolType.DrawDateMark: //标记-日期
- model.dateMark = dateMarkControl.getNowModel(this.labelStyleModel.dateMark);
- break;
- case DrawToolType.DrawTimeMark: //标记-时间
- model.timeMark = timeMarkControl.getNowModel(this.labelStyleModel.timeMark);
- break;
- case DrawToolType.DrawPointMark: //标记-点标记
- model.pointMark = pointMarkControl.getNowModel(this.labelStyleModel.pointMark);
- break;
- case DrawToolType.DrawNumberMark: //标记-数字标记
- model.numberMark = numberMarkControl.getNowModel(this.labelStyleModel.numberMark);
- break;
- case DrawToolType.DrawGainNumber: //标记-放大倍数
- model.gainNumber = gainNumberControl.getNowModel(this.labelStyleModel.gainNumber);
- break;
- case DrawToolType.DrawLine: //直线->直线
- model.lineChildLine = straightLineControl.getNowModel(this.labelStyleModel.lineChildLine);
- break;
- case DrawToolType.DrawLineSegment: //直线->线段
- model.lineChildLineSegment = segmentLineControl.getNowModel(this.labelStyleModel.lineChildLineSegment);
- break;
- case DrawToolType.DrawPencil: //曲线->铅笔
- model.pencilModel = pencilControl.getNowModel(this.labelStyleModel.pencilModel);
- break;
- case DrawToolType.DrawPolygonLine: //曲线->折线
- model.polylineModel = polylineControl.getNowModel(this.labelStyleModel.polylineModel);
- break;
- case DrawToolType.DrawCurve: //曲线->曲线
- model.curveModel = curveControl.getNowModel(this.labelStyleModel.curveModel);
- break;
- case DrawToolType.DrawClosedCurve: //曲线->闭合曲线
- model.closedCurveModel = closedCurveControl.getNowModel(this.labelStyleModel.closedCurveModel);
- break;
- case DrawToolType.DrawOneArrowLine: //箭头->单向箭头
- model.oneWayArrowModel = oneWayArrowControl.getNowModel(this.labelStyleModel.oneWayArrowModel);
- break;
- case DrawToolType.DrawTwoArrowLine: //箭头->双向箭头
- model.twoWayArrowModel = twoWayArrowControl.getNowModel(this.labelStyleModel.twoWayArrowModel);
- break;
- case DrawToolType.DrawCircle: //圆->圆
- model.circleModel = circleControl.getNowModel(this.labelStyleModel.circleModel);
- break;
- case DrawToolType.DrawEllipse: //圆->椭圆
- model.ovalModel = ovalControl.getNowModel(this.labelStyleModel.ovalModel);
- break;
- case DrawToolType.DrawRectangle: //多边形->矩形
- model.polygonRectangle = polygonRectangleControl.getNowModel(this.labelStyleModel.polygonRectangle);
- break;
- case DrawToolType.DrawPolygon: //多边形->多边形
- model.polygonPolygon = polygonControl.getNowModel(this.labelStyleModel.polygonPolygon);
- break;
- case DrawToolType.DrawRoundRectangle: //多边形->圆角矩形
- model.roundedRectangle = roundedRectangleControl.getNowModel(this.labelStyleModel.roundedRectangle);
- break;
- }
- return model;
- }
- /// <summary>
- /// 应用
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ApplicationSetting()
- {
- //修改缓存中的样式数据
- Startup.instance.labelStyleModel = this.labelStyleModel;
- //修改主配置文件中的值
- configModel.LabelStyle = this.comboBox1.Text + ".xml";
- //修改主配置文件的xml
- string configModelXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(this.configModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
- FileOperationHelper.WriteStringToFile(configModelXml, filePath, FileMode.Create);
- MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
- }
- /// <summary>
- /// 应用全部
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- switch (this.drawToolType)
- {
- case DrawToolType.DrawTextString: //文本
- this.labelStyleModel.text = textControl.getNowModel(this.labelStyleModel.text);
- break;
- case DrawToolType.DrawDateMark: //标记-日期
- this.labelStyleModel = dateMarkControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawTimeMark: //标记-时间
- this.labelStyleModel = timeMarkControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawNumberMark: //标记-数字标记
- this.labelStyleModel = numberMarkControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawGainNumber: //标记-放大倍数
- this.labelStyleModel = gainNumberControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawLine: //直线->直线
- this.labelStyleModel = straightLineControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawLineSegment: //直线->线段
- this.labelStyleModel = segmentLineControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawPencil: //曲线->铅笔
- this.labelStyleModel = pencilControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawPolygonLine: //曲线->折线
- this.labelStyleModel = polylineControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawCurve: //曲线->曲线
- this.labelStyleModel = curveControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawClosedCurve: //曲线->闭合曲线
- this.labelStyleModel = closedCurveControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawOneArrowLine: //箭头->单向箭头
- this.labelStyleModel = oneWayArrowControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawTwoArrowLine: //箭头->双向箭头
- this.labelStyleModel = twoWayArrowControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawCircle: //圆->圆
- this.labelStyleModel = circleControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawEllipse: //圆->椭圆
- this.labelStyleModel = ovalControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawRectangle: //多边形->矩形
- this.labelStyleModel = polygonRectangleControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawPolygon: //多边形->多边形
- this.labelStyleModel = polygonControl.ApplyAll(this.labelStyleModel);
- break;
- case DrawToolType.DrawRoundRectangle: //多边形->圆角矩形
- this.labelStyleModel = roundedRectangleControl.ApplyAll(this.labelStyleModel);
- break;
- }
- //以下保存xml文件信息
- string stageModelXml = XmlSerializeHelper.XmlSerialize<LabelStyleModel>(this.labelStyleModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.Text + ".xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- ApplicationSetting();
- }
- private void panel5Click(object sender, EventArgs e)
- {
- this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel5.BackColor);
- this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.panel5Changed));
- this.colorsForm2.ShowDialog();
- }
- private void panel5Changed(object sender, EventArgs e)
- {
- this.panel5.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
- this.colorsForm2.Close();
- }
- private void panel4Click(object sender, EventArgs e)
- {
- this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
- this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.panel4Changed));
- this.colorsForm3.ShowDialog();
- }
- private void panel4Changed(object sender, EventArgs e)
- {
- this.panel4.BackColor = this.colorsForm3.UserPrimaryColor.ToColor();
- this.colorsForm3.Close();
- }
- private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
- {
- }
- }
- }
|