Пример #1
0
        private void toolRenameSchema_Click(object sender, EventArgs e)
        {
            if (_module == null || _module.MapDocument == null ||
                _module[_module.MapDocument.FocusMap] == null)
            {
                return;
            }

            if (cmbSchemas.SelectedItem is SnapSchemaItem)
            {
                SnapSchemaItem item = (SnapSchemaItem)cmbSchemas.SelectedItem;
                if (!(item.SnapSchema is SnapSchema))
                {
                    return;
                }

                FormNewSchema dlg = new FormNewSchema(item.SnapSchema.Name);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    ((SnapSchema)item.SnapSchema).Name = dlg.SnapSchemaName;

                    int index = cmbSchemas.Items.IndexOf(item);
                    if (index < 0)
                    {
                        return;
                    }

                    // Refresh List
                    cmbSchemas.Items.Remove(item);
                    cmbSchemas.Items.Insert(index, item);
                    cmbSchemas.SelectedIndex = index;
                }
            }
        }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (_module == null || _module.MapDocument == null ||
                _module[_module.MapDocument.FocusMap] == null)
            {
                return;
            }

            FormNewSchema dlg = new FormNewSchema("New Schema");

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                SnapSchema schema = new SnapSchema(dlg.SnapSchemaName);
                //_module[_module.MapDocument.FocusMap].Add(schema);
                cmbSchemas.Items.Add(new SnapSchemaItem(_module.MapDocument.FocusMap, schema));

                cmbSchemas.SelectedIndex = cmbSchemas.Items.Count - 1;
            }
        }