void ExecEvEdit() { if (!(EVarsList.SelectedItem is EVar sev)) { return; } var ev = sev.Clone(); var evbox = new EVarBox(CurrentEnvironment.FNames) { Title = "Edit Environment Variable", DataContext = ev }; evbox.Closing += (sender, args) => { var evb = (EVarBox)sender; if (evb.DialogResult != true) { return; } if (EVars.Where(e => !e.Equals(sev)).Any(e => e.Name.Equals(ev.Name, StringComparison.OrdinalIgnoreCase))) { MessageBox.Show( $"Variable '{ev.Name}' is already defined.\nPlease choose a different name.", Strings.APP_NAME, MessageBoxButton.OK, MessageBoxImage.Error ); args.Cancel = true; } }; if (evbox.ShowDialog() != true) { return; } if (ev.Framework == sev.Framework) { sev.SetValue(ev); EVarsList.Items.Refresh(); } else { CurrentEnvironment.Remove(sev); CurrentEnvironment.Add(ev, null); CurrentEnvironment.Render(EVars); EVarsList.SelectedItem = EVars.First(e => e.Name == ev.Name); } CurrentEnvironment.Dirty = true; UpdateColumnWidths(EVarsList); }
void ExecEvMoveUp() { if (!(EVarsList.SelectedItem is EVar ev)) { return; } CurrentEnvironment.MoveUp(ev); CurrentEnvironment.Render(EVars); EVarsList.SelectedItem = EVars.First(e => e.Name == ev.Name); }
void ExecEvAdd() { var sev = (EVar)EVarsList.SelectedItem; var ev = new EVar { Framework = sev?.Framework }; var evbox = new EVarBox(CurrentEnvironment.FNames) { Title = "Add Environment Variable", DataContext = ev }; evbox.Closing += (sender, args) => { var evb = (EVarBox)sender; if (evb.DialogResult != true) { return; } if (EVars.Any(e => e.Name.Equals(ev.Name, StringComparison.OrdinalIgnoreCase))) { MessageBox.Show( $"Variable '{ev.Name}' is already defined.\nPlease choose a different name.", Strings.APP_NAME, MessageBoxButton.OK, MessageBoxImage.Error ); args.Cancel = true; } }; if (evbox.ShowDialog() != true) { return; } CurrentEnvironment.Add(ev, sev); CurrentEnvironment.Render(EVars); UpdateColumnWidths(EVarsList); EVarsList.SelectedItem = EVars.First(e => e.Name == ev.Name); }