1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372 |
- using Metis.ParameterSet;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.File;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.IO;
- using System.Windows.Forms;
- using System.Xml;
- namespace PaintDotNet.GeneralAnalysis
- {
- /// <summary>
- /// 图谱管理
- /// </summary>
- internal class AtlasManagerDialog : PdnBaseForm
- {
- #region 控件
- private GroupBox groupBox2;
- private GroupBox groupBox3;
- private Button button1;
- private Button button2;
- private Button button3;
- private Button button4;
- private Button button5;
- private TreeView treeView1;
- private Panel panel1;
- private Panel panel2;
- private Label label1;
- private RadioButton radioButton1;
- private RadioButton radioButton4;
- private RadioButton radioButton3;
- private RadioButton radioButton2;
- private IContainer components;
- private ListView listView1;
- private ImageList imageList1;
- private GroupBox groupBox1;
- private Label label2;
- private TextBox textBox2;
- private Label label3;
- private TextBox textBox1;
- private TextBox textBox3;
- private Label label4;
- private Button button6;
- private Button button7;
- #endregion
- /// <summary>
- /// 组织的图谱数据集合
- /// </summary>
- private List<AtlasModel> atlasModels = new List<AtlasModel>();
- /// <summary>
- /// 新建/重命名窗口
- /// </summary>
- private CreateNameDialog createNameDialog;
- /// <summary>
- /// 图像大小
- /// </summary>
- private int imgSize = 72;
- /// <summary>
- /// 1新建标准 2新建级别
- /// </summary>
- private int createType = 1;
- /// <summary>
- /// 主控件
- /// </summary>
- private AppWorkspace appWorkspace;
- private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
- public AtlasManagerDialog(AppWorkspace appWorkspace)
- {
- this.appWorkspace = appWorkspace;
- InitializeComponent();
- InitializeLanguageText();
- getLastData();
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
- }
- /// <summary>
- /// Load事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void AtlasManagerDialog_Load(object sender, EventArgs e)
- {
- InitializeAtlasFile();
- InitializeTreeView();
- InitListViewData(null);
- }
- /// <summary>
- /// 初始化图谱数据
- /// 读取图谱文件夹(Atlas文件夹)的xml文件并解析
- /// </summary>
- private void InitializeAtlasFile()
- {
- atlasModels.Clear();
- List<string> 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
- RecursiveParsingXml(root, 1, "");
- }
- }
- /// <summary>
- /// 初始化treeview
- /// </summary>
- 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.Name = this.atlasModels[i].id;
- anime.ImageKey = "Top";
- this.treeView1.Nodes.Add(anime);
- RecursiveData(anime);
- }
- }
- }
- }
- /// <summary>
- /// 递归处理treeview数据
- /// </summary>
- private void RecursiveData(TreeNode anime)
- {
- List<AtlasModel> models = this.atlasModels.FindAll(a => a.parentId.Equals(anime.Tag));
- if (models!=null && models.Count > 0)
- {
- for (int i = 0; i < models.Count; i++)
- {
- TreeNode animeC = new TreeNode();
- animeC.Tag = models[i].id;
- animeC.Text = models[i].name;
- animeC.Name = models[i].id;
- animeC.ImageKey = (models[i].type==1) ? "Catalog" : "Atlas";
- animeC.SelectedImageKey = (models[i].type == 1) ? "Catalog" : "Atlas";
- RecursiveData(animeC);
- anime.Nodes.Add(animeC);
- }
- }
- }
- /// <summary>
- /// 递归解析xml
- /// </summary>
- /// <param name="element">节点</param>
- /// <param name="level">1根节点 2分类 3图铺</param>
- private void RecursiveParsingXml(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)
- {
- RecursiveParsingXml((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"))
- {
- RecursiveParsingXml((XmlElement)node, 3, model.id);
- }
- else
- {
- RecursiveParsingXml((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);
- model.Value = element.GetAttribute("Value");
- model.Zoom = element.GetAttribute("Zoom");
- model.Dpi = element.GetAttribute("Dpi");
- this.atlasModels.Add(model);
- }
- }
- /// <summary>
- /// 新建图谱
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.treeView1.SelectedNode != null)
- {
- AtlasModel parent = this.atlasModels.Find(a => a.id.Equals(this.treeView1.SelectedNode.Tag));
- if (parent.type == 1)
- {
- 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)
- {
- try
- {
- //创建图谱节点
- AtlasModel model = new AtlasModel();
- model.dirtyFlag = true;
- model.name = Path.GetFileName(dialog.FileName);
- model.id = Guid.NewGuid().ToString();
- model.parentId = parent.id;
- model.type = 2;
- model.bitmap = new Bitmap(dialog.FileName);
- this.atlasModels.Add(model);
- //添加节点到treeview
- TreeNode anime = new TreeNode();
- anime.Tag = model.id;
- anime.Text = model.name;
- anime.Name = model.id;
- anime.ImageKey = "Atlas";
- anime.SelectedImageKey = "Atlas";
- this.treeView1.SelectedNode.Nodes.Add(anime);
- //标记顶级父级为dirtyFlag=true
- RecursiveSetTopAtlasModelDirty(parent.id);
- }
- catch (Exception)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Notanimagefile,pleasecheck.text")+"!");
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectlevel.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectlevel.text")+"!");
- }
- }
- /// <summary>
- /// 新建级别
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.treeView1.SelectedNode != null)
- {
- AtlasModel models = this.atlasModels.Find(a => a.id.Equals(this.treeView1.SelectedNode.Tag));
- if (models.type == 2)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Thelevelcandertheatlas.text"));
- }
- else
- {
- this.createType = 2;
- this.createNameDialog = new CreateNameDialog(this);
- this.createNameDialog.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Newlevel.text");
- this.createNameDialog.StartPosition = FormStartPosition.CenterParent;
- this.createNameDialog.ShowDialog();
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectstandardorlevel.text"));
- }
- }
- /// <summary>
- /// 新建标准
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- this.createType = 1;
- this.createNameDialog = new CreateNameDialog(this);
- this.createNameDialog.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Newstandard.text");
- this.createNameDialog.StartPosition = FormStartPosition.CenterParent;
- this.createNameDialog.ShowDialog();
- }
- /// <summary>
- /// 新建标准/新建级别的名称
- /// </summary>
- /// <param name="name"></param>
- public override void GetCreateName(string name)
- {
- //新建标准
- if (this.createType == 1)
- {
- AtlasModel model = new AtlasModel();
- model.dirtyFlag = true;
- model.name = name;
- model.id = Guid.NewGuid().ToString();
- model.parentId = "";
- model.type = 0;
- this.atlasModels.Add(model);
- TreeNode anime = new TreeNode();
- anime.Tag = model.id;
- anime.Text = model.name + "*";
- anime.Name = model.id;
- anime.ImageKey = "Top";
- this.treeView1.Nodes.Add(anime);
- }
- //新建级别
- else if (this.createType == 2)
- {
- AtlasModel parent = this.atlasModels.Find(a => a.id.Equals(this.treeView1.SelectedNode.Tag));
- parent.dirtyFlag = true;
- //设置顶级节点状态为被修改
- RecursiveSetTopAtlasModelDirty(parent.id);
- AtlasModel model = new AtlasModel();
- model.dirtyFlag = true;
- model.name = name;
- model.id = Guid.NewGuid().ToString();
- model.parentId = parent.id;
- model.type = 1;
- this.atlasModels.Add(model);
- TreeNode anime = new TreeNode();
- anime.Tag = model.id;
- anime.Text = model.name;
- anime.Name = model.id;
- anime.ImageKey = "Catalog";
- this.treeView1.SelectedNode.Nodes.Add(anime);
- }
- this.createNameDialog.Close();
- }
- /// <summary>
- /// 自动建立图谱
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- FolderBrowserDialog dilog = new FolderBrowserDialog();
- dilog.Description = PdnResources.GetString("Menu.Pleaseelectfolder.Text");
- if (dilog.ShowDialog() == DialogResult.OK)
- {
- DirectoryInfo folder = new DirectoryInfo(dilog.SelectedPath);
- //生成guid
- string guid = Guid.NewGuid().ToString();
- //获取文件夹名称
- string name = folder.Name;
- //获取文件夹下的所有文件夹
- DirectoryInfo[] folders = folder.GetDirectories();
-
- //新建标准
- AtlasModel model = new AtlasModel();
- model.dirtyFlag = true;
- model.name = name;
- model.id = guid;
- model.parentId = "";
- model.type = 0;
- this.atlasModels.Add(model);
- TreeNode anime = new TreeNode();
- anime.Tag = model.id;
- anime.Text = model.name + "*";
- anime.Name = model.id;
- anime.ImageKey = "Top";
- this.treeView1.Nodes.Add(anime);
- //文件夹集合
- if (folders.Length>0)
- {
- foreach (DirectoryInfo f in folders)
- {
- //新建分类
- string guid1 = Guid.NewGuid().ToString();
- AtlasModel model1 = new AtlasModel();
- model1.dirtyFlag = true;
- model1.name = f.Name;
- model1.id = guid1;
- model1.parentId = guid;
- model1.type = 1;
- this.atlasModels.Add(model1);
- TreeNode anime1 = new TreeNode();
- anime1.Tag = guid1;
- anime1.Text = f.Name;
- anime1.Name = guid1;
- anime1.ImageKey = "Catalog";
- anime.Nodes.Add(anime1);
- //寻找文件夹下的所有图片
- FileInfo[] files = f.GetFiles();
- //图片集合
- List<AtlasModel> models = new List<AtlasModel>();
- if (files.Length > 0)
- {
- foreach (FileInfo file in files)
- {
- try
- {
- string guid2 = Guid.NewGuid().ToString();
- AtlasModel amodel = new AtlasModel();
- amodel.dirtyFlag = true;
- amodel.name = Path.GetFileName(file.FullName);
- amodel.id = guid2;
- amodel.parentId = guid1;
- amodel.type = 2;
- amodel.bitmap = new Bitmap(file.FullName);
- this.atlasModels.Add(amodel);
- TreeNode anime2 = new TreeNode();
- anime2.Tag = guid2;
- anime2.Text = Path.GetFileName(file.FullName);
- anime2.Name = guid2;
- anime2.ImageKey = "Atlas";
- anime2.SelectedImageKey = "Atlas";
- anime1.Nodes.Add(anime2);
- }
- catch (Exception)
- {
- }
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 初始化listview数据
- /// </summary>
- private void InitListViewData(TreeNode node)
- {
- this.imageList1.Images.Clear();
- this.listView1.Items.Clear();
- if(node==null)
- {
- List<AtlasModel> lists = this.atlasModels.FindAll(a => a.bitmap != null);
- for (int i = 0; i < lists.Count; i++)
- {
- this.imageList1.ImageSize = new System.Drawing.Size(imgSize, imgSize);
- this.imageList1.Images.Add("img" + i, lists[i].bitmap);
- 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<AtlasModel> 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(imgSize, imgSize);
- this.imageList1.Images.Add("img" + i, lists[i].bitmap);
- 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(imgSize, imgSize);
- this.imageList1.Images.Add("img", model.bitmap);
- 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;
- }
- }
- }
- }
- /// <summary>
- /// treeview的节点点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- else
- {
- this.treeView1.SelectedNode.Text = this.treeView1.SelectedNode.Text.Replace("*", "");
- //this.treeView1.SelectedNode.BeginEdit();
- }
- }
- }
- /// <summary>
- /// 设置图像尺寸
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void SettingImageSize(object sender, EventArgs e)
- {
- if (radioButton1.Checked) imgSize = 72;
- if (radioButton2.Checked) imgSize = 96;
- if (radioButton3.Checked) imgSize = 128;
- if (radioButton4.Checked) imgSize = 256;
- InitListViewData(this.treeView1.SelectedNode);
- }
- /// <summary>
- /// 保存图谱
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if(this.atlasModels!=null && this.atlasModels.Count > 0)
- {
- List<AtlasModel> models = this.atlasModels.FindAll(a=>a.type==0);
- foreach (AtlasModel model in models)
- {
- if (model.dirtyFlag)
- {
- XmlDocument xmldoc = new XmlDocument();
- XmlDeclaration xmldec = xmldoc.CreateXmlDeclaration("1.0", "utf-8", "yes");
- xmldoc.AppendChild(xmldec);
-
- //添加根节点
- XmlElement rootElement = xmldoc.CreateElement("StandardItem");
- rootElement.SetAttribute("Name", model.name);
- xmldoc.AppendChild(rootElement);
- //添加根节点下的子节点元素
- XmlElement classElement = xmldoc.CreateElement("ItemGroup");
- rootElement.AppendChild(classElement);
- //这里递归添加节点
- RecursiveCreateXmlNode(xmldoc, classElement, model.id);
- //保存文件
- xmldoc.Save(Application.StartupPath + "\\Atlas\\" + model.name + ".xml");
- //修改状态
- model.dirtyFlag = true;
- //修改treeview状态
- TreeNode[] node = this.treeView1.Nodes.Find(model.id, false);
- node[0].Text = node[0].Text.Replace("*", "");
- }
- }
- }
- }
- /// <summary>
- /// 递归创建xml节点
- /// </summary>
- private void RecursiveCreateXmlNode(XmlDocument xmldoc, XmlElement element, string parentId)
- {
- List<AtlasModel> models = this.atlasModels.FindAll(a => a.parentId.Equals(parentId));
- if(models!=null && models.Count > 0)
- {
- foreach(AtlasModel model in models)
- {
- if(model.type==1)
- {
- XmlElement childElement = xmldoc.CreateElement("StandardItem");
- childElement.SetAttribute("Name", model.name);
- XmlElement groupElement = xmldoc.CreateElement("ItemGroup");
- childElement.AppendChild(groupElement);
- element.AppendChild(childElement);
- RecursiveCreateXmlNode(xmldoc, groupElement, model.id);
- }
- else if(model.type == 2)
- {
- XmlElement childElement = xmldoc.CreateElement("StandardItem");
- childElement.SetAttribute("Name", model.name);
- childElement.SetAttribute("Value", model.Value);
- childElement.SetAttribute("Zoom", model.Zoom);
- childElement.SetAttribute("Dpi", model.Dpi);
- XmlElement imageElement = xmldoc.CreateElement("MapImage");
- imageElement.InnerText = DrawRulerHelper.ImgToBase64String(model.bitmap);
- childElement.AppendChild(imageElement);
- element.AppendChild(childElement);
- }
- }
- }
- }
- /// <summary>
- /// 当图谱改变的时候,找到标准,标识为已改变
- /// </summary>
- /// <param name="id">分类的id,需要向上找</param>
- private void RecursiveSetTopAtlasModelDirty(string id)
- {
- AtlasModel parent = this.atlasModels.Find(a => a.id.Equals(id));
- if(parent!=null)
- {
- if (parent.type == 0)
- {
- TreeNode[] node = this.treeView1.Nodes.Find(id, false);
- node[0].Text = node[0].Text.Replace("*", "") + "*";
- parent.dirtyFlag = true;
- this.treeView1.Refresh();
- }
- else
- {
- RecursiveSetTopAtlasModelDirty(parent.parentId);
- }
- }
- }
- /// <summary>
- /// 在用户编辑节点的文本后发生
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
- {
- if (!e.CancelEdit)
- {
- AtlasModel parent = this.atlasModels.Find(a => a.id.Equals(e.Node.Tag));
- if (!e.Node.IsEditing && (parent.dirtyFlag || (e.Label != null && !e.Label.Equals(e.Node.Text))))
- {
- parent.name = e.Label == null ? e.Node.Text.Replace("*", "") : e.Label.Replace("*", "");
- e.Node.Text = parent.name;
- RecursiveSetTopAtlasModelDirty(parent.id);
- }
- e.CancelEdit = true;
- }
- }
- /// <summary>
- /// 绘制节点事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
- {
- if ((e.State & TreeNodeStates.Selected) != 0)
- {
- //演示为绿底白字
- e.Graphics.FillRectangle(Brushes.Green, e.Node.Bounds);
- Font nodeFont = e.Node.NodeFont;
- if (nodeFont == null) nodeFont = ((TreeView)sender).Font;
- e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));
- }
- else
- {
- e.DrawDefault = true;
- }
- if ((e.State & TreeNodeStates.Focused) != 0)
- {
- using (Pen focusPen = new Pen(Color.Black))
- {
- focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
- Rectangle focusBounds = e.Node.Bounds;
- focusBounds.Size = new System.Drawing.Size(focusBounds.Width - 1,
- focusBounds.Height - 1);
- e.Graphics.DrawRectangle(focusPen, focusBounds);
- }
- }
- }
- /// <summary>
- /// 删除节点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, EventArgs e)
- {
- if (this.treeView1.SelectedNode != null)
- {
- if (MessageBox.Show(PdnResources.GetString("Menu.Confirmtodeleritwillbedeleted.text")+"?", PdnResources.GetString("Menu.Thisdeletioncannotberecovered.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- string id = this.treeView1.SelectedNode.Tag.ToString();
- this.RecursiveSetTopAtlasModelDirty(id);
- this.treeView1.Nodes.Remove(this.treeView1.SelectedNode);
- //判断如果选择的是顶级节点,需要删除xml文件
- AtlasModel model = this.atlasModels.Find(a => a.id.Equals(id));
- if (model.type == 0)
- {
- try
- {
- System.IO.File.Delete(Application.StartupPath + "\\Atlas\\" + model.name + ".xml");
- }
- catch(Exception)
- {
- }
- }
- this.atlasModels.Remove(this.atlasModels.Find(a => a.id.Equals(id)));
- this.InitListViewData(this.treeView1.SelectedNode);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectagraphnode.text"));
- }
- }
- /// <summary>
- /// 设置图谱级别、放大倍数、Dpi
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- if(string.IsNullOrWhiteSpace(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseentertheatlaslevel.text"));
- return;
- }
- if (string.IsNullOrWhiteSpace(this.textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthemagnification.text"));
- return;
- }
- if (string.IsNullOrWhiteSpace(this.textBox3.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.PleaseenterDpi.text"));
- return;
- }
- if (this.listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectatleastoneatlas.text"));
- return;
- }
- bool setTopAtlasModelDirty = false;
- foreach (ListViewItem item in this.listView1.SelectedItems)
- {
- AtlasModel model = this.atlasModels.Find(a => a.id.Equals(item.Tag));
- model.Value = this.textBox1.Text;
- model.Zoom = this.textBox2.Text;
- model.Dpi = this.textBox3.Text;
- if (!setTopAtlasModelDirty)
- {
- RecursiveSetTopAtlasModelDirty(model.parentId);
- setTopAtlasModelDirty = true;
- }
- }
- MessageBox.Show(PdnResources.GetString("Menu.Setsuccessfully.text"));
- }
- private void InitializeLanguageText()
- {
- this.Text = PdnResources.GetString("Menu.GeneralAnalysis.MapManager.Text");
- this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Atlaslevel.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.LabelAction.DrawGainNumber.Text") + ":";
- this.button6.Text = PdnResources.GetString("Menu.File.Save.Text");
- this.label4.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Atlas.text") + "Dpi:";
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button7.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Deletemap.text");
- this.button5.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Savetheatlas.text");
- this.label1.Text = PdnResources.GetString("Menu.imageviewmode.text") + ":";
- this.button4.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Automaticmapping.text");
- this.button3.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Newstandard.text");
- this.button2.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Newlevel.text");
- this.button1.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Newatlas.text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Help.HelpTopics.Text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.atlasmanagement.Atlasdata.text");
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button7 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.radioButton4 = new System.Windows.Forms.RadioButton();
- this.radioButton3 = new System.Windows.Forms.RadioButton();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.label1 = new System.Windows.Forms.Label();
- 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.panel2 = new System.Windows.Forms.Panel();
- this.button6 = new System.Windows.Forms.Button();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.panel1 = new System.Windows.Forms.Panel();
- this.listView1 = new System.Windows.Forms.ListView();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.panel2.SuspendLayout();
- this.panel1.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.button7);
- this.groupBox1.Controls.Add(this.button5);
- this.groupBox1.Controls.Add(this.radioButton4);
- this.groupBox1.Controls.Add(this.radioButton3);
- this.groupBox1.Controls.Add(this.radioButton2);
- this.groupBox1.Controls.Add(this.radioButton1);
- this.groupBox1.Controls.Add(this.label1);
- 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(1065, 52);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button7
- //
- this.button7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button7.Location = new System.Drawing.Point(566, 19);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(75, 23);
- this.button7.TabIndex = 10;
- this.button7.Text = "删除图谱";
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // button5
- //
- this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button5.Location = new System.Drawing.Point(981, 18);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 9;
- this.button5.Text = "保存图谱";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // radioButton4
- //
- this.radioButton4.AutoSize = true;
- this.radioButton4.Location = new System.Drawing.Point(278, 23);
- this.radioButton4.Name = "radioButton4";
- this.radioButton4.Size = new System.Drawing.Size(65, 16);
- this.radioButton4.TabIndex = 8;
- this.radioButton4.TabStop = true;
- this.radioButton4.Text = "256*256";
- this.radioButton4.UseVisualStyleBackColor = true;
- this.radioButton4.CheckedChanged += new System.EventHandler(this.SettingImageSize);
- //
- // radioButton3
- //
- this.radioButton3.AutoSize = true;
- this.radioButton3.Location = new System.Drawing.Point(207, 23);
- this.radioButton3.Name = "radioButton3";
- this.radioButton3.Size = new System.Drawing.Size(65, 16);
- this.radioButton3.TabIndex = 7;
- this.radioButton3.TabStop = true;
- this.radioButton3.Text = "128*128";
- this.radioButton3.UseVisualStyleBackColor = true;
- this.radioButton3.CheckedChanged += new System.EventHandler(this.SettingImageSize);
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(149, 23);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(53, 16);
- this.radioButton2.TabIndex = 6;
- this.radioButton2.TabStop = true;
- this.radioButton2.Text = "96*96";
- this.radioButton2.UseVisualStyleBackColor = true;
- this.radioButton2.CheckedChanged += new System.EventHandler(this.SettingImageSize);
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(90, 23);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(53, 16);
- this.radioButton1.TabIndex = 5;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "72*72";
- this.radioButton1.UseVisualStyleBackColor = true;
- this.radioButton1.CheckedChanged += new System.EventHandler(this.SettingImageSize);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(6, 25);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(89, 12);
- this.label1.TabIndex = 4;
- this.label1.Text = "图片查看模式:";
- //
- // 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(647, 19);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(85, 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(738, 19);
- 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(819, 19);
- 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(900, 19);
- 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(248, 432);
- 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.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
- this.treeView1.HideSelection = false;
- this.treeView1.LabelEdit = true;
- this.treeView1.Location = new System.Drawing.Point(7, 21);
- this.treeView1.Name = "treeView1";
- this.treeView1.Size = new System.Drawing.Size(235, 405);
- this.treeView1.TabIndex = 0;
- this.treeView1.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.treeView1_AfterLabelEdit);
- this.treeView1.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeView1_DrawNode);
- 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)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox3.Controls.Add(this.panel2);
- this.groupBox3.Controls.Add(this.panel1);
- this.groupBox3.Location = new System.Drawing.Point(267, 72);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(811, 432);
- this.groupBox3.TabIndex = 2;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "图谱数据";
- //
- // panel2
- //
- this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.panel2.Controls.Add(this.button6);
- this.panel2.Controls.Add(this.textBox3);
- this.panel2.Controls.Add(this.label4);
- this.panel2.Controls.Add(this.textBox2);
- this.panel2.Controls.Add(this.label3);
- this.panel2.Controls.Add(this.textBox1);
- this.panel2.Controls.Add(this.label2);
- this.panel2.Location = new System.Drawing.Point(7, 371);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(798, 55);
- this.panel2.TabIndex = 1;
- //
- // button6
- //
- this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.button6.Location = new System.Drawing.Point(709, 16);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(75, 23);
- this.button6.TabIndex = 6;
- this.button6.Text = "保存";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(471, 17);
- this.textBox3.Name = "textBox3";
- this.textBox3.Size = new System.Drawing.Size(100, 21);
- this.textBox3.TabIndex = 5;
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(406, 21);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(47, 12);
- this.label4.TabIndex = 4;
- this.label4.Text = "图谱Dpi";
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(286, 17);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(100, 21);
- this.textBox2.TabIndex = 3;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(215, 21);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(65, 12);
- this.label3.TabIndex = 2;
- this.label3.Text = "放大倍数:";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(88, 17);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(100, 21);
- this.textBox1.TabIndex = 1;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(15, 21);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(65, 12);
- this.label2.TabIndex = 0;
- this.label2.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.Controls.Add(this.listView1);
- this.panel1.Location = new System.Drawing.Point(7, 21);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(798, 344);
- this.panel1.TabIndex = 0;
- //
- // 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(4, 4);
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(791, 337);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseClick);
- //
- // 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;
- //
- // AtlasManagerDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1090, 516);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Name = "AtlasManagerDialog";
- this.Text = "图谱管理";
- this.Load += new System.EventHandler(this.AtlasManagerDialog_Load);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.panel2.ResumeLayout(false);
- this.panel2.PerformLayout();
- this.panel1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- /// <summary>
- /// listview内的图片点击事件,设置下面的等级、放大倍数、dpi
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView1_MouseClick(object sender, MouseEventArgs e)
- {
- ListViewHitTestInfo info = this.listView1.HitTest(e.X, e.Y);
- if(info!=null)
- {
- AtlasModel parent = this.atlasModels.Find(a => a.id.Equals(info.Item.Tag));
- if (parent != null)
- {
- this.textBox1.Text = parent.Value;
- this.textBox2.Text = parent.Zoom;
- this.textBox3.Text = parent.Dpi;
- //查看大图
- using (ImagePreviewDialog imagePreviewDialog = new ImagePreviewDialog(parent.bitmap, this.appWorkspace))
- {
- imagePreviewDialog.Text = parent.name;
- imagePreviewDialog.StartPosition = FormStartPosition.CenterScreen;
- imagePreviewDialog.ShowDialog();
- }
- }
- }
- /*
- int clickIndex = -1;
- if(this.listView1.Items.Count>0)
- {
- for (int i= 0; i<this.listView1.Items.Count; i++)
- {
- Rectangle rectangle = this.listView1.Items[i].Bounds;
- if (rectangle.X<e.X && rectangle.X + rectangle.Width > e.X && rectangle.Y<e.Y && rectangle.Y + rectangle.Height > e.Y)
- {
- clickIndex = i;
- break;
- }
- }
- }
- if (clickIndex>-1)
- {
- if (this.listView1.Items[clickIndex] != null)
- {
- AtlasModel parent = this.atlasModels.Find(a => a.id.Equals(this.listView1.Items[clickIndex].Tag));
- if (parent != null)
- {
- this.textBox1.Text = parent.Value;
- this.textBox2.Text = parent.Zoom;
- this.textBox3.Text = parent.Dpi;
- //查看大图
- using (ImagePreviewDialog imagePreviewDialog = new ImagePreviewDialog(parent.bitmap, this.appWorkspace))
- {
- imagePreviewDialog.Text = parent.name;
- imagePreviewDialog.StartPosition = FormStartPosition.CenterScreen;
- imagePreviewDialog.ShowDialog();
- }
- }
- }
- }*/
- }
- /// <summary>
- /// 获取上次操作参数
- /// </summary>
- 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.AtlasManagerModels = new GeneralAnalysisModel.AtlasManagerModel();
- 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.AtlasManagerModels.hasUsed = false;
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
- }
- else
- {
- generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- if (generalAnalysisModel.AtlasManagerModels == null)
- {
- generalAnalysisModel.AtlasManagerModels = new GeneralAnalysisModel.AtlasManagerModel();
- }
- if (generalAnalysisModel.AtlasManagerModels.hasUsed)
- {
- switch (generalAnalysisModel.AtlasManagerModels.parameter1) {
- case 0:
- radioButton1.Checked = true;
- radioButton2.Checked = false;
- radioButton3.Checked = false;
- radioButton4.Checked = false;
- break;
- case 1:
- radioButton1.Checked = true;
- radioButton2.Checked = false;
- radioButton3.Checked = false;
- radioButton4.Checked = false;
- break;
- case 2:
- radioButton1.Checked = false;
- radioButton2.Checked = true;
- radioButton3.Checked = false;
- radioButton4.Checked = false;
- break;
- case 3:
- radioButton1.Checked = false;
- radioButton2.Checked = false;
- radioButton3.Checked = true;
- radioButton4.Checked = false;
- break;
- case 4:
- radioButton1.Checked = false;
- radioButton2.Checked = false;
- radioButton3.Checked = false;
- radioButton4.Checked = true;
- break;
- }
- textBox1.Text = generalAnalysisModel.AtlasManagerModels.parameter2;
- textBox2.Text = generalAnalysisModel.AtlasManagerModels.parameter3;
- textBox3.Text = generalAnalysisModel.AtlasManagerModels.parameter4;
- }
- }
- }
- /// <summary>
- /// 保存上次操作参数
- /// </summary>
- private void saveLastData(object sender, EventArgs e)
- {
- if (generalAnalysisModel.AtlasManagerModels == null)
- {
- generalAnalysisModel.AtlasManagerModels = new GeneralAnalysisModel.AtlasManagerModel();
- }
- generalAnalysisModel.AtlasManagerModels.hasUsed = true;
- if (radioButton1.Checked)
- {
- generalAnalysisModel.AtlasManagerModels.parameter1 = 1;
- }
- else if (radioButton2.Checked) {
- generalAnalysisModel.AtlasManagerModels.parameter1 = 2;
- }
- else if (radioButton3.Checked)
- {
- generalAnalysisModel.AtlasManagerModels.parameter1 = 3;
- }
- else if (radioButton4.Checked)
- {
- generalAnalysisModel.AtlasManagerModels.parameter1 = 4;
- }
- generalAnalysisModel.AtlasManagerModels.parameter2 = textBox1.Text;
- generalAnalysisModel.AtlasManagerModels.parameter3 = textBox2.Text;
- generalAnalysisModel.AtlasManagerModels.parameter4 = textBox3.Text;
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
- }
- }
- }
|