using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using PaintDotNet.Base.SettingModel;
namespace PaintDotNet.Setting.LabelComponent
{
///
/// 标注设置-文本设置组件
///
public class LabelTextControl : UserControl
{
#region 控件
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private Panel panel1;
private Panel panel2;
private Panel panel3;
private ComboBox comboBox1;
private NumericUpDown numericUpDown1;
private NumericUpDown numericUpDown2;
private System.Windows.Forms.Label label6;
#endregion
///
/// 文本样式
///
private LabelStyleModel.Text model;
PaintDotNet.ColorsForm colorsForm1;
PaintDotNet.ColorsForm colorsForm2;
PaintDotNet.ColorsForm colorsForm3;
///
/// 字体列表
///
ArrayList fontsItems = new ArrayList();
public LabelTextControl(LabelStyleModel.Text model)
{
this.model = model;
InitializeComponent();
InitializeLanguageText();
InitializeControlData();
InitializeData();
}
///
/// 获取当前页面model值
///
///
public LabelStyleModel.Text getNowModel(LabelStyleModel.Text model)
{
model.font = this.comboBox1.Text;
model.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
model.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
model.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
model.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
model.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
return model;
}
///
/// 设置下拉等数据源
///
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;
}
///
/// 绑定样式数据
///
private void InitializeData()
{
this.comboBox1.Text = this.model.font;
this.numericUpDown2.Value = this.model.fontSize;
this.panel1.BackColor = Color.FromArgb(this.model.textColor);
this.panel2.BackColor = Color.FromArgb(this.model.backgroundColor);
this.panel3.BackColor = Color.FromArgb(this.model.backgroundBoxColor);
this.numericUpDown1.Value = this.model.lineWidth;
}
private void InitializeLanguageText()
{
this.label1.Text = PdnResources.GetString("Menu.Textfont.text") + ":";
this.label2.Text = PdnResources.GetString("Menu.Set.Rulersettings.Fontsize.text") + ":";
this.label3.Text = PdnResources.GetString("Menu.Textcolor.text") + ":";
this.label4.Text = PdnResources.GetString("Menu.backgroundcolor.text") + ":";
this.label5.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframecolor.text") + ":";
this.label6.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframewidth.text") + ":";
}
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
((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(0, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 12);
this.label1.TabIndex = 0;
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(95, 4);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(140, 20);
this.comboBox1.TabIndex = 1;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(0, 34);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(0, 12);
this.label2.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(0, 60);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 12);
this.label3.TabIndex = 4;
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(95, 57);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(140, 20);
this.panel1.TabIndex = 5;
this.panel1.Click += new System.EventHandler(this.panel1_Click);
//
// panel2
//
this.panel2.Location = new System.Drawing.Point(95, 83);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(140, 20);
this.panel2.TabIndex = 7;
this.panel2.Click += new System.EventHandler(this.panel2_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(0, 86);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(0, 12);
this.label4.TabIndex = 6;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(0, 112);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(0, 12);
this.label5.TabIndex = 8;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(0, 139);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(0, 12);
this.label6.TabIndex = 9;
//
// panel3
//
this.panel3.Location = new System.Drawing.Point(95, 109);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(140, 20);
this.panel3.TabIndex = 10;
this.panel3.Click += new System.EventHandler(this.panel3_Click);
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(95, 135);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(140, 21);
this.numericUpDown1.TabIndex = 11;
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// numericUpDown2
//
this.numericUpDown2.Location = new System.Drawing.Point(95, 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(140, 21);
this.numericUpDown2.TabIndex = 12;
this.numericUpDown2.Value = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
//
// LabelTextControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.numericUpDown2);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.panel3);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.panel2);
this.Controls.Add(this.label4);
this.Controls.Add(this.panel1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Name = "LabelTextControl";
this.Size = new System.Drawing.Size(239, 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);
this.colorsForm3 = new ColorsForm();
this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
}
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();
}
///
/// panel2画板点击
///
///
///
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();
}
///
/// panel3 画板点击
///
///
///
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();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void numericUpDown2_ValueChanged(object sender, EventArgs e)
{
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
}
}
}