123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- using PaintDotNet.Annotation;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Annotation.Label;
- using PaintDotNet.Annotation.Other;
- using PaintDotNet.Base.SettingModel;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using static PaintDotNet.Base.SettingModel.RulerModel;
- namespace PaintDotNet.ImageLabel
- {
- /// <summary>
- /// 预存标尺
- /// </summary>
- internal class PresetRulerDialog : PdnBaseForm
- {
- private GroupBox groupBox1;
- private Button button2;
- private ListView listView1;
- private Button button1;
- private AppWorkspace appWorkspace;
- private RulerModel rulerModel = new RulerModel();
- private PresetRuler tempPresetRuler = new PresetRuler();
- public PresetRulerDialog(AppWorkspace appWorkspace)
- {
- this.appWorkspace = appWorkspace;
- this.rulerModel = Startup.instance.rulerModel;
- InitializeComponent();
- InitializeLanguageText();
- InitializeListView();
- BuildListView();
- }
- private void InitializeLanguageText()
- {
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button2.Text = PdnResources.GetString("Menu.ensure.text");
- this.button1.Text = PdnResources.GetString("Menu.cancel.text");
- this.Text = PdnResources.GetString("Menu.ImageOverlays.Pre-storedrulers.Listofpdrulers.text");
- }
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.listView1 = new System.Windows.Forms.ListView();
- this.groupBox1.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(13, 13);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(317, 57);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(168, 20);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(64, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "确定";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(247, 20);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(64, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "取消";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // listView1
- //
- this.listView1.FullRowSelect = true;
- this.listView1.GridLines = true;
- this.listView1.HideSelection = false;
- this.listView1.Location = new System.Drawing.Point(13, 85);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(317, 213);
- this.listView1.TabIndex = 1;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
- this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
- //
- // PresetRulerDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(342, 310);
- this.Controls.Add(this.listView1);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "PresetRulerDialog";
- this.Text = "预存标尺列表";
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.listView1, 0);
- this.groupBox1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- private void InitializeListView()
- {
- this.listView1.View = View.Details;
- ColumnHeader header = new ColumnHeader();
- header.Text = PdnResources.GetString("Menu.name.text");
- header.Width = 180;
- this.listView1.Columns.Add(header);
- header = new ColumnHeader();
- header.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text");
- header.Width = 132;
- this.listView1.Columns.Add(header);
- }
- /// <summary>
- /// 构建ListView数据
- /// </summary>
- private void BuildListView()
- {
- this.listView1.Items.Clear();
- this.listView1.BeginUpdate();
- foreach (PresetRuler presetRuler in this.rulerModel.presetRulers)
- {
- ListViewItem lvi = new ListViewItem();
- lvi.Text = presetRuler.name.ToString();
- lvi.SubItems.Add(presetRuler.length.ToString());
- this.listView1.Items.Add(lvi);
- }
- this.listView1.EndUpdate();
- if (this.listView1.Items.Count > 0)
- {
- this.listView1.Items[0].Selected = true;
- }
- }
- /// <summary>
- /// 取消按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 确定按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems.Count <= 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleasavedruler.Text"));
- return;
- }
- ListViewItem item = this.listView1.SelectedItems[0];
- int rulerLength = Convert.ToInt32(item.SubItems[1].Text);
- //主窗体添加
- if (this.appWorkspace.ActiveDocumentWorkspace != null)
- {
- this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawPrestoredRuler;
- List<DrawObject> objList = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.GetDrawToolTypeList(DrawToolType.DrawPrestoredRuler);
- if (objList.Count > 0)
- {
- DrawPrestoredRuler drawPrestoredRuler = (DrawPrestoredRuler)objList[0];
- drawPrestoredRuler.lineLength = rulerLength;
- this.appWorkspace.ActiveDocumentWorkspace.Refresh();
- if (this.appWorkspace.Widgets.LabelListDialog != null)
- this.appWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null);
- }
- }
- //预览窗口添加
- if (this.appWorkspace.cameraPreviewDialog != null && !this.appWorkspace.cameraPreviewDialog.IsDisposed)
- {
- this.appWorkspace.cameraPreviewDialog.documentWorkspace.ActiveTool = DrawToolType.DrawPrestoredRuler;
- List<DrawObject> objList = this.appWorkspace.cameraPreviewDialog.documentWorkspace.GraphicsList.GetDrawToolTypeList(DrawToolType.DrawPrestoredRuler);
- if (objList.Count > 0)
- {
- DrawPrestoredRuler drawPrestoredRuler = (DrawPrestoredRuler)objList[0];
- drawPrestoredRuler.lineLength = rulerLength;
- this.appWorkspace.cameraPreviewDialog.documentWorkspace.Refresh();
- if (this.appWorkspace.Widgets.LabelListDialog != null)
- this.appWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null);
- }
- }
- this.Close();
- }
- private void listView1_MouseDown(object sender, MouseEventArgs e)
- {
- if(e.Clicks == 2)
- {
- if (this.listView1.SelectedItems.Count <= 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleasavedruler.Text"));
- return;
- }
- ListViewItem item = this.listView1.SelectedItems[0];
- int rulerLength = Convert.ToInt32(item.SubItems[1].Text);
- //主窗体添加
- if (this.appWorkspace.ActiveDocumentWorkspace != null)
- {
- this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawPrestoredRuler;
- List<DrawObject> objList = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.GetDrawToolTypeList(DrawToolType.DrawPrestoredRuler);
- if (objList.Count > 0)
- {
- DrawPrestoredRuler drawPrestoredRuler = (DrawPrestoredRuler)objList[0];
- drawPrestoredRuler.lineLength = rulerLength;
- this.appWorkspace.ActiveDocumentWorkspace.Refresh();
- if (this.appWorkspace.Widgets.LabelListDialog != null)
- this.appWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null);
- }
- }
- //预览窗口添加
- if (this.appWorkspace.cameraPreviewDialog != null && !this.appWorkspace.cameraPreviewDialog.IsDisposed)
- {
- this.appWorkspace.cameraPreviewDialog.documentWorkspace.ActiveTool = DrawToolType.DrawPrestoredRuler;
- List<DrawObject> objList = this.appWorkspace.cameraPreviewDialog.documentWorkspace.GraphicsList.GetDrawToolTypeList(DrawToolType.DrawPrestoredRuler);
- if (objList.Count > 0)
- {
- DrawPrestoredRuler drawPrestoredRuler = (DrawPrestoredRuler)objList[0];
- drawPrestoredRuler.lineLength = rulerLength;
- this.appWorkspace.cameraPreviewDialog.documentWorkspace.Refresh();
- if (this.appWorkspace.Widgets.LabelListDialog != null)
- this.appWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null);
- }
- }
- this.Close();
- }
- }
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- ListViewItem defaultItem = new ListViewItem();
- foreach (ListViewItem listViewItem in this.listView1.Items)
- {
- listViewItem.ForeColor = defaultItem.ForeColor;
- listViewItem.BackColor = defaultItem.BackColor;
- }
- if (this.listView1.SelectedItems.Count <= 0)
- {
- return;
- }
- ListViewItem item = this.listView1.SelectedItems[0];
- item.ForeColor = Color.White;
- item.BackColor = Color.FromArgb(0, 120, 215);
- }
- }
- }
|