private void MapSetup_Load(object sender, EventArgs e) { // Prepare cmbMapConfigName datasource List<string> mapConfigs = new List<string>(); DirectoryInfo dirInfo = new DirectoryInfo(PathHelper.MapConfigFolder); FileInfo[] files = dirInfo.GetFiles("*.xml"); foreach (FileInfo file in files) { mapConfigs.Add(file.Name.ToString().Substring(0, file.Name.ToString().LastIndexOf("."))); } // Binding datasource for cmbMapConfigName and set default value. cmbMapConfigName.DataSource = mapConfigs; ConfigHelper ch = new ConfigHelper(); cmbMapConfigName.SelectedItem = ch.GetDefaultMapConfigName().Trim(); // Initialize nudImageColumns, nudImageRows value. nudImageColumns.Value = ch.GettlpFlawImagesColumns(cmbMapConfigName.SelectedItem.ToString()); nudImageRows.Value = ch.GettlpFlawImagesRows(cmbMapConfigName.SelectedItem.ToString()); // Initialize rdoMapGridOn,rdoMapGridOff rdoMapGridOn.Checked = ch.GetIsDisplayMapGrid(cmbMapConfigName.SelectedItem.ToString()); rdoMapGridOff.Checked = !ch.GetIsDisplayMapGrid(cmbMapConfigName.SelectedItem.ToString()); // Initialize rdoFixCellSize, rdoCountSize rdoFixCellSize.Checked = ch.GetIsFixCellSizeMode(cmbMapConfigName.SelectedItem.ToString()); rdoCountSize.Checked = !ch.GetIsFixCellSizeMode(cmbMapConfigName.SelectedItem.ToString()); if (rdoFixCellSize.Checked) { txtFixSizeCD.Text = ch.GetFixCellSizeCD(cmbMapConfigName.SelectedItem.ToString()).ToString(); txtFixSizeCD.Enabled = true; txtFixSizeMD.Text = ch.GetFixCellSizeMD(cmbMapConfigName.SelectedItem.ToString()).ToString(); txtFixSizeMD.Enabled = true; txtCountSizeCD.Text = ""; txtCountSizeCD.Enabled = false; txtCountSizeMD.Text = ""; txtCountSizeMD.Enabled = false; lblSCMD.Text = ch.GetFixCellSizeSmybol(cmbMapConfigName.SelectedItem.ToString()); lblSCCD.Text = ch.GetFixCellSizeSmybol(cmbMapConfigName.SelectedItem.ToString()); } else if (rdoCountSize.Checked) { txtCountSizeCD.Text = ch.GetCountSizeCD(cmbMapConfigName.SelectedItem.ToString()).ToString(); txtCountSizeCD.Enabled = true; txtCountSizeMD.Text = ch.GetCountSizeMD(cmbMapConfigName.SelectedItem.ToString()).ToString(); txtCountSizeMD.Enabled = true; txtFixSizeCD.Text = ""; txtFixSizeCD.Enabled = false; txtFixSizeMD.Text = ""; txtFixSizeMD.Enabled = false; } else { TextBox[] txts = { txtFixSizeCD, txtFixSizeMD, txtCountSizeCD, txtCountSizeMD }; foreach (TextBox txt in txts) { txt.Enabled = false; txt.Text = ""; } } // Initialize cmbBottomAxes default selected cmbBottomAxes.SelectedItem = ch.GetBottomAxes(cmbMapConfigName.SelectedItem.ToString()); // Initialize chkCDInverse, chkMDInverse chkCDInverse.Checked = ch.IsCdInver_X(cmbMapConfigName.SelectedItem.ToString()); chkMDInverse.Checked = ch.IsMdInver_Y(cmbMapConfigName.SelectedItem.ToString()); // Initialize cmbMapSize default. (x:y) int x = ch.GetMapProportion_X(cmbMapConfigName.SelectedItem.ToString()); int y = ch.GetMapProportion_Y(cmbMapConfigName.SelectedItem.ToString()); cmbMapSize.SelectedItem = String.Format("{0}:{1}", x, y); // prepare shape list Dictionary<string, string> shapes = new Dictionary<string, string>(); shapes.Add("Triangle", "▲"); shapes.Add("InvertedTriangle", "▼"); shapes.Add("Square", "■"); shapes.Add("Circle", "●"); shapes.Add("Plus", "✚"); shapes.Add("Cross", "✖"); shapes.Add("Star", "★"); // Initialize FlawLegend (dgvFlawLegends) List<Column> columns = new List<Column>(); Column flawType = new Column(0, "FlawType", 60); Column name = new Column(1, "Name", 120); Column shape = new Column(2, "Shape", 80); Column color = new Column(3, "Color", 80); columns.Add(flawType); columns.Add(name); columns.Add(shape); columns.Add(color); foreach (Column c in columns) { if (c.Name == "Shape") { DataGridViewComboBoxColumn cmbShape = new DataGridViewComboBoxColumn(); cmbShape.HeaderText = c.Name; cmbShape.DisplayIndex = c.Index; cmbShape.DataPropertyName = c.Name; cmbShape.Width = c.Width; cmbShape.DataSource = new BindingSource(shapes, null); cmbShape.DisplayMember = "Value"; cmbShape.ValueMember = "Key"; dgvFlawLegends.Columns.Add(cmbShape); } else { DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; if (c.Name == "FlawType" || c.Name == "Name" || c.Name == "Color") { column.ReadOnly = true; } dgvFlawLegends.Columns.Add(column); } } dgvFlawLegends.MultiSelect = false; dgvFlawLegends.AutoGenerateColumns = false; // Get datatable of _dtbFlawLegends _dtbFlawLegends = ch.GetDataTablePrevFlawLegend(cmbMapConfigName.SelectedItem.ToString()); dgvFlawLegends.DataSource = _dtbFlawLegends; }
// method using for get data from xml //--------------------------------------------------------------------------------------// // 取得 PxPTab.cs/dgvFlaw 要使用的欄位且排序完成. public List<Column> GetdgvFlawColumns() { List<Column> columns = new List<Column>(); string system_config_path = PathHelper.SystemConfigFolder + "default.xml"; using (FileStream stream = new FileStream(system_config_path, FileMode.Open)) { XPathDocument document = new XPathDocument(stream); XPathNavigator navigator = document.CreateNavigator(); XPathNodeIterator node = navigator.Select("//dgv_flaw/column"); while (node.MoveNext()) { int index = Convert.ToInt32(node.Current.SelectSingleNode("index").Value); string columnName = node.Current.SelectSingleNode("name").Value; int width = Convert.ToInt32(node.Current.SelectSingleNode("width").Value); Column column = new Column(index, columnName, width); columns.Add(column); } columns.Sort((x, y) => x.Index.CompareTo(y.Index)); return columns; } }
private void MapWindow_Load(object sender, EventArgs e) { ConfigHelper ch = new ConfigHelper(); cmbFilterType.SelectedItem = ch.GetFilterType().Trim(); // Prepare cmbGradeConfigFiles datasource List<string> gradeConfigs = new List<string>(); DirectoryInfo dirInfo = new DirectoryInfo(PathHelper.GradeConfigFolder); FileInfo[] files = dirInfo.GetFiles("*.xml"); foreach (FileInfo file in files) { gradeConfigs.Add(file.Name.ToString().Substring(0, file.Name.ToString().LastIndexOf("."))); } // Binding cmbGradeConfigFiles cmbGradeConfigFiles.DataSource = gradeConfigs; cmbGradeConfigFiles.SelectedItem = ch.GetDefaultGradeConfigName().Trim(); // Initialize dgvFlawLegend without data. List<Column> columns = new List<Column>(); Column display = new Column(0, "Display", 60); Column shape = new Column(2, "Shape", 60); columns.Add(display); columns.Add(shape); foreach (Column c in columns) { if (c.Name == "Display") { DataGridViewCell cell = new DataGridViewCheckBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; column.FillWeight = c.Width; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvFlawLegend.Columns.Add(column); } else { DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; column.FillWeight = c.Width; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; column.ReadOnly = true; dgvFlawLegend.Columns.Add(column); } } dgvFlawLegend.MultiSelect = false; dgvFlawLegend.AutoGenerateColumns = false; columns = new List<Column>(); Column flawType = new Column(1, "FlawType", 60); Column name = new Column(1, "Name", 60); shape = new Column(2, "Shape", 60); Column pieceDoff = new Column(1, "PieceDoffNum", 60); Column jobDoff = new Column(1, "JobDoffNum", 60); columns.Add(flawType); columns.Add(name); columns.Add(shape); columns.Add(pieceDoff); columns.Add(jobDoff); foreach (Column c in columns) { DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; column.FillWeight = c.Width; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvFlawLegendDetial.Columns.Add(column); } dgvFlawLegendDetial.MultiSelect = false; dgvFlawLegendDetial.AutoGenerateColumns = false; // set datasource to dgvdgvFlawLegend // Initialize merge FlawLegend _dtbFlawLegends = new DataTable(); _dtbFlawLegends.Columns.Add("Display", typeof(bool)); _dtbFlawLegends.Columns.Add("FlawType", typeof(int)); _dtbFlawLegends.Columns.Add("Name", typeof(string)); _dtbFlawLegends.Columns.Add("Shape", typeof(string)); _dtbFlawLegends.Columns.Add("Color", typeof(string)); _dtbFlawLegends.Columns.Add("PieceDoffNum", typeof(int)); _dtbFlawLegends.Columns.Add("JobDoffNum", typeof(int)); dgvFlawLegend.DataSource = _dtbFlawLegends; dgvFlawLegendDetial.DataSource = _dtbFlawLegends; // Get Points score string grade_name = ch.GetDefaultGradeConfigName(); _dtbPoints = new DataTable(); _dtbPoints = ch.GetDataTabledgvPoints(grade_name); // Get Grade _dtbGrades = new DataTable(); _dtbGrades = ch.GetDataTabledgvGrade(grade_name); // Init doffResult _doffResult = new List<bool>(); _jobDoffNum = new Dictionary<string, int>(); // Setting UI controls status SettingUIControlStatus(true); }
private void GradeSetup_Load(object sender, EventArgs e) { // Prepare cmbConfig datasource List<string> gradeConfigs = new List<string>(); DirectoryInfo dirInfo = new DirectoryInfo(PathHelper.GradeConfigFolder); FileInfo[] files = dirInfo.GetFiles("*.xml"); foreach (FileInfo file in files) { gradeConfigs.Add(file.Name.ToString().Substring(0, file.Name.ToString().LastIndexOf("."))); } // Binding cmbConfig cmbConfig.DataSource = gradeConfigs; ConfigHelper ch = new ConfigHelper(); cmbConfig.SelectedItem = ch.GetDefaultGradeConfigName().Trim(); //ROI Settings //----------------------------------------------------------------------------------------// // Initialize Roi Mode RadioButton[] rdos = { rdoNoRoi, rdoSymmetrical }; foreach (RadioButton rdo in rdos) { string roiMode = ch.GetGradeNoRoiMode(cmbConfig.SelectedItem.ToString()); if (rdo.Text == roiMode) { rdo.Checked = true; } else { rdo.Checked = false; } } // Initialize TextBox of Columns, Rows txtColumns.Text = ch.GetGradeColumns(cmbConfig.SelectedItem.ToString()).ToString(); txtRows.Text = ch.GetGradeRows(cmbConfig.SelectedItem.ToString()).ToString(); // Initialize dgvColumns without data. Column name = new Column(0, "Name", 75); Column start = new Column(1, "Start", 60); Column end = new Column(2, "End", 60); List<Column> columns = new List<Column>(); columns.Add(name); columns.Add(start); columns.Add(end); foreach (Column c in columns) { DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; column.FillWeight = c.Width; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; if (column.Name == "Name") { column.ReadOnly = true; } dgvColumns.Columns.Add(column); } dgvColumns.MultiSelect = false; dgvColumns.AutoGenerateColumns = false; // Initialize dgvRows without data. foreach (Column c in columns) { DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; column.FillWeight = c.Width; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; if (column.Name == "Name") { column.ReadOnly = true; } dgvRows.Columns.Add(column); } dgvRows.MultiSelect = false; dgvRows.AutoGenerateColumns = false; // Initialize DataTable of dgvColumns and dgvRows _dtbColumns = ch.GetDataTableOfdgvColumns(cmbConfig.SelectedItem.ToString().Trim()); dgvColumns.DataSource = _dtbColumns; _dtbRows = ch.GetDataTableOfdgvRows(cmbConfig.SelectedItem.ToString().Trim()); dgvRows.DataSource = _dtbRows; // Grade Settings //----------------------------------------------------------------------------------------// // Initialize Point is enable. chkEnablePonit.Checked = ch.IsGradePointEnable(cmbConfig.SelectedItem.ToString().Trim()); // Initialize SubPiece (cmbSubPoints) _pointsSubpieceNames = new List<string>(); _pointsSubpieceNames = ch.GetSubPointsNameList(cmbConfig.SelectedItem.ToString().Trim()); cmbSubPoints.DataSource = _pointsSubpieceNames; // Initialize dgvPoint without data Column className = new Column(0, "ClassName", 200); Column score = new Column(1, "Score", 200); columns = new List<Column>(); columns.Add(className); columns.Add(score); foreach (Column c in columns) { DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; column.FillWeight = c.Width; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; if (c.Name == "ClassName") { //column.ReadOnly = true; } dgvPoint.Columns.Add(column); } dgvPoint.MultiSelect = false; dgvPoint.AutoGenerateColumns = false; // Initialize dgvGrade without data Column gradeName = new Column(0, "GradeName", 200); score = new Column(1, "Score", 200); columns = new List<Column>(); columns.Add(gradeName); columns.Add(score); foreach (Column c in columns) { DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell; column.Name = c.Name; column.HeaderText = c.Name; column.Width = c.Width; column.DataPropertyName = c.Name; column.SortMode = DataGridViewColumnSortMode.Automatic; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; if (c.Name == "GradeName") { //column.ReadOnly = true; } dgvGrade.Columns.Add(column); } dgvGrade.MultiSelect = false; dgvGrade.AutoGenerateColumns = false; // Set dgvPoint datasource _dtbPoints = ch.GetDataTabledgvPoints(cmbConfig.SelectedItem.ToString().Trim()); dgvPoint.DataSource = _dtbPoints; DataView dvPoints = _dtbPoints.DefaultView; dvPoints.RowFilter = String.Format("SubpieceName='{0}'", cmbSubPoints.SelectedItem.ToString().Trim()); // Initialize grade is enable (marks) chkEnableGrade.Checked = ch.IsGradeMarksEnable(cmbConfig.SelectedItem.ToString().Trim()); // Initialize SubPiece (cmbSubPoints) _marksSubpieceNames = ch.GetSubMarksNameList(cmbConfig.SelectedItem.ToString().Trim()); cmbSubMarks.DataSource = _marksSubpieceNames; // Set dgvGrade datasource _dtbGrades = ch.GetDataTabledgvGrade(cmbConfig.SelectedItem.ToString().Trim()); dgvGrade.DataSource = _dtbGrades; DataView dvGrade = _dtbGrades.DefaultView; dvGrade.RowFilter = String.Format("SubpieceName='{0}'", cmbSubMarks.SelectedItem.ToString().Trim()); // Initialize Tab of grade/pass or fail chkEnablePFS.Checked = ch.IsGradePassFailEnable(cmbConfig.SelectedItem.ToString().Trim()); txtFilterScore.Text = ch.GetPassFailScore(cmbConfig.SelectedItem.ToString().Trim()).ToString(); }