From bfd4d547820554f4e73c40b3b55872e789ab29d9 Mon Sep 17 00:00:00 2001 From: Christian Rondeau Date: Sun, 27 Jul 2014 15:29:49 -0400 Subject: [PATCH] Refactoring: Move controls and resources in their own namespaces --- GoToWindow.Api/GoToWindow.Api.csproj | 1 + .../InterceptAltTab.cs | 2 +- GoToWindow/App.xaml.cs | 3 ++- GoToWindow/{ => Commands}/ExitCommand.cs | 0 .../{ => Commands}/OpenMainWindowCommand.cs | 0 GoToWindow/{ => Controls}/WindowListEntry.xaml | 6 +++--- .../{ => Controls}/WindowListEntry.xaml.cs | 2 +- .../ExecutableToIconValueConverter.cs | 5 ++++- GoToWindow/GoToWindow.csproj | 17 ++++++++--------- GoToWindow/Properties/Resources.resx | 2 +- GoToWindow/{ => Resources}/AppIcon.ico | Bin GoToWindow/{ => Windows}/MainWindow.xaml | 6 +++--- GoToWindow/{ => Windows}/MainWindow.xaml.cs | 1 - 13 files changed, 24 insertions(+), 21 deletions(-) rename {GoToWindow => GoToWindow.Api}/InterceptAltTab.cs (99%) rename GoToWindow/{ => Commands}/ExitCommand.cs (100%) rename GoToWindow/{ => Commands}/OpenMainWindowCommand.cs (100%) rename GoToWindow/{ => Controls}/WindowListEntry.xaml (84%) rename GoToWindow/{ => Controls}/WindowListEntry.xaml.cs (95%) rename GoToWindow/{ => Converters}/ExecutableToIconValueConverter.cs (92%) rename GoToWindow/{ => Resources}/AppIcon.ico (100%) rename GoToWindow/{ => Windows}/MainWindow.xaml (96%) rename GoToWindow/{ => Windows}/MainWindow.xaml.cs (99%) diff --git a/GoToWindow.Api/GoToWindow.Api.csproj b/GoToWindow.Api/GoToWindow.Api.csproj index 748200b..97168c8 100644 --- a/GoToWindow.Api/GoToWindow.Api.csproj +++ b/GoToWindow.Api/GoToWindow.Api.csproj @@ -39,6 +39,7 @@ + diff --git a/GoToWindow/InterceptAltTab.cs b/GoToWindow.Api/InterceptAltTab.cs similarity index 99% rename from GoToWindow/InterceptAltTab.cs rename to GoToWindow.Api/InterceptAltTab.cs index 35abd9c..6ebf9ab 100644 --- a/GoToWindow/InterceptAltTab.cs +++ b/GoToWindow.Api/InterceptAltTab.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; using System.Windows.Input; -namespace GoToWindow +namespace GoToWindow.Api { public class InterceptAltTab : IDisposable { diff --git a/GoToWindow/App.xaml.cs b/GoToWindow/App.xaml.cs index bf66268..98d8b2c 100644 --- a/GoToWindow/App.xaml.cs +++ b/GoToWindow/App.xaml.cs @@ -1,4 +1,5 @@ -using Hardcodet.Wpf.TaskbarNotification; +using GoToWindow.Api; +using Hardcodet.Wpf.TaskbarNotification; using System; using System.Collections.Generic; using System.Configuration; diff --git a/GoToWindow/ExitCommand.cs b/GoToWindow/Commands/ExitCommand.cs similarity index 100% rename from GoToWindow/ExitCommand.cs rename to GoToWindow/Commands/ExitCommand.cs diff --git a/GoToWindow/OpenMainWindowCommand.cs b/GoToWindow/Commands/OpenMainWindowCommand.cs similarity index 100% rename from GoToWindow/OpenMainWindowCommand.cs rename to GoToWindow/Commands/OpenMainWindowCommand.cs diff --git a/GoToWindow/WindowListEntry.xaml b/GoToWindow/Controls/WindowListEntry.xaml similarity index 84% rename from GoToWindow/WindowListEntry.xaml rename to GoToWindow/Controls/WindowListEntry.xaml index 8f423dc..5b63d53 100644 --- a/GoToWindow/WindowListEntry.xaml +++ b/GoToWindow/Controls/WindowListEntry.xaml @@ -1,13 +1,13 @@ - - + diff --git a/GoToWindow/WindowListEntry.xaml.cs b/GoToWindow/Controls/WindowListEntry.xaml.cs similarity index 95% rename from GoToWindow/WindowListEntry.xaml.cs rename to GoToWindow/Controls/WindowListEntry.xaml.cs index 761d1e5..5b46e18 100644 --- a/GoToWindow/WindowListEntry.xaml.cs +++ b/GoToWindow/Controls/WindowListEntry.xaml.cs @@ -14,7 +14,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; -namespace GoToWindow +namespace GoToWindow.Controls { /// /// Interaction logic for WindowListEntry.xaml diff --git a/GoToWindow/ExecutableToIconValueConverter.cs b/GoToWindow/Converters/ExecutableToIconValueConverter.cs similarity index 92% rename from GoToWindow/ExecutableToIconValueConverter.cs rename to GoToWindow/Converters/ExecutableToIconValueConverter.cs index 89d3af4..af6867b 100644 --- a/GoToWindow/ExecutableToIconValueConverter.cs +++ b/GoToWindow/Converters/ExecutableToIconValueConverter.cs @@ -9,13 +9,16 @@ using System.Windows.Data; using System.Windows.Media.Imaging; -namespace GoToWindow +namespace GoToWindow.Converters { [ValueConversion(typeof(string), typeof(BitmapFrame))] public class ExecutableToIconValueConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { + if (value == null) + return null; + var iconStream = new MemoryStream(); using(var icon = Icon.ExtractAssociatedIcon((string)value)) diff --git a/GoToWindow/GoToWindow.csproj b/GoToWindow/GoToWindow.csproj index 8de3369..40a5ba7 100644 --- a/GoToWindow/GoToWindow.csproj +++ b/GoToWindow/GoToWindow.csproj @@ -62,15 +62,14 @@ MSBuild:Compile Designer - - + + - - - + + WindowListEntry.xaml - + MSBuild:Compile Designer @@ -78,11 +77,11 @@ App.xaml Code - + MainWindow.xaml Code - + Designer MSBuild:Compile @@ -116,7 +115,7 @@ - + diff --git a/GoToWindow/Properties/Resources.resx b/GoToWindow/Properties/Resources.resx index 212f24c..a07f796 100644 --- a/GoToWindow/Properties/Resources.resx +++ b/GoToWindow/Properties/Resources.resx @@ -119,6 +119,6 @@ - ..\AppIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\AppIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/GoToWindow/AppIcon.ico b/GoToWindow/Resources/AppIcon.ico similarity index 100% rename from GoToWindow/AppIcon.ico rename to GoToWindow/Resources/AppIcon.ico diff --git a/GoToWindow/MainWindow.xaml b/GoToWindow/Windows/MainWindow.xaml similarity index 96% rename from GoToWindow/MainWindow.xaml rename to GoToWindow/Windows/MainWindow.xaml index 080bd07..7aed45b 100644 --- a/GoToWindow/MainWindow.xaml +++ b/GoToWindow/Windows/MainWindow.xaml @@ -1,13 +1,13 @@  - + diff --git a/GoToWindow/MainWindow.xaml.cs b/GoToWindow/Windows/MainWindow.xaml.cs similarity index 99% rename from GoToWindow/MainWindow.xaml.cs rename to GoToWindow/Windows/MainWindow.xaml.cs index a8f6a4c..aaec6d3 100644 --- a/GoToWindow/MainWindow.xaml.cs +++ b/GoToWindow/Windows/MainWindow.xaml.cs @@ -23,7 +23,6 @@ public partial class MainWindow : Window { public MainWindow() { - InitializeComponent(); }