123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Collections;
- using PaintDotNet.Base.SettingModel;
- namespace PaintDotNet.Setting.LabelComponent
- {
- /// <summary>
- /// 标注设置-多边形设置->圆角矩形
- /// </summary>
- public class LabelPolygonRoundedControl : 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.ComboBox comboBox1;
- private NumericUpDown numericUpDown1;
- private NumericUpDown numericUpDown2;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Panel panel2;
- #endregion
- /// <summary>
- /// 圆角矩形样式
- /// </summary>
- private LabelStyleModel.RoundedRectangle model;
- PaintDotNet.ColorsForm colorsForm1;
- PaintDotNet.ColorsForm colorsForm2;
- public LabelPolygonRoundedControl(LabelStyleModel.RoundedRectangle model)
- {
- this.model = model;
- InitializeComponent();
- InitializeLanguageText();
- InitializeControlData();
- InitializeData();
- }
- /// <summary>
- /// 获取当前页面model值
- /// </summary>
- /// <returns></returns>
- public LabelStyleModel.RoundedRectangle getNowModel(LabelStyleModel.RoundedRectangle model)
- {
- model.lineStyle = this.comboBox1.SelectedIndex;
- model.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.fillColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.roundAngle = Convert.ToInt32(this.numericUpDown2.Value);
- return model;
- }
- /// <summary>
- /// 应用全部
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public LabelStyleModel ApplyAll(LabelStyleModel model)
- {
- model.polygonRectangle.lineStyle = this.comboBox1.SelectedIndex;
- model.polygonRectangle.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.polygonRectangle.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.polygonRectangle.fillColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.polygonPolygon.lineStyle = this.comboBox1.SelectedIndex;
- model.polygonPolygon.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.polygonPolygon.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.polygonPolygon.fillColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.roundedRectangle.lineStyle = this.comboBox1.SelectedIndex;
- model.roundedRectangle.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
- model.roundedRectangle.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
- model.roundedRectangle.fillColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
- model.roundedRectangle.roundAngle = Convert.ToInt32(this.numericUpDown2.Value);
- return model;
- }
- /// <summary>
- /// 设置下拉等数据源
- /// </summary>
- private void InitializeControlData()
- {
- //绑定线样式数据
- this.comboBox1.Items.AddRange(InvariantData.dashStyles);
- }
- /// <summary>
- /// 绑定样式数据
- /// </summary>
- private void InitializeData()
- {
- this.comboBox1.SelectedIndex = this.model.lineStyle;
- this.numericUpDown1.Value = this.model.lineWidth;
- this.numericUpDown2.Value = this.model.roundAngle;
- this.panel1.BackColor = Color.FromArgb(this.model.lineColor);
- this.panel2.BackColor = Color.FromArgb(this.model.fillColor);
- }
- private void InitializeLanguageText()
- {
- this.label6.Text = "% (" + PdnResources.GetString("Menu.Percentageofsidelength.Text") + ")";
- this.label5.Text = PdnResources.GetString("Menu.Roundedcorners.Text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Set.Labelsettings.Fillcolor.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
- this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.text") + ":";
- }
- private void InitializeComponent()
- {
- 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.comboBox1 = new System.Windows.Forms.ComboBox();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.panel1 = new System.Windows.Forms.Panel();
- this.panel2 = new System.Windows.Forms.Panel();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- this.SuspendLayout();
- //
- // 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(53, 12);
- this.label1.TabIndex = 0;
-
- //
- // 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(41, 12);
- this.label2.TabIndex = 2;
-
- //
- // 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(53, 12);
- this.label3.TabIndex = 4;
-
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(254, 8);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(65, 12);
- this.label4.TabIndex = 4;
-
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(254, 34);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(41, 12);
- this.label5.TabIndex = 4;
-
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(390, 35);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(95, 12);
- this.label6.TabIndex = 4;
-
- //
- // 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;
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(84, 31);
- 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(320, 31);
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(70, 21);
- this.numericUpDown2.TabIndex = 11;
- this.numericUpDown2.Maximum = 30;
- //
- // 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, 5);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(152, 20);
- this.panel2.TabIndex = 5;
- this.panel2.Click += new System.EventHandler(this.panel2_Click);
- //
- // LabelPolygonRoundedControl
- //
- 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.panel1);
- this.Controls.Add(this.panel2);
- this.Controls.Add(this.comboBox1);
- 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.Name = "LabelPolygonRoundedControl";
- this.Size = new System.Drawing.Size(490, 205);
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).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);
- }
- 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();
- }
- }
- }
|