Example #1
0
        // Edit values of selected pixels in ROI as a specified value.
        private void editSelectedPixelsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (rasterGridView.SelectedCells.Count == 0)
                {
                    MessageBox.Show("Please select pixels to be edited.", "Message");
                    return;
                }

                SingleInputForm inputValueForm = new SingleInputForm("New Value:", "Edit All");
                inputValueForm.ValueValidateMethod = this.ValueValidate;

                if (inputValueForm.ShowDialog() != DialogResult.OK)
                    return;

                double newValue = Convert.ToDouble(inputValueForm.Value);

                foreach (DataGridViewCell selectedCell in rasterGridView.SelectedCells)
                {
                    if (selectedCell.ColumnIndex == 0)
                        continue;

                    double oldValue = Convert.ToDouble(selectedCell.Value);
                    if (oldValue == newValue)
                        continue;

                    EditValue(newValue, oldValue, selectedCell.ColumnIndex, selectedCell.RowIndex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }
        }
Example #2
0
        private void addNewValueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Painter.IsPainting)
                {
                    return;
                }

                SingleInputForm inputValueForm = new SingleInputForm("New Value:", "Add New Value");
                inputValueForm.ValueValidateMethod = this.ValueValidate;

                if ((inputValueForm.ShowDialog() == DialogResult.OK) &&
                    !listedValue.Contains(Convert.ToString(inputValueForm.Value)))
                {
                    ListViewItem layerItem = new ListViewItem();

                    layerItem.Text = Convert.ToString(inputValueForm.Value);
                    layerItem.SubItems.Add("    ");

                    layerItem.SubItems[1].BackColor = Color.FromArgb(randomRGB.Next(0, 255),
                                                                        randomRGB.Next(0, 255),
                                                                        randomRGB.Next(0, 255));

                    layerItem.UseItemStyleForSubItems = false;
                    valueListBox.Items.Add(layerItem);
                    listedValue.Add(layerItem.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }
        }
Example #3
0
        // Change values of pixels in ROI as a specified value.
        private void editAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                SingleInputForm inputValueForm = new SingleInputForm("New Value:", "Edit All");
                inputValueForm.ValueValidateMethod = this.ValueValidate;

                if (inputValueForm.ShowDialog() != DialogResult.OK)
                    return;

                double newValue = Convert.ToDouble(inputValueForm.Value);

                for (int col = 1; col < rasterGridView.Columns.Count; col++)
                {
                    for (int row = 0; row < rasterGridView.Rows.Count; row++)
                    {
                        double oldValue = Convert.ToDouble(rasterGridView[col, row].Value);
                        if (oldValue == newValue)
                            continue;

                        EditValue(newValue, oldValue, col, row);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }
        }