using PaintDotNet.Annotation.Enum;
using PaintDotNet.Annotation.relationModel;
using PaintDotNet.Base.SettingModel;
using PaintDotNet.Base.CommTool;
using PaintDotNet.Setting.LabelComponent;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using PaintDotNet.Base;
namespace PaintDotNet.Setting
{
///
/// 设置->标注设置
///
internal class LabelSettingDialog : PdnBaseForm
{
///
/// 标注一二级关系
///
private static List list;
///
/// 当前选中的二级标注
///
private DrawToolType drawToolType;
///
/// 标注的样式
///
private LabelStyleModel labelStyleModel = Startup.instance.labelStyleModel;
///
/// 主配置文件的model
///
private ConfigModel configModel = Startup.instance.configModel;
///
/// 操作样式下拉数据
///
private List files = new List();
///
/// 另存为弹出框显示
///
private CreateNameDialog dialog;
///
/// 另存为文件名
///
private string newName;
private int initflag = 0;
//各页面组件
private LabelTextControl textControl;
private LabelMarkDateControl dateMarkControl;
private LabelMarkTimeControl timeMarkControl;
private LabelMarkPointControl pointMarkControl;
private LabelMarkNumberControl numberMarkControl;
private LabelMarkGainNumberControl gainNumberControl;
private LabelStraightLineControl straightLineControl;
private LabelStraightLineSegmentControl segmentLineControl;
private LabelCurvePencilControl pencilControl;
private LabelCurvePolylineControl polylineControl;
private LabelCurveControl curveControl;
private LabelCurveClosedControl closedCurveControl;
private LabelArrowOneWayControl oneWayArrowControl;
private LabelArrowTwoWayControl twoWayArrowControl;
private LabelCircleControl circleControl;
private LabelCircleOvalControl ovalControl;
private LabelPolygonRectangleControl polygonRectangleControl;
private LabelPolygonControl polygonControl;
private LabelPolygonRoundedControl roundedRectangleControl;
private GroupBox groupBox4;
private System.Windows.Forms.Label label71;
private NumericUpDown numericUpDown71;
private ConfigModel config = Startup.instance.configModel;
private AppWorkspace appWorkspace;
#region 控件
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ListBox listBox1;
private Button button3;
private Button button2;
private Button button4;
private ComboBox comboBox1;
private Label label1;
private Button button5;
#endregion
public LabelSettingDialog(AppWorkspace appWorkspace)
{
if (list == null)
{
list = InvariantData.GetLabelRelations();
}
this.appWorkspace = appWorkspace;
InitializeComponent();
InitializeLanguageText();
InitializeData();
}
private void InitializeLanguageText()
{
this.label1.Text = PdnResources.GetString("Menu.Currentoperationstyle.text") + ":";
this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
this.button3.Text = PdnResources.GetString("Menu.File.SaveAs.Text");
this.button2.Text = PdnResources.GetString("Menu.File.Save.Text");
this.groupBox2.Text = PdnResources.GetString("Menu.Setting.Text");
this.groupBox4.Text = PdnResources.GetString("Menu.Setting.Text");
this.groupBox3.Text = PdnResources.GetString("Menu.Type.text");
this.button5.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
this.Text = PdnResources.GetString("Menu.Setting.LabelSetting.Text");
}
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.panel1 = new System.Windows.Forms.Panel();
this.button5 = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.numericUpDown71 = new System.Windows.Forms.NumericUpDown();
this.label71 = new System.Windows.Forms.Label();
this.groupBox4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown71)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Controls.Add(this.button4);
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Location = new System.Drawing.Point(134, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(638, 58);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(176, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 12);
this.label1.TabIndex = 5;
this.label1.Text = "当前操作样式:";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(271, 21);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(116, 20);
this.comboBox1.TabIndex = 4;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// button4
//
this.button4.Location = new System.Drawing.Point(393, 20);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 3;
this.button4.Text = "删除";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(474, 20);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 2;
this.button3.Text = "另存为";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(555, 20);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "保存";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// groupBox2
//
this.groupBox2.Location = new System.Drawing.Point(134, 120);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(633, 235);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "设置";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label71);
this.groupBox4.Controls.Add(this.numericUpDown71);
//this.groupBox4.Location = new System.Drawing.Point(137, 118);
this.groupBox4.Location = new System.Drawing.Point(137, 76);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(716, 277);
this.groupBox4.TabIndex = 6;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "设置";
this.groupBox4.Visible = false;
//
// label71
//
this.label71.AutoSize = true;
this.label71.Location = new System.Drawing.Point(13, 23);
this.label71.Name = "label71";
this.label71.Size = new System.Drawing.Size(77, 12);
this.label71.TabIndex = 0;
this.label71.Text = "标记点大小:";
//
// numericUpDown71
//
this.numericUpDown71.Location = new System.Drawing.Point(91, 23);
this.numericUpDown71.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numericUpDown71.Name = "numericUpDown71";
this.numericUpDown71.Size = new System.Drawing.Size(152, 21);
this.numericUpDown71.TabIndex = 14;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.listBox1);
this.groupBox3.Location = new System.Drawing.Point(13, 13);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(115, 342);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "类型";
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(6, 20);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(103, 316);
this.listBox1.TabIndex = 0;
this.listBox1.SelectedValueChanged += new System.EventHandler(this.listBox1_SelectedValueChanged);
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(134, 78);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(556, 36);
this.panel1.TabIndex = 5;
//
// button5
//
this.button5.Location = new System.Drawing.Point(692, 78);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 4;
this.button5.Text = "保存全部";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// LabelSettingDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(776, 366);
this.Controls.Add(this.button5);
this.Controls.Add(this.panel1);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "LabelSettingDialog";
this.Text = "标注设置";
this.Controls.SetChildIndex(this.groupBox1, 0);
this.Controls.SetChildIndex(this.groupBox2, 0);
this.Controls.SetChildIndex(this.groupBox4, 0);
this.Controls.SetChildIndex(this.groupBox3, 0);
this.Controls.SetChildIndex(this.panel1, 0);
this.Controls.SetChildIndex(this.button5, 0);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown71)).EndInit();
this.ResumeLayout(false);
}
///
/// 初始化数据
///
private void InitializeData()
{
//绑定左侧listbox数据
this.listBox1.Items.Clear();
foreach (LabelRelationModel model in list)
{
this.listBox1.Items.Add(model.name);
}
this.listBox1.SelectedIndex = 0;
//绑定样式下拉
if (initflag++ == 0)
{
InitializeStyleName();
}
//更新右侧设置界面
UpdateRightSettingUI();
this.numericUpDown71.Value = this.config.MarkpointWidth;
}
///
/// 初始化样式下拉
///
private void InitializeStyleName()
{
List fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\");
files.Clear();
foreach (string fileName in fileNames)
{
string name = fileName.Substring(0, fileName.LastIndexOf("."));
files.Add(name);
}
this.comboBox1.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
this.comboBox1.DataSource = null;
this.comboBox1.DataSource = files;
string nowModelName = Startup.instance.configModel.Watermark.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
this.comboBox1.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
this.labelStyleModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
this.comboBox1.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
}
///
/// 当前操作样式 下拉选切换
///
///
///
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.labelStyleModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
InitializeData();
}
///
/// 左侧listbox选择事件
///
///
///
private void listBox1_SelectedValueChanged(object sender, EventArgs e)
{
//首先更新右侧分类部分
UpdateRightCatalog();
//更新右侧设置界面
UpdateRightSettingUI();
//刷新右侧预览
UpdateRightPreview();
}
///
/// 更新右侧分类
///
private void UpdateRightCatalog()
{
this.panel1.Controls.Clear();
LabelRelationModel model = list[this.listBox1.SelectedIndex];
int postion = 0;
if (model.id == 8)
{
groupBox2.Visible = false;
panel1.Visible = false;
button5.Visible = false;
groupBox4.Visible = true;
comboBox1.Visible = false;
button4.Visible = false;
button3.Visible = false;
label1.Visible = false;
}
else {
groupBox2.Visible = true;
panel1.Visible = true;
button5.Visible = true;
groupBox4.Visible = false;
comboBox1.Visible = true;
button4.Visible = true;
button3.Visible = true;
label1.Visible = true;
}
foreach (LabelRelationModel.ChildLabel child in model.childLabel)
{
Button button = new Button();
button.Size = new Size(75, 23);
button.Location = new Point(postion * 75 + 5, 0);
button.Text = child.name;
button.Tag = child;
button.Click += new EventHandler(ChildButton_Click);
this.panel1.Controls.Add(button);
if (postion == 0)
{
this.drawToolType = child.drawToolType;
button.Focus();
}
postion++;
}
}
///
/// 二级分类按钮点击事件
///
///
///
private void ChildButton_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
LabelRelationModel.ChildLabel child = (LabelRelationModel.ChildLabel)button.Tag;
this.drawToolType = child.drawToolType;
this.UpdateRightSettingUI();
}
///
/// 更新右侧设置
///
private void UpdateRightSettingUI()
{
this.groupBox2.Controls.Clear();
switch (this.drawToolType)
{
case DrawToolType.DrawTextString: //文本
textControl = new LabelTextControl(this.labelStyleModel.text);
textControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(textControl);
break;
case DrawToolType.DrawDateMark: //标记-日期
dateMarkControl = new LabelMarkDateControl(this.labelStyleModel.dateMark);
dateMarkControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(dateMarkControl);
break;
case DrawToolType.DrawTimeMark: //标记-时间
timeMarkControl = new LabelMarkTimeControl(this.labelStyleModel.timeMark);
timeMarkControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(timeMarkControl);
break;
case DrawToolType.DrawPointMark: //标记-点标记
pointMarkControl = new LabelMarkPointControl(this.labelStyleModel.pointMark);
pointMarkControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(pointMarkControl);
break;
case DrawToolType.DrawNumberMark: //标记-数字标记
numberMarkControl = new LabelMarkNumberControl(this.labelStyleModel.numberMark);
numberMarkControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(numberMarkControl);
break;
case DrawToolType.DrawGainNumber: //标记-放大倍数
gainNumberControl = new LabelMarkGainNumberControl(this.labelStyleModel.gainNumber);
gainNumberControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(gainNumberControl);
break;
case DrawToolType.DrawLine: //直线->直线
straightLineControl = new LabelStraightLineControl(this.labelStyleModel.lineChildLine);
straightLineControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(straightLineControl);
break;
case DrawToolType.DrawLineSegment: //直线->线段
segmentLineControl = new LabelStraightLineSegmentControl(this.labelStyleModel.lineChildLineSegment);
segmentLineControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(segmentLineControl);
break;
case DrawToolType.DrawPencil: //曲线->铅笔
pencilControl = new LabelCurvePencilControl(this.labelStyleModel.pencilModel);
pencilControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(pencilControl);
break;
case DrawToolType.DrawPolygonLine: //曲线->折线
polylineControl = new LabelCurvePolylineControl(this.labelStyleModel.polylineModel);
polylineControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(polylineControl);
break;
case DrawToolType.DrawCurve: //曲线->曲线
curveControl = new LabelCurveControl(this.labelStyleModel.curveModel);
curveControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(curveControl);
break;
case DrawToolType.DrawClosedCurve: //曲线->闭合曲线
closedCurveControl = new LabelCurveClosedControl(this.labelStyleModel.closedCurveModel);
closedCurveControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(closedCurveControl);
break;
case DrawToolType.DrawOneArrowLine: //箭头->单向箭头
oneWayArrowControl = new LabelArrowOneWayControl(this.labelStyleModel.oneWayArrowModel);
oneWayArrowControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(oneWayArrowControl);
break;
case DrawToolType.DrawTwoArrowLine: //箭头->双向箭头
twoWayArrowControl = new LabelArrowTwoWayControl(this.labelStyleModel.twoWayArrowModel);
twoWayArrowControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(twoWayArrowControl);
break;
case DrawToolType.DrawCircle: //圆->圆
circleControl = new LabelCircleControl(this.labelStyleModel.circleModel);
circleControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(circleControl);
break;
case DrawToolType.DrawEllipse: //圆->椭圆
ovalControl = new LabelCircleOvalControl(this.labelStyleModel.ovalModel);
ovalControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(ovalControl);
break;
case DrawToolType.DrawRectangle: //多边形->矩形
polygonRectangleControl = new LabelPolygonRectangleControl(this.labelStyleModel.polygonRectangle);
polygonRectangleControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(polygonRectangleControl);
break;
case DrawToolType.DrawPolygon: //多边形->多边形
polygonControl = new LabelPolygonControl(this.labelStyleModel.polygonPolygon);
polygonControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(polygonControl);
break;
case DrawToolType.DrawRoundRectangle: //多边形->圆角矩形
roundedRectangleControl = new LabelPolygonRoundedControl(this.labelStyleModel.roundedRectangle);
roundedRectangleControl.Location = new Point(10, 15);
this.groupBox2.Controls.Add(roundedRectangleControl);
break;
}
}
///
/// 刷新右侧预览图
///
private void UpdateRightPreview()
{
}
///
/// 删除
///
///
///
private void button4_Click(object sender, EventArgs e)
{
if ("Default".Equals(this.comboBox1.Text))
{
MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
if (dr == DialogResult.OK)
{
int newIndex = 0;
int selectIndex = this.comboBox1.SelectedIndex;
int tall = files.Count - 1;
if (selectIndex < tall)
{
newIndex = selectIndex;
}
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.Text + ".xml";
FileInfo fileInfo = new FileInfo(filePath);
fileInfo.Delete();
InitializeStyleName();
this.comboBox1.SelectedIndex = newIndex;
this.labelStyleModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
InitializeData();
}
else if (dr == DialogResult.Cancel)
{
}
}
///
/// 另存为 出弹窗
///
///
///
private void button3_Click(object sender, EventArgs e)
{
dialog = new CreateNameDialog(this);
dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text");
dialog.StartPosition = FormStartPosition.CenterParent;
dialog.ShowDialog();
}
///
/// 另存为弹窗 确定保存
///
///
public override void GetCreateName(string name)
{
string currentcomboBox = this.comboBox1.Text;
this.newName = name;
if (files.Contains(this.newName))
{
MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
LabelStyleModel newModel = this.labelStyleModel;
modelSave(newModel);
//另存为
string stageModelXml = XmlSerializeHelper.XmlSerialize(newModel);
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.newName + ".xml";
FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
InitializeStyleName();
this.comboBox1.Text = currentcomboBox;
dialog.Close();
}
///
/// 保存
///
///
///
private void button2_Click(object sender, EventArgs e)
{
this.labelStyleModel = modelSave(this.labelStyleModel);
//以下保存xml文件信息
string stageModelXml = XmlSerializeHelper.XmlSerialize(this.labelStyleModel);
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.Text + ".xml";
FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
this.config.MarkpointWidth = Convert.ToInt32(this.numericUpDown71.Value);
string configModelXml = XmlSerializeHelper.XmlSerialize(config);
FileOperationHelper.WriteStringToFile(configModelXml, Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml", FileMode.Create);
MarkPointRect.markPointRectWidth = configModel.MarkpointWidth;
if (this.appWorkspace.DocumentWorkspaces != null)
{
foreach (var item in this.appWorkspace.DocumentWorkspaces)
{
if (item != null && item.GraphicsList != null)
foreach (var graObject in item.GraphicsList.graphicsList)
{
graObject.smallRectangleWidth = this.config.MarkpointWidth;
}
item.Refresh();
}
}
ApplicationSetting();
}
///
/// 各个子页面的model保存方法
///
private LabelStyleModel modelSave(LabelStyleModel model)
{
switch (this.drawToolType)
{
case DrawToolType.DrawTextString: //文本
model.text = textControl.getNowModel(this.labelStyleModel.text);
break;
case DrawToolType.DrawDateMark: //标记-日期
model.dateMark = dateMarkControl.getNowModel(this.labelStyleModel.dateMark);
break;
case DrawToolType.DrawTimeMark: //标记-时间
model.timeMark = timeMarkControl.getNowModel(this.labelStyleModel.timeMark);
break;
case DrawToolType.DrawPointMark: //标记-点标记
model.pointMark = pointMarkControl.getNowModel(this.labelStyleModel.pointMark);
break;
case DrawToolType.DrawNumberMark: //标记-数字标记
model.numberMark = numberMarkControl.getNowModel(this.labelStyleModel.numberMark);
break;
case DrawToolType.DrawGainNumber: //标记-放大倍数
model.gainNumber = gainNumberControl.getNowModel(this.labelStyleModel.gainNumber);
break;
case DrawToolType.DrawLine: //直线->直线
model.lineChildLine = straightLineControl.getNowModel(this.labelStyleModel.lineChildLine);
break;
case DrawToolType.DrawLineSegment: //直线->线段
model.lineChildLineSegment = segmentLineControl.getNowModel(this.labelStyleModel.lineChildLineSegment);
break;
case DrawToolType.DrawPencil: //曲线->铅笔
model.pencilModel = pencilControl.getNowModel(this.labelStyleModel.pencilModel);
break;
case DrawToolType.DrawPolygonLine: //曲线->折线
model.polylineModel = polylineControl.getNowModel(this.labelStyleModel.polylineModel);
break;
case DrawToolType.DrawCurve: //曲线->曲线
model.curveModel = curveControl.getNowModel(this.labelStyleModel.curveModel);
break;
case DrawToolType.DrawClosedCurve: //曲线->闭合曲线
model.closedCurveModel = closedCurveControl.getNowModel(this.labelStyleModel.closedCurveModel);
break;
case DrawToolType.DrawOneArrowLine: //箭头->单向箭头
model.oneWayArrowModel = oneWayArrowControl.getNowModel(this.labelStyleModel.oneWayArrowModel);
break;
case DrawToolType.DrawTwoArrowLine: //箭头->双向箭头
model.twoWayArrowModel = twoWayArrowControl.getNowModel(this.labelStyleModel.twoWayArrowModel);
break;
case DrawToolType.DrawCircle: //圆->圆
model.circleModel = circleControl.getNowModel(this.labelStyleModel.circleModel);
break;
case DrawToolType.DrawEllipse: //圆->椭圆
model.ovalModel = ovalControl.getNowModel(this.labelStyleModel.ovalModel);
break;
case DrawToolType.DrawRectangle: //多边形->矩形
model.polygonRectangle = polygonRectangleControl.getNowModel(this.labelStyleModel.polygonRectangle);
break;
case DrawToolType.DrawPolygon: //多边形->多边形
model.polygonPolygon = polygonControl.getNowModel(this.labelStyleModel.polygonPolygon);
break;
case DrawToolType.DrawRoundRectangle: //多边形->圆角矩形
model.roundedRectangle = roundedRectangleControl.getNowModel(this.labelStyleModel.roundedRectangle);
break;
}
return model;
}
///
/// 应用
///
///
///
private void ApplicationSetting()
{
//修改缓存中的样式数据
Startup.instance.labelStyleModel = this.labelStyleModel;
//修改主配置文件中的值
configModel.LabelStyle = this.comboBox1.Text + ".xml";
//修改主配置文件的xml
string configModelXml = XmlSerializeHelper.XmlSerialize(this.configModel);
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
FileOperationHelper.WriteStringToFile(configModelXml, filePath, FileMode.Create);
MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
}
///
/// 应用全部
///
///
///
private void button5_Click(object sender, EventArgs e)
{
switch (this.drawToolType)
{
case DrawToolType.DrawTextString: //文本
this.labelStyleModel.text = textControl.getNowModel(this.labelStyleModel.text);
break;
case DrawToolType.DrawDateMark: //标记-日期
this.labelStyleModel = dateMarkControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawTimeMark: //标记-时间
this.labelStyleModel = timeMarkControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawNumberMark: //标记-数字标记
this.labelStyleModel = numberMarkControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawGainNumber: //标记-放大倍数
this.labelStyleModel = gainNumberControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawLine: //直线->直线
this.labelStyleModel = straightLineControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawLineSegment: //直线->线段
this.labelStyleModel = segmentLineControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawPencil: //曲线->铅笔
this.labelStyleModel = pencilControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawPolygonLine: //曲线->折线
this.labelStyleModel = polylineControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawCurve: //曲线->曲线
this.labelStyleModel = curveControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawClosedCurve: //曲线->闭合曲线
this.labelStyleModel = closedCurveControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawOneArrowLine: //箭头->单向箭头
this.labelStyleModel = oneWayArrowControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawTwoArrowLine: //箭头->双向箭头
this.labelStyleModel = twoWayArrowControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawCircle: //圆->圆
this.labelStyleModel = circleControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawEllipse: //圆->椭圆
this.labelStyleModel = ovalControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawRectangle: //多边形->矩形
this.labelStyleModel = polygonRectangleControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawPolygon: //多边形->多边形
this.labelStyleModel = polygonControl.ApplyAll(this.labelStyleModel);
break;
case DrawToolType.DrawRoundRectangle: //多边形->圆角矩形
this.labelStyleModel = roundedRectangleControl.ApplyAll(this.labelStyleModel);
break;
}
//以下保存xml文件信息
string stageModelXml = XmlSerializeHelper.XmlSerialize(this.labelStyleModel);
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\" + this.comboBox1.Text + ".xml";
FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
ApplicationSetting();
}
}
}