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
{
///
/// 标注设置-曲线设置->闭合曲线
///
public class LabelCurveClosedControl : 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 label7;
private System.Windows.Forms.ComboBox comboBox1;
private NumericUpDown numericUpDown1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel4;
#endregion
///
/// 闭合曲线样式
///
private LabelStyleModel.ClosedCurve model;
PaintDotNet.ColorsForm colorsForm1;
PaintDotNet.ColorsForm colorsForm4;
public LabelCurveClosedControl(LabelStyleModel.ClosedCurve model)
{
this.model = model;
InitializeComponent();
InitializeControlData();
InitializeData();
}
///
/// 获取当前页面model值
///
///
public LabelStyleModel.ClosedCurve getNowModel(LabelStyleModel.ClosedCurve closedCurve)
{
closedCurve.lineStyle = this.comboBox1.SelectedIndex;
closedCurve.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
closedCurve.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
closedCurve.fillColor = Convert.ToInt32(this.panel4.BackColor.ToArgb());
return closedCurve;
}
///
/// 应用全部
///
///
///
public LabelStyleModel ApplyAll(LabelStyleModel labelStyleModel)
{
labelStyleModel.pencilModel.lineStyle = this.comboBox1.SelectedIndex;
labelStyleModel.pencilModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
labelStyleModel.pencilModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
labelStyleModel.polylineModel.lineStyle = this.comboBox1.SelectedIndex;
labelStyleModel.polylineModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
labelStyleModel.polylineModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
labelStyleModel.curveModel.lineStyle = this.comboBox1.SelectedIndex;
labelStyleModel.curveModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
labelStyleModel.curveModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
labelStyleModel.closedCurveModel.lineStyle = this.comboBox1.SelectedIndex;
labelStyleModel.closedCurveModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
labelStyleModel.closedCurveModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
labelStyleModel.closedCurveModel.fillColor = Convert.ToInt32(this.panel4.BackColor.ToArgb());
return labelStyleModel;
}
///
/// 设置下拉等数据源
///
private void InitializeControlData()
{
//绑定线样式数据
this.comboBox1.Items.AddRange(InvariantData.dashStyles);
}
///
/// 绑定样式数据
///
private void InitializeData()
{
this.comboBox1.SelectedIndex = this.model.lineStyle;
this.numericUpDown1.Value = this.model.lineWidth;
this.panel1.BackColor = Color.FromArgb(this.model.lineColor);
this.panel4.BackColor = Color.FromArgb(this.model.fillColor);
}
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LabelCurveClosedControl));
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.panel1 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.colorsForm1 = new PaintDotNet.ColorsForm();
this.colorsForm4 = new PaintDotNet.ColorsForm();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).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;
this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.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(41, 12);
this.label2.TabIndex = 2;
this.label2.Text = PdnResources.GetString("Menu.Linewidth.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(53, 12);
this.label3.TabIndex = 4;
this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text")+":";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(254, 8);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(65, 12);
this.label7.TabIndex = 4;
this.label7.Text = PdnResources.GetString("Menu.Set.Labelsettings.Fillcolor.text")+":";
//
// 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;
//
// 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);
//
// panel4
//
this.panel4.Location = new System.Drawing.Point(320, 5);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(152, 20);
this.panel4.TabIndex = 5;
this.panel4.Click += new System.EventHandler(this.panel4_Click);
//
// colorsForm1
//
this.colorsForm1.AnalyzeSettingModel = null;
this.colorsForm1.ClientSize = new System.Drawing.Size(209, 217);
this.colorsForm1.EnableInstanceOpacity = true;
this.colorsForm1.ForceActiveTitleBar = true;
this.colorsForm1.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.colorsForm1.KeyPreview = true;
this.colorsForm1.Location = new System.Drawing.Point(0, 0);
this.colorsForm1.MaximizeBox = false;
this.colorsForm1.MinimizeBox = false;
this.colorsForm1.Name = "colorsForm1";
this.colorsForm1.ShowInTaskbar = false;
this.colorsForm1.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.colorsForm1.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.colorsForm1.Text = PdnResources.GetString("Menu.color.text");
//this.colorsForm1.UserPrimaryColor = ((PaintDotNet.ColorBgra)(resources.GetObject("colorsForm1.UserPrimaryColor")));
//this.colorsForm1.UserSecondaryColor = ((PaintDotNet.ColorBgra)(resources.GetObject("colorsForm1.UserSecondaryColor")));
this.colorsForm1.Visible = false;
this.colorsForm1.WhichUserColor = PaintDotNet.WhichUserColor.Primary;
this.colorsForm1.UserPrimaryColorChanged += new PaintDotNet.ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
//
// colorsForm4
//
this.colorsForm4.AnalyzeSettingModel = null;
this.colorsForm4.ClientSize = new System.Drawing.Size(209, 217);
this.colorsForm4.EnableInstanceOpacity = true;
this.colorsForm4.ForceActiveTitleBar = true;
this.colorsForm4.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.colorsForm4.KeyPreview = true;
this.colorsForm4.Location = new System.Drawing.Point(0, 0);
this.colorsForm4.MaximizeBox = false;
this.colorsForm4.MinimizeBox = false;
this.colorsForm4.Name = "colorsForm4";
this.colorsForm4.ShowInTaskbar = false;
this.colorsForm4.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.colorsForm4.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.colorsForm4.Text = PdnResources.GetString("Menu.color.text");
//this.colorsForm4.UserPrimaryColor = ((PaintDotNet.ColorBgra)(resources.GetObject("colorsForm4.UserPrimaryColor")));
//this.colorsForm4.UserSecondaryColor = ((PaintDotNet.ColorBgra)(resources.GetObject("colorsForm4.UserSecondaryColor")));
this.colorsForm4.Visible = false;
this.colorsForm4.WhichUserColor = PaintDotNet.WhichUserColor.Primary;
this.colorsForm4.UserPrimaryColorChanged += new PaintDotNet.ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
//
// LabelCurveClosedControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel4);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Controls.Add(this.label7);
this.Name = "LabelCurveClosedControl";
this.Size = new System.Drawing.Size(490, 205);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
{
}
///
/// panel1画板点击
///
///
///
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();
}
///
/// panel4 画板点击
///
///
///
private void panel4_Click(object sender, EventArgs e)
{
this.colorsForm4.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
this.colorsForm4.setSaveBtn_Click(new System.EventHandler(this.panel4Changed));
this.colorsForm4.ShowDialog();
}
private void panel4Changed(object sender, EventArgs e)
{
this.panel4.BackColor = this.colorsForm4.UserPrimaryColor.ToColor();
this.colorsForm4.Close();
}
}
}