Exemple #1
0
        private void deleteValueButton_Click(object sender, EventArgs e)
        {
            if (Painter.ActiveLayer == null)
            {
                return;
            }

            SelectValueForm selectValueForm = new SelectValueForm();
            selectValueForm.InitializeValues(listedValue.ToArray());
            selectValueForm.ValueName = "Value";
            selectValueForm.NewValue = false;
            selectValueForm.Text = "Remove Values";
            selectValueForm.MultiSelect = true;

            if (selectValueForm.ShowDialog() == DialogResult.OK)
            {
                string[] removedValues = selectValueForm.SelectedValues;
                ListViewItem[] items = new ListViewItem[removedValues.Length];
                for(int i = 0; i < removedValues.Length; i++)
                {
                    for(int j = 0; j < valueListBox.Items.Count; j++)
                    {
                        if (valueListBox.Items[j].Text == removedValues[i])
                        {
                            items[i] = valueListBox.Items[j];
                            break;
                        }
                    }
                }
                foreach (ListViewItem item in items)
                {
                    listedValue.Remove(item.Text);
                    valueListBox.Items.Remove(item);
                }

            }
        }
Exemple #2
0
        private void addValueButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (Painter.ActiveLayer == null)
                {
                    return;
                }

                if (Raster.IsCategorical(Painter.ActiveLayer))
                {
                    // If this data is a categorical data, we are able to get access
                    // to its attribute table and get the value list.

                    IDataset rasterDataset = (IDataset)Painter.ActiveLayer;
                    ITable table = (ITable)rasterDataset;
                    List<string> unlistedValues = new List<string>();
                    for (int x = 0; x < table.RowCount(null); x++)
                    {
                        string value = table.GetRow(x).get_Value(1).ToString();
                        if (!listedValue.Contains(value))
                        {
                            unlistedValues.Add(value);
                        }
                    }

                    SelectValueForm selectValueForm = new SelectValueForm();
                    selectValueForm.InitializeValues(unlistedValues.ToArray());
                    selectValueForm.ValueName = "Value";
                    selectValueForm.NewValue = false;
                    selectValueForm.MultiSelect = true;
                    selectValueForm.Text = "Add Values";

                    if (selectValueForm.ShowDialog() == DialogResult.OK)
                    {
                        string[] selectedValues = selectValueForm.SelectedValues;

                        foreach (string value in selectedValues)
                        {
                            AddNewValueSymbol(value);
                        }
                    }
                }
                else
                {
                    // If it is a data with continuous data type, we are not able to
                    // get a value list. We can only add new data without using a
                    // value list.

                    addNewValueToolStripMenuItem.PerformClick();
                }
            }
            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");
            }
        }