diff --git a/SourceGen/WpfGui/EditVisualization.xaml b/SourceGen/WpfGui/EditVisualization.xaml index b942eb8..d7ecef6 100644 --- a/SourceGen/WpfGui/EditVisualization.xaml +++ b/SourceGen/WpfGui/EditVisualization.xaml @@ -121,8 +121,8 @@ limitations under the License. - private static string sLastVisIdent = string.Empty; + /// + /// Parameters specified for the last thing we saved. Convenient when there's N frames + /// of an animation where everything is the same size / color. + /// + private static ReadOnlyDictionary sLastParams = + new ReadOnlyDictionary(new Dictionary()); + private Brush mDefaultLabelColor = SystemColors.WindowTextBrush; private Brush mErrorLabelColor = Brushes.Red; @@ -250,9 +257,12 @@ namespace SourceGen.WpfGui { } } else { // New visualization. Use the set's offset as the default value for - // any parameter called "offset". + // any parameter called "offset". Otherwise try to pull a value with + // the same name out of the last thing we edited. if (vpd.Name.ToLowerInvariant() == "offset") { defaultVal = mSetOffset; + } else if (sLastParams.TryGetValue(vpd.Name, out object value)) { + defaultVal = value; } } @@ -294,6 +304,9 @@ namespace SourceGen.WpfGui { SetValue(MinHeightProperty, this.Height); previewImage.ClearValue(WidthProperty); previewImage.ClearValue(HeightProperty); + + tagTextBox.SelectAll(); + tagTextBox.Focus(); } private void Window_Closed(object sender, EventArgs e) { @@ -303,7 +316,7 @@ namespace SourceGen.WpfGui { private void OkButton_Click(object sender, RoutedEventArgs e) { VisualizationItem item = (VisualizationItem)visComboBox.SelectedItem; Debug.Assert(item != null); - ReadOnlyDictionary valueDict = CreateVisGenParams(); + ReadOnlyDictionary valueDict = sLastParams = CreateVisGenParams(); string trimTag = Visualization.TrimAndValidateTag(TagString, out bool isTagValid); Debug.Assert(isTagValid); NewVis = new Visualization(trimTag, item.VisDescriptor.Ident, valueDict, mOrigVis); diff --git a/SourceGen/WpfGui/EditVisualizationSet.xaml.cs b/SourceGen/WpfGui/EditVisualizationSet.xaml.cs index 841cb26..3aaa987 100644 --- a/SourceGen/WpfGui/EditVisualizationSet.xaml.cs +++ b/SourceGen/WpfGui/EditVisualizationSet.xaml.cs @@ -150,7 +150,12 @@ namespace SourceGen.WpfGui { } // Check to see if changes have been made. - VisualizationSet newSet = MakeVisSet(); + VisualizationSet newSet; + if (VisualizationList.Count == 0) { + newSet = null; + } else { + newSet = MakeVisSet(); + } if (newSet != mOrigSet) { string msg = (string)FindResource("str_ConfirmDiscardChanges"); string caption = (string)FindResource("str_ConfirmDiscardChangesCaption"); @@ -184,6 +189,8 @@ namespace SourceGen.WpfGui { } VisualizationList.Add(dlg.NewVis); visualizationGrid.SelectedIndex = VisualizationList.Count - 1; + + okButton.Focus(); } private void NewBitmapAnimationButton_Click(object sender, RoutedEventArgs e) { @@ -194,6 +201,8 @@ namespace SourceGen.WpfGui { } VisualizationList.Add(dlg.NewAnim); visualizationGrid.SelectedIndex = VisualizationList.Count - 1; + + okButton.Focus(); } private void EditButton_Click(object sender, RoutedEventArgs e) {