123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- 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.IO;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.Base.CommTool;
- namespace PaintDotNet.File.BatchSaveComponet
- {
- internal class HandSaveControl : UserControl
- {
- private AppWorkspace appWorkspace;
- public List<TextBox> textBoxes = new List<TextBox>();
- public List<ComboBox> comboBoxes = new List<ComboBox>();
- private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
- public System.Windows.Forms.CheckBox checkBox5;
- public System.Windows.Forms.CheckBox checkBox4;
- public System.Windows.Forms.CheckBox checkBox3;
- public System.Windows.Forms.CheckBox checkBox2;
- public System.Windows.Forms.CheckBox checkBox6;
- public NumericUpDown numericUpDown1;
- private Label label1;
- public System.Windows.Forms.CheckBox checkBox1;
- /// <summary>
- /// 文件 - 批量保存自动配置
- /// </summary>
- public BatchSaveAutoModel batchSaveAutoModel;
- public HandSaveControl(AppWorkspace appWorkspace)
- {
- this.appWorkspace = appWorkspace;
- textBoxes.Clear();
- comboBoxes.Clear();
- InitializeComponent();
- InitializeLanguageText();
- InitializeData();
- }
- private void InitializeLanguageText()
- {
- this.checkBox5.Text = PdnResources.GetString("Menu.Compressionratio.text");
- this.checkBox4.Text = PdnResources.GetString("Menu.Annotationandmddedintheimage.text");
- this.checkBox3.Text = PdnResources.GetString("Menu.Savegriddata.text");
- this.checkBox2.Text = PdnResources.GetString("Menu.Closeimageaftersaving.text");
- this.checkBox1.Text = PdnResources.GetString("Menu.Generateconfigurationfile.text");
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要修改
- /// 使用代码编辑器修改此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
- this.checkBox5 = new System.Windows.Forms.CheckBox();
- this.checkBox4 = new System.Windows.Forms.CheckBox();
- this.checkBox3 = new System.Windows.Forms.CheckBox();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.checkBox6 = new System.Windows.Forms.CheckBox();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- this.SuspendLayout();
- //
- // flowLayoutPanel1
- //
- this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.flowLayoutPanel1.AutoScroll = true;
- this.flowLayoutPanel1.BackColor = System.Drawing.Color.White;
- this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
- this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
- this.flowLayoutPanel1.Name = "flowLayoutPanel1";
- this.flowLayoutPanel1.Size = new System.Drawing.Size(546, 258);
- this.flowLayoutPanel1.TabIndex = 16;
- //
- // checkBox5
- //
- this.checkBox5.AutoSize = true;
- this.checkBox5.Location = new System.Drawing.Point(1, 308);
- this.checkBox5.Name = "checkBox5";
- this.checkBox5.Size = new System.Drawing.Size(72, 16);
- this.checkBox5.TabIndex = 15;
- this.checkBox5.Text = "压缩比例";
- this.checkBox5.UseVisualStyleBackColor = true;
- //
- // checkBox4
- //
- this.checkBox4.AutoSize = true;
- this.checkBox4.Location = new System.Drawing.Point(230, 284);
- this.checkBox4.Name = "checkBox4";
- this.checkBox4.Size = new System.Drawing.Size(156, 16);
- this.checkBox4.TabIndex = 14;
- this.checkBox4.Text = "标注和测量信息嵌入图像";
- this.checkBox4.UseVisualStyleBackColor = true;
- //
- // checkBox3
- //
- this.checkBox3.AutoSize = true;
- this.checkBox3.Location = new System.Drawing.Point(1, 284);
- this.checkBox3.Name = "checkBox3";
- this.checkBox3.Size = new System.Drawing.Size(96, 16);
- this.checkBox3.TabIndex = 13;
- this.checkBox3.Text = "保存网格数据";
- this.checkBox3.UseVisualStyleBackColor = true;
- //
- // checkBox2
- //
- this.checkBox2.AutoSize = true;
- this.checkBox2.Location = new System.Drawing.Point(230, 261);
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.Size = new System.Drawing.Size(108, 16);
- this.checkBox2.TabIndex = 12;
- this.checkBox2.Text = "保存后关闭图像";
- this.checkBox2.UseVisualStyleBackColor = true;
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(1, 261);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(96, 16);
- this.checkBox1.TabIndex = 11;
- this.checkBox1.Text = "生成配置文件";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(75, 306);
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(36, 21);
- this.numericUpDown1.TabIndex = 17;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(118, 310);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(11, 12);
- this.label1.TabIndex = 18;
- this.label1.Text = "%";
- //
- // checkBox6
- //
- this.checkBox6.AutoSize = true;
- this.checkBox6.Location = new System.Drawing.Point(230, 307);
- this.checkBox6.Name = "checkBox6";
- this.checkBox6.Size = new System.Drawing.Size(108, 16);
- this.checkBox6.TabIndex = 19;
- this.checkBox6.Text = "相信息嵌入图像";
- this.checkBox6.UseVisualStyleBackColor = true;
- //
- // HandSaveControl
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.checkBox6);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.numericUpDown1);
- this.Controls.Add(this.flowLayoutPanel1);
- this.Controls.Add(this.checkBox5);
- this.Controls.Add(this.checkBox4);
- this.Controls.Add(this.checkBox3);
- this.Controls.Add(this.checkBox2);
- this.Controls.Add(this.checkBox1);
- this.Margin = new System.Windows.Forms.Padding(0);
- this.Name = "HandSaveControl";
- this.Size = new System.Drawing.Size(546, 327);
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- /// <summary>
- /// 初始化数据
- /// </summary>
- private void InitializeData()
- {
- int sum = 0;
- batchSaveAutoModel = XmlSerializeHelper.DESerializer<BatchSaveAutoModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml", FileMode.Open));
- if (this.appWorkspace.DocumentWorkspaces != null
- && this.appWorkspace.DocumentWorkspaces.Length > 0)
- {
- if (batchSaveAutoModel.Whether)
- {
- foreach (DocumentWorkspace document in this.appWorkspace.DocumentWorkspaces)
- {
-
- PictureBox imageBox = new PictureBox();
- imageBox.Size = new Size(28, 28);
- imageBox.SizeMode = PictureBoxSizeMode.Zoom;
- imageBox.Image = document.CompositionSurface.Thumbnail;//CreateAliasedBitmap()
- imageBox.Margin = new Padding(3, 1, 0, 0);
- imageBox.Cursor = Cursors.Hand;
- imageBox.Tag = document;
- imageBox.Click += new EventHandler(Imagebox_Click);
- Label label = new Label();
- label.Size = new Size(150, 22);
- label.Text = document.GetFriendlyName();
- label.Margin = new Padding(3, 9, 0, 0);
- ComboBox comboBox = new ComboBox();
- comboBox.Size = new Size(144, 22);
- comboBox.Margin = new Padding(3, 4, 0, 0);
- comboBox.DataSource = new BindingSource(InvariantData.fileFormatDictionary, null);
- comboBox.Text = batchSaveAutoModel.format;
- comboBox.DisplayMember = "Value";
- comboBox.ValueMember = "Key";
- TextBox textBox = new TextBox();
- textBox.Size = new Size(200, 22);
- textBox.Text = batchSaveAutoModel.prefix + "_" + batchSaveAutoModel.fileName + "_" + (batchSaveAutoModel.startNum + sum) + "_" + batchSaveAutoModel.suffix;
- textBox.Margin = new Padding(3, 4, 0, 0);
- textBoxes.Add(textBox);
- comboBoxes.Add(comboBox);
- FlowLayoutPanel panel = new FlowLayoutPanel();
- panel.Size = new Size(545, 30);
- panel.Margin = new Padding(0, 0, 0, 0);
- panel.BorderStyle = BorderStyle.FixedSingle;
- panel.Controls.Add(imageBox);
- panel.Controls.Add(label);
- panel.Controls.Add(comboBox);
- panel.Controls.Add(textBox);
- this.flowLayoutPanel1.Controls.Add(panel);
- sum++;
- }
- checkBox1.Checked = batchSaveAutoModel.createConfig;
- checkBox2.Checked = batchSaveAutoModel.afterSaveClost;
- checkBox3.Checked = batchSaveAutoModel.saveGridLine;
- checkBox4.Checked = batchSaveAutoModel.implantLabelAndMeasure;
- checkBox5.Checked = batchSaveAutoModel.compress;
- numericUpDown1.Value = batchSaveAutoModel.compressRate;
- checkBox6.Checked = batchSaveAutoModel.implantPhase;
- }
- else
- {
- foreach (DocumentWorkspace document in this.appWorkspace.DocumentWorkspaces)
- {
- PictureBox imageBox = new PictureBox();
- imageBox.Size = new Size(28, 28);
- imageBox.SizeMode = PictureBoxSizeMode.Zoom;
- imageBox.Image = document.CompositionSurface.Thumbnail;//CreateAliasedBitmap()
- imageBox.Margin = new Padding(3, 1, 0, 0);
- imageBox.Cursor = Cursors.Hand;
- imageBox.Tag = document;
- imageBox.Click += new EventHandler(Imagebox_Click);
- Label label = new Label();
- label.Size = new Size(150, 22);
- label.Text = document.GetFriendlyName();
- label.Margin = new Padding(3, 9, 0, 0);
- ComboBox comboBox = new ComboBox();
- comboBox.Size = new Size(144, 22);
- comboBox.Margin = new Padding(3, 4, 0, 0);
- comboBox.DataSource = new BindingSource(InvariantData.fileFormatDictionary, null);
- comboBox.DisplayMember = "Value";
- comboBox.ValueMember = "Key";
- TextBox textBox = new TextBox();
- textBox.Size = new Size(200, 22);
- textBox.Text = Path.GetFileNameWithoutExtension(document.GetFriendlyName());
- textBox.Margin = new Padding(3, 4, 0, 0);
- textBoxes.Add(textBox);
- comboBoxes.Add(comboBox);
- FlowLayoutPanel panel = new FlowLayoutPanel();
- panel.Size = new Size(545, 30);
- panel.Margin = new Padding(0, 0, 0, 0);
- panel.BorderStyle = BorderStyle.FixedSingle;
- panel.Controls.Add(imageBox);
- panel.Controls.Add(label);
- panel.Controls.Add(comboBox);
- panel.Controls.Add(textBox);
- this.flowLayoutPanel1.Controls.Add(panel);
- }
- }
- }
- }
- private void Imagebox_Click(object sender, EventArgs e)
- {
- PictureBox imagebox = (PictureBox)sender;
- DocumentWorkspace document = (DocumentWorkspace)imagebox.Tag;
- if (imagebox.Image != null)
- {
- using (ImagePreviewDialog imagePreviewDialog = new ImagePreviewDialog(document.CompositionSurface.CreateAliasedBitmap(), this.appWorkspace))
- {
- if (!string.IsNullOrEmpty(document.GetFriendlyName()))
- {
- imagePreviewDialog.Text = document.GetFriendlyName();
- }
- imagePreviewDialog.StartPosition = FormStartPosition.CenterScreen;
- imagePreviewDialog.ShowDialog();
- }
- }
- }
- }
- }
|