示例#1
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;
        }
示例#2
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 { }
        }
示例#3
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));
            }
        }
示例#4
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);
        }
示例#5
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));
            }
        }
示例#6
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();
            }
        }