PageRenderTime 54ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/nuget.packages/WPFExtensions.cs

https://bitbucket.org/nisbus/nuget_package_config_manager
C# | 34 lines | 31 code | 3 blank | 0 comment | 0 complexity | 8065d756f3912531fb26d08145b87e48 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace nuget.packages
  7. {
  8. public static class WpfExtensions
  9. {
  10. public static System.Windows.Forms.IWin32Window GetIWin32Window(this System.Windows.Media.Visual visual)
  11. {
  12. var source = System.Windows.PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;
  13. System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
  14. return win;
  15. }
  16. private class OldWindow : System.Windows.Forms.IWin32Window
  17. {
  18. private readonly System.IntPtr _handle;
  19. public OldWindow(System.IntPtr handle)
  20. {
  21. _handle = handle;
  22. }
  23. #region IWin32Window Members
  24. System.IntPtr System.Windows.Forms.IWin32Window.Handle
  25. {
  26. get { return _handle; }
  27. }
  28. #endregion
  29. }
  30. }
  31. }