Example #1
0
        // 設定 TableLayoutPanel without data just initialize.
        public void LoadXmlTotlpImages()
        {
            ConfigHelper ch = new ConfigHelper();
            tlpFlawImages.ColumnStyles.Clear();
            tlpFlawImages.ColumnCount = ch.GettlpFlawImagesColumns();
            tlpFlawImages.RowCount = ch.GettlpFlawImagesRows();
            int phdHeight = tlpFlawImages.Height / tlpFlawImages.RowCount;
            int phdrWidth = tlpFlawImages.Width / tlpFlawImages.ColumnCount;
            for (int i = 0; i < tlpFlawImages.RowCount; i++)
            {
                tlpFlawImages.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            }

            for (int i = 0; i < tlpFlawImages.ColumnCount; i++)
            {
                tlpFlawImages.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
            }
        }
Example #2
0
 private void cmbFilterType_SelectedIndexChanged(object sender, EventArgs e)
 {
     // write data into xml right now.
     ConfigHelper ch = new ConfigHelper();
     ch.SaveFilterType(cmbFilterType.SelectedItem.ToString());
     _filterType = cmbFilterType.SelectedItem.ToString();
 }
Example #3
0
        private void cmbGradeConfigFiles_DropDownClosed(object sender, EventArgs e)
        {
            try
            {
                ConfigHelper ch = new ConfigHelper();
                ch.SaveGradeSetupConfigFile(cmbGradeConfigFiles.Text.Trim());

                // Refresh _dtbPoints
                // update _dtbPoints score.
                DataTable dtbTmp = ch.GetDataTabledgvPoints(cmbGradeConfigFiles.SelectedItem.ToString().Trim());
                foreach (DataRow d in dtbTmp.Rows)
                {
                    string subpiece = d["SubpieceName"].ToString().Trim();
                    string className = d["ClassName"].ToString().Trim();
                    string expr = String.Format("SubpieceName='{0}' AND ClassName='{1}'", subpiece, className);
                    DataRow[] drs = _dtbPoints.Select(expr);
                    if (drs.Length > 0)
                    {
                        foreach (DataRow dr in drs)
                        {
                            dr["Score"] = d["Score"];
                        }
                    }
                }
                // update _dtbGrades grade
                dtbTmp = ch.GetDataTabledgvGrade(cmbGradeConfigFiles.SelectedItem.ToString().Trim());
                foreach (DataRow d in dtbTmp.Rows)
                {
                    string subpiece = d["SubpieceName"].ToString().Trim();
                    string gradeName = d["GradeName"].ToString().Trim();
                    string expr = String.Format("SubpieceName='{0}' AND GradeName='{1}'", subpiece, gradeName);
                    DataRow[] drs = _dtbGrades.Select(expr);
                    if (drs.Length > 0)
                    {
                        foreach (DataRow dr in drs)
                        {
                            dr["Score"] = d["Score"];
                        }
                    }
                }

                // Reload datatable score
                ReloadDataTables();

                // Re-configure Chart
                XYDiagram diagram = null;
                DrawDummyPoint();
                if ((XYDiagram)chartControl.Diagram != null)
                {
                    diagram = (XYDiagram)chartControl.Diagram;
                    double width = Convert.ToDouble(diagram.AxisX.Range.ScrollingRange.MaxValue);
                    double height = Convert.ToDouble(diagram.AxisY.Range.ScrollingRange.MaxValue);
                    InitChart(width, height);

                    if (chartControl.Series != null)
                    {
                        //UNDONE: 歷史資料切換設定時需重判好壞
                        ReCalcPieceResult();
                        DrawChartPoint();
                        JobHelper.IsOnpeHistory = true;
                        UpdateUIControl();
                        JobHelper.IsOnpeHistory = false;
                    }
                }
            }
            catch { }
        }
Example #4
0
        // Save xml
        private void btnSaveGradeConfigFile_Click(object sender, EventArgs e)
        {
            // if some data wrong will tip.
            if (_dtbColumns.Rows.Count < 1 || _dtbRows.Rows.Count < 1 || _dtbPoints.Rows.Count < 1 || _dtbGrades.Rows.Count < 1)
            {
                MessageBox.Show("Input has null value.");
                return;
            }

            DataHelper dh = new DataHelper();
            if (dh.HasNull(_dtbColumns) || dh.HasNull(_dtbRows) || dh.HasNull(_dtbPoints) || dh.HasNull(_dtbGrades))
            {
                MessageBox.Show("Input has null value.");
                return;
            }

            // Save default config file to system config
            ConfigHelper ch = new ConfigHelper();
            if (String.IsNullOrEmpty(cmbConfig.Text))
            {
                cmbConfig.Text = DateTime.Now.ToShortDateString();
            }
            // if save error break;
            if (!ch.SaveGradeSetupConfigFile(cmbConfig.Text.Trim()))
            {
                MessageBox.Show("File name is empty.");
                return;
            }

            // ROI-Setting
            //----------------------------------------------------------------------------------//

            // initialize grade xml sechma
            string sechma_path = PathHelper.SystemConfigFolder + "grade_sechma.xml";
            XmlDocument document = new XmlDocument();
            document.Load(sechma_path);
            XPathNavigator navigator = document.CreateNavigator();

            // save roi mode
            RadioButton[] rdos = { rdoNoRoi, rdoSymmetrical };
            foreach (RadioButton rdo in rdos)
            {
                if (rdo.Checked)
                {
                    navigator.SelectSingleNode("//roi/mode").SetValue(rdo.Text.Trim());
                }
            }

            // Save roi columns , rows size
            navigator.SelectSingleNode("//roi/columns/size").SetValue(_dtbColumns.Rows.Count.ToString());
            navigator.SelectSingleNode("//roi/rows/size").SetValue(_dtbRows.Rows.Count.ToString());

            // save roi data (start, end) of columns , rows.
            // Remove old  columns for add new record
            if (navigator.Select("//roi/columns/column").Count > 0)
            {
                XPathNavigator first = navigator.SelectSingleNode("//roi/columns/column[1]");
                XPathNavigator last = navigator.SelectSingleNode("//roi/columns/column[last()]");
                navigator.MoveTo(first);
                navigator.DeleteRange(last);
            }
            // save _dgvColumns data to xml
            for (int i = 0; i < _dtbColumns.Rows.Count; i++)
            {
                string name = _dtbColumns.Rows[i]["Name"].ToString();
                string start = _dtbColumns.Rows[i]["Start"].ToString();
                string end = _dtbColumns.Rows[i]["End"].ToString();
                navigator.SelectSingleNode("//roi/columns").AppendChildElement(string.Empty, "column", string.Empty, null);
                // Move to last column element and add name, start, end value.
                navigator.SelectSingleNode("//roi/columns/column[last()]").AppendChildElement(string.Empty, "name", string.Empty, name);
                navigator.SelectSingleNode("//roi/columns/column[last()]").AppendChildElement(string.Empty, "start", string.Empty, start);
                navigator.SelectSingleNode("//roi/columns/column[last()]").AppendChildElement(string.Empty, "end", string.Empty, end);
            }

            // Remove old rows for add new record.
            if (navigator.Select("//roi/rows/row").Count > 0)
            {
                XPathNavigator first = navigator.SelectSingleNode("//roi/rows/row[1]");
                XPathNavigator last = navigator.SelectSingleNode("//roi/rows/row[last()]");
                navigator.MoveTo(first);
                navigator.DeleteRange(last);
            }
            // save _dtbRows data to xml
            for (int i = 0; i < _dtbRows.Rows.Count; i++)
            {
                string name = _dtbRows.Rows[i]["Name"].ToString();
                string start = _dtbRows.Rows[i]["Start"].ToString();
                string end = _dtbRows.Rows[i]["End"].ToString();
                navigator.SelectSingleNode("//roi/rows").AppendChildElement(string.Empty, "row", string.Empty, null);
                // Move to last column element and add name, start, end value.
                navigator.SelectSingleNode("//roi/rows/row[last()]").AppendChildElement(string.Empty, "name", string.Empty, name);
                navigator.SelectSingleNode("//roi/rows/row[last()]").AppendChildElement(string.Empty, "start", string.Empty, start);
                navigator.SelectSingleNode("//roi/rows/row[last()]").AppendChildElement(string.Empty, "end", string.Empty, end);
            }

            // Grade - Setting
            //----------------------------------------------------------------------------------//

            // Points
            // Save is points enable?
            navigator.SelectSingleNode("//grade/points/enable").SetValue(chkEnablePonit.Checked.ToString());

            // Remove old points/sub_piece for add new record. (_dtbPoints)
            if (navigator.Select("//grade/points/sub_piece").Count > 0)
            {
                XPathNavigator first = navigator.SelectSingleNode("//grade/points/sub_piece[1]");
                XPathNavigator last = navigator.SelectSingleNode("//grade/points/sub_piece[last()]");
                navigator.MoveTo(first);
                navigator.DeleteRange(last);
            }
            // save _dtbPoints
            List<string> pointsSubpieces = _pointsSubpieceNames;
            // prepare flawtype convert dictionary
            string map_config_path = ch.GetDefaultMapConfigName();
            Dictionary<string, int> flawlegends = ch.GetPrevFlawLegendDictionaryID(map_config_path);
            foreach (string subpieceName in pointsSubpieces)
            {
                navigator.SelectSingleNode("//grade/points").AppendChildElement(string.Empty, "sub_piece", string.Empty, null);
                // Move to last column element and add name value.
                navigator.SelectSingleNode("//grade/points/sub_piece[last()]").AppendChildElement(string.Empty, "name", string.Empty, subpieceName);
                string expr = String.Format("SubpieceName='{0}'", subpieceName);
                // check all same
                if (chkAllSameOfPoint.Checked)
                {
                    expr = String.Format("SubpieceName='{0}'", "All");
                }

                DataRow[] drs = _dtbPoints.Select(expr);
                foreach (DataRow dr in drs)
                {
                    string className = dr["ClassName"].ToString();
                    int classID = flawlegends[className];
                    string score = dr["Score"].ToString();
                    navigator.SelectSingleNode("//grade/points/sub_piece[last()]").AppendChildElement(string.Empty, "flawtype_score", string.Empty, score);
                    navigator.SelectSingleNode("//grade/points/sub_piece[last()]/flawtype_score[last()]").CreateAttribute(string.Empty, "id", string.Empty, classID.ToString());
                }
            }

            // Remove old grade(marks)/subpiece for add new record . (_dtbGrades)
            if (navigator.Select("//grade/marks/sub_piece").Count > 0)
            {
                XPathNavigator first = navigator.SelectSingleNode("//grade/marks/sub_piece[1]");
                XPathNavigator last = navigator.SelectSingleNode("//grade/marks/sub_piece[last()]");
                navigator.MoveTo(first);
                navigator.DeleteRange(last);
            }

            // Marks
            // Save is grade(marks) enable?
            navigator.SelectSingleNode("//grade/marks/enable").SetValue(chkEnableGrade.Checked.ToString());

            // save _dtbGrades
            List<string> marksSubpieces = _marksSubpieceNames;
            foreach (string subpieceName in marksSubpieces)
            {
                navigator.SelectSingleNode("//grade/marks").AppendChildElement(string.Empty, "sub_piece", string.Empty, null);
                //Move to last column element and add name value.
                navigator.SelectSingleNode("//grade/marks/sub_piece[last()]").AppendChildElement(string.Empty, "name", string.Empty, subpieceName);
                string expr = String.Format("SubpieceName='{0}'", subpieceName);
                // check all same
                if (chkAllSameOfGrade.Checked)
                {
                    expr = String.Format("SubpieceName='{0}'", "All");
                }
                DataRow[] drs = _dtbGrades.Select(expr);
                foreach (DataRow dr in drs)
                {
                    string className = dr["GradeName"].ToString();
                    string score = dr["Score"].ToString();
                    navigator.SelectSingleNode("//grade/marks/sub_piece[last()]").AppendChildElement(string.Empty, "mark", string.Empty, score);
                    navigator.SelectSingleNode("//grade/marks/sub_piece[last()]/mark[last()]").CreateAttribute(string.Empty, "id", string.Empty, className);
                }
            }

            // Pass or Fail
            // Save filter score is enable?
            navigator.SelectSingleNode("//grade/pass_fail/enable").SetValue(chkEnablePFS.Checked.ToString());
            int filterScore = int.TryParse(txtFilterScore.Text, out filterScore) ? filterScore : 0;
            navigator.SelectSingleNode("//grade/pass_fail/score").SetValue(filterScore.ToString());

            // Finish Save
            //----------------------------------------------------------------------------------//

            string grade_path = PathHelper.GradeConfigFolder + cmbConfig.Text.Trim() + ".xml";
            try
            {
                document.Save(grade_path);
                // Re binding cmbMapConfigName datasource
                List<string> graeConfigs = new List<string>();
                DirectoryInfo dirInfo = new DirectoryInfo(PathHelper.GradeConfigFolder);
                FileInfo[] files = dirInfo.GetFiles("*.xml");
                foreach (FileInfo file in files)
                {
                    graeConfigs.Add(file.Name.ToString().Substring(0, file.Name.ToString().LastIndexOf(".")));
                }
                // Binding datasource for cmbMapConfigName and set default value.
                cmbConfig.DataSource = graeConfigs;
                cmbConfig.SelectedItem = ch.GetDefaultGradeConfigName().Trim();
                MessageBox.Show("Success.");
            }
            catch
            {
                MessageBox.Show("Fail.");
            }

            // Refresh datas
            // Refresh dgvPoint datasource
            _dtbPoints.Clear();
            DataTable tmpPoints = ch.GetDataTabledgvPoints(cmbConfig.SelectedItem.ToString().Trim());
            foreach (DataRow dr in tmpPoints.Rows)
            {
                DataRow d = _dtbPoints.NewRow();
                d["SubpieceName"] = dr["SubpieceName"];
                d["ClassName"] = dr["ClassName"];
                d["Score"] = dr["Score"];
                _dtbPoints.Rows.Add(d);
            }
            DataView dvPoints = _dtbPoints.DefaultView;
            dvPoints.RowFilter = String.Format("SubpieceName='{0}'", cmbSubPoints.SelectedItem.ToString().Trim());
            tmpPoints.Dispose();

            // Refresh dgvGrade datasource
            _dtbGrades.Clear();
            DataTable tmpGrades = ch.GetDataTabledgvGrade(cmbConfig.SelectedItem.ToString().Trim());
            foreach (DataRow dr in tmpGrades.Rows)
            {
                DataRow d = _dtbGrades.NewRow();
                d["SubpieceName"] = dr["SubpieceName"];
                d["GradeName"] = dr["GradeName"];
                d["Score"] = dr["Score"];
                _dtbGrades.Rows.Add(d);
            }
            DataView dvGrade = _dtbGrades.DefaultView;
            dvGrade.RowFilter = String.Format("SubpieceName='{0}'", cmbSubMarks.SelectedItem.ToString().Trim());
            tmpGrades.Dispose();
        }
Example #5
0
        // Calculate entiry piece score and send NG signal when piece fail
        public void CalcEntirePieceResult()
        {
            // get current using unit
            NowUnit ucd = _units.Find(x => x.ComponentName == "Flaw Map CD");

            int score = 0;
            double top = Convert.ToDouble(_cuts.Last()) - JobHelper.PxPInfo.Height;
            double bottom = Convert.ToDouble(_cuts.Last());
            string rowFilter = String.Format("MD > {0} AND MD < {1} AND CD > {2}", top, bottom, _tmpOffset);
            DataRow[] flawRows = _dtbFlaws.Select(rowFilter);

            ConfigHelper ch = new ConfigHelper();
            string gradeConfigFile = ch.GetDefaultGradeConfigName();
            DataTable gradeColumn = ch.GetDataTableOfdgvColumns(gradeConfigFile);
            DataTable gradeRow = ch.GetDataTableOfdgvRows(gradeConfigFile);
            string roiMode = ch.GetGradeNoRoiMode(gradeConfigFile);
            bool showScore = ch.IsGradePointEnable(gradeConfigFile);
            double limitScore = ch.GetPassFailScore(gradeConfigFile);

            if (roiMode == "Symmetrical" && showScore)
            {
                bool pieceResult;
                if (flawRows.Length > 0)
                {
                    foreach (DataRow drCol in gradeColumn.Rows)
                    {
                        foreach (DataRow drRow in gradeRow.Rows)
                        {
                            string rangeName = String.Format("{0}{1}", drCol["Name"], drRow["Name"]);

                            int subPieceScore = 0;
                            //string subPieceFilter = String.Format("(CD >= {0} AND CD <= {1}) AND (MD > {2} AND MD < {3})", drCol["Start"], drCol["End"], (Convert.ToDouble(drRow["Start"]) + top), (Convert.ToDouble(drRow["End"]) + top));
                            string subPieceFilter = String.Format("(CD >= {0} AND CD <= {1}) AND (MD > {2} AND MD < {3})", Convert.ToDouble(drCol["Start"]) / ucd.Conversion, Convert.ToDouble(drCol["End"]) / ucd.Conversion, (Convert.ToDouble(drRow["Start"]) / ucd.Conversion + top), (Convert.ToDouble(drRow["End"]) / ucd.Conversion + top));
                            DataRow[] subFlawRows = _dtbFlaws.Select(subPieceFilter);
                            foreach (DataRow dr in subFlawRows)
                            {
                                string pointFilter = String.Format("SubpieceName = 'ROI-{0}' AND ClassName = '{1}'", rangeName, dr["FlawClass"]);
                                subPieceScore += Convert.ToInt32(_dtbPoints.Select(pointFilter).First()["Score"]);
                            }

                            score += subPieceScore;
                        }
                    }
                    if (score >= limitScore)
                    {
                        pieceResult = false;
                    }
                    else
                    {
                        pieceResult = true;
                    }
                }
                else
                {
                    pieceResult = true;
                }
                _doffResult.Add(pieceResult);

                // Fire when doff is fail
                if (!JobHelper.IsOnpeHistory)
                {
                    if (pieceResult == false)
                    {
                        _fire.FireEvent(0, 0, 0);
                    }
                    else
                    {
                        _fire.FireEvent(1, 0, 0);
                    }
                }
            }
            else
            {
                _doffResult.Add(true);
            }

            // Calc flaw number of this job
            foreach (DataRow dr in flawRows)
            {
                string name = dr["FlawClass"].ToString();
                if (!_jobDoffNum.ContainsKey(name))
                {
                    _jobDoffNum.Add(name, 1);
                }
                else
                {
                    _jobDoffNum[name]++;
                }
            }
        }
Example #6
0
        private void cmbMapConfigName_DropDownClosed(object sender, EventArgs e)
        {
            try
            {
                ConfigHelper ch = new ConfigHelper();
                // Set nudImageColumns, nudImageRows value.
                nudImageColumns.Value = ch.GettlpFlawImagesColumns(cmbMapConfigName.SelectedItem.ToString());
                nudImageRows.Value = ch.GettlpFlawImagesRows(cmbMapConfigName.SelectedItem.ToString());

                // Set rdoMapGridOn,rdoMapGridOff
                rdoMapGridOn.Checked = ch.GetIsDisplayMapGrid(cmbMapConfigName.SelectedItem.ToString());
                rdoMapGridOff.Checked = !ch.GetIsDisplayMapGrid(cmbMapConfigName.SelectedItem.ToString());

                // Set 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 = "";
                    }
                }

                // Set cmbBottomAxes default selected
                cmbBottomAxes.SelectedItem = ch.GetBottomAxes(cmbMapConfigName.SelectedItem.ToString());

                // Set chkCDInverse, chkMDInverse
                chkCDInverse.Checked = ch.IsCdInver_X(cmbMapConfigName.SelectedItem.ToString());
                chkMDInverse.Checked = ch.IsMdInver_Y(cmbMapConfigName.SelectedItem.ToString());

                // Set 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);

                // Set FlawLegends
                _dtbFlawLegends.Rows.Clear();
                DataTable dtb = ch.GetDataTablePrevFlawLegend(cmbMapConfigName.SelectedItem.ToString());
                foreach (DataRow dr in dtb.Rows)
                {
                    DataRow newDr = _dtbFlawLegends.NewRow();
                    newDr["FlawType"] = dr["FlawType"];
                    newDr["Name"] = dr["Name"];
                    newDr["Shape"] = dr["Shape"];
                    newDr["Color"] = dr["Color"];
                    _dtbFlawLegends.Rows.Add(newDr);
                }
            }
            catch { }
        }
Example #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // Save default config file to system config
            ConfigHelper ch = new ConfigHelper();
            if (String.IsNullOrEmpty(cmbMapConfigName.Text))
            {
                cmbMapConfigName.Text = DateTime.Now.ToShortDateString();
            }
            if (!ch.SaveMapSetupConfigFile(cmbMapConfigName.Text.Trim()))
            {
                return;
            }

            // initialize map xml sechma
            string sechma_path = PathHelper.SystemConfigFolder + "map_sechma.xml";
            XmlDocument document = new XmlDocument();
            document.Load(sechma_path);
            XPathNavigator navigator = document.CreateNavigator();

            // save image_grid_rows , image_grid_columns
            navigator.SelectSingleNode("//pxptab/image_grid_rows").SetValue(nudImageRows.Value.ToString());
            navigator.SelectSingleNode("//pxptab/image_grid_columns").SetValue(nudImageColumns.Value.ToString());

            // save map_proportion
            string[] proportion = cmbMapSize.SelectedItem.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            navigator.SelectSingleNode("//map_window/map_chart/map_proportion[@name='x']").SetValue(proportion[0]);
            navigator.SelectSingleNode("//map_window/map_chart/map_proportion[@name='y']").SetValue(proportion[1]);

            // save grid line display
            if (rdoMapGridOn.Checked)
            {
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_display").SetValue("true");
            }
            else
            {
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_display").SetValue("false");
            }

            // save grid line mode :Map 底格線間隔模式 0: FixSize , 1: EachCellCount
            if (rdoFixCellSize.Checked)
            {
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_mode").SetValue("0");
                // save grid line value of mode
                double md = Double.TryParse(txtFixSizeMD.Text, out md) ? md : 1;
                double cd = Double.TryParse(txtFixSizeCD.Text, out cd) ? cd : 1;
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_set/fix/md").SetValue(md.ToString());
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_set/fix/cd").SetValue(cd.ToString());
            }
            else if (rdoCountSize.Checked)
            {
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_mode").SetValue("1");
                // save grid line value of mode
                int md = Int32.TryParse(txtCountSizeMD.Text, out md) ? md : 2;
                int cd = Int32.TryParse(txtCountSizeCD.Text, out cd) ? cd : 2;
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_set/count/md").SetValue(md.ToString());
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_set/count/cd").SetValue(cd.ToString());
            }
            else
            {
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_mode").SetValue("1");
                // save grid line value of mode
                int md = Int32.TryParse(txtCountSizeMD.Text, out md) ? md : 2;
                int cd = Int32.TryParse(txtCountSizeCD.Text, out cd) ? cd : 2;
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_set/count/md").SetValue(md.ToString());
                navigator.SelectSingleNode("//map_window/map_chart/grid_line_set/count/cd").SetValue(cd.ToString());
            }

            // save bottom axes
            string bottom = cmbBottomAxes.SelectedItem.ToString().Trim();
            navigator.SelectSingleNode("//map_window/map_chart/bottom_axes").SetValue(bottom);

            // save md_inver
            if (chkMDInverse.Checked)
            {
                navigator.SelectSingleNode("//map_window/map_chart/md_inver").SetValue("true");
            }
            else
            {
                navigator.SelectSingleNode("//map_window/map_chart/md_inver").SetValue("false");
            }
            // save cd_inver
            if (chkCDInverse.Checked)
            {
                navigator.SelectSingleNode("//map_window/map_chart/cd_inver").SetValue("true");
            }
            else
            {
                navigator.SelectSingleNode("//map_window/map_chart/cd_inver").SetValue("false");
            }

            // save flawlegends
            // remove old flawlegend for add records
            if (navigator.Select("//map_window/flaw_legend").Count > 0 && _dtbFlawLegends.Rows.Count > 0)
            {
                XPathNavigator first = navigator.SelectSingleNode("//map_window/flaw_legend[1]");
                XPathNavigator last = navigator.SelectSingleNode("//map_window/flaw_legend[last()]");
                navigator.MoveTo(first);
                navigator.DeleteRange(last);
            }
            // save _dtbFlawLegends to xml
            for (int i = 0; i < _dtbFlawLegends.Rows.Count; i++)
            {
                string flawType = _dtbFlawLegends.Rows[i]["FlawType"].ToString();
                string flawName = _dtbFlawLegends.Rows[i]["Name"].ToString();
                string shape = _dtbFlawLegends.Rows[i]["Shape"].ToString();
                string color = _dtbFlawLegends.Rows[i]["Color"].ToString();
                navigator.SelectSingleNode("//config/map_window").AppendChildElement(string.Empty, "flaw_legend", string.Empty, null);
                // Move to last column element and add name, start, end value.
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "flaw_type", string.Empty, flawType);
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "name", string.Empty, flawName);
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "color", string.Empty, color);
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "shape", string.Empty, shape);
            }

            // save
            string map_path = PathHelper.MapConfigFolder + cmbMapConfigName.Text.Trim() + ".xml";
            try
            {
                document.Save(map_path);
                // Re binding 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;
                cmbMapConfigName.SelectedItem = ch.GetDefaultMapConfigName().Trim();
                MessageBox.Show("Success.");
            }
            catch
            {
                //MessageBox.Show("Fail.");
            }
        }
Example #8
0
        // Initial flaw chart
        public void InitChart(double width, double height)
        {
            ConfigHelper ch = new ConfigHelper();
            string mapConfigFile = ch.GetDefaultMapConfigName();
            bool isDisplayGrid = ch.GetIsDisplayMapGrid(mapConfigFile);
            bool isCdInvert = ch.IsCdInver_X(mapConfigFile);
            bool isMdInvert = ch.IsMdInver_Y(mapConfigFile);
            bool isFixCellSize = ch.GetIsFixCellSizeMode(mapConfigFile);
            double fixCdSize = ch.GetFixCellSizeCD(mapConfigFile);
            double fixMdSize = ch.GetFixCellSizeMD(mapConfigFile);
            double countCdSize = ch.GetCountSizeCD(mapConfigFile);
            double countMdSize = ch.GetCountSizeMD(mapConfigFile);
            string bottomAxes = ch.GetBottomAxes(mapConfigFile);

            if (chartControl.Series != null)
            {
                chartControl.Series.Clear();
            }
            Series series = new Series();
            chartControl.RuntimeHitTesting = true;
            chartControl.Legend.Visible = false;
            chartControl.Series.Add(series);

            XYDiagram diagram = (XYDiagram)chartControl.Diagram;
            // Setting AxisX format
            diagram.EnableAxisXZooming = true;
            diagram.EnableAxisXScrolling = true;
            diagram.AxisX.Range.MinValue = 0;
            diagram.AxisX.Range.MaxValue = width;
            diagram.AxisX.Range.ScrollingRange.SetMinMaxValues(0, width);
            diagram.AxisX.NumericOptions.Format = NumericFormat.Number;
            diagram.AxisX.NumericOptions.Precision = 6;
            diagram.AxisX.Reverse = isCdInvert;
            diagram.AxisX.GridLines.Visible = isDisplayGrid;
            diagram.AxisX.GridLines.LineStyle.DashStyle = DashStyle.Dash;
            diagram.AxisX.GridSpacingAuto = false;

            // Setting AxisY format
            diagram.EnableAxisYZooming = true;
            diagram.EnableAxisYScrolling = true;
            diagram.AxisY.Range.MinValue = 0;
            diagram.AxisY.Range.MaxValue = height;
            diagram.AxisY.Range.ScrollingRange.SetMinMaxValues(0, height);
            diagram.AxisY.NumericOptions.Format = NumericFormat.Number;
            diagram.AxisY.NumericOptions.Precision = 6;
            diagram.AxisY.Reverse = isMdInvert;
            diagram.AxisY.GridLines.Visible = isDisplayGrid;
            diagram.AxisY.GridLines.LineStyle.DashStyle = DashStyle.Dash;
            diagram.AxisY.GridSpacingAuto = false;

            // Setting chart cell size
            if (isFixCellSize) // Specify cell size
            {
                diagram.AxisX.GridSpacing = fixCdSize;
                diagram.AxisY.GridSpacing = fixMdSize;
            }
            else // Equal cell count
            {
                diagram.AxisX.GridSpacing = width / countCdSize;
                diagram.AxisY.GridSpacing = height / countMdSize;
            }

            // Setting Axes position
            if (isCdInvert)
            {
                if (isMdInvert)
                {
                    diagram.AxisX.Alignment = AxisAlignment.Far;
                    diagram.AxisY.Alignment = AxisAlignment.Far;
                }
                else
                {
                    diagram.AxisX.Alignment = AxisAlignment.Near;
                    diagram.AxisY.Alignment = AxisAlignment.Far;
                }
            }
            else
            {
                if (isMdInvert)
                {
                    diagram.AxisX.Alignment = AxisAlignment.Far;
                    diagram.AxisY.Alignment = AxisAlignment.Near;
                }
                else
                {
                    diagram.AxisX.Alignment = AxisAlignment.Near;
                    diagram.AxisY.Alignment = AxisAlignment.Near;
                }
            }

            // Rotate chart when bottom axes is MD
            if (bottomAxes == "CD")
            {
                diagram.Rotated = false;
            }
            else
            {
                diagram.Rotated = true;
            }
            DrawSubPiece();
        }
Example #9
0
        // Initial flaw legend datagridview
        public void InitFlawLegendGrid()
        {
            _dtbFlawLegends.Rows.Clear();
            // Add jobloaded records
            foreach (FlawLegend f in _legend)
            {
                DataRow dr = _dtbFlawLegends.NewRow();
                dr["Display"] = f.VisibleFlags;
                dr["FlawType"] = f.ClassID;
                dr["Name"] = f.Name;
                dr["Shape"] = "Cone";
                dr["Color"] = String.Format("#{0:X2}{1:X2}{2:X2}", ColorTranslator.FromWin32((int)f.Color).R,
                                                        ColorTranslator.FromWin32((int)f.Color).G,
                                                        ColorTranslator.FromWin32((int)f.Color).B);
                dr["PieceDoffNum"] = 0;
                dr["JobDoffNum"] = 0;
                _dtbFlawLegends.Rows.Add(dr);
            }

            // Deal Flaw Legends datasoure
            ConfigHelper ch = new ConfigHelper();

            string mapConfig = ch.GetDefaultMapConfigName().Trim();
            DataTable dtbLegendFromConfig = ch.GetDataTablePrevFlawLegend(mapConfig);

            foreach (DataRow d in dtbLegendFromConfig.Rows)
            {
                string expr = String.Format("FlawType={0} AND Name='{1}'", d["FlawType"].ToString().Trim(), d["Name"].ToString().Trim());
                DataRow[] drs = _dtbFlawLegends.Select(expr);
                if (drs.Length > 0)
                {
                    drs[0]["Shape"] = d["Shape"].ToString().Trim();
                    drs[0]["Color"] = d["Color"].ToString().Trim();
                }
            }

            // Save new record to xml
            string map_path = PathHelper.MapConfigFolder + mapConfig + ".xml";
            XmlDocument document = new XmlDocument();
            document.Load(map_path);
            XPathNavigator navigator = document.CreateNavigator();
            XPathNodeIterator node = navigator.Select("//map_window/flaw_legend");

            // remove old flawlegend for add records
            if (navigator.Select("//map_window/flaw_legend").Count > 0 && _dtbFlawLegends.Rows.Count > 0)
            {
                XPathNavigator first = navigator.SelectSingleNode("//map_window/flaw_legend[1]");
                XPathNavigator last = navigator.SelectSingleNode("//map_window/flaw_legend[last()]");
                navigator.MoveTo(first);
                navigator.DeleteRange(last);
            }

            // save _dtbFlawLegends to xml
            for (int i = 0; i < _dtbFlawLegends.Rows.Count; i++)
            {
                string flawType = _dtbFlawLegends.Rows[i]["FlawType"].ToString();
                string flawName = _dtbFlawLegends.Rows[i]["Name"].ToString();
                string shape = _dtbFlawLegends.Rows[i]["Shape"].ToString();
                string color = _dtbFlawLegends.Rows[i]["Color"].ToString();
                navigator.SelectSingleNode("//config/map_window").AppendChildElement(string.Empty, "flaw_legend", string.Empty, null);
                // Move to last column element and add name, start, end value.
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "flaw_type", string.Empty, flawType);
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "name", string.Empty, flawName);
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "color", string.Empty, color);
                navigator.SelectSingleNode("//config/map_window/flaw_legend[last()]").AppendChildElement(string.Empty, "shape", string.Empty, shape);
            }
            try
            {
                document.Save(map_path);
            }
            catch
            {
                MessageBox.Show("Fail.");
            }
        }
Example #10
0
        // Draw sub piece range and annotation
        private void DrawSubPiece()
        {
            // get current using unit
            NowUnit ucd = _units.Find(x => x.ComponentName == "Flaw Map CD");

            _totalScore = 0;
            DataRow[] flawRows = _dtbFlaws.Select(_dtbFlaws.DefaultView.RowFilter);

            ConfigHelper ch = new ConfigHelper();
            string gradeConfigFile = ch.GetDefaultGradeConfigName();
            DataTable gradeColumn = ch.GetDataTableOfdgvColumns(gradeConfigFile);
            DataTable gradeRow = ch.GetDataTableOfdgvRows(gradeConfigFile);
            string roiMode = ch.GetGradeNoRoiMode(gradeConfigFile);
            bool showScore = ch.IsGradePointEnable(gradeConfigFile);
            bool showGrade = ch.IsGradeMarksEnable(gradeConfigFile);

            if (roiMode == "Symmetrical")
            {
                foreach (DataRow drCol in gradeColumn.Rows)
                {
                    foreach (DataRow drRow in gradeRow.Rows)
                    {
                        // Add rangearea
                        string rangeName = String.Format("{0}{1}", drCol["Name"], drRow["Name"]);
                        Series range = new Series(rangeName, ViewType.RangeArea);
                        range.ShowInLegend = false;
                        range.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False;
                        range.ArgumentScaleType = ScaleType.Numerical;

                        range.Points.Add(new SeriesPoint(drCol["Start"], drRow["Start"], drRow["End"]));
                        range.Points.Add(new SeriesPoint(drCol["End"], drRow["Start"], drRow["End"]));

                        RangeAreaSeriesView view = (RangeAreaSeriesView)range.View;
                        view.Color = Color.Red;
                        view.Transparency = 230;
                        view.Marker1.Visible = false;
                        view.Marker2.Visible = false;
                        view.Border1.Color = Color.Transparent;
                        view.Border2.Color = Color.Transparent;

                        chartControl.Series.Add(range);

                        int subPieceScore = 0;
                        string subPieceGrade = "F";
                        if (showScore)
                        {
                            string subPieceFilter = String.Format("(CD >= {0} AND CD <= {1}) AND (MD > {2} AND MD < {3})", Convert.ToDouble(drCol["Start"]) / ucd.Conversion, Convert.ToDouble(drCol["End"]) / ucd.Conversion, (Convert.ToDouble(drRow["Start"]) / ucd.Conversion + _topOfPart), (Convert.ToDouble(drRow["End"]) / ucd.Conversion + _topOfPart));
                            DataRow[] subFlawRows = _dtbFlaws.Select(subPieceFilter);
                            foreach (DataRow dr in subFlawRows)
                            {
                                string pointFilter = String.Format("SubpieceName = 'ROI-{0}' AND ClassName = '{1}'", rangeName, dr["FlawClass"]);
                                subPieceScore += Convert.ToInt32(_dtbPoints.Select(pointFilter).First()["Score"]);
                            }
                        }
                        if (showGrade)
                        {
                            string gradeFilter = String.Format("SubpieceName = 'ROI-{0}' AND Score >= {1}", rangeName, subPieceScore);
                            DataRow[] r = _dtbGrades.Select(gradeFilter);
                            if (_dtbGrades.Select(gradeFilter).Length > 0)
                            {
                                subPieceGrade = _dtbGrades.Select(gradeFilter).First()["GradeName"].ToString();
                            }
                        }

                        // Add annotation
                        TextAnnotation annotation = new TextAnnotation();
                        PaneAnchorPoint paPoint = new PaneAnchorPoint();
                        RelativePosition relPosition = new RelativePosition();

                        annotation.LabelMode = true;
                        annotation.BackColor = System.Drawing.Color.Transparent;
                        annotation.Border.Visible = false;
                        annotation.ConnectorStyle = AnnotationConnectorStyle.None;
                        annotation.Font = new System.Drawing.Font("Tahoma", 8F, FontStyle.Bold);
                        annotation.TextColor = Color.Blue;
                        annotation.Name = rangeName;
                        string annotationScore = "";
                        if (showScore)
                        {
                            annotationScore = String.Format(" - {0}", subPieceScore);
                        }
                        string annotationGrade = "";
                        if (showGrade)
                        {
                            annotationGrade = String.Format("({0})", subPieceGrade);
                        }
                        annotation.Text = String.Format("{0}{1}{2}", rangeName, annotationScore, annotationGrade);
                        string annotationX = Convert.ToString(Convert.ToDouble(drCol["Start"]) + (Convert.ToDouble(drCol["End"]) - Convert.ToDouble(drCol["Start"])) * 0.3);
                        string annotationY = Convert.ToString(Convert.ToDouble(drRow["End"]) - (Convert.ToDouble(drRow["End"]) - Convert.ToDouble(drRow["Start"])) * 0.1);
                        paPoint.AxisXCoordinate.AxisValueSerializable = annotationX;
                        paPoint.AxisYCoordinate.AxisValueSerializable = annotationY;
                        annotation.AnchorPoint = paPoint;
                        relPosition.Angle = 0;
                        relPosition.ConnectorLength = 0;
                        annotation.ShapePosition = relPosition;
                        chartControl.AnnotationRepository.AddRange(new Annotation[] { annotation });

                        _totalScore += subPieceScore;
                    }
                }
            }
            DrawDummyPoint();

            // Calculate flaw quantity
            Dictionary<string, int> flawLegendRefDic = new Dictionary<string, int>();
            int i = 0;
            foreach (DataGridViewRow dgvr in dgvFlawLegendDetial.Rows)
            {
                dgvr.Cells["PieceDoffNum"].Value = "0";
                flawLegendRefDic.Add(dgvr.Cells["Name"].Value.ToString(), i);
                i++;
            }
            if (flawRows.Length > 0)
            {
                foreach (DataRow dr in flawRows)
                {
                    string flawName = dr["FlawClass"].ToString();
                    int rowPosition = flawLegendRefDic[flawName];
                    int flawQuantity = Convert.ToInt32(dgvFlawLegendDetial.Rows[rowPosition].Cells["PieceDoffNum"].Value) + 1;
                    dgvFlawLegendDetial.Rows[rowPosition].Cells["PieceDoffNum"].Value = flawQuantity.ToString();
                }
            }
        }
Example #11
0
        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);
        }
Example #12
0
        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();
        }
Example #13
0
        private void btnCreateGrid_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to create new subpiece setting?", "Create Setting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dialogResult == DialogResult.Yes)
            {
                int x = int.TryParse(txtColumns.Text, out x) ? x : 1;
                int y = int.TryParse(txtRows.Text, out y) ? y : 1;

                _dtbColumns.Clear();
                for (int i = 0; i < x; i++)
                {
                    DataRow dr = _dtbColumns.NewRow();
                    dr["Name"] = i + 1;
                    _dtbColumns.Rows.Add(dr);
                }
                _dtbRows.Clear();
                for (int i = 0; i < y; i++)
                {
                    DataRow dr = _dtbRows.NewRow();
                    dr["Name"] = i + 1;
                    _dtbRows.Rows.Add(dr);
                }

                // SubpieceName Reset

                _pointsSubpieceNames = new List<string>();
                _marksSubpieceNames = new List<string>();
                _pointsSubpieceNames.Add("All");
                _marksSubpieceNames.Add("All");
                for (int i = 0; i < x; i++)
                {
                    for (int j = 0; j < y; j++)
                    {
                        string name = String.Format("ROI-{0}{1}", i + 1, j + 1);
                        _pointsSubpieceNames.Add(name);
                        _marksSubpieceNames.Add(name);
                    }
                }
                cmbSubMarks.DataSource = null;
                cmbSubMarks.DataSource = _marksSubpieceNames;
                cmbSubPoints.DataSource = null;
                cmbSubPoints.DataSource = _pointsSubpieceNames;

                // Add Points set
                ConfigHelper ch = new ConfigHelper();
                string map_path = ch.GetDefaultMapConfigName();
                Dictionary<int, string> legends = ch.GetPrevFlawLegendDictionary(map_path);
                _dtbPoints.Rows.Clear();
                foreach (string subpiece in _pointsSubpieceNames)
                {
                    foreach (KeyValuePair<int, string> l in legends)
                    {
                        // SubpieceName, ClassName, Score
                        DataRow dr = _dtbPoints.NewRow();
                        dr["SubpieceName"] = subpiece;
                        dr["ClassName"] = l.Value;
                        dr["Score"] = 0;
                        _dtbPoints.Rows.Add(dr);
                    }
                }

                // Refresh Mark
                foreach (string subpiece in _marksSubpieceNames)
                {
                    string expr = String.Format("SubpieceName='{0}'", subpiece);
                    DataRow[] drs = _dtbGrades.Select(expr);
                    if (drs.Length < 1)
                    {
                        DataRow dr = _dtbGrades.NewRow();
                        dr["SubpieceName"] = subpiece;
                        dr["GradeName"] = "A";
                        dr["Score"] = 0;
                        _dtbGrades.Rows.Add(dr);
                    }
                }
            }
        }
Example #14
0
        private void cmbConfig_DropDownClosed(object sender, EventArgs e)
        {
            ConfigHelper ch = new ConfigHelper();

            //ROI Settings
            //----------------------------------------------------------------------------------------//

            // Set 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;
                }
            }

            // Set TextBox of Columns, Rows
            txtColumns.Text = ch.GetGradeColumns(cmbConfig.SelectedItem.ToString()).ToString();
            txtRows.Text = ch.GetGradeRows(cmbConfig.SelectedItem.ToString()).ToString();

            // Reload DataTable of dgvColumns and dgvRows
            _dtbColumns.Clear();
            DataTable tmpColumns = ch.GetDataTableOfdgvColumns(cmbConfig.SelectedItem.ToString().Trim());
            foreach (DataRow dr in tmpColumns.Rows)
            {
                DataRow d = _dtbColumns.NewRow();
                d["Name"] = dr["Name"];
                d["Start"] = dr["Start"];
                d["End"] = dr["End"];
                _dtbColumns.Rows.Add(d);
            }
            tmpColumns.Dispose();
            _dtbRows.Clear();
            DataTable tmpRows = ch.GetDataTableOfdgvRows(cmbConfig.SelectedItem.ToString().Trim());
            foreach (DataRow dr in tmpRows.Rows)
            {
                DataRow d = _dtbRows.NewRow();
                d["Name"] = dr["Name"];
                d["Start"] = dr["Start"];
                d["End"] = dr["End"];
                _dtbRows.Rows.Add(d);
            }
            tmpRows.Dispose();

            // Grade Settings
            //----------------------------------------------------------------------------------------//

            // Initialize Point is enable.
            chkEnablePonit.Checked = ch.IsGradePointEnable(cmbConfig.SelectedItem.ToString().Trim());

            // Initialize SubPiece (cmbSubPoints)
            _pointsSubpieceNames = ch.GetSubPointsNameList(cmbConfig.SelectedItem.ToString().Trim());
            cmbSubPoints.DataSource = _pointsSubpieceNames;

            // Set dgvPoint datasource
            _dtbPoints.Clear();
            DataTable tmpPoints = ch.GetDataTabledgvPoints(cmbConfig.SelectedItem.ToString().Trim());
            foreach (DataRow dr in tmpPoints.Rows)
            {
                DataRow d = _dtbPoints.NewRow();
                d["SubpieceName"] = dr["SubpieceName"];
                d["ClassName"] = dr["ClassName"];
                d["Score"] = dr["Score"];
                _dtbPoints.Rows.Add(d);
            }
            DataView dvPoints = _dtbPoints.DefaultView;
            dvPoints.RowFilter = String.Format("SubpieceName='{0}'", cmbSubPoints.SelectedItem.ToString().Trim());
            tmpPoints.Dispose();

            // Initialize grade is enable (marks)
            chkEnableGrade.Checked = ch.IsGradeMarksEnable(cmbConfig.SelectedItem.ToString().Trim());

            // Initialize SubPiece (cmbSubPoints)
            cmbSubMarks.DataSource = ch.GetSubMarksNameList(cmbConfig.SelectedItem.ToString().Trim());

            // Set dgvGrade datasource
            _dtbGrades.Clear();
            DataTable tmpGrades = ch.GetDataTabledgvGrade(cmbConfig.SelectedItem.ToString().Trim());
            foreach (DataRow dr in tmpGrades.Rows)
            {
                DataRow d = _dtbGrades.NewRow();
                d["SubpieceName"] = dr["SubpieceName"];
                d["GradeName"] = dr["GradeName"];
                d["Score"] = dr["Score"];
                _dtbGrades.Rows.Add(d);
            }
            DataView dvGrade = _dtbGrades.DefaultView;
            dvGrade.RowFilter = String.Format("SubpieceName='{0}'", cmbSubMarks.SelectedItem.ToString().Trim());
            tmpGrades.Dispose();

            // Initialize Tab of grade/pass or fail
            chkEnablePFS.Checked = ch.IsGradePassFailEnable(cmbConfig.SelectedItem.ToString().Trim());
            txtFilterScore.Text = ch.GetPassFailScore(cmbConfig.SelectedItem.ToString().Trim()).ToString();
        }
Example #15
0
        // (16)
        public void OnJobLoaded(IList<IFlawTypeName> flawTypes, IList<ILaneInfo> lanes, IList<ISeverityInfo> severityInfo, IJobInfo jobInfo)
        {
            // WriteHelper.Log("OnJobLoaded()");
            // Reset to default.
            _cuts = new List<double>();
            //_newCuts = new List<Cut>();
            lblNowPage.Text = "---";
            lblTotalPage.Text = "---";
            btnNextFlawImages.Enabled = false;
            btnPrevFlawImages.Enabled = false;
            btnShowGoPage.Enabled = false;
            _nowPage = 0;
            _totalPage = 0;
            _dvFiliter = new DataView();

            // save datas in global helper.
            JobHelper.FlawTypes = flawTypes;
            JobHelper.JobInfo = jobInfo;
            JobHelper.Lanes = lanes;
            JobHelper.SeverityInfo = severityInfo;

            //update dgvFlaw HeaderText + (Unit)
            NowUnit unitFlawListCD = _units.Find(x => x.ComponentName == "Flaw List CD");
            dgvFlaw.Columns["CD"].HeaderText = dgvFlaw.Columns["CD"].Name + String.Format("({0})", unitFlawListCD.Symbol);
            NowUnit unitFlawListMD = _units.Find(x => x.ComponentName == "Flaw List MD");
            dgvFlaw.Columns["MD"].HeaderText = dgvFlaw.Columns["MD"].Name + String.Format("({0})", unitFlawListMD.Symbol);
            NowUnit unitFlawListWidth = _units.Find(x => x.ComponentName == "Flaw List Width");
            dgvFlaw.Columns["Width"].HeaderText = dgvFlaw.Columns["Width"].Name + String.Format("({0})", unitFlawListWidth.Symbol);
            NowUnit unitFlawListLength = _units.Find(x => x.ComponentName == "Flaw List Height");
            dgvFlaw.Columns["Length"].HeaderText =  dgvFlaw.Columns["Length"].Name + String.Format("({0})", unitFlawListLength.Symbol);
            NowUnit unitFlawListArea = _units.Find(x => x.ComponentName == "Flaw List Area");
            dgvFlaw.Columns["Area"].HeaderText = dgvFlaw.Columns["Area"].Name + String.Format("({0})", unitFlawListArea.Symbol);

            // initialize datatable  flaw format without data.
            _dtbFlaws = new DataTable("Flaws");

            _dtbFlaws.Columns.Add("FlawID", typeof(int));
            _dtbFlaws.Columns.Add("CD", typeof(double));
            _dtbFlaws.Columns.Add("MD", typeof(double));
            _dtbFlaws.Columns.Add("Area", typeof(string));
            _dtbFlaws.Columns.Add("FlawClass", typeof(string));
            _dtbFlaws.Columns.Add("FlawType", typeof(int));
            _dtbFlaws.Columns.Add("Images", typeof(IList<IImageInfo>));
            _dtbFlaws.Columns.Add("LeftEdge", typeof(double));
            _dtbFlaws.Columns.Add("RightEdge", typeof(double));
            _dtbFlaws.Columns.Add("Length", typeof(double));
            _dtbFlaws.Columns.Add("Width", typeof(double));
            _dtbFlaws.Columns.Add("Roll", typeof(int));
            _dtbFlaws.Columns.Add("RollMD", typeof(double));
            _dtbFlaws.Columns.Add("RightRollCD", typeof(double));
            _dtbFlaws.Columns.Add("LeftRollCD", typeof(double));
            _dtbFlaws.Columns.Add("DateTime", typeof(DateTime));

            // other columns for deal grade and score.
            _dtbFlaws.Columns.Add("Priority", typeof(int));
            _dtbFlaws.Columns.Add("PointScore", typeof(double));
            _dtbFlaws.Columns.Add("SubPieceName", typeof(string));

            // sort by default column
            ConfigHelper ch = new ConfigHelper();
            _dtbFlaws.DefaultView.Sort = String.Format("{0} ASC", ch.GetSortByColumnName().Trim());

            // set dgvFlaws datasource
            dgvFlaw.DataSource = _dtbFlaws;

            // Refresh TableLayoutPanel
            tlpFlawImages.Controls.Clear();
            tlpFlawImages.ColumnStyles.Clear();
            tlpFlawImages.ColumnCount = ch.GettlpFlawImagesColumns();
            tlpFlawImages.RowCount = ch.GettlpFlawImagesRows();
            int phdHeight = tlpFlawImages.Height / tlpFlawImages.RowCount;
            int phdrWidth = tlpFlawImages.Width / tlpFlawImages.ColumnCount;
            for (int i = 0; i < tlpFlawImages.RowCount; i++)
            {
                tlpFlawImages.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            }

            for (int i = 0; i < tlpFlawImages.ColumnCount; i++)
            {
                tlpFlawImages.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
            }

            // For MapWindow.cs
            //---------------------------------------------------------------------------

            // Setting MapWindow
            _mp.InitJobInfo(jobInfo);
            _mp.InitFlawLegendGrid();
            _mp.InitDatatableFlaws(ref _dtbFlaws);
            _mp.InitUnits(ref _units);
            _mp.InitCutList(ref _cuts);

            // UNDONE: New Cut List
            // _mp.InitCutList(ref _newCuts);
            _mp.InitFire(ref Fire);

            // Initial Flaw Chart FlawLegend
            NowUnit unitFlawMapCD = _units.Find(x => x.ComponentName == "Flaw Map CD");
            double mapWidth = JobHelper.PxPInfo.Width * unitFlawMapCD.Conversion;
            double mapHeight = JobHelper.PxPInfo.Height * unitFlawMapCD.Conversion;
            _mp.InitChart(mapWidth, mapHeight);
        }
Example #16
0
        // Reload points and grades data
        public void ReloadDataTables()
        {
            ConfigHelper ch = new ConfigHelper();
            string grade_name = ch.GetDefaultGradeConfigName();

            // Get Points score
            _dtbPoints = ch.GetDataTabledgvPoints(grade_name);
            // Get Grade
            _dtbGrades = ch.GetDataTabledgvGrade(grade_name);
        }
Example #17
0
        // (1)
        public PxPTab()
        {
            // WriteHelper.Log("PxPTab()");
            InitializeComponent();
            // initialize dgvFlaw without datasource.
            ConfigHelper ch = new ConfigHelper();
            List<Column> lstColumns = ch.GetdgvFlawColumns();
            foreach (Column c in lstColumns)
            {
                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;
                dgvFlaw.Columns.Add(column);
            }
            dgvFlaw.MultiSelect = false;
            dgvFlaw.AutoGenerateColumns = false;

            // initialize tlpFlawImages layout without pictures.
            SetDoubleBuffered(tlpFlawImages); // start double buffer.
            tlpFlawImages.ColumnStyles.Clear();
            tlpFlawImages.ColumnCount = ch.GettlpFlawImagesColumns();
            tlpFlawImages.RowCount = ch.GettlpFlawImagesRows();
            int phdHeight = tlpFlawImages.Height / tlpFlawImages.RowCount;
            int phdrWidth = tlpFlawImages.Width / tlpFlawImages.ColumnCount;
            for (int i = 0; i < tlpFlawImages.RowCount; i++)
            {
                tlpFlawImages.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            }

            for (int i = 0; i < tlpFlawImages.ColumnCount; i++)
            {
                tlpFlawImages.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
            }
        }
Example #18
0
        private void btnGradeSetting_Click(object sender, EventArgs e)
        {
            try
            {
                ConfigHelper ch = new ConfigHelper();
                GradeSetup gs = new GradeSetup();
                gs.ShowDialog();

                // re-binding datasource
                // 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();

                // Reload datatable score
                ReloadDataTables();

                // Re-configure Chart
                XYDiagram diagram = null;
                DrawDummyPoint();
                if ((XYDiagram)chartControl.Diagram != null)
                {
                    diagram = (XYDiagram)chartControl.Diagram;
                    double width = Convert.ToDouble(diagram.AxisX.Range.ScrollingRange.MaxValue);
                    double height = Convert.ToDouble(diagram.AxisY.Range.ScrollingRange.MaxValue);
                    InitChart(width, height);

                    if (chartControl.Series != null)
                    {
                        //UNDONE: 歷史資料切換設定時需重判好壞
                        ReCalcPieceResult();
                        DrawChartPoint();
                        JobHelper.IsOnpeHistory = true;
                        UpdateUIControl();
                        JobHelper.IsOnpeHistory = false;
                    }
                }
            }
            catch { }
        }
Example #19
0
        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;
        }
Example #20
0
        private void btnMapSetting_Click(object sender, EventArgs e)
        {
            // Deal Flaw Legends datasoure
            ConfigHelper ch = new ConfigHelper();

            XYDiagram diagram = null;
            if ((XYDiagram)chartControl.Diagram != null)
            {
                diagram = (XYDiagram)chartControl.Diagram;
            }

            MapSetup ms = new MapSetup();
            ms.ShowDialog();
            if (_legend != null && _legend.Count > 0)
            {
                // Reload flawlegend
                _dtbFlawLegends.Rows.Clear();
                // Add jobloaded records
                foreach (FlawLegend f in _legend)
                {
                    DataRow dr = _dtbFlawLegends.NewRow();
                    dr["Display"] = f.VisibleFlags;
                    dr["FlawType"] = f.ClassID;
                    dr["Name"] = f.Name;
                    dr["Shape"] = "Cone";
                    dr["Color"] = String.Format("#{0:X2}{1:X2}{2:X2}", ColorTranslator.FromWin32((int)f.Color).R,
                                                            ColorTranslator.FromWin32((int)f.Color).G,
                                                            ColorTranslator.FromWin32((int)f.Color).B);
                    dr["PieceDoffNum"] = 0;
                    dr["JobDoffNum"] = 0;
                    _dtbFlawLegends.Rows.Add(dr);
                }

                string mapConfig = ch.GetDefaultMapConfigName().Trim();
                DataTable dtbLegendFromConfig = ch.GetDataTablePrevFlawLegend(mapConfig);

                foreach (DataRow d in dtbLegendFromConfig.Rows)
                {
                    string expr = String.Format("FlawType={0} AND Name='{1}'", d["FlawType"].ToString().Trim(), d["Name"].ToString().Trim());
                    DataRow[] drs = _dtbFlawLegends.Select(expr);
                    if (drs.Length > 0)
                    {
                        drs[0]["Shape"] = d["Shape"].ToString().Trim();
                        drs[0]["Color"] = d["Color"].ToString().Trim();
                    }
                }

                dgvFlawLegend.ClearSelection();
                dgvFlawLegendDetial.ClearSelection();

                // Re-configure Chart
                if (diagram != null)
                {
                    double width = Convert.ToDouble(diagram.AxisX.Range.ScrollingRange.MaxValue);
                    double height = Convert.ToDouble(diagram.AxisY.Range.ScrollingRange.MaxValue);
                    InitChart(width, height);
                    DrawChartPoint();
                }
            }
            // Refresh pxptab tablelayout
            _pnl.ColumnCount = ch.GettlpFlawImagesColumns();
            _pnl.RowCount = ch.GettlpFlawImagesRows();
            _pnl.ColumnStyles.Clear();
            int phdHeight = _pnl.Height / _pnl.RowCount;
            int phdrWidth = _pnl.Width / _pnl.ColumnCount;
            for (int i = 0; i < _pnl.RowCount; i++)
            {
                _pnl.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            }

            for (int i = 0; i < _pnl.ColumnCount; i++)
            {
                _pnl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
            }
            // 呼叫 RefreshtlpImagesControls 重新加入控制項, 然後重新計算總頁數
            if (_dtbFlaws != null)
            {
                _pxp.RefreshtlpImagesControls(1);
                int dataCount = _dtbFlaws.Select(_dtbFlaws.DefaultView.RowFilter).Length;
                int totalPage = dataCount % (_pnl.ColumnCount * _pnl.RowCount) == 0 ?
                             dataCount / (_pnl.ColumnCount * _pnl.RowCount) :
                             dataCount / (_pnl.ColumnCount * _pnl.RowCount) + 1;
                _pxp.Controls["lblTotalPage"].Text = totalPage.ToString();
            }
        }
Example #21
0
 private void rdoFixCellSize_CheckedChanged(object sender, EventArgs e)
 {
     ConfigHelper ch = new ConfigHelper();
     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());
 }
Example #22
0
        private void btnReset_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to reset subpiece setting?", "Reset Setting", MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
            if (dialogResult == DialogResult.Yes)
            {
                // 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 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 = ch.GetSubPointsNameList(cmbConfig.SelectedItem.ToString().Trim());

                // 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)
                cmbSubMarks.DataSource = ch.GetSubMarksNameList(cmbConfig.SelectedItem.ToString().Trim());

                // 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();
            }
        }