using PaintDotNet.Base.CommTool; using PaintDotNet.Base.SettingModel; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PaintDotNet.Instrument { internal class ImageInformation : PdnBaseForm { private GroupBox groupBox1; private GroupBox groupBox2; private Label label1; private Label label9; private Label label8; private Label label7; private Label label6; private RichTextBox richTextBox1; private TextBox textBox4; private Label label5; private Label label4; private Label label3; private Label label2; private TextBox textBox1; private TextBox textBox8; private TextBox textBox7; private TextBox textBox6; private TextBox textBox5; private ComboBox comboBox1; private DateTimePicker dateTimePicker1; private Button button1; private AppWorkspace appWorkspace; public ImageInformation(AppWorkspace appWorkspace) { this.appWorkspace = appWorkspace; InitializeComponent(); InitializeLanguageText(); InitializeInformation(); } private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.button1.Text = PdnResources.GetString("Menu.File.Close.Text"); this.groupBox2.Text = PdnResources.GetString("Menu.information.text"); this.label9.Text = PdnResources.GetString("Menu.timeofexposure.text") + ":"; this.label8.Text = PdnResources.GetString("Menu.magnificationchanger.text") + ":"; this.label7.Text = PdnResources.GetString("Menu.Objectlens.text") + ":"; this.label6.Text = PdnResources.GetString("Menu.microscope.text") + ":"; this.label5.Text = PdnResources.GetString("Menu.tool.imageinformation.Imageannotation.text") + ":"; this.label4.Text = PdnResources.GetString("Menu.tool.imageinformation.Imagesize.text") + ":"; this.label3.Text = PdnResources.GetString("Menu.tool.imageinformation.Createdate.text") + ":"; this.label2.Text = PdnResources.GetString("Menu.tool.imageinformation.Imageformat.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.Imagename.text") + ":"; this.Text = PdnResources.GetString("Menu.Tools.ImageInfo.Text"); } private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.textBox8 = new System.Windows.Forms.TextBox(); this.textBox7 = new System.Windows.Forms.TextBox(); this.textBox6 = new System.Windows.Forms.TextBox(); this.textBox5 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.textBox4 = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // 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(403, 56); this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // button1 // this.button1.Location = new System.Drawing.Point(306, 20); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = "关闭"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox2 // this.groupBox2.Controls.Add(this.dateTimePicker1); this.groupBox2.Controls.Add(this.comboBox1); this.groupBox2.Controls.Add(this.textBox8); this.groupBox2.Controls.Add(this.textBox7); this.groupBox2.Controls.Add(this.textBox6); this.groupBox2.Controls.Add(this.textBox5); this.groupBox2.Controls.Add(this.label9); this.groupBox2.Controls.Add(this.label8); this.groupBox2.Controls.Add(this.label7); this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.richTextBox1); this.groupBox2.Controls.Add(this.textBox4); this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Controls.Add(this.textBox1); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new System.Drawing.Point(13, 86); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(403, 464); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "信息"; // // dateTimePicker1 // this.dateTimePicker1.CustomFormat = "yyyy/MM/dd HH:mm:ss"; this.dateTimePicker1.Enabled = false; this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.dateTimePicker1.Location = new System.Drawing.Point(89, 91); this.dateTimePicker1.Name = "dateTimePicker1"; this.dateTimePicker1.Size = new System.Drawing.Size(275, 21); this.dateTimePicker1.TabIndex = 19; // // comboBox1 // this.comboBox1.Enabled = false; this.comboBox1.FormattingEnabled = true; this.comboBox1.Location = new System.Drawing.Point(89, 59); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(275, 20); this.comboBox1.TabIndex = 18; // // textBox8 // this.textBox8.Location = new System.Drawing.Point(89, 428); this.textBox8.Name = "textBox8"; this.textBox8.ReadOnly = true; this.textBox8.Size = new System.Drawing.Size(275, 21); this.textBox8.TabIndex = 17; // // textBox7 // this.textBox7.Location = new System.Drawing.Point(89, 394); this.textBox7.Name = "textBox7"; this.textBox7.ReadOnly = true; this.textBox7.Size = new System.Drawing.Size(275, 21); this.textBox7.TabIndex = 16; // // textBox6 // this.textBox6.Location = new System.Drawing.Point(89, 357); this.textBox6.Name = "textBox6"; this.textBox6.ReadOnly = true; this.textBox6.Size = new System.Drawing.Size(275, 21); this.textBox6.TabIndex = 15; // // textBox5 // this.textBox5.Location = new System.Drawing.Point(89, 322); this.textBox5.Name = "textBox5"; this.textBox5.ReadOnly = true; this.textBox5.Size = new System.Drawing.Size(275, 21); this.textBox5.TabIndex = 14; // // label9 // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(18, 431); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(65, 12); this.label9.TabIndex = 13; this.label9.Text = "曝光时间:"; // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(18, 397); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(53, 12); this.label8.TabIndex = 12; this.label8.Text = "变倍器:"; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(18, 360); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(41, 12); this.label7.TabIndex = 11; this.label7.Text = "物镜:"; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(18, 325); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(53, 12); this.label6.TabIndex = 10; this.label6.Text = "显微镜:"; // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(89, 175); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.ReadOnly = true; this.richTextBox1.Size = new System.Drawing.Size(275, 128); this.richTextBox1.TabIndex = 9; this.richTextBox1.Text = ""; // // textBox4 // this.textBox4.Location = new System.Drawing.Point(89, 132); this.textBox4.Name = "textBox4"; this.textBox4.ReadOnly = true; this.textBox4.Size = new System.Drawing.Size(275, 21); this.textBox4.TabIndex = 8; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(18, 190); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(65, 12); this.label5.TabIndex = 5; this.label5.Text = "图像注释:"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(16, 135); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(65, 12); this.label4.TabIndex = 4; this.label4.Text = "图像大小:"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(16, 97); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(65, 12); this.label3.TabIndex = 3; this.label3.Text = "创建日期:"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(16, 62); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(65, 12); this.label2.TabIndex = 2; this.label2.Text = "图像格式:"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(89, 23); this.textBox1.Name = "textBox1"; this.textBox1.ReadOnly = true; this.textBox1.Size = new System.Drawing.Size(275, 21); this.textBox1.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(16, 26); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(65, 12); this.label1.TabIndex = 0; this.label1.Text = "图像名称:"; // // ImageInformation // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.ClientSize = new System.Drawing.Size(428, 562); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ImageInformation"; this.Text = "图片信息"; this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.ResumeLayout(false); } /// /// 关闭 /// /// /// private void button1_Click(object sender, EventArgs e) { this.Close(); } private void InitializeInformation() { if (this.appWorkspace.ActiveDocumentWorkspace != null) { if (this.appWorkspace.ActiveDocumentWorkspace.CompositionSurface != null) { //获取图片路径 string fileName; //FileType fileType; //SaveConfigToken saveConfigToken; this.appWorkspace.ActiveDocumentWorkspace.GetDocumentSaveOptions(out fileName/*, out fileType, out saveConfigToken*/); if (fileName != null) { //获取图片对应xml PicConfigModel configModel = null; try { string path = Path.GetDirectoryName(fileName); string xmlPath = path + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".xml"; //如果xml存在 if (System.IO.File.Exists(xmlPath)) { configModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(xmlPath, FileMode.Open)); if (configModel != null) { this.textBox1.Text = configModel.meta.text; this.comboBox1.Text = configModel.meta.format; if (configModel.meta.createdTime != null && configModel.meta.createdTime != "") { this.dateTimePicker1.Value = Convert.ToDateTime(configModel.meta.createdTime); } this.textBox4.Text = configModel.meta.imageSize; this.textBox5.Text = configModel.hardware.microscope; this.textBox6.Text = configModel.hardware.objective; this.textBox7.Text = configModel.hardware.magnificationChanger; this.textBox8.Text = configModel.hardware.exposureTime; } } else { //获取图片信息 if (System.IO.File.Exists(fileName)) { FileInfo fi = new FileInfo(fileName); this.textBox1.Text = System.IO.Path.GetFileNameWithoutExtension(fileName); this.comboBox1.Text = Path.GetExtension(fileName);//fileType.Name; this.dateTimePicker1.Value = fi.CreationTime; this.textBox4.Text = FileOperationHelper.GetLength(fi.Length); } else { clearDateTimePicker(); } } } catch (Exception) { clearDateTimePicker(); } } else { clearDateTimePicker(); } } else { clearDateTimePicker(); } } else { clearDateTimePicker(); } } /// /// 清空日期控件的显示数据,默认会显示当前时间 /// private void clearDateTimePicker() { this.dateTimePicker1.CustomFormat = " "; } } }