123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Collections;
- using PaintDotNet.Base.SettingModel;
- namespace PaintDotNet.Setting.LabelComponent
- {
- /// <summary>
- /// 标注设置-标记设置->日期
- /// </summary>
- public class LabelMarkDateControl : UserControl
- {
- #region 控件
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.Label label10;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.ComboBox comboBox1;
- private System.Windows.Forms.ComboBox comboBox2;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Panel panel2;
- private System.Windows.Forms.Panel panel3;
- private NumericUpDown numericUpDown1;
- private NumericUpDown numericUpDown2;
- private NumericUpDown numericUpDown3;
- private NumericUpDown numericUpDown4;
- #endregion
- /// <summary>
- /// 日期样式
- /// </summary>
- private LabelStyleModel.DateMark model;
- PaintDotNet.ColorsForm colorsForm1;
- PaintDotNet.ColorsForm colorsForm2;
- PaintDotNet.ColorsForm colorsForm3;
- ///// <summary>
- ///// 位置下拉选
- ///// </summary>
- //string[] position = new string[] { PdnResources.GetString("Menu.Upperleft.text")
- // , PdnResources.GetString("Menu.Upperright.text")
- // , PdnResources.GetString("Menu.Lowerleft.text")
- // , PdnResources.GetString("Menu.Lowerright.text") };
- /// <summary>
- /// 字体列表
- /// </summary>
- ArrayList fontsItems = new ArrayList();
- public LabelMarkDateControl(LabelStyleModel.DateMark model)
- {
- this.model = model;
- InitializeComponent();
- InitializeControlData();
- InitializeData();
- }
- /// <summary>
- /// 获取当前页面model值
- /// </summary>
- /// <returns></returns>
- public LabelStyleModel.DateMark getNowModel(LabelStyleModel.DateMark model)
- {
- model.font = this.comboBox1.Text;
- model.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
- model.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
- model.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.position = this.comboBox2.SelectedIndex.ToString();
- model.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
- model.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
- return model;
- }
- /// <summary>
- /// 应用全部
- /// </summary>
- /// <param name="model"></param>
- public LabelStyleModel ApplyAll(LabelStyleModel model)
- {
- model.dateMark.font = this.comboBox1.Text;
- model.dateMark.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
- model.dateMark.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.dateMark.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
- model.dateMark.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.dateMark.position = this.comboBox2.SelectedIndex.ToString();
- model.dateMark.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
- model.dateMark.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.dateMark.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
- model.timeMark.font = this.comboBox1.Text;
- model.timeMark.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
- model.timeMark.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.timeMark.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
- model.timeMark.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.timeMark.position = this.comboBox2.SelectedIndex.ToString();
- model.timeMark.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
- model.timeMark.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.timeMark.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
- model.numberMark.font = this.comboBox1.Text;
- model.numberMark.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
- model.numberMark.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.numberMark.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
- model.numberMark.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.numberMark.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.numberMark.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
- model.gainNumber.font = this.comboBox1.Text;
- model.gainNumber.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
- model.gainNumber.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.gainNumber.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
- model.gainNumber.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.gainNumber.position = this.comboBox2.SelectedIndex.ToString();
- model.gainNumber.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
- model.gainNumber.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.gainNumber.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
- return model;
- }
- /// <summary>
- /// 设置下拉等数据源
- /// </summary>
- private void InitializeControlData()
- {
- System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
- foreach (FontFamily fontFamily in fonts.Families)
- {
- fontsItems.Add(fontFamily.Name);
- }
- this.comboBox1.DataSource = fontsItems;
- //绑定位置下拉
- //this.comboBox2.DataSource = position;
- this.comboBox2.DataSource = new BindingSource(InvariantData.tagLocation, null);
- this.comboBox2.DisplayMember = "Value";
- this.comboBox2.ValueMember = "Key";
- }
- /// <summary>
- /// 绑定样式数据
- /// </summary>
- private void InitializeData()
- {
- this.comboBox1.Text = this.model.font;
- this.comboBox2.SelectedIndex = Convert.ToInt32(this.model.position);
- this.numericUpDown1.Value = this.model.lineWidth;
- this.numericUpDown2.Value = this.model.fontSize;
- this.numericUpDown3.Value = this.model.positionSize;
- this.numericUpDown4.Value = this.model.backgroundSize;
- this.panel1.BackColor = Color.FromArgb(this.model.textColor);
- this.panel2.BackColor = Color.FromArgb(this.model.backgroundColor);
- this.panel3.BackColor = Color.FromArgb(this.model.backgroundBoxColor);
- }
- private void InitializeComponent()
- {
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.comboBox2 = new System.Windows.Forms.ComboBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.label10 = new System.Windows.Forms.Label();
- this.label11 = new System.Windows.Forms.Label();
- this.panel1 = new System.Windows.Forms.Panel();
- this.panel2 = new System.Windows.Forms.Panel();
- this.panel3 = new System.Windows.Forms.Panel();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
- this.SuspendLayout();
- //
- // comboBox1
- //
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(84, 4);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(152, 20);
- this.comboBox1.TabIndex = 1;
- //
- // comboBox2
- //
- this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox2.FormattingEnabled = true;
- this.comboBox2.Location = new System.Drawing.Point(320, 5);
- this.comboBox2.Name = "comboBox2";
- this.comboBox2.Size = new System.Drawing.Size(152, 20);
- this.comboBox2.TabIndex = 1;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(4, 8);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(65, 12);
- this.label1.TabIndex = 0;
- this.label1.Text = PdnResources.GetString("Menu.Textfont.text") + ":";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(6, 34);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(65, 12);
- this.label2.TabIndex = 2;
- this.label2.Text = PdnResources.GetString("Menu.Set.Rulersettings.Fontsize.text") + ":";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(6, 60);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(65, 12);
- this.label3.TabIndex = 4;
- this.label3.Text = PdnResources.GetString("Menu.Textcolor.text") + ":";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(254, 60);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(65, 12);
- this.label4.TabIndex = 6;
- this.label4.Text = PdnResources.GetString("Menu.backgroundcolor.text") + ":";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(6, 86);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(77, 12);
- this.label5.TabIndex = 8;
- this.label5.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframecolor.text") + ":";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(6, 112);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(77, 12);
- this.label6.TabIndex = 9;
- this.label6.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframewidth.text") + ":";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(260, 8);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(41, 12);
- this.label7.TabIndex = 6;
- this.label7.Text = PdnResources.GetString("Menu.position.text") + ":";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(260, 34);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(65, 12);
- this.label8.TabIndex = 2;
- this.label8.Text = PdnResources.GetString("Menu.Set.Labelsettings.Locationsize.text") + ":";
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(461, 34);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(11, 12);
- this.label9.TabIndex = 13;
- this.label9.Text = "%";
- //
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(260, 86);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(65, 12);
- this.label10.TabIndex = 2;
- this.label10.Text = PdnResources.GetString("Menu.Backgroundsize.text") + ":";
- //
- // label11
- //
- this.label11.AutoSize = true;
- this.label11.Location = new System.Drawing.Point(461, 86);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(11, 12);
- this.label11.TabIndex = 13;
- this.label11.Text = "%";
- //
- // panel1
- //
- this.panel1.Location = new System.Drawing.Point(84, 57);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(152, 20);
- this.panel1.TabIndex = 5;
- this.panel1.Click += new System.EventHandler(this.panel1_Click);
- //
- // panel2
- //
- this.panel2.Location = new System.Drawing.Point(320, 57);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(135, 20);
- this.panel2.TabIndex = 7;
- this.panel2.Click += new System.EventHandler(this.panel2_Click);
- //
- // panel3
- //
- this.panel3.Location = new System.Drawing.Point(84, 83);
- this.panel3.Name = "panel3";
- this.panel3.Size = new System.Drawing.Size(152, 20);
- this.panel3.TabIndex = 10;
- this.panel3.Click += new System.EventHandler(this.panel3_Click);
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(84, 109);
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
- this.numericUpDown1.TabIndex = 11;
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(84, 30);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 49000,
- 0,
- 0,
- 0});
- this.numericUpDown2.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(152, 21);
- this.numericUpDown2.TabIndex = 12;
- this.numericUpDown2.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(320, 31);
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(135, 21);
- this.numericUpDown3.TabIndex = 12;
- //
- // numericUpDown4
- //
- this.numericUpDown4.Location = new System.Drawing.Point(320, 83);
- this.numericUpDown4.Name = "numericUpDown4";
- this.numericUpDown4.Size = new System.Drawing.Size(135, 21);
- this.numericUpDown4.TabIndex = 12;
- //
- // LabelMarkDateControl
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.numericUpDown1);
- this.Controls.Add(this.numericUpDown2);
- this.Controls.Add(this.numericUpDown3);
- this.Controls.Add(this.numericUpDown4);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.panel2);
- this.Controls.Add(this.panel3);
- this.Controls.Add(this.comboBox1);
- this.Controls.Add(this.comboBox2);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.label6);
- this.Controls.Add(this.label7);
- this.Controls.Add(this.label8);
- this.Controls.Add(this.label9);
- this.Controls.Add(this.label10);
- this.Controls.Add(this.label11);
- this.Name = "LabelMarkDateControl";
- this.Size = new System.Drawing.Size(490, 205);
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
- this.colorsForm1 = new ColorsForm();
- this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- this.colorsForm2 = new ColorsForm();
- this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- this.colorsForm3 = new ColorsForm();
- this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- }
- private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
- {
- }
- /// <summary>
- /// panel1画板点击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel1_Click(object sender, EventArgs e)
- {
- this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
- this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
- this.colorsForm1.ShowDialog();
- }
- private void panel1Changed(object sender, EventArgs e)
- {
- this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
- this.colorsForm1.Close();
- }
- /// <summary>
- /// panel2画板点击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel2_Click(object sender, EventArgs e)
- {
- this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
- this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
- this.colorsForm2.ShowDialog();
- }
- private void panel2Changed(object sender, EventArgs e)
- {
- this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
- this.colorsForm2.Close();
- }
- /// <summary>
- /// panel3 画板点击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel3_Click(object sender, EventArgs e)
- {
- this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel3.BackColor);
- this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.panel3Changed));
- this.colorsForm3.ShowDialog();
- }
- private void panel3Changed(object sender, EventArgs e)
- {
- this.panel3.BackColor = this.colorsForm3.UserPrimaryColor.ToColor();
- this.colorsForm3.Close();
- }
- }
- }
|