/nuget.packages/WPFExtensions.cs
C# | 34 lines | 31 code | 3 blank | 0 comment | 0 complexity | 8065d756f3912531fb26d08145b87e48 MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace nuget.packages
- {
- public static class WpfExtensions
- {
- public static System.Windows.Forms.IWin32Window GetIWin32Window(this System.Windows.Media.Visual visual)
- {
- var source = System.Windows.PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;
- System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
- return win;
- }
-
- private class OldWindow : System.Windows.Forms.IWin32Window
- {
- private readonly System.IntPtr _handle;
- public OldWindow(System.IntPtr handle)
- {
- _handle = handle;
- }
-
- #region IWin32Window Members
- System.IntPtr System.Windows.Forms.IWin32Window.Handle
- {
- get { return _handle; }
- }
- #endregion
- }
- }
- }