using Metis.ParameterSet;
using PaintDotNet.Base.CommTool;
using PaintDotNet.Base.Functionodel;
using PaintDotNet.Base.XmlSaveModel;
using PaintDotNet.DbOpreate.DbBll;
using PaintDotNet.DbOpreate.DbModel;
using PaintDotNet.GeneralAnalysis.CustomInterface;
using PaintDotNet.Processing;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace PaintDotNet.GeneralAnalysis
{
///
/// 图谱比照
///
internal class AtlasComparisonDialog : PdnBaseForm
{
#region 控件
private Label label6;
private GroupBox groupBox2;
private TreeView treeView1;
private GroupBox groupBox3;
private ListView listView1;
private GroupBox groupBox4;
private GroupBox groupBox5;
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
private CheckBox checkBox1;
private RadioButton radioButton2;
private RadioButton radioButton1;
private Panel panel1;
private Label label1;
private Label label2;
private GroupBox groupBox1;
private ImageList imageList1;
private IContainer components;
private Panel panel2;
private RadioButton radioButton3;
private RadioButton radioButton6;
private RadioButton radioButton5;
private RadioButton radioButton4;
private PictureUserControl pictureUserControl1, pictureUserControl2,
pictureUserControl3, pictureUserControl4, pictureUserControl5,
pictureUserControl7, pictureUserControl8, pictureUserControl9, pictureUserControl10, pictureUserControl11,
pictureUserControl20, pictureUserControl21, pictureUserControl22,
pictureUserControl23, pictureUserControl24, pictureUserControl25,
pictureUserControl26, pictureUserControl27, pictureUserControl28;
#region 对比对照控件
private Panel panel3;
private Label label3;
private NumericUpDown numericUpDown2;
private NumericUpDown numericUpDown1;
private Label label4;
private Panel panel4;
private Label label5;
private TrackBar trackBar1;
private NumericUpDown numericUpDown3;
private Button button6;
#endregion
private ComboBox comboBox1;
#endregion
///
/// 组织的图谱数据集合
///
public List atlasModels = new List();
///
/// 1/2/4/8
///
private int num = 1;
///
/// 待比照的图片
///
private Bitmap bitmap;
///
/// 图片选择窗口
///
private InterImagePickerDialog imagePickerDialog;
///
/// 主空间
///
private AppWorkspace appWorkspace;
///
/// 关联图片
///
public bool RelatedPic = false;
///
/// 1平铺 2对比
///
private int mode = 1;
///
/// 步长 初始值1,依次增加
///
private string stepLength = "00" + Startup.instance.step_length;
private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
public AtlasComparisonDialog(AppWorkspace appWorkspace)
{
this.appWorkspace = appWorkspace;
InitializeComponent();
InitializeLanguageText();
this.panel3.Visible = false;
this.panel2.Visible = true;
this.pictureUserControl1 = new PictureUserControl(1, this);
this.pictureUserControl2 = new PictureUserControl(2, this);
InitializeRules();
InitializeAtlasFile();
InitializeTreeView();
InitializeCompareControls();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
this.label6.Text = "";
SetAnalyzeModelFromXml("Template.Manager.item2.AtlasComparison");
this.FormClosing += new FormClosingEventHandler(this.ClosingEvent);
//用来处理对比对照切换图片的时候,生成右边的二值图层
this.pictureUserControl2.pictureBox1.Paint += this.pictureBox1_Paint;
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if(this.pictureUserControl2.bitmap!=null)
{
if (this.mode == 2)
{
IninializeBinaryCompare();
}
}
}
private void ClosingEvent(object sender, FormClosingEventArgs e)
{
this.saveLastData(sender,e);
if (imagePickerDialog != null)
{
if (!imagePickerDialog.IsDisposed)
{
imagePickerDialog.Close();
}
}
}
///
/// 窗口加载
///
///
///
private void AtlasComparisonDialog_Load(object sender, EventArgs e)
{
pictureUserControl20 = new PictureUserControl(2, this); pictureUserControl21 = new PictureUserControl(2, this); pictureUserControl22 = new PictureUserControl(2, this);
pictureUserControl23 = new PictureUserControl(2, this); pictureUserControl24 = new PictureUserControl(1, this); pictureUserControl25 = new PictureUserControl(2, this);
pictureUserControl26 = new PictureUserControl(2, this); pictureUserControl27 = new PictureUserControl(2, this); pictureUserControl28 = new PictureUserControl(2, this);
getLastData();
}
List list;
///
/// 初始化标尺
///
private void InitializeRules()
{
//List list = mic_rulers_BLL.FindAll();
list = Startup.instance.mic_rulersAll;
this.comboBox1.DisplayMember = "ruler_name";
this.comboBox1.ValueMember = "id";
this.comboBox1.DataSource = list;
}
///
/// 标尺乘以放大倍数
///
///
private double GetRulerMultiple()
{
DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
Document document = Document.FromImageMat(Camera.Tools.ToMat(bitmap));
dw.Document = document;
if (list != null && list.Count > 0)
{
for (int i = 0; i < list.Count; i++)
{
if (list[i].ruler_name == this.comboBox1.Text)
{
dw.xmlSaveModel = list[i];
}
}
}
dw.InitRulerInfo();
double pantographRatio = dw.GetRulerMultiple(MeasurementUnit.Micron);
this.appWorkspace.RemoveDocumentWorkspace(dw);
return pantographRatio;
}
///
/// 生成报告
///
///
///
private void button1_Click(object sender, EventArgs e)
{
if (this.checkBox1.Checked)
this.button5.PerformClick();
if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
{
List bitList = new List();
if (bitmap == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
return;
}
double pantographRatio = GetRulerMultiple();
//平铺
if (this.radioButton1.Checked)
{
switch (this.num)
{
case 1:
if (this.pictureUserControl2.Bitmap != null)
{
this.pictureUserControl2.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl2.Bitmap);
}
if (this.pictureUserControl1.Bitmap != null)
{
this.pictureUserControl1.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl1.Bitmap);
}
break;
case 2:
if (this.pictureUserControl5.Bitmap != null)
{
this.pictureUserControl5.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl5.Bitmap);
}
if (this.pictureUserControl4.Bitmap != null)
{
this.pictureUserControl4.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl4.Bitmap);
}
if (this.pictureUserControl3.Bitmap != null)
{
this.pictureUserControl3.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl3.Bitmap);
}
break;
case 4:
if (this.pictureUserControl8.Bitmap != null)
{
this.pictureUserControl8.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl8.Bitmap);
}
if (this.pictureUserControl11.Bitmap != null)
{
this.pictureUserControl11.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl11.Bitmap);
}
if (this.pictureUserControl7.Bitmap != null)
{
this.pictureUserControl7.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl7.Bitmap);
}
if (this.pictureUserControl9.Bitmap != null)
{
this.pictureUserControl9.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl9.Bitmap);
}
if (this.pictureUserControl10.Bitmap != null)
{
this.pictureUserControl10.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl10.Bitmap);
}
break;
case 8:
if (this.pictureUserControl20.Bitmap != null)
{
this.pictureUserControl20.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl20.Bitmap);
}
if (this.pictureUserControl21.Bitmap != null)
{
this.pictureUserControl21.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl21.Bitmap);
}
if (this.pictureUserControl22.Bitmap != null)
{
this.pictureUserControl22.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl22.Bitmap);
}
if (this.pictureUserControl23.Bitmap != null)
{
this.pictureUserControl23.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl23.Bitmap);
}
if (this.pictureUserControl24.Bitmap != null)
{
this.pictureUserControl24.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl24.Bitmap);
}
if (this.pictureUserControl25.Bitmap != null)
{
this.pictureUserControl25.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl25.Bitmap);
}
if (this.pictureUserControl26.Bitmap != null)
{
this.pictureUserControl26.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl26.Bitmap);
}
if (this.pictureUserControl27.Bitmap != null)
{
this.pictureUserControl27.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl27.Bitmap);
}
if (this.pictureUserControl28.Bitmap != null)
{
this.pictureUserControl28.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl28.Bitmap);
}
break;
}
}
//对比
else if (this.radioButton2.Checked)
{
if (this.pictureUserControl2.Bitmap != null)
{
this.pictureUserControl2.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl2.Bitmap);
}
if (this.pictureUserControl1.ComBitmap != null && this.pictureUserControl1.Bitmap != null)
{
Bitmap comBit = GetCombineBit();
if (comBit != null)
{
comBit.Tag = pantographRatio;
bitList.Add(comBit);
}
}
else if (this.pictureUserControl1.ComBitmap != null && this.pictureUserControl1.Bitmap == null)
{
this.pictureUserControl1.ComBitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl1.ComBitmap);
}
else if (this.pictureUserControl1.ComBitmap == null && this.pictureUserControl1.Bitmap != null)
{
this.pictureUserControl1.Bitmap.Tag = pantographRatio;
bitList.Add(this.pictureUserControl1.Bitmap);
}
}
this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, null, bitList, null);
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
}
}
private Bitmap GetCombineBit()
{
if (this.pictureUserControl1.Bitmap != null && this.pictureUserControl1.ComBitmap != null)
{
Bitmap bitmap = null;
try
{
int aw = this.pictureUserControl1.Bitmap.Width;
int ah = this.pictureUserControl1.Bitmap.Height;
int bw = this.pictureUserControl1.ComBitmap.Width;
int bh = this.pictureUserControl1.ComBitmap.Height;
int width = aw > bw ? aw : bw;
int height = ah > bh ? ah : bh;
bitmap = new Bitmap(width, height);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.DrawImage(this.pictureUserControl1.Bitmap, (width - aw) / 2, (height - ah) / 2, aw, ah);
graphics.DrawImage(this.pictureUserControl1.ComBitmap, (width - bw) / 2, (height - bh) / 2, bw, bh);
return bitmap;
}
catch (Exception)
{
return null;
}
}
else
return null;
}
///
/// 关联图片,同步放大缩小平移旋转...
///
///
///
private void button2_Click(object sender, EventArgs e)
{
this.RelatedPic = !this.RelatedPic;
}
///
/// 浏览已经打开的所有图片
///
///
///
private void button4_Click(object sender, EventArgs e)
{
if (imagePickerDialog == null)
{
imagePickerDialog = new InterImagePickerDialog(this.appWorkspace);
imagePickerDialog.StartPosition = FormStartPosition.Manual;
if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width-150)
{
imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
}
else
{
imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
}
imagePickerDialog.Top = ((Button)sender).Bottom + 46 + this.Top;
imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
imagePickerDialog.Show();
}
else
{
if (!imagePickerDialog.IsDisposed)
{
imagePickerDialog.WindowState = FormWindowState.Normal;
}
else
{
imagePickerDialog = new InterImagePickerDialog(this.appWorkspace);
imagePickerDialog.StartPosition = FormStartPosition.Manual;
if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - 150)
{
imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
}
else
{
imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
}
imagePickerDialog.Top = ((Button)sender).Bottom + 46 + this.Top;
imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
imagePickerDialog.Show();
}
}
}
///
/// 从图库选择待对照图片
///
///
///
private void inputMat_ValueChanged(object sender, EventArgs e)
{
if (sender is DocumentWorkspace)
{
this.bitmap = ((DocumentWorkspace)sender).CompositionSurface.CreateAliasedBitmap();
//如果存在相,则绘制相
if (((DocumentWorkspace)sender).phaseModels!=null && ((DocumentWorkspace)sender).phaseModels.Count>0)
{
Graphics graphics = Graphics.FromImage(this.bitmap);
foreach (PhaseModel model in ((DocumentWorkspace)sender).phaseModels)
{
if(model.mat!=null)
{
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat), new PointF(0,0));
}
}
}
switch (num)
{
case 1:
this.pictureUserControl1.Bitmap = this.bitmap;
break;
case 2:
this.pictureUserControl4.Bitmap = this.bitmap;
break;
case 4:
this.pictureUserControl7.Bitmap = this.bitmap;
break;
case 8:
this.pictureUserControl24.Bitmap = this.bitmap;
break;
}
}
}
///
/// 打开文件浏览
///
///
///
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = PdnResources.GetString("Menu.Theimagefile.Text")+"|*.jpg;*.png;*.bmp;";
dialog.InitialDirectory = Environment.CurrentDirectory;
dialog.ShowDialog();
if (dialog.FileName != String.Empty)
{
this.bitmap = new Bitmap(dialog.FileName);
switch (num)
{
case 1:
this.pictureUserControl1.Bitmap = this.bitmap;
break;
case 2:
this.pictureUserControl4.Bitmap = this.bitmap;
break;
case 4:
this.pictureUserControl7.Bitmap = this.bitmap;
break;
case 8:
this.pictureUserControl24.Bitmap = this.bitmap;
break;
}
}
}
///
/// 初始化对比控件
///
private void InitializeCompareControls()
{
this.panel1.Controls.Clear();
switch (this.num)
{
case 1:
this.pictureUserControl2.Dock = DockStyle.Left;
this.pictureUserControl2.Width = this.panel1.Width / 2;
this.pictureUserControl1.Dock = DockStyle.Left;
this.pictureUserControl1.Width = this.panel1.Width / 2;
this.panel1.Controls.Add(this.pictureUserControl1);
this.panel1.Controls.Add(this.pictureUserControl2);
this.pictureUserControl1.Bitmap = this.bitmap;
break;
case 2:
if(pictureUserControl3 == null) pictureUserControl3 = new PictureUserControl(2, this);
pictureUserControl3.Dock = DockStyle.Left;
pictureUserControl3.Width = this.panel1.Width / 3;
if(pictureUserControl4==null) pictureUserControl4 = new PictureUserControl(1, this);
pictureUserControl4.Dock = DockStyle.Left;
pictureUserControl4.Width = this.panel1.Width / 3;
if (pictureUserControl5 == null) pictureUserControl5 = new PictureUserControl(2, this);
pictureUserControl5.Dock = DockStyle.Left;
pictureUserControl5.Width = this.panel1.Width / 3;
this.panel1.Controls.Add(pictureUserControl3);
this.panel1.Controls.Add(pictureUserControl4);
this.panel1.Controls.Add(pictureUserControl5);
this.pictureUserControl4.Bitmap = this.bitmap;
break;
case 4:
if (pictureUserControl7 == null) pictureUserControl7 = new PictureUserControl(1, this);
pictureUserControl7.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
pictureUserControl7.Width = this.panel1.Width / 3;
pictureUserControl7.Height = this.panel1.Height / 3;
pictureUserControl7.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
if (pictureUserControl8 == null) pictureUserControl8 = new PictureUserControl(2, this);
pictureUserControl8.Anchor = AnchorStyles.Top;
pictureUserControl8.Width = this.panel1.Width / 3;
pictureUserControl8.Height = this.panel1.Height / 3;
pictureUserControl8.Location = new Point(this.panel1.Width / 3, 0);
if (pictureUserControl9 == null) pictureUserControl9 = new PictureUserControl(2, this);
pictureUserControl9.Anchor = AnchorStyles.Right;
pictureUserControl9.Width = this.panel1.Width / 3;
pictureUserControl9.Height = this.panel1.Height / 3;
pictureUserControl9.Location = new Point((this.panel1.Width / 3)*2, this.panel1.Height / 3);
if (pictureUserControl10 == null) pictureUserControl10 = new PictureUserControl(2, this);
pictureUserControl10.Anchor = AnchorStyles.Bottom;
pictureUserControl10.Width = this.panel1.Width / 3;
pictureUserControl10.Height = this.panel1.Height / 3;
pictureUserControl10.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3)*2);
if (pictureUserControl11 == null) pictureUserControl11 = new PictureUserControl(2, this);
pictureUserControl11.Anchor = AnchorStyles.Left;
pictureUserControl11.Width = this.panel1.Width / 3;
pictureUserControl11.Height = this.panel1.Height / 3;
pictureUserControl11.Location = new Point(0, this.panel1.Height / 3);
this.panel1.Controls.Add(pictureUserControl8);
this.panel1.Controls.Add(pictureUserControl9);
this.panel1.Controls.Add(pictureUserControl10);
this.panel1.Controls.Add(pictureUserControl11);
this.panel1.Controls.Add(pictureUserControl7);
this.pictureUserControl7.Bitmap = this.bitmap;
break;
case 8:
pictureUserControl20.Anchor = AnchorStyles.Top | AnchorStyles.Left;
pictureUserControl20.Width = this.panel1.Width / 3;
pictureUserControl20.Height = this.panel1.Height / 3;
pictureUserControl20.Location = new Point(0, 0);
pictureUserControl21.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
pictureUserControl21.Width = this.panel1.Width / 3;
pictureUserControl21.Height = this.panel1.Height / 3;
pictureUserControl21.Location = new Point(this.panel1.Width / 3, 0);
pictureUserControl22.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pictureUserControl22.Width = this.panel1.Width / 3;
pictureUserControl22.Height = this.panel1.Height / 3;
pictureUserControl22.Location = new Point((this.panel1.Width / 3) * 2, 0);
pictureUserControl23.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
pictureUserControl23.Width = this.panel1.Width / 3;
pictureUserControl23.Height = this.panel1.Height / 3;
pictureUserControl23.Location = new Point(0, this.panel1.Height / 3);
pictureUserControl24.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
pictureUserControl24.Width = this.panel1.Width / 3;
pictureUserControl24.Height = this.panel1.Height / 3;
pictureUserControl24.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
pictureUserControl25.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
pictureUserControl25.Width = this.panel1.Width / 3;
pictureUserControl25.Height = this.panel1.Height / 3;
pictureUserControl25.Location = new Point((this.panel1.Width / 3) * 2, this.panel1.Height / 3);
pictureUserControl26.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
pictureUserControl26.Width = this.panel1.Width / 3;
pictureUserControl26.Height = this.panel1.Height / 3;
pictureUserControl26.Location = new Point(0, (this.panel1.Height / 3)*2);
pictureUserControl27.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
pictureUserControl27.Width = this.panel1.Width / 3;
pictureUserControl27.Height = this.panel1.Height / 3;
pictureUserControl27.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3) * 2);
pictureUserControl28.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
pictureUserControl28.Width = this.panel1.Width / 3;
pictureUserControl28.Height = this.panel1.Height / 3;
pictureUserControl28.Location = new Point((this.panel1.Width / 3) * 2, (this.panel1.Height / 3)*2);
this.panel1.Controls.Add(pictureUserControl20);
this.panel1.Controls.Add(pictureUserControl21);
this.panel1.Controls.Add(pictureUserControl22);
this.panel1.Controls.Add(pictureUserControl23);
this.panel1.Controls.Add(pictureUserControl24);
this.panel1.Controls.Add(pictureUserControl25);
this.panel1.Controls.Add(pictureUserControl26);
this.panel1.Controls.Add(pictureUserControl27);
this.panel1.Controls.Add(pictureUserControl28);
this.pictureUserControl24.Bitmap = this.bitmap;
break;
}
}
///
/// 初始化图谱数据
/// 读取图谱文件夹(Atlas文件夹)的xml文件并解析
///
private void InitializeAtlasFile()
{
atlasModels.Clear();
List fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Atlas\\");
XmlDocument xml = new XmlDocument();
foreach (string fileName in fileNames)
{
//Load Xml
xml.Load(Application.StartupPath + "\\Atlas\\" + fileName);
//读取根元素
XmlElement root = xml.DocumentElement;
//递归解析xml
ParsingXml(root, 1, "");
}
}
///
/// 初始化treeview
///
private void InitializeTreeView()
{
this.treeView1.ImageList = new ImageList();
this.treeView1.ImageList.Images.Add("Top", PdnResources.GetImageResource("Icons.SettingsIcon.png").Reference);
this.treeView1.ImageList.Images.Add("Catalog", PdnResources.GetImageResource("Icons.ImageFromDiskIcon.png").Reference);
this.treeView1.ImageList.Images.Add("Atlas", PdnResources.GetImageResource("Icons.AddNoiseEffect.png").Reference);
if (this.atlasModels.Count > 0)
{
for (int i = 0; i < this.atlasModels.Count; i++)
{
if (this.atlasModels[i].parentId.Equals(""))
{
TreeNode anime = new TreeNode();
anime.Tag = this.atlasModels[i].id;
anime.Text = this.atlasModels[i].name;
anime.ImageKey = "Top";
this.treeView1.Nodes.Add(anime);
RecursiveData(anime);
}
}
}
}
///
/// 递归处理treeview数据
///
private void RecursiveData(TreeNode anime)
{
List models = this.atlasModels.FindAll(a => a.parentId.Equals(anime.Tag));
if (models != null && models.Count > 0)
{
for (int i = 0; i < models.Count; i++)
{
if (models[i].type == 1)
{
TreeNode animeC = new TreeNode();
animeC.Tag = models[i].id;
animeC.Text = models[i].name;
animeC.ImageKey = "Catalog";
animeC.SelectedImageKey = "Catalog";
RecursiveData(animeC);
anime.Nodes.Add(animeC);
}
}
}
}
///
/// 递归解析xml
///
/// 节点
/// 1根节点 2分类 3图铺
private void ParsingXml(XmlElement element, int level, string parentId)
{
if (level == 1)
{
AtlasModel model = new AtlasModel();
model.name = element.GetAttribute("Name");
model.id = Guid.NewGuid().ToString();
model.parentId = parentId;
model.path = model.name;
model.type = 0;
this.atlasModels.Add(model);
XmlNodeList list = element.FirstChild.ChildNodes;
if (list != null && list.Count > 0)
{
foreach (XmlNode node in list)
{
ParsingXml((XmlElement)node, 2, model.id);
}
}
}
else if (level == 2)
{
AtlasModel model = new AtlasModel();
model.name = element.GetAttribute("Name");
model.id = Guid.NewGuid().ToString();
model.parentId = parentId;
model.path = model.name;
model.type = 1;
this.atlasModels.Add(model);
XmlNodeList list = element.FirstChild.ChildNodes;
if (list != null && list.Count > 0)
{
foreach (XmlNode node in list)
{
if (node.FirstChild.Name.Equals("MapImage"))
{
ParsingXml((XmlElement)node, 3, model.id);
}
else
{
ParsingXml((XmlElement)node, 2, model.id);
}
}
}
}
else if (level == 3)
{
AtlasModel model = new AtlasModel();
model.name = element.GetAttribute("Name");
model.id = Guid.NewGuid().ToString();
model.parentId = parentId;
model.path = model.name;
model.type = 2;
model.bitmap = DrawRulerHelper.Base64StringToImage(element.InnerText);
this.atlasModels.Add(model);
}
}
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node != null)
{
if (this.treeView1.SelectedNode != e.Node)
{
this.imageList1.Images.Clear();
this.listView1.Items.Clear();
this.treeView1.SelectedNode = e.Node;
this.InitListViewData(this.treeView1.SelectedNode);
this.InitializePlayUserControl();
}
}
}
private void InitializePlayUserControl()
{
switch(this.num)
{
case 1:
this.pictureUserControl2.ImageCollection = this.imageList1.Images;
this.pictureUserControl2.CurrentPosition = 1;
break;
case 2:
this.pictureUserControl3.ImageCollection = this.imageList1.Images;
this.pictureUserControl3.CurrentPosition = 2;
this.pictureUserControl5.ImageCollection = this.imageList1.Images;
this.pictureUserControl5.CurrentPosition = 1;
break;
case 4:
this.pictureUserControl8.ImageCollection = this.imageList1.Images;
this.pictureUserControl8.CurrentPosition = 1;
this.pictureUserControl9.ImageCollection = this.imageList1.Images;
this.pictureUserControl9.CurrentPosition = 2;
this.pictureUserControl10.ImageCollection = this.imageList1.Images;
this.pictureUserControl10.CurrentPosition = 3;
this.pictureUserControl11.ImageCollection = this.imageList1.Images;
this.pictureUserControl11.CurrentPosition = 4;
break;
case 8:
this.pictureUserControl20.ImageCollection = this.imageList1.Images;
this.pictureUserControl20.CurrentPosition = 1;
this.pictureUserControl21.ImageCollection = this.imageList1.Images;
this.pictureUserControl21.CurrentPosition = 2;
this.pictureUserControl22.ImageCollection = this.imageList1.Images;
this.pictureUserControl22.CurrentPosition = 3;
this.pictureUserControl23.ImageCollection = this.imageList1.Images;
this.pictureUserControl23.CurrentPosition = 4;
this.pictureUserControl25.ImageCollection = this.imageList1.Images;
this.pictureUserControl25.CurrentPosition = 5;
this.pictureUserControl26.ImageCollection = this.imageList1.Images;
this.pictureUserControl26.CurrentPosition = 6;
this.pictureUserControl27.ImageCollection = this.imageList1.Images;
this.pictureUserControl27.CurrentPosition = 7;
this.pictureUserControl28.ImageCollection = this.imageList1.Images;
this.pictureUserControl28.CurrentPosition = 8;
break;
}
}
///
/// 使用标尺的切换
///
///
///
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
// TODO ZYH 标尺切换改变图像大小
if (this.comboBox1.SelectedIndex >= 0)
{
}
}
private void InitListViewData(TreeNode node)
{
this.imageList1.Images.Clear();
this.listView1.Items.Clear();
if (node == null)
{
List lists = this.atlasModels.FindAll(a => a.bitmap != null);
for (int i = 0; i < lists.Count; i++)
{
this.imageList1.ImageSize = new System.Drawing.Size(72, 72);
this.imageList1.Images.Add("img" + i, lists[i].bitmap);
this.imageList1.Images.SetKeyName(i, lists[i].id);
this.listView1.Items.Add("", i);
this.listView1.Items[i].Tag = lists[i].id;
this.listView1.Items[i].ImageIndex = i;
this.listView1.Items[i].Text = lists[i].name;
}
}
else
{
AtlasModel model = this.atlasModels.Find(a => a.id.Equals(node.Tag.ToString()));
if (model != null)
{
if (model.type == 0 || model.type == 1)
{
List lists = this.atlasModels.FindAll(a => a.bitmap != null && a.parentId.Equals(model.id));
for (int i = 0; i < lists.Count; i++)
{
this.imageList1.ImageSize = new System.Drawing.Size(72, 72);
this.imageList1.Images.Add("img" + i, lists[i].bitmap);
this.imageList1.Images.SetKeyName(i, lists[i].id);
this.listView1.Items.Add("", i);
this.listView1.Items[i].Tag = lists[i].id;
this.listView1.Items[i].ImageIndex = i;
this.listView1.Items[i].Text = lists[i].name;
}
}
else if (model.type == 2)
{
this.imageList1.ImageSize = new System.Drawing.Size(72, 72);
this.imageList1.Images.Add("img", model.bitmap);
this.imageList1.Images.SetKeyName(0, model.id);
this.listView1.Items.Add("", 0);
this.listView1.Items[0].Tag = model.id;
this.listView1.Items[0].ImageIndex = 0;
this.listView1.Items[0].Text = model.name;
}
}
}
}
///
/// 设置
///
///
///
private void button5_Click(object sender, EventArgs e)
{
AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.AtlasComparison");
if (recombinationRateSetDialog.hasModule)
{
recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
recombinationRateSetDialog.ShowDialog();
}
else
{
recombinationRateSetDialog = null;
}
/*using (AtlasSettingDialog atlasSettingDialog = new AtlasSettingDialog())
{
atlasSettingDialog.StartPosition = FormStartPosition.CenterScreen;
atlasSettingDialog.ShowDialog();
}*/
}
private void panel1_SizeChanged(object sender, EventArgs e)
{
switch (this.num)
{
case 1:
this.pictureUserControl1.Width = this.panel1.Width / 2;
this.pictureUserControl2.Width = this.panel1.Width / 2;
break;
case 2:
this.pictureUserControl3.Width = this.panel1.Width / 3;
this.pictureUserControl4.Width = this.panel1.Width / 3;
this.pictureUserControl5.Width = this.panel1.Width / 3;
break;
case 4:
foreach (Control control in this.panel1.Controls)
{
control.Width = this.panel1.Width / 3;
control.Height = this.panel1.Height / 3;
}
this.pictureUserControl7.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
this.pictureUserControl8.Location = new Point(this.panel1.Width / 3, 0);
this.pictureUserControl9.Location = new Point((this.panel1.Width / 3) * 2, this.panel1.Height / 3);
this.pictureUserControl10.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3) * 2);
this.pictureUserControl11.Location = new Point(0, this.panel1.Height / 3);
break;
case 8:
foreach (Control control in this.panel1.Controls)
{
control.Width = this.panel1.Width / 3;
control.Height = this.panel1.Height / 3;
}
pictureUserControl20.Location = new Point(0, 0);
pictureUserControl21.Location = new Point(this.panel1.Width / 3, 0);
pictureUserControl22.Location = new Point((this.panel1.Width / 3) * 2, 0);
pictureUserControl23.Location = new Point(0, this.panel1.Height / 3);
pictureUserControl24.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
pictureUserControl25.Location = new Point((this.panel1.Width / 3) * 2, this.panel1.Height / 3);
pictureUserControl26.Location = new Point(0, (this.panel1.Height / 3) * 2);
pictureUserControl27.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3) * 2);
pictureUserControl28.Location = new Point((this.panel1.Width / 3) * 2, (this.panel1.Height / 3) * 2);
break;
}
}
///
/// 对照模式切换事件
///
///
///
private void radioButton_CheckedChanged(object sender, EventArgs e)
{
if(this.radioButton1.Checked)
{
this.mode = 1;
this.panel3.Visible = false;
this.panel2.Visible = true;
}
else if (this.radioButton2.Checked)
{
this.mode = 2;
this.panel2.Visible = false;
this.panel3.Visible = true;
this.num = 1;
this.radioButton3.Checked = true;
this.IninializeBinaryCompare();
}
}
#region 对比对照
///
/// 对比对照
///
private unsafe void IninializeBinaryCompare()
{
if(this.pictureUserControl2.Bitmap!=null)
{
OpenCvSharp.Mat source = PaintDotNet.Camera.Tools.ToMat(this.pictureUserControl2.Bitmap);
OpenCvSharp.Mat srcGray;
if (source.Type() == OpenCvSharp.MatType.CV_8UC1)
{
srcGray = source;
}
else
{
srcGray = source.CvtColor(OpenCvSharp.ColorConversionCodes.BGR2GRAY);
}
OpenCvSharp.Mat src = new OpenCvSharp.Mat(source.Rows, source.Cols, OpenCvSharp.MatType.CV_8UC4, new OpenCvSharp.Scalar(0, 0, 0, 0));
int index1 = 0;
byte* ptr1 = (byte*)srcGray.Data;
int index2 = 0;
byte* ptr2 = (byte*)src.Data;
for (int o = 0; o < srcGray.Height; o++)
{
for (int p = 0; p < srcGray.Width; p++)
{
index1 = (int)((srcGray.Step() * o) + (p * 1));
index2 = (int)((src.Step() * o) + (p * 4));
if (ptr1[index1] >= this.numericUpDown1.Value && ptr1[index1] <= this.numericUpDown2.Value)
{
ptr2[index2] = this.panel4.BackColor.B;
ptr2[index2 + 1] = this.panel4.BackColor.G;
ptr2[index2 + 2] = this.panel4.BackColor.R;
ptr2[index2 + 3] = (byte)this.numericUpDown3.Value;
}
}
}
this.pictureUserControl1.ComBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src);
this.pictureUserControl1.pictureBox1.Refresh();
}
}
///
/// 对比对照 二值初始值
///
///
///
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
IninializeBinaryCompare();
}
///
/// 对比对照 二值结束值
///
///
///
private void numericUpDown2_ValueChanged(object sender, EventArgs e)
{
IninializeBinaryCompare();
}
///
/// 对比对照 颜色panel点击事件
///
///
///
private void panel4_Click(object sender, EventArgs e)
{
IninializeBinaryCompare();
}
///
/// 透明度值改变事件
///
///
///
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
this.numericUpDown3.Value = this.trackBar1.Value;
}
///
/// 透明度值改变事件
///
///
///
private void numericUpDown3_ValueChanged(object sender, EventArgs e)
{
this.trackBar1.Value = (int)this.numericUpDown3.Value;
IninializeBinaryCompare();
}
///
/// 创建图片,合成图片
///
///
///
private void button6_Click(object sender, EventArgs e)
{
if (this.pictureUserControl1.Bitmap!=null && this.pictureUserControl1.ComBitmap!=null)
{
Bitmap bitmap = null;
try
{
int aw = this.pictureUserControl1.Bitmap.Width;
int ah = this.pictureUserControl1.Bitmap.Height;
int bw = this.pictureUserControl1.ComBitmap.Width;
int bh = this.pictureUserControl1.ComBitmap.Height;
int width = aw > bw ? aw : bw;
int height = ah > bh ? ah : bh;
bitmap = new Bitmap(width, height);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.DrawImage(this.pictureUserControl1.Bitmap, (width - aw)/2, (height - ah)/2, aw, ah);
graphics.DrawImage(this.pictureUserControl1.ComBitmap, (width - bw)/2, (height - bh)/2, bw, bh);
//OpenCvSharp.Cv2.ImShow("123", PaintDotNet.Camera.Tools.ToMat(bitmap));
DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
Document document = Document.FromImageMat(Camera.Tools.ToMat(bitmap));
dw.Document = document;
if (list != null && list.Count >0)
{
for (int i = 0; i < list.Count; i++)
{
if (list[i].ruler_name == this.comboBox1.Text)
{
dw.xmlSaveModel = list[i];
}
}
}
dw.InitRulerInfo();
dw.fileText = this.Text + "-" + stepLength;
this.appWorkspace.ActiveDocumentWorkspace = dw;
Startup.instance.step_length += 1;
stepLength = "00" + Startup.instance.step_length;
}
catch(Exception)
{
}
finally
{
if (bitmap != null) bitmap.Dispose();
}
}
}
#endregion
private void pp_radioButton_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton3.Checked)
{
this.num = 1;
}
else if(this.radioButton4.Checked)
{
this.num = 2;
}
else if (this.radioButton5.Checked)
{
this.num = 4;
}
else if (this.radioButton6.Checked)
{
this.num = 8;
}
if (((RadioButton)sender).Checked)
{
InitializeCompareControls();
InitializePlayUserControl();
}
}
///
/// 关联放大
///
public void ZoomInButton_click()
{
foreach (Control control in this.panel1.Controls)
{
if(control.GetType() == typeof(PictureUserControl))
{
((PictureUserControl)control).ZoomIn();
}
}
}
///
/// 关联缩小
///
public void ZoomOutButton_click()
{
foreach (Control control in this.panel1.Controls)
{
if (control.GetType() == typeof(PictureUserControl))
{
((PictureUserControl)control).ZoomOut();
}
}
}
///
/// 关联顺时针旋转90
///
public void Rotate90Button_click()
{
foreach (Control control in this.panel1.Controls)
{
if (control.GetType() == typeof(PictureUserControl))
{
((PictureUserControl)control).Rotate90();
}
}
}
///
/// 关联逆时针旋转90
///
public void Rotate_90Button_click()
{
foreach (Control control in this.panel1.Controls)
{
if (control.GetType() == typeof(PictureUserControl))
{
((PictureUserControl)control).Rotate_90();
}
}
}
public void SetSelectFlag()
{
foreach (Control control in this.panel1.Controls)
{
if (control.GetType() == typeof(PictureUserControl))
{
((PictureUserControl)control).selectFlag = false;
}
}
this.panel1.Refresh();
}
#region Windows Form Designer generated code
private void InitializeLanguageText()
{
this.radioButton2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Contrast.text");
this.radioButton1.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Tilecontrast.text");
this.groupBox5.Text = PdnResources.GetString("Menu.Setting.Text");
this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Currentlevel.text") + ":";
this.label1.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Useruler.text") + ":";
this.Text = PdnResources.GetString("Menu.GeneralAnalysis.MapComparison.Text");
this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Atlasselection.text");
this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Atlascatalog.text");
this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Controlmode.text");
this.button6.Text = PdnResources.GetString("Menu.Createpicture.text");
this.label5.Text = PdnResources.GetString("Menu.transparency.text") + ":";
this.label4.Text = PdnResources.GetString("Menu.color.text") + ":";
this.label3.Text = PdnResources.GetString("Menu.Binarization.text") + ":";
this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
this.button5.Text = PdnResources.GetString("Menu.Setting.Text");
this.button4.Text = PdnResources.GetString("Menu.Gallery.text");
this.button3.Text = PdnResources.GetString("Menu.harddisk.text");
this.button2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Associatedpicture.text");
this.button1.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button5 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.treeView1 = new System.Windows.Forms.TreeView();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.panel2 = new System.Windows.Forms.Panel();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.panel3 = new System.Windows.Forms.Panel();
this.button6 = new System.Windows.Forms.Button();
this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.label5 = new System.Windows.Forms.Label();
this.panel4 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.label6 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.groupBox5.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Controls.Add(this.button5);
this.groupBox1.Controls.Add(this.button4);
this.groupBox1.Controls.Add(this.button3);
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(1229, 52);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "操作";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(89, 23);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(132, 16);
this.checkBox1.TabIndex = 5;
this.checkBox1.Text = "生成报告时打开设置";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button5
//
this.button5.Location = new System.Drawing.Point(7, 20);
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);
//
// button4
//
this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button4.Location = new System.Drawing.Point(905, 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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button3.Location = new System.Drawing.Point(986, 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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Location = new System.Drawing.Point(1067, 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);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(1148, 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.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox2.Controls.Add(this.treeView1);
this.groupBox2.Location = new System.Drawing.Point(13, 72);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(186, 484);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "图谱选择";
//
// treeView1
//
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.treeView1.Location = new System.Drawing.Point(7, 21);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(173, 457);
this.treeView1.TabIndex = 0;
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox3.Controls.Add(this.listView1);
this.groupBox3.Location = new System.Drawing.Point(205, 72);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(133, 385);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "图谱目录";
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.HideSelection = false;
this.listView1.LargeImageList = this.imageList1;
this.listView1.Location = new System.Drawing.Point(7, 21);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(120, 358);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.panel2);
this.groupBox4.Controls.Add(this.panel3);
this.groupBox4.Controls.Add(this.radioButton2);
this.groupBox4.Controls.Add(this.radioButton1);
this.groupBox4.Location = new System.Drawing.Point(205, 463);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(690, 93);
this.groupBox4.TabIndex = 3;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "对照模式";
//
// panel2
//
this.panel2.Controls.Add(this.radioButton6);
this.panel2.Controls.Add(this.radioButton5);
this.panel2.Controls.Add(this.radioButton4);
this.panel2.Controls.Add(this.radioButton3);
this.panel2.Location = new System.Drawing.Point(87, 12);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(320, 75);
this.panel2.TabIndex = 2;
//
// radioButton6
//
this.radioButton6.AutoSize = true;
this.radioButton6.Location = new System.Drawing.Point(118, 14);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(29, 16);
this.radioButton6.TabIndex = 3;
this.radioButton6.TabStop = true;
this.radioButton6.Text = "8";
this.radioButton6.UseVisualStyleBackColor = true;
this.radioButton6.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
//
// radioButton5
//
this.radioButton5.AutoSize = true;
this.radioButton5.Location = new System.Drawing.Point(83, 14);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(29, 16);
this.radioButton5.TabIndex = 2;
this.radioButton5.TabStop = true;
this.radioButton5.Text = "4";
this.radioButton5.UseVisualStyleBackColor = true;
this.radioButton5.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(48, 14);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(29, 16);
this.radioButton4.TabIndex = 1;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "2";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Checked = true;
this.radioButton3.Location = new System.Drawing.Point(13, 14);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(29, 16);
this.radioButton3.TabIndex = 0;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "1";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
//
// panel3
//
this.panel3.Controls.Add(this.button6);
this.panel3.Controls.Add(this.numericUpDown3);
this.panel3.Controls.Add(this.trackBar1);
this.panel3.Controls.Add(this.label5);
this.panel3.Controls.Add(this.panel4);
this.panel3.Controls.Add(this.label4);
this.panel3.Controls.Add(this.numericUpDown2);
this.panel3.Controls.Add(this.numericUpDown1);
this.panel3.Controls.Add(this.label3);
this.panel3.Location = new System.Drawing.Point(87, 12);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(320, 75);
this.panel3.TabIndex = 4;
//
// button6
//
this.button6.Location = new System.Drawing.Point(223, 38);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(75, 23);
this.button6.TabIndex = 8;
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// numericUpDown3
//
this.numericUpDown3.Location = new System.Drawing.Point(169, 39);
this.numericUpDown3.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown3.Name = "numericUpDown3";
this.numericUpDown3.Size = new System.Drawing.Size(48, 21);
this.numericUpDown3.TabIndex = 7;
this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
//
// trackBar1
//
this.trackBar1.Location = new System.Drawing.Point(59, 41);
this.trackBar1.Maximum = 255;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(104, 45);
this.trackBar1.TabIndex = 6;
this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(11, 43);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(0, 12);
this.label5.TabIndex = 5;
//
// panel4
//
this.panel4.BackColor = System.Drawing.Color.Red;
this.panel4.Location = new System.Drawing.Point(211, 10);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(48, 21);
this.panel4.TabIndex = 4;
this.panel4.Click += new System.EventHandler(this.panel4_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(171, 14);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(0, 12);
this.label4.TabIndex = 3;
//
// numericUpDown2
//
this.numericUpDown2.Location = new System.Drawing.Point(118, 10);
this.numericUpDown2.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(48, 21);
this.numericUpDown2.TabIndex = 2;
this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(65, 10);
this.numericUpDown1.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(48, 21);
this.numericUpDown1.TabIndex = 1;
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(11, 14);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 12);
this.label3.TabIndex = 0;
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(10, 49);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(71, 16);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "对比对照";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(10, 26);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(71, 16);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "平铺对照";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//
// groupBox5
//
this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox5.Controls.Add(this.label6);
this.groupBox5.Controls.Add(this.comboBox1);
this.groupBox5.Controls.Add(this.label2);
this.groupBox5.Controls.Add(this.label1);
this.groupBox5.Location = new System.Drawing.Point(901, 463);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(341, 93);
this.groupBox5.TabIndex = 4;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "设置";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(86, 54);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(65, 12);
this.label6.TabIndex = 3;
this.label6.Text = "当前级别:";
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(87, 22);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(248, 20);
this.comboBox1.TabIndex = 2;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(15, 54);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 1;
this.label2.Text = "当前级别:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(15, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 0;
this.label1.Text = "使用标尺:";
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Location = new System.Drawing.Point(344, 72);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(898, 385);
this.panel1.TabIndex = 5;
this.panel1.SizeChanged += new System.EventHandler(this.panel1_SizeChanged);
//
// AtlasComparisonDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.ClientSize = new System.Drawing.Size(1254, 568);
this.Controls.Add(this.panel1);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "AtlasComparisonDialog";
this.Text = "图谱比照";
this.Load += new System.EventHandler(this.AtlasComparisonDialog_Load);
this.Controls.SetChildIndex(this.groupBox1, 0);
this.Controls.SetChildIndex(this.groupBox2, 0);
this.Controls.SetChildIndex(this.groupBox3, 0);
this.Controls.SetChildIndex(this.groupBox4, 0);
this.Controls.SetChildIndex(this.groupBox5, 0);
this.Controls.SetChildIndex(this.panel1, 0);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.ResumeLayout(false);
}
#endregion
///
/// 获取上次操作参数
///
private void getLastData()
{
string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
if (!System.IO.File.Exists(filePath))
{
generalAnalysisModel = new GeneralAnalysisModel();
generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
generalAnalysisModel.AtlasComparisonModels = new GeneralAnalysisModel.AtlasComparisonModel();
generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
generalAnalysisModel.AtlasComparisonModels.hasUsed = false;
string porosityInfoXml = XmlSerializeHelper.XmlSerialize(generalAnalysisModel);
Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
}
else
{
generalAnalysisModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
if (generalAnalysisModel.AtlasComparisonModels == null)
{
generalAnalysisModel.AtlasComparisonModels = new GeneralAnalysisModel.AtlasComparisonModel();
}
if (generalAnalysisModel.AtlasComparisonModels.hasUsed)
{
checkBox1.Checked = generalAnalysisModel.AtlasComparisonModels.parameter1;
radioButton1.Checked = generalAnalysisModel.AtlasComparisonModels.parameter2 == 1 ? true:false;
radioButton2.Checked = generalAnalysisModel.AtlasComparisonModels.parameter2 == 2 ? true:false;
switch (generalAnalysisModel.AtlasComparisonModels.parameter3) {
case 0:
radioButton3.Checked = true;
radioButton4.Checked = false;
radioButton5.Checked = false;
radioButton6.Checked = false;
break;
case 1:
radioButton3.Checked = true;
radioButton4.Checked = false;
radioButton5.Checked = false;
radioButton6.Checked = false;
break;
case 2:
radioButton3.Checked = false;
radioButton4.Checked = true;
radioButton5.Checked = false;
radioButton6.Checked = false;
break;
case 3:
radioButton3.Checked = false;
radioButton4.Checked = false;
radioButton5.Checked = true;
radioButton6.Checked = false;
break;
case 4:
radioButton3.Checked = false;
radioButton4.Checked = false;
radioButton5.Checked = false;
radioButton6.Checked = true;
break;
}
numericUpDown1.Value = generalAnalysisModel.AtlasComparisonModels.parameter4;
numericUpDown2.Value = generalAnalysisModel.AtlasComparisonModels.parameter5;
panel4.BackColor = Color.FromArgb(generalAnalysisModel.AtlasComparisonModels.parameter6);
trackBar1.Value = generalAnalysisModel.AtlasComparisonModels.parameter7;
numericUpDown3.Value = generalAnalysisModel.AtlasComparisonModels.parameter7;
}
}
}
///
/// 保存上次操作参数
///
private void saveLastData(object sender, EventArgs e)
{
if (generalAnalysisModel.AtlasComparisonModels == null)
{
generalAnalysisModel.AtlasComparisonModels = new GeneralAnalysisModel.AtlasComparisonModel();
}
generalAnalysisModel.AtlasComparisonModels.hasUsed = true;
generalAnalysisModel.AtlasComparisonModels.parameter1 = checkBox1.Checked;
generalAnalysisModel.AtlasComparisonModels.parameter2 = radioButton1.Checked ? 1 : 2;
if (radioButton3.Checked) {
generalAnalysisModel.AtlasComparisonModels.parameter3 = 1;
}
else if (radioButton4.Checked)
{
generalAnalysisModel.AtlasComparisonModels.parameter3 = 2;
}
else if (radioButton5.Checked)
{
generalAnalysisModel.AtlasComparisonModels.parameter3 = 3;
}
else if (radioButton6.Checked)
{
generalAnalysisModel.AtlasComparisonModels.parameter3 = 4;
}
generalAnalysisModel.AtlasComparisonModels.parameter4 = (int)numericUpDown1.Value;
generalAnalysisModel.AtlasComparisonModels.parameter5 = (int)numericUpDown2.Value;
generalAnalysisModel.AtlasComparisonModels.parameter6 = panel4.BackColor.ToArgb();
generalAnalysisModel.AtlasComparisonModels.parameter7 = trackBar1.Value;
string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
string porosityInfoXml = XmlSerializeHelper.XmlSerialize(generalAnalysisModel);
FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
}
}
}