using PaintDotNet.Annotation;
using PaintDotNet.Annotation.Enum;
using PaintDotNet.Annotation.Measure;
using PaintDotNet.Annotation.relationModel;
using PaintDotNet.Base.SettingModel;
using PaintDotNet.Base.CommTool;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
using Button = System.Windows.Forms.Button;
using Label = System.Windows.Forms.Label;
using DataTable = System.Data.DataTable;
using Metis.Measuring;
using Metis.ParameterSet;
using PaintDotNet.Preview2;
using PaintDotNet.Menus;
namespace PaintDotNet.Measuring
{
///
/// 测量列表
///
internal class MeasureListDialog : FloatingToolForm
{
#region 控件
private TabControl tabControl1;
private TabPage tabPage1;
private TabPage tabPage2;
private Panel panel1;
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
private Button button6;
private ListView listView1;
private ListView listView2;
public NumericUpDown numericUpDown1;
private Label label2;
private ComboBox comboBox2;
private ComboBox comboBox4;
private ComboBox comboBox3;
private Panel panel2;
private ComboBox comboBox5;
private ToolTip toolTip1;
#endregion
///
/// 主控件
///
private AppWorkspace appWorkspace;
public Preview2Dialog _p2Form => Preview2Dialog.Instance;
///
/// 关系数据
///
private static List list;
private MeasureRelationModel model;
private Dictionary valuePairs;
///
/// 设置画面属性(绘制属性)
///
public static TreeView drawNodes;
///
/// 设置画面属性(数据属性)
///
public static TreeView dataNodes;
///
/// 设置画面属性(绘制元素属性)
///
public static TreeView allDrawNodes;
private Button button7;
///
/// 设置画面属性(数据元素属性)
///
public static TreeView allDataNodes;
private MeasureModel measureModel = new MeasureModel();
///
public MeasureListDialog(AppWorkspace appWorkspace)
{
if (list == null)
{
list = InvariantData.GetMeasureRelations();
list.RemoveAt(list.Count - 1);
}
this.appWorkspace = appWorkspace;
InitializeComponent();
InitializeLanguageText();
InitializeButtonBackgroudImage();
//InitializeUnitComboBox();
InitializeClassComboBox();
InitializeItemizedComboBox();
InitializeItemizedHeader();
InitializeTotalData();
GetAttributeFromConfigurationFile();
appWorkspace.ActiveDocumentWorkspaceChanged += new EventHandler(RefreshListView);//切换窗口
appWorkspace.ActiveDocumentWorkspaceChanged += new EventHandler(SetDrawNodes);//切换窗口
this.toolTip1 = new ToolTip();
this.toolTip1.SetToolTip(this.button1, PdnResources.GetString("Menu.Setting.Text"));
this.toolTip1.SetToolTip(this.button2, PdnResources.GetString("Menu.Exporttotemplate.Text"));
this.toolTip1.SetToolTip(this.button3, PdnResources.GetString("Menu.Statistics.Text"));
this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Edit.Delete.Text"));
this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Empty.text"));
this.toolTip1.SetToolTip(this.button6, PdnResources.GetString("Menu.Exporttoexcel.Text"));
this.toolTip1.SetToolTip(this.button7, PdnResources.GetString("Menu.Exportall.text"));
this.toolTip1.ShowAlways = true;
getLastData();
}
private DocumentView _document => _p2Form == null ? appWorkspace.ActiveDocumentWorkspace : (DocumentView)_p2Form._document;
private void InitializeButtonBackgroudImage()
{
this.button7.FlatStyle = FlatStyle.Flat;
this.button7.FlatAppearance.BorderSize = 0;
this.button7.BackgroundImageLayout = ImageLayout.Center;
this.button7.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListALLIcon.png").Reference;
this.button1.FlatStyle = FlatStyle.Flat;
this.button1.FlatAppearance.BorderSize = 0;
this.button1.BackgroundImageLayout = ImageLayout.Center;
this.button1.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListSettingIcon.png").Reference;
this.button2.FlatStyle = FlatStyle.Flat;
this.button2.FlatAppearance.BorderSize = 0;
this.button2.BackgroundImageLayout = ImageLayout.Center;
this.button2.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListTemplateIcon.png").Reference;
this.button3.FlatStyle = FlatStyle.Flat;
this.button3.FlatAppearance.BorderSize = 0;
this.button3.BackgroundImageLayout = ImageLayout.Center;
this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListStatisticsIcon.png").Reference;
this.button4.FlatStyle = FlatStyle.Flat;
this.button4.FlatAppearance.BorderSize = 0;
this.button4.BackgroundImageLayout = ImageLayout.Center;
this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListChoiseIcon.png").Reference;
this.button5.FlatStyle = FlatStyle.Flat;
this.button5.FlatAppearance.BorderSize = 0;
this.button5.BackgroundImageLayout = ImageLayout.Center;
this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListClearIcon.png").Reference;
this.button6.FlatStyle = FlatStyle.Flat;
this.button6.FlatAppearance.BorderSize = 0;
this.button6.BackgroundImageLayout = ImageLayout.Center;
this.button6.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListExportIcon.png").Reference;
}
///
/// 刷新列表数据
///
///
///
public void RefreshListView(object sender, EventArgs e)
{
this.InitializeItemizedComboBox();
this.listView1.Items.Clear();
this.InitializeItemizedHeader();
this.InitializeItemizedData();
this.listView2.Clear();
this.InitializeTotalData();
this.InitialMasterDataSheetData();
//if (_document != null)
//{
//_document.UpdateMeasureUnit((MeasurementUnit)(this.comboBox1.SelectedIndex + 1));
//}
if (_p2Form != null)
{
}
else
if (_document != null
&& _document.GraphicsList != null
&& _document.GraphicsList.Count > 0)
{
int count = _document.GraphicsList.Count;
for (int i = 0; i < count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure)
{
DrawObject dd = (DrawObject)_document.GraphicsList[i];
if (dd != null)
{
if (dd.Selected)
{
this.comboBox5.SelectedValue = dd.drawToolType;
}
}
}
}
}
this.listView1.SelectedIndexChanged -= new System.EventHandler(this.ListView1_SelectedIndexChanged);
if (listView1.Items.Count > 0)
{
this.listView1.SelectedItems.Clear();
for (int k = 0; k < this.listView1.Items.Count; k++)
{
DrawObject dd = (DrawObject)this.listView1.Items[k].Tag;
if (dd != null)
{
if (dd.Selected)
{
this.listView1.Items[k].Selected = true;
}
}
}
}
if (listView2.Items.Count > 1)
{
this.listView2.SelectedItems.Clear();
for (int i = 0; i < this.listView2.Items.Count; i++)
{
DrawObject dd = (DrawObject)this.listView2.Items[i].Tag;
if (dd != null)
{
if (dd.Selected)
{
this.listView2.Items[i].Selected = true;
}
}
}
}
this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListView1_SelectedIndexChanged);
}
///
/// 设置绘制属性
///
public void SetDrawNodes(object sender, EventArgs e)
{
if (drawNodes != null && _document != null)
{
this.SetDrawNodes(drawNodes);
}
}
private void SetDrawNodes(TreeView drawTreeView)
{
for (int i = 0; i < _document.GraphicsList.Count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure)
{
int count1 = drawTreeView.Nodes.Count;
((MeasureDrawObject)(_document.GraphicsList[i])).drawingProperties.Clear();
((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Clear();
for (int k = 0; k < count1; k++)
{
int count2 = drawTreeView.Nodes[k].Nodes.Count;
for (int j = 0; j < count2; j++)
{
if (_document.GraphicsList[i].drawToolType == (DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name))
{
bool drawb = false;
if (drawTreeView.Nodes[k].Nodes[j].Nodes.Count == 0)
{
((MeasureDrawObject)(_document.GraphicsList[i])).drawingProperties.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), new string[] { "nothing" });
if (_document.oldDrawTreeView != null)
{
if (_document.oldDrawTreeView.Nodes[k].Nodes[j].Nodes.Count != 0)
((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
}
else
{
((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
}
}
else
{
int a = 0;
string[] arr = new string[drawTreeView.Nodes[k].Nodes[j].Nodes.Count];
foreach (TreeNode node2 in drawTreeView.Nodes[k].Nodes[j].Nodes)
{
arr[a] = node2.Name;
a++;
}
((MeasureDrawObject)(_document.GraphicsList[i])).drawingProperties.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), arr);
if (_document.oldDrawTreeView != null)
{
if (drawTreeView.Nodes[k].Nodes[j].Nodes.Count != _document.oldDrawTreeView.Nodes[k].Nodes[j].Nodes.Count)
{
((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
}
else
{
foreach (TreeNode oldNode in _document.oldDrawTreeView.Nodes[k].Nodes[j].Nodes)
{
if (!arr.Contains(oldNode.Name))
{
drawb = true;
}
}
if (drawb)
((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), drawb);
}
}
else
{
((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
}
}
this.Refresh();
}
}
}
}
}
_document.oldDrawTreeView = drawTreeView;
}
///
/// 从配置文件中读取设置信息
///
private void GetAttributeFromConfigurationFile()
{
MeasureListSetModel measureListSetModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(System.Windows.Forms.Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\MeasureListSetModel.xml", FileMode.Open));
drawNodes = new TreeView();
dataNodes = new TreeView();
allDrawNodes = new TreeView();
allDataNodes = new TreeView();
if (measureListSetModel != null && measureListSetModel.AttributeMapDrawNodes != null)
{
for (int i = 0; i < measureListSetModel.AttributeMapDrawNodes.Count; i++)
{
TreeNode firstNode = new TreeNode();
firstNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Name;
for (int j = 0; j < measureListSetModel.AttributeMapDrawNodes[i].Attribute.Count; j++)
{
TreeNode scondNode = new TreeNode();
scondNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Text;
scondNode.Name = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Name;
for (int k = 0; k < measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute.Count; k++)
{
if (measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute.Count > 0)
{
TreeNode thirdNode = new TreeNode();
thirdNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute[k].Text;
thirdNode.Name = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute[k].Name;
scondNode.Nodes.Add(thirdNode);
}
}
firstNode.Nodes.Add(scondNode);
}
drawNodes.Nodes.Add(firstNode);
}
}
if (measureListSetModel != null && measureListSetModel.AttributeMapDataNodes != null)
{
for (int i = 0; i < measureListSetModel.AttributeMapDataNodes.Count; i++)
{
TreeNode firstNode = new TreeNode();
firstNode.Text = measureListSetModel.AttributeMapDataNodes[i].Name;
for (int j = 0; j < measureListSetModel.AttributeMapDataNodes[i].Attribute.Count; j++)
{
TreeNode scondNode = new TreeNode();
scondNode.Text = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Text;
scondNode.Name = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Name;
for (int k = 0; k < measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute.Count; k++)
{
if (measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute.Count > 0)
{
TreeNode thirdNode = new TreeNode();
thirdNode.Text = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute[k].Text;
thirdNode.Name = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute[k].Name;
scondNode.Nodes.Add(thirdNode);
}
}
firstNode.Nodes.Add(scondNode);
}
dataNodes.Nodes.Add(firstNode);
}
}
if (measureListSetModel != null && measureListSetModel.AttributeMapAllDrawNodes != null)
{
for (int i = 0; i < measureListSetModel.AttributeMapAllDrawNodes.Count; i++)
{
TreeNode firstNode = new TreeNode();
firstNode.Text = measureListSetModel.AttributeMapAllDrawNodes[i].Name;
for (int j = 0; j < measureListSetModel.AttributeMapAllDrawNodes[i].Attribute.Count; j++)
{
TreeNode scondNode = new TreeNode();
scondNode.Text = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Text;
scondNode.Name = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Name;
for (int k = 0; k < measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute.Count; k++)
{
if (measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute.Count > 0)
{
TreeNode thirdNode = new TreeNode();
thirdNode.Text = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute[k].Text;
thirdNode.Name = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute[k].Name;
scondNode.Nodes.Add(thirdNode);
}
}
firstNode.Nodes.Add(scondNode);
}
allDrawNodes.Nodes.Add(firstNode);
}
}
if (measureListSetModel != null && measureListSetModel.AttributeMapAllDataNodes != null)
{
for (int i = 0; i < measureListSetModel.AttributeMapAllDataNodes.Count; i++)
{
TreeNode firstNode = new TreeNode();
firstNode.Text = measureListSetModel.AttributeMapAllDataNodes[i].Name;
for (int j = 0; j < measureListSetModel.AttributeMapAllDataNodes[i].Attribute.Count; j++)
{
TreeNode scondNode = new TreeNode();
scondNode.Text = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Text;
scondNode.Name = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Name;
for (int k = 0; k < measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute.Count; k++)
{
if (measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute.Count > 0)
{
TreeNode thirdNode = new TreeNode();
thirdNode.Text = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute[k].Text;
thirdNode.Name = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute[k].Name;
scondNode.Nodes.Add(thirdNode);
}
}
firstNode.Nodes.Add(scondNode);
}
allDataNodes.Nodes.Add(firstNode);
}
}
}
///
/// 初始化分项数据下拉
///
private void InitializeItemizedComboBox()
{
valuePairs = new Dictionary();
if (_document != null
&& _document.GraphicsList != null
&& _document.GraphicsList.Count > 0)
{
int count = _document.GraphicsList.Count;
for (int i = 0; i < count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure)
{
if (!valuePairs.ContainsKey(_document.GraphicsList[i].drawToolType))
{
valuePairs.Add(_document.GraphicsList[i].drawToolType,
PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
}
}
}
if (valuePairs.Count != 0)
{
this.comboBox5.DataSource = new BindingSource(valuePairs, null);
this.comboBox5.DisplayMember = "Value";
this.comboBox5.ValueMember = "Key";
}
}
else
{
this.comboBox5.DataSource = null;
}
}
///
/// 初始化分项数据的头
///
private void InitializeItemizedHeader()
{
if (_document != null
&& _document.GraphicsList != null
&& _document.GraphicsList.Count > 0)
{
if (this.comboBox5.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.comboBox5.Text))
{
if (valuePairs.Count == 0)
return;
DrawToolType type = (DrawToolType)valuePairs.ElementAt(this.comboBox5.SelectedIndex).Key;
//初始化头
this.listView1.Clear();
this.listView1.View = View.Details;
ColumnHeader header0 = new ColumnHeader();
header0.Text = "";
header0.Width = 0;
this.listView1.Columns.Add(header0);
ColumnHeader header = new ColumnHeader();
header.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text");
header.Width = 40;
this.listView1.Columns.Add(header);
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int i = 0; i < count3; i++)
{
int count4 = dataNodes.Nodes[i].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (this.comboBox5.Text == dataNodes.Nodes[i].Nodes[j].Text)
{
foreach (TreeNode node2 in dataNodes.Nodes[i].Nodes[j].Nodes)
{
ColumnHeader header1 = new ColumnHeader();
header1.Text = node2.Text;
header1.Width = 100;
this.listView1.Columns.Add(header1);
}
}
}
}
}
else
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(type, out arr);
foreach (int v in arr)
{
if (v > 0)
{
ColumnHeader header1 = new ColumnHeader();
object value;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)v, out value);
header1.Text = value.ToString();
header1.Width = 100;
this.listView1.Columns.Add(header1);
}
}
}
}
}
}
///
/// 初始化分项数据
///
private void InitializeItemizedData()
{
if (this.comboBox5.SelectedIndex >= 0)
{
if (_document != null)
{
if (_document.GraphicsList != null
&& _document.GraphicsList.Count > 0)
{
int count = _document.GraphicsList.Count;
int no = 0;
for (int i = 0; i < count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure)
{
if (_document.GraphicsList[i].drawToolType == (DrawToolType)valuePairs.ElementAt(this.comboBox5.SelectedIndex).Key)
{
Dictionary data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
no++;
ListViewItem item = new ListViewItem();
item.SubItems.Add("" + (no));
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int a = 0; a < count3; a++)
{
int count4 = dataNodes.Nodes[a].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (this.comboBox5.Text == dataNodes.Nodes[a].Nodes[j].Text)
{
foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
{
foreach (var keys in data)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)keys.Key, out v);
if (v.ToString() == node2.Text)
{
item.SubItems.Add(keys.Value.ToString());
}
}
}
}
}
}
}
else
{
foreach (var keys in data)
{
item.SubItems.Add(keys.Value.ToString());
}
}
this.listView1.Items.Add(item);
this.listView1.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
this.ReSizeListViewColumns();
}
}
}
}
private void ReSizeListViewColumns()
{
int width = (this.listView1.Columns.Count - 2) * 110;
//使列自使用宽度
//对于DataGridView的每一个列都调整
/*for (int i = 0; i < this.listView1.Columns.Count; i++)
{
//将每一列都调整为自动适应模式
this.listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize);
//记录整个DataGridView的宽度
width += this.listView1.Columns[i].Width;
}*/
//判断调整后的宽度与原来设定的宽度的关系,如果是调整后的宽度大于原来设定的宽度,
//则将DataGridView的列自动调整模式设置为显示的列即可,
//如果是小于原来设定的宽度,将模式改为填充。
if (width > this.listView1.Size.Width)
{
for (int i = 2; i < this.listView1.Columns.Count; i++)
{
this.listView1.Columns[i].Width = 110;
}
}
else
{
for (int i = 2; i < this.listView1.Columns.Count; i++)
{
this.listView1.Columns[i].Width = (int)((this.listView1.Size.Width - this.listView1.Columns[1].Width) / (this.listView1.Columns.Count - 2));
}
}
}
///
/// 初始化总数据表
///
private void InitializeTotalData()
{
//初始化头
this.listView2.View = View.Details;
ColumnHeader header0 = new ColumnHeader();
header0.Text = "";
header0.Width = 0;
this.listView2.Columns.Add(header0);
ColumnHeader header = new ColumnHeader();
header.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text");
header.Width = 39;
this.listView2.Columns.Add(header);
ColumnHeader header1 = new ColumnHeader();
header1.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.classification.text");
header1.Width = 154;
this.listView2.Columns.Add(header1);
ColumnHeader header2 = new ColumnHeader();
header2.Text = PdnResources.GetString("Menu.name.text");
header2.Width = 154;
this.listView2.Columns.Add(header2);
ColumnHeader header3 = new ColumnHeader();
header3.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Attributes.text");
header3.Width = 154;
this.listView2.Columns.Add(header3);
ColumnHeader header4 = new ColumnHeader();
header4.Text = PdnResources.GetString("Menu.unit.text");
header4.Width = 154;
this.listView2.Columns.Add(header4);
ColumnHeader header5 = new ColumnHeader();
header5.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.value.text");
header5.Width = 150;
this.listView2.Columns.Add(header5);
}
///
/// 初始化总数据表数据
///
private void InitialMasterDataSheetData()
{
//初始化数据
if (_document != null
&& _document.GraphicsList != null
&& _document.GraphicsList.Count > 0)
{
int count = _document.GraphicsList.Count;
int no = 0;
for (int i = 0; i < count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure)
{
Dictionary data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
object MeasureMethod;
data.TryGetValue(MeasureAttributes.MeasureMethod, out MeasureMethod);
if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex <= 0 && this.comboBox4.SelectedIndex <= 0)
{
if (this.comboBox2.Text.Equals(MeasureMethod))
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int a = 0; a < count3; a++)
{
if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
{
int count4 = dataNodes.Nodes[a].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
{
foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
{
foreach (var keys in models)
{
if (keys.Value.ToString() == node2.Text)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
}
}
}
else
{
foreach (var keys in models)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
else if (this.comboBox2.SelectedIndex <= 0 && this.comboBox3.SelectedIndex <= 0 && this.comboBox4.SelectedIndex > 0)
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int a = 0; a < count3; a++)
{
if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
{
int count4 = dataNodes.Nodes[a].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
{
foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
{
foreach (var keys in models)
{
if (this.comboBox4.Text.Equals(keys.Value))
{
if (keys.Value.ToString() == node2.Text)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
}
}
}
}
else
{
foreach (var keys in models)
{
if (this.comboBox4.Text.Equals(keys.Value))
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
else if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex > 0 && this.comboBox4.SelectedIndex <= 0)
{
if (this.comboBox2.Text.Equals(MeasureMethod) && this.comboBox3.Text.Equals(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text")))
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int a = 0; a < count3; a++)
{
if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
{
int count4 = dataNodes.Nodes[a].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
{
foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
{
foreach (var keys in models)
{
if (keys.Value.ToString() == node2.Text)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
}
}
}
else
{
foreach (var keys in models)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
else if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex <= 0 && this.comboBox4.SelectedIndex > 0)
{
if (this.comboBox2.Text.Equals(MeasureMethod))
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int a = 0; a < count3; a++)
{
if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
{
int count4 = dataNodes.Nodes[a].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
{
foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
{
foreach (var keys in models)
{
if (this.comboBox4.Text.Equals(keys.Value))
{
if (keys.Value.ToString() == node2.Text)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
}
}
}
}
else
{
foreach (var keys in models)
{
if (this.comboBox4.Text.Equals(keys.Value))
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
else if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex > 0 && this.comboBox4.SelectedIndex > 0)
{
if (this.comboBox2.Text.Equals(MeasureMethod) && this.comboBox3.Text.Equals(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text")))
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int a = 0; a < count3; a++)
{
if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
{
int count4 = dataNodes.Nodes[a].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
{
foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
{
foreach (var keys in models)
{
if (this.comboBox4.Text.Equals(keys.Value))
{
if (keys.Value.ToString() == node2.Text)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
}
}
}
}
else
{
foreach (var keys in models)
{
if (this.comboBox4.Text.Equals(keys.Value))
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
else
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
if (dataNodes != null)
{
int count3 = dataNodes.Nodes.Count;
for (int a = 0; a < count3; a++)
{
if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
{
int count4 = dataNodes.Nodes[a].Nodes.Count;
for (int j = 0; j < count4; j++)
{
if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
{
foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
{
foreach (var keys in models)
{
if (keys.Value.ToString() == node2.Text)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
}
}
}
else
{
foreach (var keys in models)
{
no++;
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("" + (no));
item1.SubItems.Add(MeasureMethod.ToString());
item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
item1.SubItems.Add(keys.Value.ToString());
object unit;
data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
item1.SubItems.Add(unit.ToString());
object values;
data.TryGetValue(keys.Key, out values);
item1.SubItems.Add(values.ToString());
this.listView2.Items.Add(item1);
this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
}
}
}
}
}
}
}
///
/// 初始化总数据表的三级下拉
///
private void InitializeClassComboBox()
{
this.comboBox2.DataSource = list;
this.comboBox2.DisplayMember = "name";
this.comboBox2.ValueMember = "id";
//初始化第三级菜单
this.comboBox4.DataSource = new BindingSource(InvariantData.measureAttributes, null);
this.comboBox4.DisplayMember = "Value";
this.comboBox4.ValueMember = "Key";
}
///
/// 初始数据Excel
///
private void InitialDataExcel()
{
var selectedItems1 = this.listView1.SelectedItems;
var selectedItems2 = this.listView2.SelectedItems;
if ((this.listView1.Visible && selectedItems1.Count == 0) || (this.listView2.Visible && selectedItems2.Count == 0))
{
int count = _document.GraphicsList.Count;
System.Data.DataSet ds = new DataSet();
DataTable MeasureLine = new DataTable();
MeasureLine.TableName = PdnResources.GetString("Menu.LabelAction.DrawLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureLine.Columns.Add(c.ToString());
}
DataTable MeasureLength = new DataTable();
MeasureLength.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text");
for (int c = 0; c < 18; c++)
{
MeasureLength.Columns.Add(c.ToString());
}
DataTable MeasureHLine = new DataTable();
MeasureHLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureHLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureHLine.Columns.Add(c.ToString());
}
DataTable MeasureVLine = new DataTable();
MeasureVLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureVLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureVLine.Columns.Add(c.ToString());
}
DataTable MeasureMulLine = new DataTable();
MeasureMulLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureMulLine.Columns.Add(c.ToString());
}
DataTable MeasureMulHVLine = new DataTable();
MeasureMulHVLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulHVLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureMulHVLine.Columns.Add(c.ToString());
}
DataTable MeasureMulSegment = new DataTable();
MeasureMulSegment.TableName = PdnResources.GetString("Menu.MeasureAction.MultiPointLineSegment.Text");
for (int c = 0; c < 18; c++)
{
MeasureMulSegment.Columns.Add(c.ToString());
}
DataTable MeasureMulVLine = new DataTable();
MeasureMulVLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulPLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureMulVLine.Columns.Add(c.ToString());
}
DataTable MeasureBrokenLine = new DataTable();
MeasureBrokenLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureBrokenLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureBrokenLine.Columns.Add(c.ToString());
}
DataTable MeasureTraceCurve = new DataTable();
MeasureTraceCurve.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureTraceCurve.Text");
for (int c = 0; c < 18; c++)
{
MeasureTraceCurve.Columns.Add(c.ToString());
}
DataTable MeasureCurveLine = new DataTable();
MeasureCurveLine.TableName = PdnResources.GetString("Menu.LabelAction.DrawCurve.Text");
for (int c = 0; c < 18; c++)
{
MeasureCurveLine.Columns.Add(c.ToString());
}
DataTable MeasurePLine = new DataTable();
MeasurePLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasurePLine.Text");
for (int c = 0; c < 18; c++)
{
MeasurePLine.Columns.Add(c.ToString());
}
DataTable MeasureMulPLine = new DataTable();
MeasureMulPLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulPLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureMulPLine.Columns.Add(c.ToString());
}
DataTable MeasureHMulPLine = new DataTable();
MeasureHMulPLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureHMulPLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureHMulPLine.Columns.Add(c.ToString());
}
DataTable MeasureVMulPLine = new DataTable();
MeasureVMulPLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureVMulPLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureVMulPLine.Columns.Add(c.ToString());
}
DataTable MeasureParallelLine = new DataTable();
MeasureParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureParallelLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureParallelLine.Columns.Add(c.ToString());
}
DataTable MeasureMulParallelLine = new DataTable();
MeasureMulParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulParallelLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureMulParallelLine.Columns.Add(c.ToString());
}
DataTable MeasureVMulParallelLine = new DataTable();
MeasureVMulParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureVMulParallelLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureVMulParallelLine.Columns.Add(c.ToString());
}
DataTable MeasureHMulParallelLine = new DataTable();
MeasureHMulParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureHMulParallelLine.Text");
for (int c = 0; c < 18; c++)
{
MeasureHMulParallelLine.Columns.Add(c.ToString());
}
DataTable MeasureClosedCurve = new DataTable();
MeasureClosedCurve.TableName = PdnResources.GetString("Menu.LabelAction.DrawClosedCurve.Text");
for (int c = 0; c < 18; c++)
{
MeasureClosedCurve.Columns.Add(c.ToString());
}
DataTable MeasurePolygon = new DataTable();
MeasurePolygon.TableName = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
for (int c = 0; c < 18; c++)
{
MeasurePolygon.Columns.Add(c.ToString());
}
DataTable MeasureRectangle = new DataTable();
MeasureRectangle.TableName = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
for (int c = 0; c < 18; c++)
{
MeasureRectangle.Columns.Add(c.ToString());
}
DataTable MeasureRandRectangle = new DataTable();
MeasureRandRectangle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureRandRectangle.Text");
for (int c = 0; c < 18; c++)
{
MeasureRandRectangle.Columns.Add(c.ToString());
}
DataTable MeasureSquare = new DataTable();
MeasureSquare.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureSquare.Text");
for (int c = 0; c < 18; c++)
{
MeasureSquare.Columns.Add(c.ToString());
}
DataTable MeasureRandSquare = new DataTable();
MeasureRandSquare.TableName = PdnResources.GetString("Menu.Anypositivedirection.Text");
for (int c = 0; c < 18; c++)
{
MeasureRandSquare.Columns.Add(c.ToString());
}
DataTable MeasureTracePolygon = new DataTable();
MeasureTracePolygon.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureTracePolygon.Text");
for (int c = 0; c < 18; c++)
{
MeasureTracePolygon.Columns.Add(c.ToString());
}
DataTable MeasureCircle = new DataTable();
MeasureCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureCircle.Text");
for (int c = 0; c < 18; c++)
{
MeasureCircle.Columns.Add(c.ToString());
}
DataTable MeasureInnerCircle = new DataTable();
MeasureInnerCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureInnerCircle.Text");
for (int c = 0; c < 18; c++)
{
MeasureInnerCircle.Columns.Add(c.ToString());
}
DataTable MeasureOuterCircle = new DataTable();
MeasureOuterCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureOuterCircle.Text");
for (int c = 0; c < 18; c++)
{
MeasureOuterCircle.Columns.Add(c.ToString());
}
DataTable MeasureDiameterCircle = new DataTable();
MeasureDiameterCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureDiameterCircle.Text");
for (int c = 0; c < 18; c++)
{
MeasureDiameterCircle.Columns.Add(c.ToString());
}
DataTable MeasurePointEdgeSize = new DataTable();
MeasurePointEdgeSize.TableName = PdnResources.GetString("Menu.MeasureAction.MeasurePointEdgeSize.Text");
for (int c = 0; c < 18; c++)
{
MeasurePointEdgeSize.Columns.Add(c.ToString());
}
DataTable MeasurePointCenterSize = new DataTable();
MeasurePointCenterSize.TableName = PdnResources.GetString("Menu.MeasureAction.MeasurePointCenterSize.Text");
for (int c = 0; c < 18; c++)
{
MeasurePointCenterSize.Columns.Add(c.ToString());
}
DataTable MeasureThreePointAngle = new DataTable();
MeasureThreePointAngle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureThreePointAngle.Text");
for (int c = 0; c < 18; c++)
{
MeasureThreePointAngle.Columns.Add(c.ToString());
}
DataTable MeasureFourPointAngle = new DataTable();
MeasureFourPointAngle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureFourPointAngle.Text");
for (int c = 0; c < 18; c++)
{
MeasureFourPointAngle.Columns.Add(c.ToString());
}
DataTable MeasureThreePointArc = new DataTable();
MeasureThreePointArc.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureThreePointArc.Text");
for (int c = 0; c < 18; c++)
{
MeasureThreePointArc.Columns.Add(c.ToString());
}
for (int i = 0; i < count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure)
{
Dictionary data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureLine)
{
DataRow row = MeasureLine.NewRow();
int a = 0;
if (MeasureLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureLine.Rows.Add(row);
}
row = MeasureLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureLength)
{
DataRow row = MeasureLength.NewRow();
int a = 0;
if (MeasureLength.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureLength.Rows.Add(row);
}
row = MeasureLength.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureLength.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureHLine)
{
DataRow row = MeasureHLine.NewRow();
int a = 0;
if (MeasureHLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureHLine.Rows.Add(row);
}
row = MeasureHLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureHLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureVLine)
{
DataRow row = MeasureVLine.NewRow();
int a = 0;
if (MeasureVLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureVLine.Rows.Add(row);
}
row = MeasureVLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureVLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulLine)
{
DataRow row = MeasureMulLine.NewRow();
int a = 0;
if (MeasureMulLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureMulLine.Rows.Add(row);
}
row = MeasureMulLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureMulLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulHVLine)
{
DataRow row = MeasureMulHVLine.NewRow();
int a = 0;
if (MeasureMulHVLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureMulHVLine.Rows.Add(row);
}
row = MeasureMulHVLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureMulHVLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulSegment)
{
DataRow row = MeasureMulSegment.NewRow();
int a = 0;
if (MeasureMulSegment.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureMulSegment.Rows.Add(row);
}
row = MeasureMulSegment.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureMulSegment.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulVLine)
{
DataRow row = MeasureMulVLine.NewRow();
int a = 0;
if (MeasureMulVLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureMulVLine.Rows.Add(row);
}
row = MeasureMulVLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureMulVLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureBrokenLine)
{
DataRow row = MeasureBrokenLine.NewRow();
int a = 0;
if (MeasureBrokenLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureBrokenLine.Rows.Add(row);
}
row = MeasureBrokenLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureBrokenLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureTraceCurve)
{
DataRow row = MeasureTraceCurve.NewRow();
int a = 0;
if (MeasureTraceCurve.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureTraceCurve.Rows.Add(row);
}
row = MeasureTraceCurve.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureTraceCurve.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureCurveLine)
{
DataRow row = MeasureCurveLine.NewRow();
int a = 0;
if (MeasureCurveLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureCurveLine.Rows.Add(row);
}
row = MeasureCurveLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureCurveLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePLine)
{
DataRow row = MeasurePLine.NewRow();
int a = 0;
if (MeasurePLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasurePLine.Rows.Add(row);
}
row = MeasurePLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasurePLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulPLine)
{
DataRow row = MeasureMulPLine.NewRow();
int a = 0;
if (MeasureMulPLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureMulPLine.Rows.Add(row);
}
row = MeasureMulPLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureMulPLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureHMulPLine)
{
DataRow row = MeasureHMulPLine.NewRow();
int a = 0;
if (MeasureHMulPLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureHMulPLine.Rows.Add(row);
}
row = MeasureHMulPLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureHMulPLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureVMulPLine)
{
DataRow row = MeasureVMulPLine.NewRow();
int a = 0;
if (MeasureVMulPLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureVMulPLine.Rows.Add(row);
}
row = MeasureVMulPLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureVMulPLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureParallelLine)
{
DataRow row = MeasureParallelLine.NewRow();
int a = 0;
if (MeasureParallelLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureParallelLine.Rows.Add(row);
}
row = MeasureParallelLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureParallelLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulParallelLine)
{
DataRow row = MeasureMulParallelLine.NewRow();
int a = 0;
if (MeasureMulParallelLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureMulParallelLine.Rows.Add(row);
}
row = MeasureMulParallelLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureMulParallelLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureVMulParallelLine)
{
DataRow row = MeasureVMulParallelLine.NewRow();
int a = 0;
if (MeasureVMulParallelLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureVMulParallelLine.Rows.Add(row);
}
row = MeasureVMulParallelLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureVMulParallelLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureHMulParallelLine)
{
DataRow row = MeasureHMulParallelLine.NewRow();
int a = 0;
if (MeasureHMulParallelLine.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureHMulParallelLine.Rows.Add(row);
}
row = MeasureHMulParallelLine.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureHMulParallelLine.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureClosedCurve)
{
DataRow row = MeasureClosedCurve.NewRow();
int a = 0;
if (MeasureClosedCurve.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureClosedCurve.Rows.Add(row);
}
row = MeasureClosedCurve.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureClosedCurve.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePolygon)
{
DataRow row = MeasurePolygon.NewRow();
int a = 0;
if (MeasurePolygon.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasurePolygon.Rows.Add(row);
}
row = MeasurePolygon.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasurePolygon.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureRectangle)
{
DataRow row = MeasureRectangle.NewRow();
int a = 0;
if (MeasureRectangle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureRectangle.Rows.Add(row);
}
row = MeasureRectangle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureRectangle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureRandRectangle)
{
DataRow row = MeasureRandRectangle.NewRow();
int a = 0;
if (MeasureRandRectangle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureRandRectangle.Rows.Add(row);
}
row = MeasureRandRectangle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureRandRectangle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureSquare)
{
DataRow row = MeasureSquare.NewRow();
int a = 0;
if (MeasureSquare.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureSquare.Rows.Add(row);
}
row = MeasureSquare.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureSquare.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureRandSquare)
{
DataRow row = MeasureRandSquare.NewRow();
int a = 0;
if (MeasureRandSquare.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureRandSquare.Rows.Add(row);
}
row = MeasureRandSquare.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureRandSquare.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureTracePolygon)
{
DataRow row = MeasureTracePolygon.NewRow();
int a = 0;
if (MeasureTracePolygon.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureTracePolygon.Rows.Add(row);
}
row = MeasureTracePolygon.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureTracePolygon.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureCircle)
{
DataRow row = MeasureCircle.NewRow();
int a = 0;
if (MeasureCircle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureCircle.Rows.Add(row);
}
row = MeasureCircle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureCircle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureInnerCircle)
{
DataRow row = MeasureInnerCircle.NewRow();
int a = 0;
if (MeasureInnerCircle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureInnerCircle.Rows.Add(row);
}
row = MeasureInnerCircle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureInnerCircle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureOuterCircle)
{
DataRow row = MeasureOuterCircle.NewRow();
int a = 0;
if (MeasureOuterCircle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureOuterCircle.Rows.Add(row);
}
row = MeasureOuterCircle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureOuterCircle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureDiameterCircle)
{
DataRow row = MeasureDiameterCircle.NewRow();
int a = 0;
if (MeasureDiameterCircle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureDiameterCircle.Rows.Add(row);
}
row = MeasureDiameterCircle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureDiameterCircle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePointEdgeSize)
{
DataRow row = MeasurePointEdgeSize.NewRow();
int a = 0;
if (MeasurePointEdgeSize.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasurePointEdgeSize.Rows.Add(row);
}
row = MeasurePointEdgeSize.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasurePointEdgeSize.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePointCenterSize)
{
DataRow row = MeasurePointCenterSize.NewRow();
int a = 0;
if (MeasurePointCenterSize.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasurePointCenterSize.Rows.Add(row);
}
row = MeasurePointCenterSize.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasurePointCenterSize.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureThreePointAngle)
{
DataRow row = MeasureThreePointAngle.NewRow();
int a = 0;
if (MeasureThreePointAngle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureThreePointAngle.Rows.Add(row);
}
row = MeasureThreePointAngle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureThreePointAngle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureFourPointAngle)
{
DataRow row = MeasureFourPointAngle.NewRow();
int a = 0;
if (MeasureFourPointAngle.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureFourPointAngle.Rows.Add(row);
}
row = MeasureFourPointAngle.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureFourPointAngle.Rows.Add(row);
}
else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureThreePointArc)
{
DataRow row = MeasureThreePointArc.NewRow();
int a = 0;
if (MeasureThreePointArc.Rows.Count == 0)
{
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
MeasureThreePointArc.Rows.Add(row);
}
row = MeasureThreePointArc.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
MeasureThreePointArc.Rows.Add(row);
}
}
}
if (MeasureLine.Rows.Count > 0) ds.Tables.Add(MeasureLine);
if (MeasureLength.Rows.Count > 0) ds.Tables.Add(MeasureLength);
if (MeasureHLine.Rows.Count > 0) ds.Tables.Add(MeasureHLine);
if (MeasureVLine.Rows.Count > 0) ds.Tables.Add(MeasureVLine);
if (MeasureMulLine.Rows.Count > 0) ds.Tables.Add(MeasureMulLine);
if (MeasureMulHVLine.Rows.Count > 0) ds.Tables.Add(MeasureMulHVLine);
if (MeasureMulSegment.Rows.Count > 0) ds.Tables.Add(MeasureMulSegment);
if (MeasureMulVLine.Rows.Count > 0) ds.Tables.Add(MeasureMulVLine);
if (MeasureBrokenLine.Rows.Count > 0) ds.Tables.Add(MeasureBrokenLine);
if (MeasureTraceCurve.Rows.Count > 0) ds.Tables.Add(MeasureTraceCurve);
if (MeasureCurveLine.Rows.Count > 0) ds.Tables.Add(MeasureCurveLine);
if (MeasurePLine.Rows.Count > 0) ds.Tables.Add(MeasurePLine);
if (MeasureMulPLine.Rows.Count > 0) ds.Tables.Add(MeasureMulPLine);
if (MeasureHMulPLine.Rows.Count > 0) ds.Tables.Add(MeasureHMulPLine);
if (MeasureVMulPLine.Rows.Count > 0) ds.Tables.Add(MeasureVMulPLine);
if (MeasureParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureParallelLine);
if (MeasureMulParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureMulParallelLine);
if (MeasureVMulParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureVMulParallelLine);
if (MeasureHMulParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureHMulParallelLine);
if (MeasureClosedCurve.Rows.Count > 0) ds.Tables.Add(MeasureClosedCurve);
if (MeasurePolygon.Rows.Count > 0) ds.Tables.Add(MeasurePolygon);
if (MeasureRectangle.Rows.Count > 0) ds.Tables.Add(MeasureRectangle);
if (MeasureRandRectangle.Rows.Count > 0) ds.Tables.Add(MeasureRandRectangle);
if (MeasureSquare.Rows.Count > 0) ds.Tables.Add(MeasureSquare);
if (MeasureRandSquare.Rows.Count > 0) ds.Tables.Add(MeasureRandSquare);
if (MeasureTracePolygon.Rows.Count > 0) ds.Tables.Add(MeasureTracePolygon);
if (MeasureCircle.Rows.Count > 0) ds.Tables.Add(MeasureCircle);
if (MeasureInnerCircle.Rows.Count > 0) ds.Tables.Add(MeasureInnerCircle);
if (MeasureOuterCircle.Rows.Count > 0) ds.Tables.Add(MeasureOuterCircle);
if (MeasureDiameterCircle.Rows.Count > 0) ds.Tables.Add(MeasureDiameterCircle);
if (MeasurePointEdgeSize.Rows.Count > 0) ds.Tables.Add(MeasurePointEdgeSize);
if (MeasurePointCenterSize.Rows.Count > 0) ds.Tables.Add(MeasurePointCenterSize);
if (MeasureThreePointAngle.Rows.Count > 0) ds.Tables.Add(MeasureThreePointAngle);
if (MeasureFourPointAngle.Rows.Count > 0) ds.Tables.Add(MeasureFourPointAngle);
if (MeasureThreePointArc.Rows.Count > 0) ds.Tables.Add(MeasureThreePointArc);
DataToExcle(ds);
}
else
{
SaveFileDialog exe = new SaveFileDialog();
exe.Filter = "Execl files (*.xlsx)|*.xlsx";
exe.FilterIndex = 0;
exe.RestoreDirectory = true;
//exe.CreatePrompt = true;
exe.Title = "Export Excel File";
exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.Measurementdatasheet.Text");
DialogResult dr = exe.ShowDialog();
if (dr != DialogResult.OK)
{
return;
}
DataTable dtb = new DataTable();
for (int i = 0; i < 18; i++)
{
dtb.Columns.Add(i.ToString());
}
if (selectedItems1.Count > 0 && this.listView1.Visible)
{
for (int j = 0; j < selectedItems1.Count; j++)
{
int count = _document.GraphicsList.Count;
for (int i = 0; i < count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure && _document.GraphicsList[i] == selectedItems1[j].Tag)
{
Dictionary data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
DataRow row = dtb.NewRow();
int a = 0;
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
dtb.Rows.Add(row);
row = dtb.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
dtb.Rows.Add(row);
row = dtb.NewRow();
dtb.Rows.Add(row);
}
}
}
}
else if (selectedItems2.Count > 0 && this.listView2.Visible)
{
ArrayList arrayList = new ArrayList();
object tag = string.Empty;
for (int j = 0; j < selectedItems2.Count; j++)
{
if (tag != selectedItems2[j].Tag)
{
arrayList.Add(selectedItems2[j].Tag);
}
tag = selectedItems2[j].Tag;
}
foreach (var tags in arrayList)
{
int count = _document.GraphicsList.Count;
for (int i = 0; i < count; i++)
{
if (_document.GraphicsList[i].objectType == DrawClass.Measure && _document.GraphicsList[i] == tags)
{
Dictionary data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
Dictionary models = new Dictionary();
if (arr != null)
{
foreach (int t in arr)
{
if (t != 0)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((MeasureAttributes)t, v);
}
}
}
DataRow row = dtb.NewRow();
int a = 0;
foreach (var item in models)
{
row[a.ToString()] = item.Value;
a++;
}
dtb.Rows.Add(row);
row = dtb.NewRow();
a = 0;
foreach (var item in data)
{
object cnvalue;
InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
row[a.ToString()] = item.Value;
a++;
}
dtb.Rows.Add(row);
row = dtb.NewRow();
dtb.Rows.Add(row);
}
}
}
}
List list = new List();
list.Add(dtb);
this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, false, false, true);
}
}
///
/// 测量统计数据Excel
///
private void StatisticalDataExcel()
{
SaveFileDialog exe = new SaveFileDialog();
exe.Filter = "Execl files (*.xlsx)|*.xlsx";
exe.FilterIndex = 0;
exe.RestoreDirectory = true;
exe.Title = "Export Excel File";
exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.Statisticaldattable.Text");
DialogResult dr = exe.ShowDialog();
if (dr != DialogResult.OK)
{
return;
}
DataTable dtb = new DataTable();
for (int c = 0; c < this.listView1.Columns.Count; c++)
{
if (c == 1)
dtb.Columns.Add(PdnResources.GetString("Menu.compute.text"));
if (c > 1)
dtb.Columns.Add(listView1.Columns[c].Text);
}
ArrayList arrayList1 = new ArrayList();
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
ArrayList arrayList4 = new ArrayList();
ArrayList arrayList5 = new ArrayList();
Regex r1 = new Regex(@"^[0-9]+$");
Regex r = new Regex(@"^([0-9]{1,}[.][0-9]*)$");
for (int j = 2; j < this.listView1.Columns.Count; j++)
{
string maxValue = "0";
string minValue = "0";
string sumValue = "0";
string averageValue = "0";
for (int i = 0; i < this.listView1.Items.Count; i++)
{
if (j > 1)
{
if ((r.Match(this.listView1.Items[i].SubItems[j].Text).Success
|| r1.Match(this.listView1.Items[i].SubItems[j].Text).Success) && i != 0)
{
// 最大值
if (Convert.ToDouble(this.listView1.Items[i].SubItems[j].Text) > Convert.ToDouble(maxValue))
maxValue = this.listView1.Items[i].SubItems[j].Text;
// 最小值
if (Convert.ToDouble(this.listView1.Items[i].SubItems[j].Text) < Convert.ToDouble(minValue))
minValue = this.listView1.Items[i].SubItems[j].Text;
// 和
sumValue = Math.Round((Convert.ToDouble(sumValue) + Convert.ToDouble(this.listView1.Items[i].SubItems[j].Text)), (int)this.numericUpDown1.Value).ToString();
// 平均值
averageValue = Math.Round((Convert.ToDouble(sumValue) / this.listView1.Items.Count), (int)this.numericUpDown1.Value).ToString();
}
else
{
maxValue = this.listView1.Items[i].SubItems[j].Text;
minValue = this.listView1.Items[i].SubItems[j].Text;
sumValue = this.listView1.Items[i].SubItems[j].Text;
averageValue = this.listView1.Items[i].SubItems[j].Text;
}
}
}
arrayList1.Add(maxValue);
arrayList2.Add(minValue);
arrayList3.Add(averageValue);
arrayList4.Add(sumValue);
arrayList5.Add(this.listView1.Items.Count);
}
for (int i = 0; i < 5; i++)
{
DataRow dataRow = dtb.NewRow();
string rowHeader = string.Empty;
ArrayList arrayList = new ArrayList();
if (i == 0)
{
rowHeader = PdnResources.GetString("Menu.Image.Max.Text");
arrayList = arrayList1;
}
else if (i == 1)
{
rowHeader = PdnResources.GetString("Menu.Image.Min.Text");
arrayList = arrayList2;
}
else if (i == 2)
{
rowHeader = PdnResources.GetString("Menu.averagevalue.text");
arrayList = arrayList3;
}
else if (i == 3)
{
rowHeader = PdnResources.GetString("Menu.and.Text");
arrayList = arrayList4;
}
else
{
rowHeader = PdnResources.GetString("Menu.count.Text");
arrayList = arrayList5;
}
for (int c = 0; c < this.listView1.Columns.Count; c++)
{
if (c == 1)
dataRow[PdnResources.GetString("Menu.count.Text")] = rowHeader;
if (c > 1)
{
dataRow[listView1.Columns[c].Text] = arrayList[c - 2];
}
}
dtb.Rows.Add(dataRow);
}
List list = new List();
list.Add(dtb);
this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, false, false, true);
}
///
/// 模板数据Excel
///
private void TemplateDataExcel()
{
DataTable dtb = new DataTable();
if (this.listView1.Visible)
{
for (int c = 1; c < this.listView1.Columns.Count; c++)
{
dtb.Columns.Add(listView1.Columns[c].Text);
}
for (int i = 0; i < this.listView1.Items.Count; i++)
{
DataRow dataRow = dtb.NewRow();
if (i == 0)
{
for (int j = 1; j < this.listView1.Columns.Count; j++)
{
dataRow[this.listView1.Columns[j].Text] = this.listView1.Columns[j].Text;
}
dtb.Rows.Add(dataRow);
dataRow = dtb.NewRow();
}
for (int j = 1; j < this.listView1.Columns.Count; j++)
{
if (this.listView1.Items.Count > i && this.listView1.Items[i].SubItems.Count > j)
dataRow[this.listView1.Columns[j].Text] = this.listView1.Items[i].SubItems[j].Text;//#20103
else
dataRow[this.listView1.Columns[j].Text] = "";
}
dtb.Rows.Add(dataRow);
}
}
else
{
for (int c = 1; c < this.listView2.Columns.Count; c++)
{
dtb.Columns.Add(listView2.Columns[c].Text);
}
for (int i = 0; i < this.listView2.Items.Count; i++)
{
DataRow dataRow = dtb.NewRow();
if (i == 0)
{
for (int j = 1; j < this.listView2.Columns.Count; j++)
{
dataRow[this.listView2.Columns[j].Text] = this.listView2.Columns[j].Text;
}
dtb.Rows.Add(dataRow);
dataRow = dtb.NewRow();
}
for (int j = 1; j < this.listView2.Columns.Count; j++)
{
if (this.listView2.Items.Count > i && this.listView2.Items[i].SubItems.Count > j)
dataRow[this.listView2.Columns[j].Text] = this.listView2.Items[i].SubItems[j].Text;
else
dataRow[this.listView2.Columns[j].Text] = "";
}
dtb.Rows.Add(dataRow);
}
}
datatable = dtb;
//List list = new List();
//list.Add(dtb);
//this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName);
}
private DataTable datatable;
private void InitializeLanguageText()
{
this.tabPage1.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Itemizeddatasheet.text");
this.tabPage2.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Generaldatasheet.text");
this.comboBox4.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
this.comboBox3.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
this.comboBox2.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
this.label2.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Decimalpoint.text") + ":";
this.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Listofmeasuringelements.text");
}
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.listView1 = new System.Windows.Forms.ListView();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.listView2 = new System.Windows.Forms.ListView();
this.panel1 = new System.Windows.Forms.Panel();
this.comboBox4 = new System.Windows.Forms.ComboBox();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.panel2 = new System.Windows.Forms.Panel();
this.comboBox5 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label();
this.button7 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.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.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(898, 369);
this.tabControl1.TabIndex = 0;
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
//
// tabPage1
//
this.tabPage1.Controls.Add(this.listView1);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(890, 343);
this.tabPage1.TabIndex = 0;
this.tabPage1.UseVisualStyleBackColor = true;
//
// 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.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(6, 6);
this.listView1.Margin = new System.Windows.Forms.Padding(0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(877, 330);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListView1_SelectedIndexChanged);
//
// tabPage2
//
this.tabPage2.Controls.Add(this.listView2);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(890, 343);
this.tabPage2.TabIndex = 1;
this.tabPage2.UseVisualStyleBackColor = true;
//
// listView2
//
this.listView2.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.listView2.FullRowSelect = true;
this.listView2.GridLines = true;
this.listView2.HideSelection = false;
this.listView2.Location = new System.Drawing.Point(6, 6);
this.listView2.Margin = new System.Windows.Forms.Padding(0);
this.listView2.Name = "listView2";
this.listView2.Size = new System.Drawing.Size(805, 330);
this.listView2.TabIndex = 0;
this.listView2.UseCompatibleStateImageBehavior = false;
this.listView2.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.listView2_ItemSelectionChanged);
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panel1.Controls.Add(this.comboBox4);
this.panel1.Controls.Add(this.comboBox3);
this.panel1.Controls.Add(this.comboBox2);
this.panel1.Location = new System.Drawing.Point(12, 388);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(618, 45);
this.panel1.TabIndex = 1;
//
// comboBox4
//
this.comboBox4.FormattingEnabled = true;
this.comboBox4.Location = new System.Drawing.Point(382, 11);
this.comboBox4.Name = "comboBox4";
this.comboBox4.Size = new System.Drawing.Size(230, 20);
this.comboBox4.TabIndex = 2;
this.comboBox4.SelectedIndexChanged += new System.EventHandler(this.comboBox4_SelectedIndexChanged);
//
// comboBox3
//
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(196, 11);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(180, 20);
this.comboBox3.TabIndex = 1;
this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
//
// comboBox2
//
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(10, 11);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(180, 20);
this.comboBox2.TabIndex = 0;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// panel2
//
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.panel2.Controls.Add(this.comboBox5);
this.panel2.Location = new System.Drawing.Point(12, 388);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(618, 45);
this.panel2.TabIndex = 3;
//
// comboBox5
//
this.comboBox5.FormattingEnabled = true;
this.comboBox5.Location = new System.Drawing.Point(10, 11);
this.comboBox5.Name = "comboBox5";
this.comboBox5.Size = new System.Drawing.Size(180, 20);
this.comboBox5.TabIndex = 0;
this.comboBox5.SelectedIndexChanged += new System.EventHandler(this.comboBox5_SelectedIndexChanged);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
this.button1.Location = new System.Drawing.Point(686, 5);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(29, 23);
this.button1.TabIndex = 2;
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Cursor = System.Windows.Forms.Cursors.Hand;
this.button2.Location = new System.Drawing.Point(721, 5);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(33, 23);
this.button2.TabIndex = 3;
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button3.Cursor = System.Windows.Forms.Cursors.Hand;
this.button3.Location = new System.Drawing.Point(760, 5);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(33, 23);
this.button3.TabIndex = 4;
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button4.Cursor = System.Windows.Forms.Cursors.Hand;
this.button4.Location = new System.Drawing.Point(799, 5);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(33, 23);
this.button4.TabIndex = 5;
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button5.Cursor = System.Windows.Forms.Cursors.Hand;
this.button5.Location = new System.Drawing.Point(838, 5);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(33, 23);
this.button5.TabIndex = 6;
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button6.Cursor = System.Windows.Forms.Cursors.Hand;
this.button6.Location = new System.Drawing.Point(877, 5);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(33, 23);
this.button6.TabIndex = 7;
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// numericUpDown1
//
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDown1.Location = new System.Drawing.Point(831, 399);
this.numericUpDown1.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDown1.Minimum = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(75, 21);
this.numericUpDown1.TabIndex = 11;
this.numericUpDown1.Value = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true;
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(771, 403);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 10;
this.label2.Text = "小数点:";
//
// button7
//
this.button7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button7.Cursor = System.Windows.Forms.Cursors.Hand;
this.button7.Location = new System.Drawing.Point(651, 5);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(29, 23);
this.button7.TabIndex = 12;
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// MeasureListDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(922, 442);
this.Controls.Add(this.button7);
this.Controls.Add(this.panel2);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.label2);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.tabControl1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
this.Name = "MeasureListDialog";
this.Text = "测量元素列表";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MeasureListDialog_FormClosing);
this.Load += new System.EventHandler(this.MeasureListDialog_Load);
this.Controls.SetChildIndex(this.tabControl1, 0);
this.Controls.SetChildIndex(this.panel1, 0);
this.Controls.SetChildIndex(this.button1, 0);
this.Controls.SetChildIndex(this.button2, 0);
this.Controls.SetChildIndex(this.button3, 0);
this.Controls.SetChildIndex(this.button4, 0);
this.Controls.SetChildIndex(this.button5, 0);
this.Controls.SetChildIndex(this.button6, 0);
this.Controls.SetChildIndex(this.label2, 0);
this.Controls.SetChildIndex(this.numericUpDown1, 0);
this.Controls.SetChildIndex(this.panel2, 0);
this.Controls.SetChildIndex(this.button7, 0);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
///
/// 总数据表,一级下拉改变事件
///
///
///
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.comboBox2.SelectedIndex == 0)
{
if (this.comboBox3.Items.Count > 0)
{
this.comboBox3.DataSource = null;
this.comboBox3.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
this.comboBox3.Items.Clear();
}
}
else
{
model = list.Find(a => a.id == this.comboBox2.SelectedIndex);
this.comboBox3.DataSource = model.childLabel;
this.comboBox3.DisplayMember = "name";
this.comboBox3.ValueMember = "drawToolType";
}
this.listView2.Items.Clear();
this.InitialMasterDataSheetData();
}
///
/// 总数据表,二级下拉改变事件
///
///
///
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.comboBox3.SelectedIndex <= 0)
{
this.comboBox4.DataSource = new BindingSource(InvariantData.measureAttributes, null);
this.comboBox4.DisplayMember = "Value";
this.comboBox4.ValueMember = "Key";
}
else
{
int[] arr;
InvariantData.measureRelationAttributes.TryGetValue(model.childLabel[this.comboBox3.SelectedIndex].drawToolType, out arr);
if (arr != null)
{
Dictionary models = new Dictionary();
foreach (int t in arr)
{
object v;
InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
models.Add((DrawToolType)t, v);
}
//Dictionary models = (Dictionary)InvariantData.measureAttributes.Keys.(a=> arr.Contains((int)((DrawToolType)a)));
this.comboBox4.DataSource = new BindingSource(models, null);
this.comboBox4.DisplayMember = "Value";
this.comboBox4.ValueMember = "Key";
}
else
{
this.comboBox4.DataSource = new BindingSource(InvariantData.measureAttributes, null);
this.comboBox4.DisplayMember = "Value";
this.comboBox4.ValueMember = "Key";
}
}
this.listView2.Items.Clear();
this.InitialMasterDataSheetData();
}
///
/// 总数据表,三级下拉改变事件
///
///
///
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
this.listView2.Items.Clear();
this.InitialMasterDataSheetData();
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.tabControl1.SelectedIndex == 0)
{
this.panel1.Visible = false;
this.panel2.Visible = true;
}
else if (this.tabControl1.SelectedIndex == 1)
{
this.panel1.Visible = true;
this.panel2.Visible = false;
}
}
///
/// listView1 ItemSelectionChanged事件
///
///
///
private void ListView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.listView1.SelectedItems.Count > 0)
{
var senderGrid = (ListView)sender;
var selectedItems = senderGrid.SelectedItems;
if (selectedItems.Count > 0)
{
DrawObject dObject;
_document.GraphicsList.UnselectAll();
for (int i = 0; i < selectedItems.Count; i++)
{
dObject = (DrawObject)senderGrid.SelectedItems[i].Tag;
dObject.Selected = true;
}
_document.Refresh();
}
this.listView1.EndUpdate();
}
}
///
/// listView2 ItemSelectionChanged事件
///
///
///
private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
if (this.listView2.SelectedItems.Count > 0)
{
var senderGrid = (ListView)sender;
var selectedItems = senderGrid.SelectedItems;
if (selectedItems.Count > 0)
{
DrawObject dObject;
_document.GraphicsList.UnselectAll();
for (int i = 0; i < selectedItems.Count; i++)
{
dObject = (DrawObject)senderGrid.SelectedItems[i].Tag;
dObject.Selected = true;
}
_document.Refresh();
}
this.listView2.EndUpdate();
}
}
///
/// 分项数据表 测量方式下拉改变事件
///
///
///
private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
{
this.listView1.Clear();
this.InitializeItemizedHeader();
this.InitializeItemizedData();
}
///
/// 单位下拉改变事件
///
///
///
//private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
//{
// if (this.comboBox1.SelectedIndex > -1 && _document != null)
// {
// _document.UpdateMeasureUnit((MeasurementUnit)(this.comboBox1.SelectedIndex + 1));// + 1
// this.listView1.Items.Clear();
// this.InitializeItemizedData();
// this.listView2.Items.Clear();
// this.InitialMasterDataSheetData();
// }
//}
///
/// 小数点位数更改事件
///
///
///
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(numericUpDown1.Value.ToString()))
{
this.UpdateMeasureDecimalPlaces((int)numericUpDown1.Value);
if (this.appWorkspace.Widgets != null)
this.appWorkspace.Widgets.GeometryMeasureDialog.numericUpDown5.Value = numericUpDown1.Value;
//_document.UpdateMeasureDecimalPlaces((int)numericUpDown1.Value);
this.listView1.Items.Clear();
this.InitializeItemizedData();
this.listView2.Items.Clear();
this.InitialMasterDataSheetData();
}
}
///
/// 更新小数位数
///
///
public void UpdateMeasureDecimalPlaces(int praDecimalPlaces)
{
MeasureDrawObject.decimalPlaces = praDecimalPlaces;
if (_document != null)
{
for (int i = 0; i < _document.GraphicsList.Count; i++)
{
if (!"Measure".Equals(_document.GraphicsList[i].objectType.ToString()))
continue;
((MeasureDrawObject)_document.GraphicsList[i]).mouseUpAttribute = true;
}
_document.Refresh();
}
}
///
/// 设置按钮按下
///
///
///
private void button1_Click(object sender, EventArgs e)
{
using (MeasureListSetDialog dialog = new MeasureListSetDialog(this.appWorkspace, drawNodes, dataNodes, allDrawNodes, allDataNodes))
{
dialog.StartPosition = FormStartPosition.CenterParent;
dialog.ShowDialog();
}
}
///
/// 导出到模板
///
///
///
private void button2_Click(object sender, EventArgs e)
{
//if(this.listView2.Items.Count > 0)
this.TemplateDataExcel();
//else
// MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text")+"!", PdnResources.GetString("Menu.hint.text"));
MeasureListSettingDialog measureListSettingDialog = new MeasureListSettingDialog(this, "Template.Manager.item1.MeasureList", this.appWorkspace, datatable);
if (measureListSettingDialog.hasModule)
{
measureListSettingDialog.StartPosition = FormStartPosition.CenterScreen;
measureListSettingDialog.ShowDialog();
}
else
{
measureListSettingDialog = null;
}
}
///
/// 数据统计导出到Excel
///
///
///
private void button3_Click(object sender, EventArgs e)
{
if (this.listView1.Items.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
return;
}
if (!this.listView1.Visible)
{
MessageBox.Show(PdnResources.GetString("Menu.Thetotaldatatableisnotstatistical.Text") + "!", PdnResources.GetString("Menu.hint.text"));
return;
}
MeasureListStatisticalDataDialog measureListStatisticalDataDialog = new MeasureListStatisticalDataDialog(this.appWorkspace, this.listView1, this.comboBox5.SelectedIndex);
measureListStatisticalDataDialog.StartPosition = FormStartPosition.CenterParent;
measureListStatisticalDataDialog.ShowDialog();
//if (this.listView1.Items.Count > 0)
//{
// if(this.listView1.Visible)
// this.StatisticalDataExcel();
// else
// MessageBox.Show(PdnResources.GetString("Menu.Thetotaldatatableisnotstatistical.Text")+"!", PdnResources.GetString("Menu.hint.text"));
//}
//else
// MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text")+"!", PdnResources.GetString("Menu.hint.text"));
//if (this.listView1.Items.Count > 0)
//{
// if(this.listView1.Visible)
// this.StatisticalDataExcel();
// else
// MessageBox.Show(PdnResources.GetString("Menu.Thetotaldatatableisnotstatistical.Text")+"!", PdnResources.GetString("Menu.hint.text"));
//}
//else
// MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text")+"!", PdnResources.GetString("Menu.hint.text"));
}
///
/// 选择清除按钮按下事件
///
///
///
private void button4_Click(object sender, EventArgs e)
{
if (this.listView2.Items.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
}
else
{
var selectedItems1 = this.listView1.SelectedItems;
var selectedItems2 = this.listView2.SelectedItems;
if (selectedItems1.Count == 0 && selectedItems2.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text") + "!", PdnResources.GetString("Menu.hint.text"));
}
else
{
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Aresuredeletemeasurementdata.Text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
// 分项数据表
if (selectedItems1.Count > 0 && this.listView1.Visible)
{
int index1 = this.listView1.SelectedIndices[0];
if (_document != null)
{
for (int i = _document.GraphicsList.Count - 1; i >= 0; i--)
{
if (_document.GraphicsList[i] == this.listView1.Items[index1].Tag)
{
_document.GraphicsList.RemoveAt(i);
break;
}
}
if (_document.GraphicsList.Count > 0)
{
this.InitializeItemizedComboBox();
this.InitializeItemizedHeader();
this.listView1.Items.Clear();
this.InitializeItemizedData();
this.listView2.Items.Clear();
this.InitialMasterDataSheetData();
}
else
{
this.listView2.Clear();
this.listView1.Clear();
this.comboBox5.DataSource = null;
}
_document.Refresh();
}
}
// 总数据表
if (selectedItems2.Count > 0 && this.listView2.Visible)
{
int index2 = this.listView2.SelectedIndices[0];
if (_document != null)
{
for (int i = _document.GraphicsList.Count - 1; i >= 0; i--)
{
if (_document.GraphicsList[i] == this.listView2.Items[index2].Tag)
{
_document.GraphicsList.RemoveAt(i);
break;
}
}
if (_document.GraphicsList.Count > 0)
{
this.InitializeItemizedComboBox();
this.InitializeItemizedHeader();
this.listView1.Items.Clear();
this.InitializeItemizedData();
this.listView2.Items.Clear();
this.InitialMasterDataSheetData();
}
else
{
this.listView2.Clear();
this.listView1.Clear();
this.comboBox5.DataSource = null;
}
_document.Refresh();
}
}
}
}
}
}
///
/// /// 清除按钮按下事件
/// ///
/// ///
/// ///
private void button5_Click(object sender, EventArgs e)
{
if (this.listView2.Items.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
}
else
{
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Aresuredeletemeasurementdata.Text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
// 分项数据表
if (this.listView1.Visible)
{
if (this.comboBox5.SelectedIndex >= 0)
{
if (_document != null)
{
for (int i = _document.GraphicsList.Count - 1; i >= 0; i--)
{
if (_document.GraphicsList[i].drawToolType == (DrawToolType)this.comboBox5.SelectedValue)
{
_document.GraphicsList.RemoveAt(i);
}
}
if (_document.GraphicsList.Count > 0)
{
this.InitializeItemizedComboBox();
this.InitializeItemizedHeader();
this.InitializeItemizedData();
this.listView2.Items.Clear();
this.InitialMasterDataSheetData();
}
else
{
this.listView2.Clear();
this.listView1.Clear();
this.comboBox5.DataSource = null;
}
_document.Refresh();
}
}
}
// 总数据表
if (this.listView2.Visible)
{
if (_document != null)
{
_document.GraphicsList.Clear();
_document.Refresh();
this.listView2.Items.Clear();
this.listView1.Clear();
this.comboBox5.DataSource = null;
this.comboBox2.SelectedIndex = 0;
}
}
}
}
}
///
/// 导出数据到Excel按钮按下
///
///
///
private void button6_Click(object sender, EventArgs e)
{
if (this.listView2.Items.Count > 0)
this.InitialDataExcel();
else
MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
}
///
/// 导出多 Sheet 报表
///
/// 要导出的数据
public void DataToExcle(System.Data.DataSet ds)
{
try
{
if (ds.Tables == null || ds.Tables.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text") + "!");
return;
}
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.DefaultExt = "xlsx";
saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
saveFileDialog.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.Measurementdatasheet.Text");
saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
saveFileDialog.RestoreDirectory = true;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
System.Reflection.Missing miss = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel.Application xlapp = new Microsoft.Office.Interop.Excel.Application();
Workbooks workbooks = xlapp.Workbooks;
Workbook workbook = workbooks.Add(true);
if (ds.Tables.Count > 1)
{
workbook.Sheets.Add(miss, workbook.Sheets[1], ds.Tables.Count - 1, miss);
}
for (int d = 0; d < ds.Tables.Count; d++)
{
Worksheet ws = workbook.Worksheets[d + 1] as Worksheet;
ws.Name = ds.Tables[d].TableName;
int totalCellsCount = ds.Tables[d].Columns.Count;
Range range = ws.Range[ws.Cells[1, 1], ws.Cells[1, ds.Tables[d].Columns.Count]];
//生成列
for (int i = 0; i < ds.Tables[d].Columns.Count; i++)
{
range.EntireColumn.AutoFit();
range.EntireRow.AutoFit();
}
//插入数据
for (int r = 0; r < ds.Tables[d].Rows.Count; r++)
{
for (int i = 0; i < ds.Tables[d].Columns.Count; i++)
{
ws.Cells[r + 1, i + 1] = "'" + ds.Tables[d].Rows[r][i].ToString();
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(range);
range = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
ws = null;
}
((Worksheet)workbook.Sheets[1]).Select(true);//选中第一个worksheet
workbook.SaveAs(saveFileDialog.FileName, miss, miss, miss, miss, miss, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, miss, miss, miss);
System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook);
workbook = null;
xlapp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlapp);
xlapp = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
catch (Exception e)
{
throw e;
}
}
private void MeasureListDialog_Load(object sender, EventArgs e)
{
if (this.appWorkspace != null)
{
this.appWorkspace.RefreshListView();
}
}
private void MeasureListDialog_FormClosing(object sender, FormClosingEventArgs e)
{
appWorkspace.Widgets.MeasureListDialog.Visible = false;
this.appWorkspace.toolBar.RefreshBtnSelect(false, "MeasureList");
this.appWorkspace.toolsPanel.RefreshBtnSelect(false, "MeasureList");
saveLastData();
}
///
/// 总数据导出
///
///
///
private void button7_Click(object sender, EventArgs e)
{
DataTable dtb = new DataTable();
for (int c = 0; c < 5; c++)
{
dtb.Columns.Add(c.ToString());
}
// 单位
DataRow dataRow = dtb.NewRow();
dataRow[0] = "单位";
dataRow[1] = this.appWorkspace.GetPxPerUnit()[2];
dtb.Rows.Add(dataRow);
// 标题
dataRow = dtb.NewRow();
dataRow[0] = "图片名称";
dataRow[1] = "分组";
dataRow[2] = "测量工具名称";
dataRow[3] = "测量属性名称";
dataRow[4] = "值";
dtb.Rows.Add(dataRow);
// 所有图片
for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
{
// 图片名称
string imgName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
List measures = new List();
// 所有测量工具
for (int g = this.appWorkspace.DocumentWorkspaces[i].GraphicsList.Count - 1; g >= 0; g--)
{
if (this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].objectType == DrawClass.Measure)
{
measures.Add(this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType.ToString());
// 测量数据
Dictionary data = ((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).GetData();
// 测量工具名称
string drawName = PdnResources.GetString("Menu.MeasureAction." + this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType.ToString() + ".Text");
string[] drawingPropertiesList;
((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).drawingProperties.TryGetValue(this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType, out drawingPropertiesList);
int addCount = 0;
foreach (var measure in measures)
{
if (measure.Equals(this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType.ToString()))
addCount++;
}
// 所有可见的属性
foreach (var item in drawingPropertiesList)
{
dataRow = dtb.NewRow();
string itemFirst = item.Substring(0, 1);
string itemToLower = item.Substring(1, item.Length - 1).ToLower();
string itemAll = itemFirst + itemToLower;
// 测量属性名称
string attributeName = PdnResources.GetString("Menu." + itemAll + ".text");
// 属性值
object value;
MeasureAttributes type = (MeasureAttributes)System.Enum.Parse(typeof(MeasureAttributes), item);
data.TryGetValue(type, out value);
dataRow[0] = imgName;
dataRow[1] = addCount;
dataRow[2] = drawName;
dataRow[3] = attributeName;
dataRow[4] = value;
dtb.Rows.Add(dataRow);
}
if (((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).lengthParagraphs != null
&& ((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).lengthParagraphs.Count > 0)
{
int length = 0;
foreach (var lengthParagraph in ((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).lengthParagraphs)
{
length++;
dataRow = dtb.NewRow();
dataRow[0] = imgName;
dataRow[1] = addCount;
dataRow[2] = drawName;
dataRow[3] = "物理长度(段" + length + ")";
dataRow[4] = lengthParagraph;
dtb.Rows.Add(dataRow);
}
}
}
}
}
MeasureListSettingDialog measureListSettingDialog = new MeasureListSettingDialog(this, "Template.Manager.item1.MeasureListAll", this.appWorkspace, dtb);
if (measureListSettingDialog.hasModule)
{
measureListSettingDialog.StartPosition = FormStartPosition.CenterScreen;
measureListSettingDialog.ShowDialog();
}
else
{
measureListSettingDialog = null;
}
}
///
/// 获取上次操作参数
///
private void getLastData()
{
string filePath = System.Windows.Forms.Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterMeasureModel.xml";
if (!System.IO.File.Exists(filePath))
{
measureModel = new MeasureModel();
measureModel.MeasureListModels = new MeasureModel.MeasureListModel();
measureModel.MeasureListModels.hasUsed = false;
string porosityInfoXml = XmlSerializeHelper.XmlSerialize(measureModel);
Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
}
else
{
measureModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
if (measureModel.MeasureListModels == null)
{
measureModel.MeasureListModels = new MeasureModel.MeasureListModel();
}
if (measureModel.MeasureListModels.hasUsed)
{
numericUpDown1.Value = measureModel.MeasureListModels.parameter1;
}
}
}
///
/// 保存上次操作参数
///
private void saveLastData()
{
if (measureModel.MeasureListModels == null)
{
measureModel.MeasureListModels = new MeasureModel.MeasureListModel();
}
measureModel.MeasureListModels.hasUsed = true;
measureModel.MeasureListModels.parameter1 = Convert.ToInt32(numericUpDown1.Value);
string filePath = System.Windows.Forms.Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterMeasureModel.xml";
string porosityInfoXml = XmlSerializeHelper.XmlSerialize(measureModel);
FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
}
}
}