コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: fednep/UV-Outliner
        void ChangeColumnName(object sender, ExecutedRoutedEventArgs e)
        {
            wnd_ColumnsManager wnd = new wnd_ColumnsManager();
            wnd.InitList(Document.ColumnDefinitions, "Select column to change name", "Change Name");
            wnd.Owner = this;
            if (wnd.ShowDialog() == true)
            {
                OutlinerColumnDefinition definition = wnd.ColumnsList.SelectedItem as OutlinerColumnDefinition;
                if (definition == null)
                    return;

                wnd_RenameColumn rename = new wnd_RenameColumn();
                rename.Owner = this;
                rename.ColumnName.Text = definition.ColumnName;
                rename.ColumnName.SelectAll();
                if (rename.ShowDialog() == true)
                {
                    definition.ColumnName = rename.ColumnName.Text;
                }
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: fednep/UV-Outliner
        void RemoveColumn(object sender, ExecutedRoutedEventArgs e)
        {
            wnd_ColumnsManager wnd = new wnd_ColumnsManager();
            wnd.InitList(Document.ColumnDefinitions, "Select column to remove", "Remove Column");
            wnd.Owner = this;
            if (wnd.ShowDialog() == true)
            {
                OutlinerColumnDefinition definition = (wnd.ColumnsList.SelectedItem as OutlinerColumnDefinition);
                if (definition == null)
                    return;
                int defIdx = Document.ColumnDefinitions.IndexOf(definition);
                if (defIdx == 0)
                {
                    MessageBox.Show("Main column cannot be removed.", "Cannot remove column", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    MessageBoxResult result = MessageBox.Show(
                        String.Format("This will remove column '{0}'. This action cannot be undone. \nDo you want to continue?", definition.ColumnName),
                        "Column removal", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    if (result == MessageBoxResult.Yes)
                        RemoveColumn(defIdx);

                    Document.UndoManager.ClearStacks();
                    OutlinerTree.HeaderVisible = (Document.ColumnDefinitions.Count > 1) ? Visibility.Visible : Visibility.Collapsed;
                }
            }
        }