using System;
using System.Drawing;
using System.Windows.Forms;
using PaintDotNet.Base.SettingModel;
namespace PaintDotNet.Setting.LabelComponent
{
///
/// 标注设置-箭头设置->单项箭头
///
public class LabelArrowTwoWayControl : UserControl
{
#region 控件
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comboBox1;
private NumericUpDown numericUpDown1;
private System.Windows.Forms.Panel panel1;
#endregion
///
/// 单项箭头样式
///
private LabelStyleModel.TwoWayArrow model;
PaintDotNet.ColorsForm colorsForm;
public LabelArrowTwoWayControl(LabelStyleModel.TwoWayArrow model)
{
this.model = model;
InitializeComponent();
this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.text") + ":";
this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text") + ":";
this.colorsForm = new ColorsForm();
this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
InitializeControlData();
InitializeData();
}
///
/// 获取当前页面model值
///
///
public LabelStyleModel.TwoWayArrow getNowModel(LabelStyleModel.TwoWayArrow twoWayArrow)
{
twoWayArrow.lineStyle = this.comboBox1.SelectedIndex;
twoWayArrow.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
twoWayArrow.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
return model;
}
///
/// 应用全部
///
///
///
public LabelStyleModel ApplyAll(LabelStyleModel labelStyleModel)
{
labelStyleModel.oneWayArrowModel.lineStyle = this.comboBox1.SelectedIndex;
labelStyleModel.oneWayArrowModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
labelStyleModel.oneWayArrowModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
labelStyleModel.twoWayArrowModel.lineStyle = this.comboBox1.SelectedIndex;
labelStyleModel.twoWayArrowModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
labelStyleModel.twoWayArrowModel.lineColor = Convert.ToInt32(this.panel1.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);
}
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.comboBox1 = new System.Windows.Forms.ComboBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.panel1 = new System.Windows.Forms.Panel();
((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;
//
// 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;
//
// 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);
//
// LabelArrowTwoWayControl
//
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.comboBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Name = "LabelArrowTwoWayControl";
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)
{
}
///
/// 画板点击
///
///
///
private void panel1_Click(object sender, EventArgs e)
{
this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
this.colorsForm.ShowDialog();
}
private void panel1Changed(object sender, EventArgs e)
{
this.panel1.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
this.colorsForm.Close();
}
}
}