| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326 | using PaintDotNet.Base.CommTool;using PaintDotNet.Base.SettingModel;using System;using System.Collections;using System.Drawing;using System.IO;using System.Windows.Forms;using static PaintDotNet.Base.SettingModel.RulerModel;namespace PaintDotNet.Setting{    internal class RulerSettingDialog : PdnBaseForm    {        #region 属性        #region 组件定义        private System.Windows.Forms.GroupBox groupBox1;        private System.Windows.Forms.Button cancelBtn;        private System.Windows.Forms.Button saveBtn;        private System.Windows.Forms.GroupBox groupBox2;        private System.Windows.Forms.Label label4;        private System.Windows.Forms.Label label7;        private System.Windows.Forms.Label label5;        private System.Windows.Forms.Label label6;        private System.Windows.Forms.Label label12;        private System.Windows.Forms.Label label8;        private System.Windows.Forms.Label label11;        private System.Windows.Forms.Label label10;        private System.Windows.Forms.Label label3;        private System.Windows.Forms.Label label2;        private System.Windows.Forms.Label label9;        private System.Windows.Forms.Label label1;        private System.Windows.Forms.GroupBox previewGroupBox;        private System.Windows.Forms.GroupBox groupBox4;        private System.Windows.Forms.Label label14;        private System.Windows.Forms.Label label13;        private System.Windows.Forms.GroupBox groupBox5;        private System.Windows.Forms.Label label16;        private System.Windows.Forms.RadioButton rulerPositionVal2;        private System.Windows.Forms.RadioButton rulerPositionVal4;        private System.Windows.Forms.RadioButton rulerPositionVal3;        private System.Windows.Forms.RadioButton rulerPositionVal1;        private System.Windows.Forms.Label label15;        private System.Windows.Forms.GroupBox groupBox6;        private System.Windows.Forms.Button addRulerBtn;        private System.Windows.Forms.Button deleteRulerBtn;        private System.Windows.Forms.ComboBox textFontVal;        private System.Windows.Forms.Label label17;        private System.Windows.Forms.Label label19;        private System.Windows.Forms.Label label18;        private System.Windows.Forms.ComboBox textPositionVal;        private System.Windows.Forms.Panel textColorPanel;        private System.Windows.Forms.Panel lineColorPanel;        private System.Windows.Forms.ListView listView1;        private System.Windows.Forms.NumericUpDown textFontSizeVal;        private System.Windows.Forms.NumericUpDown lineWidthVal;        private System.Windows.Forms.NumericUpDown verticalLineLengthVal;        private System.Windows.Forms.NumericUpDown textHeightVal;        private System.Windows.Forms.Panel backColorPanel;        private System.Windows.Forms.Panel borderColorPanel;        private System.Windows.Forms.NumericUpDown backgroundSizeVal;        private System.Windows.Forms.NumericUpDown borderWidthVal;        private System.Windows.Forms.Panel previewPanel;        private System.Windows.Forms.NumericUpDown autoRulerValueVal;        private System.Windows.Forms.NumericUpDown rulerMarginVal;        private System.Windows.Forms.Label label20;        PaintDotNet.ColorsForm colorsFormFont;        PaintDotNet.ColorsForm colorsFormLine;        PaintDotNet.ColorsForm colorsFormBackground;        PaintDotNet.ColorsForm colorsFormBorder;        private System.Windows.Forms.Panel panel2;        private System.Windows.Forms.Panel panel1;        private Form addRulerform = new PdnBaseForm();        private TextBox nameValue = new TextBox();        private NumericUpDown lengthVal = new NumericUpDown();        #endregion        private RulerModel rulerModel = new RulerModel();        private PresetRuler tempPresetRuler = new PresetRuler();        private ComboBox textBold;        private Label label21;        private AppWorkspace appWorkspace;        #endregion        public RulerSettingDialog(AppWorkspace appWorkspace)        {            this.appWorkspace = appWorkspace;            InitializeComponent();            InitializeLanguageText();            InitializeComponent2();            addRulerformInit();            readData();            buildListView();        }        #region 组件相关        #region Windows Form Designer generated code        /// <summary>        /// Required designer variable.        /// </summary>        private System.ComponentModel.IContainer components = null;        /// <summary>        /// Clean up any resources being used.        /// </summary>        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>        protected override void Dispose(bool disposing)        {            if (disposing && (components != null))            {                components.Dispose();            }            base.Dispose(disposing);        }        private void InitializeLanguageText()        {            this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");            this.cancelBtn.Text = PdnResources.GetString("Menu.cancel.text");            this.saveBtn.Text = PdnResources.GetString("Menu.application.text");            this.groupBox2.Text = PdnResources.GetString("Menu.Set.typesettings.Stylesetting.text");            this.label12.Text = PdnResources.GetString("Menu.Set.Rulersettings.Borderlinewidth.text") + ":";            this.label8.Text = PdnResources.GetString("Menu.Set.Rulersettings.Textheight.text") + ":";            this.label4.Text = PdnResources.GetString("Menu.Set.Rulersettings.Textposition.text") + ":";            this.label11.Text = PdnResources.GetString("Menu.backgroundcolor.text") + ":";            this.label10.Text = PdnResources.GetString("Menu.Set.Rulersettings.Borderlinecolor.text") + ":";            this.label3.Text = PdnResources.GetString("Menu.Set.Rulersettings.Linecolor.text") + ":";            this.label2.Text = PdnResources.GetString("Menu.Set.Rulersettings.lengthofperpendicular.text") + ":";            this.label9.Text = PdnResources.GetString("Menu.Backgroundsize.text") + ":";            this.label7.Text = PdnResources.GetString("Menu.Set.Rulersettings.Fontsize.text") + ":";            this.label1.Text = PdnResources.GetString("Menu.Set.Rulersettings.Linewidth.text") + ":";            this.label5.Text = PdnResources.GetString("Menu.Textcolor.text") + ":";            this.label6.Text = PdnResources.GetString("Menu.Textfont.text") + ":";            this.previewGroupBox.Text = PdnResources.GetString("Menu.Preview.text");            this.groupBox4.Text = PdnResources.GetString("Menu.Set.Rulersettings.automaticannotation.text");            this.label14.Text = PdnResources.GetString("Menu.Set.Rulersettings.Dividebymagnification.text");            this.label13.Text = PdnResources.GetString("Menu.Set.Rulersettings.Calculationoflabellength.text") + ":";            this.groupBox5.Text = PdnResources.GetString("Menu.Set.Rulersettings.Rulerposition.text");            this.label16.Text = PdnResources.GetString("Menu.Set.Rulersettings.Labelmargin.text") + ":";            this.rulerPositionVal2.Text = PdnResources.GetString("Menu.Upperright.text");            this.rulerPositionVal4.Text = PdnResources.GetString("Menu.Lowerright.text");            this.rulerPositionVal3.Text = PdnResources.GetString("Menu.Lowerleft.text");            this.rulerPositionVal1.Text = PdnResources.GetString("Menu.Upperleft.text");            this.label15.Text = PdnResources.GetString("Menu.Set.Rulersettings.Rulerposition.text") + ":";            this.groupBox6.Text = PdnResources.GetString("Menu.Set.Rulersettings.Pre-storedannotation.text");            this.Text = PdnResources.GetString("Menu.Setting.RuleSetting.Text");        }        /// <summary>        /// Required method for Designer support - do not modify        /// the contents of this method with the code editor.        /// </summary>        private void InitializeComponent()        {            this.groupBox1 = new System.Windows.Forms.GroupBox();            this.cancelBtn = new System.Windows.Forms.Button();            this.saveBtn = new System.Windows.Forms.Button();            this.groupBox2 = new System.Windows.Forms.GroupBox();            this.textBold = new System.Windows.Forms.ComboBox();            this.label21 = new System.Windows.Forms.Label();            this.panel2 = new System.Windows.Forms.Panel();            this.panel1 = new System.Windows.Forms.Panel();            this.borderColorPanel = new System.Windows.Forms.Panel();            this.backColorPanel = new System.Windows.Forms.Panel();            this.textHeightVal = new System.Windows.Forms.NumericUpDown();            this.backgroundSizeVal = new System.Windows.Forms.NumericUpDown();            this.verticalLineLengthVal = new System.Windows.Forms.NumericUpDown();            this.borderWidthVal = new System.Windows.Forms.NumericUpDown();            this.lineWidthVal = new System.Windows.Forms.NumericUpDown();            this.textFontSizeVal = new System.Windows.Forms.NumericUpDown();            this.lineColorPanel = new System.Windows.Forms.Panel();            this.textColorPanel = new System.Windows.Forms.Panel();            this.textPositionVal = new System.Windows.Forms.ComboBox();            this.label19 = new System.Windows.Forms.Label();            this.label18 = new System.Windows.Forms.Label();            this.label17 = new System.Windows.Forms.Label();            this.textFontVal = new System.Windows.Forms.ComboBox();            this.label12 = new System.Windows.Forms.Label();            this.label8 = new System.Windows.Forms.Label();            this.label4 = new System.Windows.Forms.Label();            this.label11 = new System.Windows.Forms.Label();            this.label10 = new System.Windows.Forms.Label();            this.label3 = new System.Windows.Forms.Label();            this.label2 = new System.Windows.Forms.Label();            this.label9 = new System.Windows.Forms.Label();            this.label7 = new System.Windows.Forms.Label();            this.label1 = new System.Windows.Forms.Label();            this.label5 = new System.Windows.Forms.Label();            this.label6 = new System.Windows.Forms.Label();            this.previewGroupBox = new System.Windows.Forms.GroupBox();            this.previewPanel = new System.Windows.Forms.Panel();            this.groupBox4 = new System.Windows.Forms.GroupBox();            this.autoRulerValueVal = new System.Windows.Forms.NumericUpDown();            this.label14 = new System.Windows.Forms.Label();            this.label13 = new System.Windows.Forms.Label();            this.groupBox5 = new System.Windows.Forms.GroupBox();            this.rulerMarginVal = new System.Windows.Forms.NumericUpDown();            this.label20 = new System.Windows.Forms.Label();            this.label16 = new System.Windows.Forms.Label();            this.rulerPositionVal2 = new System.Windows.Forms.RadioButton();            this.rulerPositionVal4 = new System.Windows.Forms.RadioButton();            this.rulerPositionVal3 = new System.Windows.Forms.RadioButton();            this.rulerPositionVal1 = new System.Windows.Forms.RadioButton();            this.label15 = new System.Windows.Forms.Label();            this.groupBox6 = new System.Windows.Forms.GroupBox();            this.listView1 = new System.Windows.Forms.ListView();            this.addRulerBtn = new System.Windows.Forms.Button();            this.deleteRulerBtn = new System.Windows.Forms.Button();            this.groupBox1.SuspendLayout();            this.groupBox2.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.textHeightVal)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.backgroundSizeVal)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.verticalLineLengthVal)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.borderWidthVal)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.lineWidthVal)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.textFontSizeVal)).BeginInit();            this.previewGroupBox.SuspendLayout();            this.groupBox4.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.autoRulerValueVal)).BeginInit();            this.groupBox5.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.rulerMarginVal)).BeginInit();            this.groupBox6.SuspendLayout();            this.SuspendLayout();            //             // groupBox1            //             this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox1.Controls.Add(this.cancelBtn);            this.groupBox1.Controls.Add(this.saveBtn);            this.groupBox1.Location = new System.Drawing.Point(13, 13);            this.groupBox1.Name = "groupBox1";            this.groupBox1.Size = new System.Drawing.Size(508, 58);            this.groupBox1.TabIndex = 2;            this.groupBox1.TabStop = false;            this.groupBox1.Text = "操作";            //             // cancelBtn            //             this.cancelBtn.Anchor = System.Windows.Forms.AnchorStyles.Right;            this.cancelBtn.Location = new System.Drawing.Point(420, 21);            this.cancelBtn.Name = "cancelBtn";            this.cancelBtn.Size = new System.Drawing.Size(75, 23);            this.cancelBtn.TabIndex = 1;            this.cancelBtn.Text = "取消";            this.cancelBtn.UseVisualStyleBackColor = true;            this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);            //             // saveBtn            //             this.saveBtn.Anchor = System.Windows.Forms.AnchorStyles.Right;            this.saveBtn.Location = new System.Drawing.Point(339, 21);            this.saveBtn.Name = "saveBtn";            this.saveBtn.Size = new System.Drawing.Size(75, 23);            this.saveBtn.TabIndex = 0;            this.saveBtn.Text = "确定";            this.saveBtn.UseVisualStyleBackColor = true;            this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);            //             // groupBox2            //             this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox2.Controls.Add(this.textBold);            this.groupBox2.Controls.Add(this.label21);            this.groupBox2.Controls.Add(this.panel2);            this.groupBox2.Controls.Add(this.panel1);            this.groupBox2.Controls.Add(this.borderColorPanel);            this.groupBox2.Controls.Add(this.backColorPanel);            this.groupBox2.Controls.Add(this.textHeightVal);            this.groupBox2.Controls.Add(this.backgroundSizeVal);            this.groupBox2.Controls.Add(this.verticalLineLengthVal);            this.groupBox2.Controls.Add(this.borderWidthVal);            this.groupBox2.Controls.Add(this.lineWidthVal);            this.groupBox2.Controls.Add(this.textFontSizeVal);            this.groupBox2.Controls.Add(this.lineColorPanel);            this.groupBox2.Controls.Add(this.textColorPanel);            this.groupBox2.Controls.Add(this.textPositionVal);            this.groupBox2.Controls.Add(this.label19);            this.groupBox2.Controls.Add(this.label18);            this.groupBox2.Controls.Add(this.label17);            this.groupBox2.Controls.Add(this.textFontVal);            this.groupBox2.Controls.Add(this.label12);            this.groupBox2.Controls.Add(this.label8);            this.groupBox2.Controls.Add(this.label4);            this.groupBox2.Controls.Add(this.label11);            this.groupBox2.Controls.Add(this.label10);            this.groupBox2.Controls.Add(this.label3);            this.groupBox2.Controls.Add(this.label2);            this.groupBox2.Controls.Add(this.label9);            this.groupBox2.Controls.Add(this.label7);            this.groupBox2.Controls.Add(this.label1);            this.groupBox2.Controls.Add(this.label5);            this.groupBox2.Controls.Add(this.label6);            this.groupBox2.Location = new System.Drawing.Point(13, 77);            this.groupBox2.Name = "groupBox2";            this.groupBox2.Size = new System.Drawing.Size(508, 167);            this.groupBox2.TabIndex = 3;            this.groupBox2.TabStop = false;            this.groupBox2.Text = "样式设置";            //             // textBold            //             this.textBold.FormattingEnabled = true;            this.textBold.Location = new System.Drawing.Point(84, 138);            this.textBold.Name = "textBold";            this.textBold.Size = new System.Drawing.Size(72, 20);            this.textBold.TabIndex = 55;            this.textBold.SelectedIndexChanged += new System.EventHandler(this.textBold_SelectedIndexChanged);            //             // label21            //             this.label21.AutoSize = true;            this.label21.Location = new System.Drawing.Point(15, 142);            this.label21.Name = "label21";            this.label21.Size = new System.Drawing.Size(65, 12);            this.label21.TabIndex = 54;            this.label21.Text = "文字加粗:";            //             // panel2            //             this.panel2.BackColor = System.Drawing.SystemColors.WindowText;            this.panel2.Location = new System.Drawing.Point(333, 13);            this.panel2.Name = "panel2";            this.panel2.Size = new System.Drawing.Size(1, 146);            this.panel2.TabIndex = 53;            //             // panel1            //             this.panel1.BackColor = System.Drawing.SystemColors.WindowText;            this.panel1.Location = new System.Drawing.Point(166, 13);            this.panel1.Name = "panel1";            this.panel1.Size = new System.Drawing.Size(1, 146);            this.panel1.TabIndex = 53;            //             // borderColorPanel            //             this.borderColorPanel.BackColor = System.Drawing.SystemColors.Window;            this.borderColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;            this.borderColorPanel.Location = new System.Drawing.Point(427, 81);            this.borderColorPanel.Name = "borderColorPanel";            this.borderColorPanel.Size = new System.Drawing.Size(72, 21);            this.borderColorPanel.TabIndex = 52;            this.borderColorPanel.Click += new System.EventHandler(this.borderColorValPanel_Click);            //             // backColorPanel            //             this.backColorPanel.BackColor = System.Drawing.SystemColors.Window;            this.backColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;            this.backColorPanel.Location = new System.Drawing.Point(427, 23);            this.backColorPanel.Name = "backColorPanel";            this.backColorPanel.Size = new System.Drawing.Size(72, 21);            this.backColorPanel.TabIndex = 51;            this.backColorPanel.Click += new System.EventHandler(this.backColorPanel_Click);            //             // textHeightVal            //             this.textHeightVal.Location = new System.Drawing.Point(254, 110);            this.textHeightVal.Name = "textHeightVal";            this.textHeightVal.Size = new System.Drawing.Size(55, 21);            this.textHeightVal.TabIndex = 50;            this.textHeightVal.ValueChanged += new System.EventHandler(this.textHeightVal_ValueChanged);            //             // backgroundSizeVal            //             this.backgroundSizeVal.Location = new System.Drawing.Point(427, 52);            this.backgroundSizeVal.Name = "backgroundSizeVal";            this.backgroundSizeVal.Size = new System.Drawing.Size(55, 21);            this.backgroundSizeVal.TabIndex = 50;            this.backgroundSizeVal.ValueChanged += new System.EventHandler(this.backgroundSizeVal_ValueChanged);            //             // verticalLineLengthVal            //             this.verticalLineLengthVal.Location = new System.Drawing.Point(254, 81);            this.verticalLineLengthVal.Name = "verticalLineLengthVal";            this.verticalLineLengthVal.Size = new System.Drawing.Size(55, 21);            this.verticalLineLengthVal.TabIndex = 50;            this.verticalLineLengthVal.ValueChanged += new System.EventHandler(this.verticalLineLengthVal_ValueChanged);            //             // borderWidthVal            //             this.borderWidthVal.Location = new System.Drawing.Point(427, 109);            this.borderWidthVal.Name = "borderWidthVal";            this.borderWidthVal.Size = new System.Drawing.Size(72, 21);            this.borderWidthVal.TabIndex = 50;            this.borderWidthVal.ValueChanged += new System.EventHandler(this.borderWidthVal_ValueChanged);            //             // lineWidthVal            //             this.lineWidthVal.Location = new System.Drawing.Point(254, 53);            this.lineWidthVal.Minimum = new decimal(new int[] {            1,            0,            0,            0});            this.lineWidthVal.Name = "lineWidthVal";            this.lineWidthVal.Size = new System.Drawing.Size(72, 21);            this.lineWidthVal.TabIndex = 50;            this.lineWidthVal.Value = new decimal(new int[] {            1,            0,            0,            0});            this.lineWidthVal.ValueChanged += new System.EventHandler(this.lineWidthVal_ValueChanged);            //             // textFontSizeVal            //             this.textFontSizeVal.Location = new System.Drawing.Point(84, 23);            this.textFontSizeVal.Maximum = new decimal(new int[] {            49000,            0,            0,            0});            this.textFontSizeVal.Minimum = new decimal(new int[] {            1,            0,            0,            0});            this.textFontSizeVal.Name = "textFontSizeVal";            this.textFontSizeVal.Size = new System.Drawing.Size(72, 21);            this.textFontSizeVal.TabIndex = 50;            this.textFontSizeVal.Value = new decimal(new int[] {            1,            0,            0,            0});            this.textFontSizeVal.ValueChanged += new System.EventHandler(this.textFontSizeVal_ValueChanged);            //             // lineColorPanel            //             this.lineColorPanel.BackColor = System.Drawing.SystemColors.Window;            this.lineColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;            this.lineColorPanel.Location = new System.Drawing.Point(254, 23);            this.lineColorPanel.Name = "lineColorPanel";            this.lineColorPanel.Size = new System.Drawing.Size(72, 21);            this.lineColorPanel.TabIndex = 49;            this.lineColorPanel.Click += new System.EventHandler(this.lineColorPanel_Click);            //             // textColorPanel            //             this.textColorPanel.BackColor = System.Drawing.SystemColors.Window;            this.textColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;            this.textColorPanel.Location = new System.Drawing.Point(84, 81);            this.textColorPanel.Name = "textColorPanel";            this.textColorPanel.Size = new System.Drawing.Size(72, 21);            this.textColorPanel.TabIndex = 0;            this.textColorPanel.Click += new System.EventHandler(this.textColorPanel_Click);            //             // textPositionVal            //             this.textPositionVal.FormattingEnabled = true;            this.textPositionVal.Location = new System.Drawing.Point(84, 110);            this.textPositionVal.Name = "textPositionVal";            this.textPositionVal.Size = new System.Drawing.Size(72, 20);            this.textPositionVal.TabIndex = 40;            this.textPositionVal.SelectedIndexChanged += new System.EventHandler(this.textPositionVal_SelectedIndexChanged);            //             // label19            //             this.label19.AutoSize = true;            this.label19.Location = new System.Drawing.Point(488, 57);            this.label19.Name = "label19";            this.label19.Size = new System.Drawing.Size(11, 12);            this.label19.TabIndex = 37;            this.label19.Text = "%";            //             // label18            //             this.label18.AutoSize = true;            this.label18.Location = new System.Drawing.Point(314, 114);            this.label18.Name = "label18";            this.label18.Size = new System.Drawing.Size(11, 12);            this.label18.TabIndex = 35;            this.label18.Text = "%";            //             // label17            //             this.label17.AutoSize = true;            this.label17.Location = new System.Drawing.Point(315, 85);            this.label17.Name = "label17";            this.label17.Size = new System.Drawing.Size(11, 12);            this.label17.TabIndex = 32;            this.label17.Text = "%";            //             // textFontVal            //             this.textFontVal.FormattingEnabled = true;            this.textFontVal.Location = new System.Drawing.Point(84, 53);            this.textFontVal.Name = "textFontVal";            this.textFontVal.Size = new System.Drawing.Size(72, 20);            this.textFontVal.TabIndex = 0;            this.textFontVal.SelectedIndexChanged += new System.EventHandler(this.textFontVal_SelectedIndexChanged);            //             // label12            //             this.label12.AutoSize = true;            this.label12.Location = new System.Drawing.Point(349, 114);            this.label12.Name = "label12";            this.label12.Size = new System.Drawing.Size(65, 12);            this.label12.TabIndex = 33;            this.label12.Text = "边框线宽:";            //             // label8            //             this.label8.AutoSize = true;            this.label8.Location = new System.Drawing.Point(182, 114);            this.label8.Name = "label8";            this.label8.Size = new System.Drawing.Size(65, 12);            this.label8.TabIndex = 33;            this.label8.Text = "文字高度:";            //             // label4            //             this.label4.AutoSize = true;            this.label4.Location = new System.Drawing.Point(15, 114);            this.label4.Name = "label4";            this.label4.Size = new System.Drawing.Size(65, 12);            this.label4.TabIndex = 33;            this.label4.Text = "文字位置:";            //             // label11            //             this.label11.AutoSize = true;            this.label11.Location = new System.Drawing.Point(349, 27);            this.label11.Name = "label11";            this.label11.Size = new System.Drawing.Size(65, 12);            this.label11.TabIndex = 27;            this.label11.Text = "背景颜色:";            //             // label10            //             this.label10.AutoSize = true;            this.label10.Location = new System.Drawing.Point(349, 85);            this.label10.Name = "label10";            this.label10.Size = new System.Drawing.Size(65, 12);            this.label10.TabIndex = 31;            this.label10.Text = "边框颜色:";            //             // label3            //             this.label3.AutoSize = true;            this.label3.Location = new System.Drawing.Point(182, 27);            this.label3.Name = "label3";            this.label3.Size = new System.Drawing.Size(65, 12);            this.label3.TabIndex = 27;            this.label3.Text = "线条颜色:";            //             // label2            //             this.label2.AutoSize = true;            this.label2.Location = new System.Drawing.Point(182, 85);            this.label2.Name = "label2";            this.label2.Size = new System.Drawing.Size(65, 12);            this.label2.TabIndex = 31;            this.label2.Text = "垂线长度:";            //             // label9            //             this.label9.AutoSize = true;            this.label9.Location = new System.Drawing.Point(349, 57);            this.label9.Name = "label9";            this.label9.Size = new System.Drawing.Size(65, 12);            this.label9.TabIndex = 29;            this.label9.Text = "背景大小:";            //             // label7            //             this.label7.AutoSize = true;            this.label7.Location = new System.Drawing.Point(15, 27);            this.label7.Name = "label7";            this.label7.Size = new System.Drawing.Size(65, 12);            this.label7.TabIndex = 27;            this.label7.Text = "文字字号:";            //             // label1            //             this.label1.AutoSize = true;            this.label1.Location = new System.Drawing.Point(182, 57);            this.label1.Name = "label1";            this.label1.Size = new System.Drawing.Size(65, 12);            this.label1.TabIndex = 29;            this.label1.Text = "线条宽度:";            //             // label5            //             this.label5.AutoSize = true;            this.label5.Location = new System.Drawing.Point(15, 85);            this.label5.Name = "label5";            this.label5.Size = new System.Drawing.Size(65, 12);            this.label5.TabIndex = 31;            this.label5.Text = "文字颜色:";            //             // label6            //             this.label6.AutoSize = true;            this.label6.Location = new System.Drawing.Point(15, 57);            this.label6.Name = "label6";            this.label6.Size = new System.Drawing.Size(65, 12);            this.label6.TabIndex = 29;            this.label6.Text = "文字字体:";            //             // previewGroupBox            //             this.previewGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.previewGroupBox.Controls.Add(this.previewPanel);            this.previewGroupBox.Location = new System.Drawing.Point(13, 246);            this.previewGroupBox.Name = "previewGroupBox";            this.previewGroupBox.Size = new System.Drawing.Size(508, 180);            this.previewGroupBox.TabIndex = 4;            this.previewGroupBox.TabStop = false;            this.previewGroupBox.Text = "预览";            //             // previewPanel            //             this.previewPanel.Location = new System.Drawing.Point(7, 12);            this.previewPanel.Name = "previewPanel";            this.previewPanel.Size = new System.Drawing.Size(495, 153);            this.previewPanel.TabIndex = 0;            this.previewPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.previewPanel_Paint);            //             // groupBox4            //             this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox4.Controls.Add(this.autoRulerValueVal);            this.groupBox4.Controls.Add(this.label14);            this.groupBox4.Controls.Add(this.label13);            this.groupBox4.Location = new System.Drawing.Point(13, 417);            this.groupBox4.Name = "groupBox4";            this.groupBox4.Size = new System.Drawing.Size(246, 90);            this.groupBox4.TabIndex = 5;            this.groupBox4.TabStop = false;            this.groupBox4.Text = "自动标注";            //             // autoRulerValueVal            //             this.autoRulerValueVal.Location = new System.Drawing.Point(110, 37);            this.autoRulerValueVal.Maximum = new decimal(new int[] {            1410065407,            2,            0,            0});            this.autoRulerValueVal.Name = "autoRulerValueVal";            this.autoRulerValueVal.Size = new System.Drawing.Size(117, 21);            this.autoRulerValueVal.TabIndex = 51;            this.autoRulerValueVal.ValueChanged += new System.EventHandler(this.autoRulerValueVal_ValueChanged);            //             // label14            //             this.label14.AutoSize = true;            this.label14.Location = new System.Drawing.Point(150, 61);            this.label14.Name = "label14";            this.label14.Size = new System.Drawing.Size(77, 12);            this.label14.TabIndex = 37;            this.label14.Text = "除以放大倍数";            //             // label13            //             this.label13.AutoSize = true;            this.label13.Location = new System.Drawing.Point(15, 41);            this.label13.Name = "label13";            this.label13.Size = new System.Drawing.Size(89, 12);            this.label13.TabIndex = 35;            this.label13.Text = "自动长度计算:";            //             // groupBox5            //             this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox5.Controls.Add(this.rulerMarginVal);            this.groupBox5.Controls.Add(this.label20);            this.groupBox5.Controls.Add(this.label16);            this.groupBox5.Controls.Add(this.rulerPositionVal2);            this.groupBox5.Controls.Add(this.rulerPositionVal4);            this.groupBox5.Controls.Add(this.rulerPositionVal3);            this.groupBox5.Controls.Add(this.rulerPositionVal1);            this.groupBox5.Controls.Add(this.label15);            this.groupBox5.Location = new System.Drawing.Point(269, 417);            this.groupBox5.Name = "groupBox5";            this.groupBox5.Size = new System.Drawing.Size(252, 90);            this.groupBox5.TabIndex = 6;            this.groupBox5.TabStop = false;            this.groupBox5.Text = "标尺位置";            //             // rulerMarginVal            //             this.rulerMarginVal.DecimalPlaces = 2;            this.rulerMarginVal.Location = new System.Drawing.Point(77, 57);            this.rulerMarginVal.Name = "rulerMarginVal";            this.rulerMarginVal.Size = new System.Drawing.Size(132, 21);            this.rulerMarginVal.TabIndex = 52;            this.rulerMarginVal.ValueChanged += new System.EventHandler(this.rulerMarginVal_ValueChanged);            //             // label20            //             this.label20.AutoSize = true;            this.label20.Location = new System.Drawing.Point(215, 61);            this.label20.Name = "label20";            this.label20.Size = new System.Drawing.Size(11, 12);            this.label20.TabIndex = 51;            this.label20.Text = "%";            //             // label16            //             this.label16.AutoSize = true;            this.label16.Location = new System.Drawing.Point(6, 61);            this.label16.Name = "label16";            this.label16.Size = new System.Drawing.Size(65, 12);            this.label16.TabIndex = 43;            this.label16.Text = "标注边距:";            //             // rulerPositionVal2            //             this.rulerPositionVal2.AutoSize = true;            this.rulerPositionVal2.Location = new System.Drawing.Point(155, 13);            this.rulerPositionVal2.Name = "rulerPositionVal2";            this.rulerPositionVal2.Size = new System.Drawing.Size(47, 16);            this.rulerPositionVal2.TabIndex = 42;            this.rulerPositionVal2.TabStop = true;            this.rulerPositionVal2.Text = "右上";            this.rulerPositionVal2.UseVisualStyleBackColor = true;            this.rulerPositionVal2.CheckedChanged += new System.EventHandler(this.rulerPositionVal2_CheckedChanged);            //             // rulerPositionVal4            //             this.rulerPositionVal4.AutoSize = true;            this.rulerPositionVal4.Location = new System.Drawing.Point(155, 35);            this.rulerPositionVal4.Name = "rulerPositionVal4";            this.rulerPositionVal4.Size = new System.Drawing.Size(47, 16);            this.rulerPositionVal4.TabIndex = 41;            this.rulerPositionVal4.TabStop = true;            this.rulerPositionVal4.Text = "右下";            this.rulerPositionVal4.UseVisualStyleBackColor = true;            this.rulerPositionVal4.CheckedChanged += new System.EventHandler(this.rulerPositionVal4_CheckedChanged);            //             // rulerPositionVal3            //             this.rulerPositionVal3.AutoSize = true;            this.rulerPositionVal3.Location = new System.Drawing.Point(100, 35);            this.rulerPositionVal3.Name = "rulerPositionVal3";            this.rulerPositionVal3.Size = new System.Drawing.Size(47, 16);            this.rulerPositionVal3.TabIndex = 40;            this.rulerPositionVal3.TabStop = true;            this.rulerPositionVal3.Text = "左下";            this.rulerPositionVal3.UseVisualStyleBackColor = true;            this.rulerPositionVal3.CheckedChanged += new System.EventHandler(this.rulerPositionVal3_CheckedChanged);            //             // rulerPositionVal1            //             this.rulerPositionVal1.AutoSize = true;            this.rulerPositionVal1.Checked = true;            this.rulerPositionVal1.Location = new System.Drawing.Point(100, 13);            this.rulerPositionVal1.Name = "rulerPositionVal1";            this.rulerPositionVal1.Size = new System.Drawing.Size(47, 16);            this.rulerPositionVal1.TabIndex = 39;            this.rulerPositionVal1.TabStop = true;            this.rulerPositionVal1.Text = "左上";            this.rulerPositionVal1.UseVisualStyleBackColor = true;            this.rulerPositionVal1.CheckedChanged += new System.EventHandler(this.rulerPositionVal1_CheckedChanged);            //             // label15            //             this.label15.AutoSize = true;            this.label15.Location = new System.Drawing.Point(6, 26);            this.label15.Name = "label15";            this.label15.Size = new System.Drawing.Size(65, 12);            this.label15.TabIndex = 38;            this.label15.Text = "标尺位置:";            //             // groupBox6            //             this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox6.Controls.Add(this.listView1);            this.groupBox6.Controls.Add(this.addRulerBtn);            this.groupBox6.Controls.Add(this.deleteRulerBtn);            this.groupBox6.Location = new System.Drawing.Point(13, 513);            this.groupBox6.Name = "groupBox6";            this.groupBox6.Size = new System.Drawing.Size(508, 122);            this.groupBox6.TabIndex = 7;            this.groupBox6.TabStop = false;            this.groupBox6.Text = "预存标注";            //             // listView1            //             this.listView1.FullRowSelect = true;            this.listView1.GridLines = true;            this.listView1.HideSelection = false;            this.listView1.Location = new System.Drawing.Point(0, 37);            this.listView1.MultiSelect = false;            this.listView1.Name = "listView1";            this.listView1.ShowItemToolTips = true;            this.listView1.Size = new System.Drawing.Size(508, 85);            this.listView1.TabIndex = 5;            this.listView1.UseCompatibleStateImageBehavior = false;            this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);            //             // addRulerBtn            //             this.addRulerBtn.Location = new System.Drawing.Point(351, 8);            this.addRulerBtn.Name = "addRulerBtn";            this.addRulerBtn.Size = new System.Drawing.Size(75, 23);            this.addRulerBtn.TabIndex = 4;            this.addRulerBtn.Text = "+";            this.addRulerBtn.UseVisualStyleBackColor = true;            this.addRulerBtn.Click += new System.EventHandler(this.addRulerBtn_Click);            //             // deleteRulerBtn            //             this.deleteRulerBtn.Location = new System.Drawing.Point(427, 8);            this.deleteRulerBtn.Name = "deleteRulerBtn";            this.deleteRulerBtn.Size = new System.Drawing.Size(75, 23);            this.deleteRulerBtn.TabIndex = 2;            this.deleteRulerBtn.Text = "-";            this.deleteRulerBtn.UseVisualStyleBackColor = true;            this.deleteRulerBtn.Click += new System.EventHandler(this.deleteRulerBtn_Click);            //             // RulerSettingDialog            //             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;            this.ClientSize = new System.Drawing.Size(533, 646);            this.Controls.Add(this.groupBox6);            this.Controls.Add(this.groupBox5);            this.Controls.Add(this.groupBox4);            this.Controls.Add(this.previewGroupBox);            this.Controls.Add(this.groupBox1);            this.Controls.Add(this.groupBox2);            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;            this.MaximizeBox = false;            this.MinimizeBox = false;            this.Name = "RulerSettingDialog";            this.ShowIcon = false;            this.Text = "标尺设置";            this.Controls.SetChildIndex(this.groupBox2, 0);            this.Controls.SetChildIndex(this.groupBox1, 0);            this.Controls.SetChildIndex(this.previewGroupBox, 0);            this.Controls.SetChildIndex(this.groupBox4, 0);            this.Controls.SetChildIndex(this.groupBox5, 0);            this.Controls.SetChildIndex(this.groupBox6, 0);            this.groupBox1.ResumeLayout(false);            this.groupBox2.ResumeLayout(false);            this.groupBox2.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.textHeightVal)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.backgroundSizeVal)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.verticalLineLengthVal)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.borderWidthVal)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.lineWidthVal)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.textFontSizeVal)).EndInit();            this.previewGroupBox.ResumeLayout(false);            this.groupBox4.ResumeLayout(false);            this.groupBox4.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.autoRulerValueVal)).EndInit();            this.groupBox5.ResumeLayout(false);            this.groupBox5.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.rulerMarginVal)).EndInit();            this.groupBox6.ResumeLayout(false);            this.ResumeLayout(false);        }        #endregion        #region InitializeComponent2        /// <summary>        /// 初始化组件        /// </summary>        private void InitializeComponent2()        {            this.listView1.View = View.Details;            ColumnHeader header = new ColumnHeader();            header.Text = PdnResources.GetString("Menu.name.text");            header.Width = 240;            this.listView1.Columns.Add(header);            header = new ColumnHeader();            header.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text");            header.Width = 240;            this.listView1.Columns.Add(header);            System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();            ArrayList fontsItems = new ArrayList();            foreach (FontFamily fontFamily in fonts.Families)            {                fontsItems.Add(fontFamily.Name);            }            this.textFontVal.DataSource = fontsItems;            this.textPositionVal.DataSource = new string[] { PdnResources.GetString("Menu.Set.Rulersettings.Left.text"),                PdnResources.GetString("Menu.nthemiddle.Text")                , PdnResources.GetString("Menu.Set.Rulersettings.Right.text") };            this.textBold.DataSource = new string[] { PdnResources.GetString("Menu.no.text") ,PdnResources.GetString("Menu.Yes.text")};            this.colorsFormFont = new ColorsForm();            this.colorsFormFont.StartPosition = FormStartPosition.CenterScreen;            this.colorsFormFont.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);            this.colorsFormLine = new ColorsForm();            this.colorsFormLine.StartPosition = FormStartPosition.CenterScreen;            this.colorsFormLine.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);            this.colorsFormBackground = new ColorsForm();            this.colorsFormBackground.StartPosition = FormStartPosition.CenterScreen;            this.colorsFormBackground.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);            this.colorsFormBorder = new ColorsForm();            this.colorsFormBorder.StartPosition = FormStartPosition.CenterScreen;            this.colorsFormBorder.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);        }        #endregion        #region addRulerformInit        /// <summary>        /// 新增预存标注        /// </summary>        private void addRulerformInit()        {            this.addRulerform.StartPosition = FormStartPosition.CenterScreen;            this.addRulerform.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;            this.addRulerform.FormBorderStyle = FormBorderStyle.FixedSingle;            this.addRulerform.ClientSize = new System.Drawing.Size(330, 105);            this.addRulerform.MaximizeBox = false;            this.addRulerform.MinimizeBox = false;            this.addRulerform.Name = "addRulerDialog";            this.addRulerform.ShowIcon = false;            this.addRulerform.Text = PdnResources.GetString("Menu.Set.Rulersettings.Newpre-storedannotation.text");            Label nameLabel = new Label();            nameLabel.Location = new System.Drawing.Point(15, 15);            nameLabel.Size = new System.Drawing.Size(45, 12);            nameLabel.Name = "nameLabel";            nameLabel.Text = PdnResources.GetString("Menu.name.text")+":";            this.nameValue.Location = new System.Drawing.Point(60, 11);            this.nameValue.Name = "nameValue";            this.nameValue.Size = new System.Drawing.Size(250, 21);            this.nameValue.TextChanged += new System.EventHandler(this.nameValue_TextChanged);            Label lengthLabel = new Label();            lengthLabel.Location = new System.Drawing.Point(15, 42);            lengthLabel.Size = new System.Drawing.Size(45, 12);            lengthLabel.Name = "lengthLabel";            lengthLabel.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text")+":";            this.lengthVal.Location = new System.Drawing.Point(60, 38);            this.lengthVal.Name = "lengthVal";            this.lengthVal.Size = new System.Drawing.Size(50, 21);            this.lengthVal.ValueChanged += new System.EventHandler(this.lengthVal_ValueChanged);            this.lengthVal.Maximum = 9999999999;            Label descriptionLabel = new Label();            descriptionLabel.Location = new System.Drawing.Point(115, 42);            descriptionLabel.Size = new System.Drawing.Size(230, 12);            descriptionLabel.Name = "descriptionLabel";            descriptionLabel.Text = PdnResources.GetString("Menu.Micronoronethousandthofanin.Text");            Button saveButton = new Button();            saveButton.Location = new System.Drawing.Point(235, 69);            saveButton.Name = "saveButton";            saveButton.Size = new System.Drawing.Size(75, 23);            saveButton.Text = PdnResources.GetString("Menu.File.Save.Text");            saveButton.UseVisualStyleBackColor = true;            saveButton.Click += new System.EventHandler(this.saveButton_Click);            this.addRulerform.Controls.Add(nameLabel);            this.addRulerform.Controls.Add(nameValue);            this.addRulerform.Controls.Add(lengthLabel);            this.addRulerform.Controls.Add(lengthVal);            this.addRulerform.Controls.Add(descriptionLabel);            this.addRulerform.Controls.Add(saveButton);        }        #endregion        #endregion        #region 事件        #region 主要窗体事件        private void saveBtn_Click(object sender, EventArgs e)        {            string stageModelXml = XmlSerializeHelper.XmlSerialize<RulerModel>(this.rulerModel);            string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Ruler.xml";            if (FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create))            {                Startup.instance.rulerModel = this.rulerModel;                this.Close();            }            else            {                MessageBox.Show(PdnResources.GetString("Menu.Rulerinformationsavingfaile.Text"));            }        }        private void cancelBtn_Click(object sender, EventArgs e)        {            this.Close();        }        private void textFontSizeVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.textFontSize = this.textFontSizeVal.Value;            this.previewPanel.Invalidate();        }        private void textFontVal_SelectedIndexChanged(object sender, EventArgs e)        {            this.rulerModel.textFont = this.textFontVal.Text;            this.previewPanel.Invalidate();        }        private void textColorPanel_Click(object sender, EventArgs e)        {            this.colorsFormFont.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.textColor));            this.colorsFormFont.setSaveBtn_Click(new System.EventHandler(this.textColorChanged));            this.colorsFormFont.ShowDialog();        }        private void textPositionVal_SelectedIndexChanged(object sender, EventArgs e)        {            this.rulerModel.textPosition = this.textPositionVal.SelectedIndex;            this.previewPanel.Invalidate();        }        private void textBold_SelectedIndexChanged(object sender, EventArgs e)        {            this.rulerModel.textBold = this.textBold.SelectedIndex;            this.previewPanel.Invalidate();        }        private void lineColorPanel_Click(object sender, EventArgs e)        {            this.colorsFormLine.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.lineColor));            this.colorsFormLine.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));            this.colorsFormLine.ShowDialog();        }        private void lineWidthVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.lineWidth = this.lineWidthVal.Value;            this.previewPanel.Invalidate();        }        private void verticalLineLengthVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.verticalLineLength = this.verticalLineLengthVal.Value;            this.previewPanel.Invalidate();        }        private void textHeightVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.textHeight = this.textHeightVal.Value;            this.previewPanel.Invalidate();        }        private void backColorPanel_Click(object sender, EventArgs e)        {            this.colorsFormBackground.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.backColor));            this.colorsFormBackground.setSaveBtn_Click(new System.EventHandler(this.backColorChanged));            this.colorsFormBackground.ShowDialog();        }        private void backgroundSizeVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.backgroundSize = this.backgroundSizeVal.Value;            this.previewPanel.Invalidate();        }        private void borderColorValPanel_Click(object sender, EventArgs e)        {            this.colorsFormBorder.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.borderColor));            this.colorsFormBorder.setSaveBtn_Click(new System.EventHandler(this.borderColorChanged));            this.colorsFormBorder.ShowDialog();        }        private void borderWidthVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.borderWidth = this.borderWidthVal.Value;            this.previewPanel.Invalidate();        }        private void autoRulerValueVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.autoRulerValue = this.autoRulerValueVal.Value;        }        private void rulerPositionVal1_CheckedChanged(object sender, EventArgs e)        {            this.rulerModel.rulerPosition = 1;        }        private void rulerPositionVal2_CheckedChanged(object sender, EventArgs e)        {            this.rulerModel.rulerPosition = 2;        }        private void rulerPositionVal3_CheckedChanged(object sender, EventArgs e)        {            this.rulerModel.rulerPosition = 3;        }        private void rulerPositionVal4_CheckedChanged(object sender, EventArgs e)        {            this.rulerModel.rulerPosition = 4;        }        private void rulerMarginVal_ValueChanged(object sender, EventArgs e)        {            this.rulerModel.rulerMargin = this.rulerMarginVal.Value;        }        private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)        {        }        private void textColorChanged(object sender, EventArgs e)        {            this.textColorPanel.BackColor = this.colorsFormFont.UserPrimaryColor.ToColor();            this.rulerModel.textColor = this.colorsFormFont.UserPrimaryColor.ToColor().ToArgb();            this.colorsFormFont.Close();            this.previewPanel.Invalidate();        }        private void lineColorChanged(object sender, EventArgs e)        {            this.lineColorPanel.BackColor = this.colorsFormLine.UserPrimaryColor.ToColor();            this.rulerModel.lineColor = this.colorsFormLine.UserPrimaryColor.ToColor().ToArgb();            this.colorsFormLine.Close();            this.previewPanel.Invalidate();        }        private void backColorChanged(object sender, EventArgs e)        {            this.backColorPanel.BackColor = this.colorsFormBackground.UserPrimaryColor.ToColor();            this.rulerModel.backColor = this.colorsFormBackground.UserPrimaryColor.ToColor().ToArgb();            this.colorsFormBackground.Close();            this.previewPanel.Invalidate();        }        private void borderColorChanged(object sender, EventArgs e)        {            this.borderColorPanel.BackColor = this.colorsFormBorder.UserPrimaryColor.ToColor();            this.rulerModel.borderColor = this.colorsFormBorder.UserPrimaryColor.ToColor().ToArgb();            this.colorsFormBorder.Close();            this.previewPanel.Invalidate();        }        private void previewPanel_Paint(object sender, PaintEventArgs e)        {            Point center = new Point(this.previewPanel.Width / 2, this.previewPanel.Height * 3 / 4);            DrawRulerHelper.drawRuler(this.rulerModel, e.Graphics, center, 200, "100μm", out RectangleF rectangleF);        }        private void addRulerBtn_Click(object sender, EventArgs e)        {            this.nameValue.Text = null;            this.lengthVal.Value = 0;            this.addRulerform.ShowDialog(this);        }        private void deleteRulerBtn_Click(object sender, EventArgs e)        {            if (this.listView1.SelectedItems.Count <= 0)                return;            if (MessageBox.Show(PdnResources.GetString("Menu.eyousureyouwanttodeletetheselectedsaved.Text")+"?", PdnResources.GetString("Menu.Thisdeletioncannotberecovered.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)            {                ListViewItem item = this.listView1.SelectedItems[0];                int indexNum = item.Index;                bool reSelected = false;                if (indexNum > 0 && indexNum + 1 != this.listView1.Items.Count)                    reSelected = true;                this.rulerModel.presetRulers.Remove(this.rulerModel.presetRulers[item.Index]);                this.buildListView();                if (reSelected)                {                    this.listView1.Items[indexNum].Selected = true;                }            }        }        private void listView1_SelectedIndexChanged(object sender, EventArgs e)        {            ListViewItem defaultItem = new ListViewItem();            foreach (ListViewItem listViewItem in this.listView1.Items)            {                listViewItem.ForeColor = defaultItem.ForeColor;                listViewItem.BackColor = defaultItem.BackColor;            }            if (this.listView1.SelectedItems.Count <= 0)            {                return;            }            ListViewItem item = this.listView1.SelectedItems[0];            item.ForeColor = Color.White;            item.BackColor = Color.FromArgb(0, 120, 215);        }        #endregion        #region 新增预存标注窗体事件        private void nameValue_TextChanged(object sender, EventArgs e)        {            this.tempPresetRuler.name = ((TextBox)sender).Text;        }        private void lengthVal_ValueChanged(object sender, EventArgs e)        {            this.tempPresetRuler.length = ((NumericUpDown)sender).Value;        }        private void saveButton_Click(object sender, EventArgs e)        {            if (String.IsNullOrEmpty(this.tempPresetRuler.name))            {                MessageBox.Show(PdnResources.GetString("Menu.Pleasefillinthename.Text"));                return;            }            this.rulerModel.presetRulers.Add(this.tempPresetRuler);            this.tempPresetRuler = new PresetRuler();            buildListView();            this.addRulerform.Close();        }        #endregion        #endregion        #region 读取数据        /// <summary>        /// 读取数据        /// </summary>        private void readData()        {            //this.rulerModel = Startup.instance.rulerModel;//原有获取方式改变设置项后标尺样式即时刷新            this.rulerModel = XmlSerializeHelper.DESerializer<RulerModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Ruler.xml", FileMode.Open));            this.textFontSizeVal.Value = this.rulerModel.textFontSize;            this.textFontVal.Text = this.rulerModel.textFont;            //this.textColorVal.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.textColor));            this.textPositionVal.SelectedIndex = this.rulerModel.textPosition;            this.textBold.SelectedIndex = this.rulerModel.textBold;            //this.lineColorVal.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.lineColor));            this.lineWidthVal.Value = this.rulerModel.lineWidth;            this.verticalLineLengthVal.Value = this.rulerModel.verticalLineLength;            this.textHeightVal.Value = this.rulerModel.textHeight;            //this.backColorVal.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.backColor));            this.backgroundSizeVal.Value = this.rulerModel.backgroundSize;            //this.borderColorVal.UserPrimaryColor = ColorBgra.FromColor(Color.FromArgb(this.rulerModel.borderColor));            this.borderWidthVal.Value = this.rulerModel.borderWidth;            this.textColorPanel.BackColor = Color.FromArgb(this.rulerModel.textColor);            this.lineColorPanel.BackColor = Color.FromArgb(this.rulerModel.lineColor);            this.backColorPanel.BackColor = Color.FromArgb(this.rulerModel.backColor);            this.borderColorPanel.BackColor = Color.FromArgb(this.rulerModel.borderColor);            this.autoRulerValueVal.Value = this.rulerModel.autoRulerValue;            switch (this.rulerModel.rulerPosition)            {                case 1: this.rulerPositionVal1.Checked = true; break;                case 2: this.rulerPositionVal2.Checked = true; break;                case 3: this.rulerPositionVal3.Checked = true; break;                case 4: this.rulerPositionVal4.Checked = true; break;            }            this.rulerMarginVal.Value = this.rulerModel.rulerMargin;        }        #endregion        #region 其他        /// <summary>        /// 构建ListView数据        /// </summary>        private void buildListView()        {            this.listView1.Items.Clear();            this.listView1.BeginUpdate();            foreach (PresetRuler presetRuler in this.rulerModel.presetRulers)            {                ListViewItem lvi = new ListViewItem();                lvi.Text = presetRuler.name.ToString();                lvi.SubItems.Add(presetRuler.length.ToString());                this.listView1.Items.Add(lvi);            }            this.listView1.EndUpdate();            if (this.listView1.Items.Count > 0)            {                this.listView1.Items[0].Selected = true;            }        }        #endregion    }}
 |