Exemple #1
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 { }
        }
Exemple #2
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;
        }
Exemple #3
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();
        }