123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353 |
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.Base.CommTool;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.Entity.Core.Metadata.Edm;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- using PaintDotNet.DedicatedAnalysis.GrainSize;
- namespace PaintDotNet.DedicatedAnalysis
- {
- /// <summary>
- /// 晶粒度(仲裁法)辅助线设置
- /// </summary>
- public partial class ArbitrationLawGuideDialog : Form
- {
- #region 控件
- private GroupBox groupBox2;
- private GroupBox groupBox3;
- private Button button1;
- private Button button2;
- private Label label3;
- private Label label2;
- private Panel panel1;
- private Panel panel2;
- private GroupBox groupBox1;
- private NumericUpDown numericUpDown2;
- private GroupBox groupBox4;
- private Button button5;
- private Button button4;
- private Button button3;
- private Label label7;
- private TextBox textBox1;
- private ComboBox comboBox1;
- private DataGridView dataGridView1;
- #endregion
- /// <summary>
- /// 字体列表
- /// </summary>
- ArrayList fontsItems = new ArrayList();
- /// <summary>
- /// 超出尺寸
- /// </summary>
- private bool exceed;
- /// <summary>
- /// 调色板
- /// </summary>
- PaintDotNet.ColorsForm colorsForm;
- /// <summary>
- /// 操作区分(0 :添加 1 :编辑)
- /// </summary>
- private int operation = -1;
- /// <summary>
- /// 临时数据
- /// </summary>
- private List<ArrayList> arrayLists = new List<ArrayList>();
- /// <summary>
- /// 跳转画面 0:截点法 1:面积法
- /// </summary>
- private int picture;
- /// <summary>
- /// 直径
- /// </summary>
- public int diameter;
- /// <summary>
- /// 边距
- /// </summary>
- public int margin;
- /// <summary>
- /// 长度(垂线)
- /// </summary>
- public int vLineLength;
- /// <summary>
- /// 长度(水平线)
- /// </summary>
- public int hLineLength;
- /// <summary>
- /// 左上到右下斜线长度
- /// </summary>
- public int TopleftLineLength;
- /// <summary>
- /// 左下到右上斜线长度
- /// </summary>
- public int ToprightLineLength;
- /// <summary>
- /// 垂线到圆距离
- /// </summary>
- public int VLineToCDistance;
- /// <summary>
- /// 水平线到圆距离
- /// </summary>
- public int HLineToCDistance;
- /// <summary>
- /// 线宽
- /// </summary>
- public int lineWidth;
- /// %
- /// </summary>
- public decimal percentage;
- private Label label24;
- private NumericUpDown numericUpDown5;
- private Label label6;
- private NumericUpDown numericUpDown4;
- private Label label5;
- private NumericUpDown numericUpDown3;
- private Label label4;
- private NumericUpDown numericUpDown1;
- private Label label1;
- private DataGridViewTextBoxColumn GuideName;
- private int width;
- private int height;
- private ToolTip toolTip1;
- private IContainer components;
- /// <summary>
- /// 排列顺序
- /// </summary>
- private int index = 0;
- public ArbitrationLawGuideDialog(int width, int height)
- {
- this.width = width;
- this.height = height;
- InitializeComponent();
- InitializeLanguageText();
- InitializeButtonBackgroudImage();
- InitializeToolTip();
- InitializeData();
- //调色板
- this.colorsForm = new ColorsForm();
- this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- }
- private void InitializeToolTip()
- {
- this.toolTip1 = new ToolTip();
- this.toolTip1.SetToolTip(this.button3, PdnResources.GetString("Menu.Addto.text"));
- this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Edit.Text"));
- this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Edit.Delete.Text"));
- this.toolTip1.ShowAlways = true;
- }
- private void InitializeButtonBackgroudImage()
- {
- this.button3.FlatStyle = FlatStyle.Flat;
- this.button3.FlatAppearance.BorderSize = 0;
- this.button3.BackgroundImageLayout = ImageLayout.Center;
- this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListAddIcon.png").Reference;
- this.button4.FlatStyle = FlatStyle.Flat;
- this.button4.FlatAppearance.BorderSize = 0;
- this.button4.BackgroundImageLayout = ImageLayout.Center;
- this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListEditIcon.png").Reference;
- this.button5.FlatStyle = FlatStyle.Flat;
- this.button5.FlatAppearance.BorderSize = 0;
- this.button5.BackgroundImageLayout = ImageLayout.Center;
- this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListDeleteIcon.png").Reference;
- }
- private void RefreshGridIntersections()
- {
- float hGridSpacingDraw;
- float vGridSpacingDraw;
- if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
- {
- float space = 1;
- //避免不必要的提示网格尺寸已超出图像
- if (this.numericUpDown5.Value > 0)
- space = (float)this.numericUpDown5.Value;
- hGridSpacingDraw = (float)(this.height - 2 * Convert.ToInt32(space)) / (Convert.ToInt32(this.numericUpDown1.Value) - 1);
- vGridSpacingDraw = (float)(this.width - 2 * Convert.ToInt32(space)) / ( Convert.ToInt32(this.numericUpDown3.Value) - 1);
- }
- else
- {
- hGridSpacingDraw = Convert.ToInt32(this.numericUpDown4.Value);
- vGridSpacingDraw = Convert.ToInt32(this.numericUpDown4.Value);
- }
- exceed = false;
- ArrayList xs = new ArrayList();
- ArrayList ys = new ArrayList();
- if ( Convert.ToInt32(this.numericUpDown1.Value) > 0)
- {
- if ( Convert.ToInt32(this.numericUpDown1.Value) % 2 == 0)
- {
- float Spacing = hGridSpacingDraw / 2;
- for (int i = 0; i < Convert.ToInt32(this.numericUpDown1.Value) / 2; i++)
- {
- if ((float)this.height / 2 - Spacing >= 0
- && (float)this.height / 2 + Spacing <= this.height)
- {
- ys.Add((float)this.height / 2 - Spacing);
- ys.Add((float)this.height / 2 + Spacing);
- }
- else
- exceed = true;
- Spacing += hGridSpacingDraw;
- }
- }
- else
- {
- if ( Convert.ToInt32(this.numericUpDown1.Value) == 1)
- ys.Add((float)this.height / 2);
- else
- {
- float Spacing = hGridSpacingDraw;
- for (int i = 0; i < ( Convert.ToInt32(this.numericUpDown1.Value) - 1) / 2; i++)
- {
- if (i == 0)
- ys.Add((float)this.height / 2);
- if ((float)this.height / 2 - Spacing >= 0
- && (float)this.height / 2 + Spacing <= this.height)
- {
- ys.Add((float)this.height / 2 - Spacing);
- ys.Add((float)this.height / 2 + Spacing);
- }
- else
- exceed = true;
- Spacing += hGridSpacingDraw;
- }
- }
- }
- }
- if ( Convert.ToInt32(this.numericUpDown3.Value) > 0)
- {
- if ( Convert.ToInt32(this.numericUpDown3.Value) % 2 == 0)
- {
- float Spacing = vGridSpacingDraw / 2;
- for (int i = 0; i < Convert.ToInt32(this.numericUpDown3.Value) / 2; i++)
- {
- if ((float)this.width / 2 - Spacing >= 0
- && (float)this.width / 2 + Spacing <= this.width)
- {
- xs.Add((float)this.width / 2 - Spacing);
- xs.Add((float)this.width / 2 + Spacing);
- }
- else
- exceed = true;
- Spacing += vGridSpacingDraw;
- }
- }
- else
- {
- if ( Convert.ToInt32(this.numericUpDown3.Value) == 1)
- xs.Add((float)this.width / 2);
- else
- {
- float Spacing = vGridSpacingDraw;
- for (int i = 0; i < ( Convert.ToInt32(this.numericUpDown3.Value) - 1) / 2; i++)
- {
- if (i == 0)
- xs.Add((float)this.width / 2);
- if ((float)this.width / 2 + Spacing <= this.width
- && (float)this.width / 2 - Spacing >= 0)
- {
- xs.Add((float)this.width / 2 - Spacing);
- xs.Add((float)this.width / 2 + Spacing);
- }
- else
- exceed = true;
- Spacing += vGridSpacingDraw;
- }
- }
- }
- }
- if(exceed)
- MessageBox.Show(PdnResources.GetString("Menu.Thegridsizehasexceededtheimage.text")+"!");
- }
- #region 初始化
- private void InitializeLanguageText()
- {
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button2.Text = PdnResources.GetString("CommonAction.Save");
- this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Tools.AuxiliaryLine.Text");
- this.label6.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Gridmargin.text") + ":";
- this.label5.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Gridspacing.text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Numberofvertical.text") + ":";
- this.label1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thelevelofthenumber.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.Gridlinewidth.text") + ":";
- this.comboBox1.Items.AddRange(new object[] {
- PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text"),
- PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text")});
- this.label7.Text = PdnResources.GetString("Menu.name.text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.Gridcolor.text") + ":";
- this.label24.Text = PdnResources.GetString("Menu.Type.text") + ":";
- this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Preview.text");
- this.Text = PdnResources.GetString("Menu.Auxiliarylinestylesettings.text");
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
- this.label6 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.label4 = new System.Windows.Forms.Label();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.label3 = new System.Windows.Forms.Label();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.panel2 = new System.Windows.Forms.Panel();
- this.label7 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label24 = new System.Windows.Forms.Label();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.panel1 = new System.Windows.Forms.Panel();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.GuideName = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.button5 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- this.groupBox3.SuspendLayout();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(12, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(500, 54);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(414, 16);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(70, 28);
- this.button2.TabIndex = 1;
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(325, 16);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(70, 28);
- this.button1.TabIndex = 0;
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.numericUpDown5);
- this.groupBox2.Controls.Add(this.numericUpDown4);
- this.groupBox2.Controls.Add(this.label6);
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.numericUpDown3);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.numericUpDown1);
- this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Controls.Add(this.numericUpDown2);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Controls.Add(this.comboBox1);
- this.groupBox2.Controls.Add(this.textBox1);
- this.groupBox2.Controls.Add(this.panel2);
- this.groupBox2.Controls.Add(this.label7);
- this.groupBox2.Controls.Add(this.label2);
- this.groupBox2.Controls.Add(this.label24);
- this.groupBox2.Location = new System.Drawing.Point(193, 72);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(319, 177);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- //
- // numericUpDown5
- //
- this.numericUpDown5.Location = new System.Drawing.Point(90, 116);
- this.numericUpDown5.Maximum = new decimal(new int[] {
- 10000,
- 0,
- 0,
- 0});
- this.numericUpDown5.Name = "numericUpDown5";
- this.numericUpDown5.Size = new System.Drawing.Size(67, 21);
- this.numericUpDown5.TabIndex = 37;
- this.numericUpDown5.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);
- //
- // numericUpDown4
- //
- this.numericUpDown4.Location = new System.Drawing.Point(90, 116);
- this.numericUpDown4.Maximum = new decimal(new int[] {
- 10000,
- 0,
- 0,
- 0});
- this.numericUpDown4.Name = "numericUpDown4";
- this.numericUpDown4.Size = new System.Drawing.Size(67, 21);
- this.numericUpDown4.TabIndex = 35;
- this.numericUpDown4.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(19, 120);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(0, 12);
- this.label6.TabIndex = 36;
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(19, 120);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(0, 12);
- this.label5.TabIndex = 34;
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(229, 85);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 10000,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(67, 21);
- this.numericUpDown3.TabIndex = 33;
- this.numericUpDown3.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(158, 88);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(0, 12);
- this.label4.TabIndex = 32;
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(90, 85);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 10000,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(67, 21);
- this.numericUpDown1.TabIndex = 31;
- this.numericUpDown1.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(19, 88);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(0, 12);
- this.label1.TabIndex = 30;
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(90, 146);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 10000,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(67, 21);
- this.numericUpDown2.TabIndex = 14;
- this.numericUpDown2.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(19, 150);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(0, 12);
- this.label3.TabIndex = 2;
- //
- // comboBox1
- //
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(55, 49);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(241, 20);
- this.comboBox1.TabIndex = 20;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged_1);
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(55, 17);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(241, 21);
- this.textBox1.TabIndex = 19;
- //
- // panel2
- //
- this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel2.Location = new System.Drawing.Point(229, 116);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(67, 21);
- this.panel2.TabIndex = 12;
- this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged);
- this.panel2.Click += new System.EventHandler(this.panel2_Click);
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(19, 23);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(0, 12);
- this.label7.TabIndex = 18;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(160, 120);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(0, 12);
- this.label2.TabIndex = 1;
- //
- // label24
- //
- this.label24.AutoSize = true;
- this.label24.Location = new System.Drawing.Point(19, 52);
- this.label24.Name = "label24";
- this.label24.Size = new System.Drawing.Size(0, 12);
- this.label24.TabIndex = 29;
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.panel1);
- this.groupBox3.Location = new System.Drawing.Point(193, 255);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(319, 213);
- this.groupBox3.TabIndex = 1;
- this.groupBox3.TabStop = false;
- //
- // panel1
- //
- this.panel1.Location = new System.Drawing.Point(6, 17);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(307, 190);
- this.panel1.TabIndex = 0;
- this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.dataGridView1);
- this.groupBox4.Controls.Add(this.button5);
- this.groupBox4.Controls.Add(this.button4);
- this.groupBox4.Controls.Add(this.button3);
- this.groupBox4.Location = new System.Drawing.Point(12, 72);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(175, 396);
- this.groupBox4.TabIndex = 2;
- this.groupBox4.TabStop = false;
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.ColumnHeadersVisible = false;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.GuideName});
- this.dataGridView1.Location = new System.Drawing.Point(6, 53);
- this.dataGridView1.MultiSelect = false;
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView1.Size = new System.Drawing.Size(162, 337);
- this.dataGridView1.TabIndex = 4;
- this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
- //
- // GuideName
- //
- this.GuideName.HeaderText = "";
- this.GuideName.Name = "GuideName";
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(138, 18);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(30, 25);
- this.button5.TabIndex = 3;
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(104, 18);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(30, 25);
- this.button4.TabIndex = 2;
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(70, 18);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(30, 25);
- this.button3.TabIndex = 1;
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // ArbitrationLawGuideDialog
- //
- this.ClientSize = new System.Drawing.Size(521, 473);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(537, 512);
- this.MinimizeBox = false;
- this.MinimumSize = new System.Drawing.Size(537, 512);
- this.Name = "ArbitrationLawGuideDialog";
- this.ShowInTaskbar = false;
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- this.groupBox3.ResumeLayout(false);
- this.groupBox4.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// 初始化数据
- /// </summary>
- private void InitializeData()
- {
- this.comboBox1.SelectedIndex = 0;
- this.groupBox2.Enabled = false;
- this.dataGridView1.ReadOnly = true;
- GrainSizeArbitrationLawModel grainSizeArbitrationLawModel = XmlSerializeHelper.DESerializer<GrainSizeArbitrationLawModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeArbitrationLawModel.xml", FileMode.Open));
- if (grainSizeArbitrationLawModel.GridStyleList != null)
- {
- foreach (var GridStyle in grainSizeArbitrationLawModel.GridStyleList)
- {
- index++;
- DataGridViewRow row = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView1.Columns)
- {
- row.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- row.Cells[0].Value = GridStyle.gridName;
- this.dataGridView1.Rows.Add(row);
- ArrayList arrayList = new ArrayList();
- arrayList.Add(GridStyle.gridName);
- arrayList.Add(GridStyle.hNumber);
- arrayList.Add(GridStyle.vNumber);
- arrayList.Add(GridStyle.gridWidth);
- arrayList.Add(GridStyle.gridSpacing);
- arrayList.Add(GridStyle.gridColor);
- arrayList.Add(GridStyle.wholePicture);
- arrayList.Add(GridStyle.blank);
- this.arrayLists.Add(arrayList);
- }
- }
- }
- /// <summary>
- /// 保存到配置文件
- /// </summary>
- private void SaveXmlFile()
- {
- GrainSizeArbitrationLawModel grainSizeArbitrationLawModel = new GrainSizeArbitrationLawModel();
- grainSizeArbitrationLawModel.GridStyleList = new List<GrainSizeArbitrationLawModel.GridStyle>();
- if(this.arrayLists.Count == 0)
- {
- //以下保存xml文件信息
- string stageModelXml = XmlSerializeHelper.XmlSerialize<GrainSizeArbitrationLawModel>(grainSizeArbitrationLawModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeArbitrationLawModel.xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- }
- foreach (ArrayList arrayList1 in this.arrayLists)
- {
- GrainSizeArbitrationLawModel.GridStyle gridStyle = new GrainSizeArbitrationLawModel.GridStyle();
- gridStyle.gridName = arrayList1[0].ToString();
- gridStyle.hNumber = Convert.ToInt32(arrayList1[1]);
- gridStyle.vNumber = Convert.ToInt32(arrayList1[2]);
- gridStyle.gridWidth = Convert.ToInt32(arrayList1[3]);
- gridStyle.gridSpacing = Convert.ToInt32(arrayList1[4]);
- gridStyle.gridColor = Convert.ToInt32(arrayList1[5]);
- gridStyle.wholePicture = Convert.ToBoolean(arrayList1[6]);
- gridStyle.blank = Convert.ToInt32(arrayList1[7]);
- grainSizeArbitrationLawModel.GridStyleList.Add(gridStyle);
- //以下保存xml文件信息
- string stageModelXml = XmlSerializeHelper.XmlSerialize<GrainSizeArbitrationLawModel>(grainSizeArbitrationLawModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeArbitrationLawModel.xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- }
- }
- /// <summary>
- /// 页面关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
- {
- }
- private void panel2_Click(object sender, EventArgs e)
- {
- this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
- this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
- this.colorsForm.ShowDialog();
- }
- private void panel2Changed(object sender, EventArgs e)
- {
- this.panel2.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
- this.colorsForm.Close();
- }
- private void InitGroupbox2()
- {
- this.textBox1.Clear();
- this.comboBox1.SelectedIndex = 0;
- this.numericUpDown1.Value = 0;
- this.numericUpDown2.Value = 0;
- this.numericUpDown3.Value = 0;
- this.numericUpDown4.Value = 0;
- this.numericUpDown5.Value = 0;
- }
- /// <summary>
- /// 返回维护的辅助线
- /// </summary>
- private void ReturnGrainSize()
- {
- ArrayList arrayList = new ArrayList();
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- arrayList.Add(this.dataGridView1.Rows[i].Cells[0].Value);
- }
- GrainSizeArbitrationLawDialog grainSizeArbitrationLawDialog = (GrainSizeArbitrationLawDialog)this.Owner;
- grainSizeArbitrationLawDialog.comboboxChange = false;
- grainSizeArbitrationLawDialog.InitComboboxValue(arrayList);
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- // 添加
- if (this.operation == 0)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.namecannotbeEmpty.text")+"!");
- }
- else
- {
- bool next = true;
- for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
- {
- if (this.dataGridView1.Rows[r].Cells[0].Value.Equals(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
- next = false;
- break;
- }
- }
- if (next)
- {
- ArrayList arrayList = new ArrayList();
- arrayList.Add(this.textBox1.Text);
- arrayList.Add(Convert.ToInt32(this.numericUpDown1.Value));
- arrayList.Add(Convert.ToInt32(this.numericUpDown3.Value));
- arrayList.Add(Convert.ToInt32(this.numericUpDown2.Value));
- arrayList.Add(Convert.ToInt32(this.numericUpDown4.Value));
- arrayList.Add(Convert.ToInt32(this.panel2.BackColor.ToArgb()));
- if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
- arrayList.Add(true);
- else if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text").Equals(this.comboBox1.SelectedItem))
- arrayList.Add(false);
- arrayList.Add(Convert.ToInt32(numericUpDown5.Value));
- this.arrayLists.Add(arrayList);
- DataGridViewRow row = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView1.Columns)
- {
- row.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- row.Cells[0].Value = this.textBox1.Text;
- this.dataGridView1.Rows.Add(row);
- SaveXmlFile();
- MessageBox.Show(PdnResources.GetString("Menu.Addsuccessfully.text")+"!");
- operation = -1;
- this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Selected = true;
- }
- }
- }
- // 编辑
- else if (this.operation == 1)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.namecannotbeEmpty.text")+"!");
- }
- else
- {
- bool next = true;
- for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
- {
- if (this.dataGridView1.Rows[r].Cells[0].Value.Equals(this.textBox1.Text) && this.dataGridView1.SelectedRows[0].Index != r)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
- next = false;
- break;
- }
- }
- if (next)
- {
- int updIndex = 0;
- foreach (var arrayList1 in this.arrayLists)
- {
- if (arrayList1[0].ToString().Equals(this.dataGridView1.SelectedRows[0].Cells[0].Value))
- {
- updIndex = Convert.ToInt32(arrayList1[arrayList1.Count - 1]);
- this.arrayLists.Remove(arrayList1);
- break;
- }
- }
- ArrayList arrayList = new ArrayList();
- arrayList.Add(this.textBox1.Text);
- arrayList.Add(Convert.ToInt32(this.numericUpDown1.Value));
- arrayList.Add(Convert.ToInt32(this.numericUpDown3.Value));
- arrayList.Add(Convert.ToInt32(this.numericUpDown2.Value));
- arrayList.Add(Convert.ToInt32(this.numericUpDown4.Value));
- arrayList.Add(Convert.ToInt32(this.panel2.BackColor.ToArgb()));
- if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
- arrayList.Add(true);
- else if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text").Equals(this.comboBox1.SelectedItem))
- arrayList.Add(false);
- arrayList.Add(Convert.ToInt32(numericUpDown5.Value));
- this.arrayLists.Add(arrayList);
- this.dataGridView1.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
- SaveXmlFile();
- MessageBox.Show(PdnResources.GetString("Menu.Editsuccessfully.text")+"!");
- operation = -1;
- this.groupBox2.Enabled = false;
- }
- }
- }
- ReturnGrainSize();
- }
- /// <summary>
- /// 辅助线样式预览
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- Draw(e.Graphics);
- }
-
- /// <summary>
- /// 辅助线样式预览是(面积法)
- /// </summary>
- private void Draw(Graphics g)
- {
- Pen linePen = new Pen(this.panel2.BackColor,Convert.ToInt32(this.numericUpDown2.Value));
- float hGridSpacingDraw;
- float vGridSpacingDraw;
- float blankDraw;
- bool wholePicture;
- int hNumber = Convert.ToInt32(this.numericUpDown1.Value) + 1;
- int vNumber = Convert.ToInt32(this.numericUpDown3.Value) + 1;
- float minX = this.panel1.Width / 2 - (vNumber - 1) * 10;
- float maxX = this.panel1.Width / 2 + (vNumber - 1) * 10;
- float minY = this.panel1.Height / 2 - (hNumber - 1) * 10;
- float maxY = this.panel1.Height / 2 + (hNumber - 1) * 10;
- if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
- wholePicture = true;
- else
- wholePicture = false;
- if (wholePicture)
- {
- hGridSpacingDraw = (float)this.panel1.Height / Convert.ToInt32(this.numericUpDown1.Value);
- vGridSpacingDraw = (float)this.panel1.Width / Convert.ToInt32(this.numericUpDown3.Value);
- blankDraw = 0;
- }
- else
- {
- blankDraw = 0;
- hGridSpacingDraw = 20;
- vGridSpacingDraw = 20;
- }
- if (hNumber > 0)
- {
- if (hNumber % 2 == 0)
- {
- float Spacing = hGridSpacingDraw / 2;
- for (int i = 0; i < (float)hNumber / 2; i++)
- {
- if (wholePicture)
- {
- if ((float)this.panel1.Height / 2 - Spacing >= blankDraw)
- {
- g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 - Spacing)
- , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 - Spacing));
- }
- if ((float)this.panel1.Height / 2 + Spacing <= this.panel1.Height - blankDraw)
- {
- g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 + Spacing)
- , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 + Spacing));
- }
- }
- else
- {
- if ((float)this.panel1.Height / 2 - Spacing >= 0)
- {
- g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 - Spacing)
- , new PointF(maxX, (float)this.panel1.Height / 2 - Spacing));
- }
- if ((float)this.panel1.Height / 2 + Spacing <= this.panel1.Height)
- {
- g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 + Spacing)
- , new PointF(maxX, (float)this.panel1.Height / 2 + Spacing));
- }
- }
- Spacing += hGridSpacingDraw;
- }
- }
- else
- {
- if ((float)this.panel1.Width > 2 * blankDraw)
- {
- if (hNumber == 1)
- g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2)
- , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2));
- else
- {
- float Spacing = hGridSpacingDraw;
- for (int i = 0; i < (hNumber - 1) / 2; i++)
- {
- if (wholePicture)
- {
-
- if (i == 0)
- g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2)
- , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2));
- if (this.panel1.Height / 2 - Spacing >= blankDraw)
- {
- g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 - Spacing)
- , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 - Spacing));
- }
- if (this.panel1.Height / 2 + Spacing <= this.panel1.Height - blankDraw)
- {
- g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 + Spacing)
- , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 + Spacing));
- }
- }
- else
- {
- if (i == 0)
- g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2)
- , new PointF(maxX, (float)this.panel1.Height / 2));
- if (this.panel1.Height / 2 - Spacing >= 0)
- {
- g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 - Spacing)
- , new PointF(maxX, (float)this.panel1.Height / 2 - Spacing));
- }
- if (this.panel1.Height / 2 + Spacing <= this.panel1.Height)
- {
- g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 + Spacing)
- , new PointF(maxX, (float)this.panel1.Height / 2 + Spacing));
- }
- }
- Spacing += hGridSpacingDraw;
- }
- }
- }
- }
- }
- if (vNumber > 0)
- {
- if (vNumber % 2 == 0)
- {
- float Spacing = vGridSpacingDraw / 2;
- for (int i = 0; i < (float)vNumber / 2; i++)
- {
- if (wholePicture)
- {
-
- if ((float)this.panel1.Width / 2 - Spacing >= 0
- && (float)this.panel1.Width / 2 - Spacing >= blankDraw)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, blankDraw)
- , new PointF((float)this.panel1.Width / 2 - Spacing, (float)(this.panel1.Height - blankDraw)));
- }
- if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width
- && (float)this.panel1.Width / 2 + Spacing <= this.panel1.Width - blankDraw)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, blankDraw)
- , new PointF((float)this.panel1.Width / 2 + Spacing, (float)(this.panel1.Height - blankDraw)));
- }
- }
- else
- {
- if ((float)this.panel1.Width / 2 - Spacing >= 0)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, minY)
- , new PointF((float)this.panel1.Width / 2 - Spacing, maxY));
- }
- if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, minY)
- , new PointF((float)this.panel1.Width / 2 + Spacing, maxY));
- }
- }
- Spacing += vGridSpacingDraw;
- }
- }
- else
- {
- if (this.panel1.Height > 2 * blankDraw)
- {
- if (vNumber == 1)
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2, blankDraw)
- , new PointF((float)this.panel1.Width / 2, (float)(this.panel1.Height - blankDraw)));
- else
- {
- float Spacing = vGridSpacingDraw;
- for (int i = 0; i < (vNumber - 1) / 2; i++)
- {
- if (wholePicture)
- {
-
- if (i == 0)
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2, blankDraw)
- , new PointF((float)this.panel1.Width / 2, (float)(this.panel1.Height - blankDraw)));
- if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width
- && this.panel1.Width / 2 + Spacing <= this.panel1.Width - blankDraw)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, blankDraw)
- , new PointF((float)this.panel1.Width / 2 + Spacing, (float)(this.panel1.Height - blankDraw)));
- }
- if ((float)this.panel1.Width / 2 - Spacing >= 0 && (float)this.panel1.Width / 2 - Spacing >= blankDraw)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, blankDraw)
- , new PointF((float)this.panel1.Width / 2 - Spacing, (float)(this.panel1.Height - blankDraw)));
- }
- }
- else
- {
- if (i == 0)
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2, minY)
- , new PointF((float)this.panel1.Width / 2, maxY));
- if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, minY)
- , new PointF((float)this.panel1.Width / 2 + Spacing, maxY));
- }
- if ((float)this.panel1.Width / 2 - Spacing >= 0)
- {
- g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, minY)
- , new PointF((float)this.panel1.Width / 2 - Spacing, maxY));
- }
- }
- Spacing += vGridSpacingDraw;
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 线颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel2_BackColorChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 切换辅助线类型
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
- {
- if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
- {
- this.label6.Visible = true;
- this.numericUpDown5.Visible = true;
- this.label5.Visible = false;
- this.numericUpDown4.Visible = false;
- }
- else if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text").Equals(this.comboBox1.SelectedItem))
- {
- this.label6.Visible = false;
- this.numericUpDown5.Visible = false;
- this.label5.Visible = true;
- this.numericUpDown4.Visible = true;
- }
- this.panel1.Refresh();
- }
- /// <summary>
- /// 添加辅助线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- // 添加
- this.textBox1.Focus();
- this.dataGridView1.ClearSelection();
- operation = 0;
- this.groupBox2.Enabled = true;
- InitGroupbox2();
- }
- /// <summary>
- /// 编辑辅助线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if(this.dataGridView1.Rows.Count > 0)
- {
- if(this.dataGridView1.SelectedRows.Count > 0)
- {
- // 编辑
- operation = 1;
- this.groupBox2.Enabled = true;
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheauxiliarylinetoedit.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseaddauxiliarylines.text")+"!");
- }
- }
- /// <summary>
- /// 切换辅助线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridView1_SelectionChanged(object sender, EventArgs e)
- {
- this.groupBox2.Enabled = false;
-
- if (this.dataGridView1.SelectedRows.Count > 0)
- {
- ArrayList arrayList1 = new ArrayList();
- foreach (var arrayList in this.arrayLists)
- {
- if (this.dataGridView1.SelectedRows[0].Cells[0].Value.Equals(arrayList[0]))
- arrayList1 = arrayList;
- }
- this.textBox1.Text = arrayList1[0].ToString();
- if (Convert.ToBoolean(arrayList1[6]))
- this.comboBox1.SelectedItem = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text");
- else
- this.comboBox1.SelectedItem = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text");
- this.numericUpDown1.Value = Convert.ToInt32(arrayList1[1]);
- this.numericUpDown3.Value = Convert.ToInt32(arrayList1[2]);
- this.numericUpDown2.Value = Convert.ToInt32(arrayList1[3]);
- this.numericUpDown4.Value = Convert.ToInt32(arrayList1[4]);
- this.numericUpDown5.Value = Convert.ToInt32(arrayList1[7]);
- this.panel2.BackColor = Color.FromArgb(Convert.ToInt32(arrayList1[5]));
- this.panel1.Refresh();
- }
- }
- /// <summary>
- /// 删除辅助线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if(this.dataGridView1.SelectedRows.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeletetheauxiliaryline?.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- foreach (var arrayList in this.arrayLists)
- {
- if (this.dataGridView1.SelectedRows[0].Cells[0].Value.Equals(arrayList[0]))
- {
- this.arrayLists.Remove(arrayList);
- break;
- }
- }
- SaveXmlFile();
- this.dataGridView1.Rows.Remove(this.dataGridView1.SelectedRows[0]);
- if (this.dataGridView1.Rows.Count == 0)
- InitGroupbox2();
- ReturnGrainSize();
- }
- this.panel1.Refresh();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheauxiliarylinetodelete.text")+"!");
- }
- }
- /// <summary>
- /// 间距
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown21_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 线条数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown20_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 间距
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown17_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- /// <summary>
- /// 线条数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown19_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- int hOldValue;
- int vOldValue;
- int sOldValue;
- int bOldValue;
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- RefreshGridIntersections();
- if (this.exceed)
- this.numericUpDown1.Value = this.hOldValue;
- this.hOldValue = Convert.ToInt32(this.numericUpDown1.Value);
- this.panel1.Refresh();
- }
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- RefreshGridIntersections();
- if (this.exceed)
- this.numericUpDown3.Value = this.vOldValue;
- this.vOldValue = Convert.ToInt32(this.numericUpDown3.Value);
- this.panel1.Refresh();
- }
- private void numericUpDown5_ValueChanged(object sender, EventArgs e)
- {
- RefreshGridIntersections();
- if (this.exceed)
- this.numericUpDown5.Value = this.bOldValue;
- this.bOldValue = Convert.ToInt32(this.numericUpDown5.Value);
- this.panel1.Refresh();
- }
- private void numericUpDown4_ValueChanged(object sender, EventArgs e)
- {
- RefreshGridIntersections();
- if (this.exceed)
- this.numericUpDown4.Value = this.sOldValue;
- this.sOldValue = Convert.ToInt32(this.numericUpDown4.Value);
- this.panel1.Refresh();
- }
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- this.panel1.Refresh();
- }
- }
- }
|