From 0ffd5c401b4a45d67142a45beda22a336a33a19a Mon Sep 17 00:00:00 2001 From: Jordan Wages Date: Wed, 4 Jul 2018 19:46:33 -0500 Subject: [PATCH] Menu progress --- butterflow-ui/ButterflowSubregion.cs | 12 ++++ butterflow-ui/Icons.xaml | 4 +- .../Localization/Localization.Designer.cs | 27 +++++++ butterflow-ui/Localization/Localization.resx | 9 +++ butterflow-ui/MainWindow.xaml | 35 ++++----- butterflow-ui/MainWindow.xaml.cs | 71 +++++++++++++++++++ butterflow-ui/OptionsConfiguration.cs | 4 +- 7 files changed, 142 insertions(+), 20 deletions(-) diff --git a/butterflow-ui/ButterflowSubregion.cs b/butterflow-ui/ButterflowSubregion.cs index 1f7c20a..c40926c 100644 --- a/butterflow-ui/ButterflowSubregion.cs +++ b/butterflow-ui/ButterflowSubregion.cs @@ -21,6 +21,8 @@ namespace butterflow_ui private decimal value; /// True if the subregion runs to the end, false if not. private bool toEnd; + /// A unique identifier used to locate this subregion withing a subregion collection. + private Guid identifier = new Guid(); #endregion @@ -100,6 +102,16 @@ namespace butterflow_ui OnPropertyChanged(); } } + + /// Gets a unique identifier used to locate this subregion withing a subregion collection. + /// The unique identifier. + public Guid Identifier + { + get + { + return this.identifier; + } + } #endregion } diff --git a/butterflow-ui/Icons.xaml b/butterflow-ui/Icons.xaml index 8e389fe..6ca2dbc 100644 --- a/butterflow-ui/Icons.xaml +++ b/butterflow-ui/Icons.xaml @@ -150,7 +150,7 @@ - + @@ -159,7 +159,7 @@ - + diff --git a/butterflow-ui/Localization/Localization.Designer.cs b/butterflow-ui/Localization/Localization.Designer.cs index 684a790..26c8463 100644 --- a/butterflow-ui/Localization/Localization.Designer.cs +++ b/butterflow-ui/Localization/Localization.Designer.cs @@ -402,6 +402,15 @@ namespace butterflow_ui.Localization { } } + /// + /// Looks up a localized string similar to _Open.... + /// + public static string OpenMenuItem { + get { + return ResourceManager.GetString("OpenMenuItem", resourceCulture); + } + } + /// /// Looks up a localized string similar to Pixel Neighborhood. /// @@ -501,6 +510,24 @@ namespace butterflow_ui.Localization { } } + /// + /// Looks up a localized string similar to Save Configuration _As.... + /// + public static string SaveAsMenuItem { + get { + return ResourceManager.GetString("SaveAsMenuItem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Save Configuration.... + /// + public static string SaveMenuItem { + get { + return ResourceManager.GetString("SaveMenuItem", resourceCulture); + } + } + /// /// Looks up a localized string similar to Skip backward in the video.. /// diff --git a/butterflow-ui/Localization/Localization.resx b/butterflow-ui/Localization/Localization.resx index 02f2572..009ebf0 100644 --- a/butterflow-ui/Localization/Localization.resx +++ b/butterflow-ui/Localization/Localization.resx @@ -273,6 +273,9 @@ The number of pyramid layers. + + _Open... + Pixel Neighborhood @@ -291,6 +294,12 @@ + + Save Configuration _As... + + + _Save Configuration... + Smooth Derivative diff --git a/butterflow-ui/MainWindow.xaml b/butterflow-ui/MainWindow.xaml index ae674e6..ed05cf9 100644 --- a/butterflow-ui/MainWindow.xaml +++ b/butterflow-ui/MainWindow.xaml @@ -29,17 +29,17 @@ - + - + - + @@ -47,18 +47,18 @@ - + - + - + @@ -222,16 +222,19 @@ - - - - - - - - - - + + + + + + + + + + + diff --git a/butterflow-ui/MainWindow.xaml.cs b/butterflow-ui/MainWindow.xaml.cs index ea0a78d..c53ec25 100644 --- a/butterflow-ui/MainWindow.xaml.cs +++ b/butterflow-ui/MainWindow.xaml.cs @@ -1,6 +1,7 @@ using Microsoft.Win32; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -312,6 +313,76 @@ namespace butterflow_ui this.ButterflowWrapper.Run(this.OptionsConfiguration); } + /// Event handler. Called by btnRemoveSubregion for click events. + /// Source of the event. + /// Routed event information. + private void btnRemoveSubregion_Click(object sender, RoutedEventArgs e) + { + var button = sender as Button; + + if(button != null) + { + if (button.Tag.GetType() == typeof(Guid)) + { + var identifier = (Guid)button.Tag; + + if (this.OptionsConfiguration.Subregions.Any(sr => sr.Identifier == identifier)) + { + var item = this.OptionsConfiguration.Subregions.Where(sr => sr.Identifier == identifier).First(); + this.OptionsConfiguration.Subregions.Remove(item); + } + } + } + } + + /// Event handler. Called by menuOpen for click events. + /// Source of the event. + /// Routed event information. + private void menuOpen_Click(object sender, RoutedEventArgs e) + { + + } + + /// Event handler. Called by menuSaveConfiguration for click events. + /// Source of the event. + /// Routed event information. + private void menuSaveConfiguration_Click(object sender, RoutedEventArgs e) + { + + } + + /// Event handler. Called by menuSaveConfigurationAs for click events. + /// Source of the event. + /// Routed event information. + private void menuSaveConfigurationAs_Click(object sender, RoutedEventArgs e) + { + + } + + /// Event handler. Called by menuButterflowGithub for click events. + /// Source of the event. + /// Routed event information. + private void menuButterflowGithub_Click(object sender, RoutedEventArgs e) + { + Process.Start("https://github.com/dthpham/butterflow"); + } + + /// Event handler. Called by menuButterflowUIGithub for click events. + /// Source of the event. + /// Routed event information. + private void menuButterflowUIGithub_Click(object sender, RoutedEventArgs e) + { + Process.Start("https://github.com/wagesj45/butterflow-ui"); + } + + /// Event handler. Called by menuAboutButterflowUI for click events. + /// Source of the event. + /// Routed event information. + private void menuAboutButterflowUI_Click(object sender, RoutedEventArgs e) + { + + } + #endregion } } diff --git a/butterflow-ui/OptionsConfiguration.cs b/butterflow-ui/OptionsConfiguration.cs index 0ba4d02..c6ca0fb 100644 --- a/butterflow-ui/OptionsConfiguration.cs +++ b/butterflow-ui/OptionsConfiguration.cs @@ -312,6 +312,7 @@ namespace butterflow_ui /// Gets or sets the size of the pixel neighborhood. /// The size of the pixel neighborhood. + /// Per butterflow's documentation, the valid range for --poly-n is {5,7}. public string PixelNeighborhood { get @@ -322,8 +323,7 @@ namespace butterflow_ui { interpreter.Interpret(value); - // Per butterflow's documentation, the valid range for --poly-n is {5,7} - if (interpreter.Int >= 5 || interpreter.Int <= 7) + if (interpreter.Int >= 5 && interpreter.Int <= 7) { this.pixelNeighborhood = interpreter.Int; }