diff --git a/MainWindow.xaml b/MainWindow.xaml index d7a2ff4..74fa1bb 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -3,6 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="d3gamepad" Height="720" Width="1280" Topmost="True" AllowsTransparency="True" WindowStyle="None" Background="{x:Null}" Left="0" Top="0"> - + \ No newline at end of file diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 788508e..4c5ba98 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -18,6 +18,8 @@ using System.Text; using System.Windows.Input; using System.Drawing; +using System.Windows.Media.Imaging; +using System.Windows.Interop; namespace d3gamepad { @@ -36,6 +38,10 @@ public partial class MainWindow : Window [DllImport("user32.dll")] static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); + [DllImport("gdi32.dll", EntryPoint = "DeleteObject")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DeleteObject([In] IntPtr hObject); + public static Bitmap CaptureFromScreen(System.Drawing.Point location, int width, int height) { Bitmap bmpScreenCapture = new Bitmap(width, height); @@ -293,6 +299,24 @@ public static void ThreadUI() } } + public static Bitmap GetImageByName(string imageName) + { + System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); + string resourceName = asm.GetName().Name + ".Properties.Resources"; + var rm = new System.Resources.ResourceManager(resourceName, asm); + return (Bitmap)rm.GetObject(imageName); + } + + public ImageSource ImageSourceFromBitmap(Bitmap bmp) + { + var handle = bmp.GetHbitmap(); + try + { + return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); + } + finally { DeleteObject(handle); } + } + static d3gamepad.MainWindow myForm; static Canvas myCanvas; static System.Windows.Controls.Image myGamepad; @@ -331,7 +355,7 @@ public MainWindow() { Fill = new ImageBrush { - ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(".\\Ressources\\XBOne_" + ico + ".png", UriKind.Relative)) + ImageSource = ImageSourceFromBitmap(GetImageByName("XBOne_" + ico)) }, Stretch = Stretch.Uniform, }; diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 13d3c20..530f090 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -1,71 +1,253 @@ //------------------------------------------------------------------------------ // -// Ce code a été généré par un outil. -// Version du runtime :4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si -// le code est régénéré. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ -namespace d3gamepad.Properties -{ - - +namespace d3gamepad.Properties { + using System; + + /// - /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder - // à l'aide d'un outil, tel que ResGen ou Visual Studio. - // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen - // avec l'option /str ou régénérez votre projet VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("d3gamepad.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// - /// Remplace la propriété CurrentUICulture du thread actuel pour toutes - /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_A { + get { + object obj = ResourceManager.GetObject("XBOne_A", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_B { + get { + object obj = ResourceManager.GetObject("XBOne_B", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad { + get { + object obj = ResourceManager.GetObject("XBOne_DPad", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad_All { + get { + object obj = ResourceManager.GetObject("XBOne_DPad_All", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad_Down { + get { + object obj = ResourceManager.GetObject("XBOne_DPad_Down", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad_Left { + get { + object obj = ResourceManager.GetObject("XBOne_DPad_Left", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad_Right { + get { + object obj = ResourceManager.GetObject("XBOne_DPad_Right", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad_Up { + get { + object obj = ResourceManager.GetObject("XBOne_DPad_Up", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad_XAxis { + get { + object obj = ResourceManager.GetObject("XBOne_DPad_XAxis", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_DPad_YAxis { + get { + object obj = ResourceManager.GetObject("XBOne_DPad_YAxis", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_Gamepad { + get { + object obj = ResourceManager.GetObject("XBOne_Gamepad", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_LB { + get { + object obj = ResourceManager.GetObject("XBOne_LB", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_LT { + get { + object obj = ResourceManager.GetObject("XBOne_LT", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_Menu { + get { + object obj = ResourceManager.GetObject("XBOne_Menu", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_RB { + get { + object obj = ResourceManager.GetObject("XBOne_RB", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_RT { + get { + object obj = ResourceManager.GetObject("XBOne_RT", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_View { + get { + object obj = ResourceManager.GetObject("XBOne_View", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_X { + get { + object obj = ResourceManager.GetObject("XBOne_X", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap XBOne_Y { + get { + object obj = ResourceManager.GetObject("XBOne_Y", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Properties/Resources.resx b/Properties/Resources.resx index ffecec8..23fc1ff 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,67 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\img\XBOne_A.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_B.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad_All.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad_Down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad_Left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad_Right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad_Up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad_XAxis.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_DPad_YAxis.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_Gamepad.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_LB.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_LT.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_Menu.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_RB.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_RT.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_View.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_X.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\img\XBOne_Y.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Ressources/ImageSearchDLL.dll b/Ressources/ImageSearchDLL.dll deleted file mode 100644 index 8f6f27e..0000000 Binary files a/Ressources/ImageSearchDLL.dll and /dev/null differ diff --git a/Ressources/XBOne_A.png b/Ressources/XBOne_A.png deleted file mode 100644 index 6d9ff3c..0000000 Binary files a/Ressources/XBOne_A.png and /dev/null differ diff --git a/Ressources/XBOne_B.png b/Ressources/XBOne_B.png deleted file mode 100644 index 622cd59..0000000 Binary files a/Ressources/XBOne_B.png and /dev/null differ diff --git a/Ressources/XBOne_DPad.png b/Ressources/XBOne_DPad.png deleted file mode 100644 index 97a3310..0000000 Binary files a/Ressources/XBOne_DPad.png and /dev/null differ diff --git a/Ressources/XBOne_DPad_All.png b/Ressources/XBOne_DPad_All.png deleted file mode 100644 index 885cd8f..0000000 Binary files a/Ressources/XBOne_DPad_All.png and /dev/null differ diff --git a/Ressources/XBOne_DPad_Down.png b/Ressources/XBOne_DPad_Down.png deleted file mode 100644 index d504160..0000000 Binary files a/Ressources/XBOne_DPad_Down.png and /dev/null differ diff --git a/Ressources/XBOne_DPad_Left.png b/Ressources/XBOne_DPad_Left.png deleted file mode 100644 index 93df4c4..0000000 Binary files a/Ressources/XBOne_DPad_Left.png and /dev/null differ diff --git a/Ressources/XBOne_DPad_Right.png b/Ressources/XBOne_DPad_Right.png deleted file mode 100644 index 80b213f..0000000 Binary files a/Ressources/XBOne_DPad_Right.png and /dev/null differ diff --git a/Ressources/XBOne_DPad_Up.png b/Ressources/XBOne_DPad_Up.png deleted file mode 100644 index 42b288a..0000000 Binary files a/Ressources/XBOne_DPad_Up.png and /dev/null differ diff --git a/Ressources/XBOne_DPad_XAxis.png b/Ressources/XBOne_DPad_XAxis.png deleted file mode 100644 index 497ab78..0000000 Binary files a/Ressources/XBOne_DPad_XAxis.png and /dev/null differ diff --git a/Ressources/XBOne_DPad_YAxis.png b/Ressources/XBOne_DPad_YAxis.png deleted file mode 100644 index bd1d746..0000000 Binary files a/Ressources/XBOne_DPad_YAxis.png and /dev/null differ diff --git a/Ressources/XBOne_LB.png b/Ressources/XBOne_LB.png deleted file mode 100644 index d7ac370..0000000 Binary files a/Ressources/XBOne_LB.png and /dev/null differ diff --git a/Ressources/XBOne_LT.png b/Ressources/XBOne_LT.png deleted file mode 100644 index c4efce9..0000000 Binary files a/Ressources/XBOne_LT.png and /dev/null differ diff --git a/Ressources/XBOne_Menu.png b/Ressources/XBOne_Menu.png deleted file mode 100644 index 152bdfe..0000000 Binary files a/Ressources/XBOne_Menu.png and /dev/null differ diff --git a/Ressources/XBOne_RB.png b/Ressources/XBOne_RB.png deleted file mode 100644 index a6edf0a..0000000 Binary files a/Ressources/XBOne_RB.png and /dev/null differ diff --git a/Ressources/XBOne_RT.png b/Ressources/XBOne_RT.png deleted file mode 100644 index ed253fe..0000000 Binary files a/Ressources/XBOne_RT.png and /dev/null differ diff --git a/Ressources/XBOne_View.png b/Ressources/XBOne_View.png deleted file mode 100644 index ad9b661..0000000 Binary files a/Ressources/XBOne_View.png and /dev/null differ diff --git a/Ressources/XBOne_X.png b/Ressources/XBOne_X.png deleted file mode 100644 index 6e9a061..0000000 Binary files a/Ressources/XBOne_X.png and /dev/null differ diff --git a/Ressources/XBOne_Y.png b/Ressources/XBOne_Y.png deleted file mode 100644 index fc8f1fc..0000000 Binary files a/Ressources/XBOne_Y.png and /dev/null differ diff --git a/d3gamepad.csproj b/d3gamepad.csproj index f671e86..0f5a7e8 100644 --- a/d3gamepad.csproj +++ b/d3gamepad.csproj @@ -167,70 +167,6 @@ - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - - Always - - - Always - - False @@ -238,6 +174,63 @@ false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +