WindowWrapper.Desktop.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using System.Windows;
  19. namespace Infrastructure
  20. {
  21. /// <summary>
  22. /// Defines a wrapper for the <see cref="Window"/> class that implements the <see cref="IWindow"/> interface.
  23. /// </summary>
  24. public class WindowWrapper : IWindow
  25. {
  26. private readonly Window window;
  27. /// <summary>
  28. /// Initializes a new instance of <see cref="WindowWrapper"/>.
  29. /// </summary>
  30. public WindowWrapper()
  31. {
  32. this.window = new Window();
  33. }
  34. /// <summary>
  35. /// Ocurrs when the <see cref="Window"/> is closed.
  36. /// </summary>
  37. public event EventHandler Closed
  38. {
  39. add { this.window.Closed += value; }
  40. remove { this.window.Closed -= value; }
  41. }
  42. /// <summary>
  43. /// Gets or Sets the content for the <see cref="Window"/>.
  44. /// </summary>
  45. public object Content
  46. {
  47. get { return this.window.Content; }
  48. set { this.window.Content = value; }
  49. }
  50. /// <summary>
  51. /// Gets or Sets the <see cref="Window.Owner"/> control of the <see cref="Window"/>.
  52. /// </summary>
  53. public object Owner
  54. {
  55. get { return this.window.Owner; }
  56. set { this.window.Owner = value as Window; }
  57. }
  58. /// <summary>
  59. /// Gets or Sets the <see cref="FrameworkElement.Style"/> to apply to the <see cref="Window"/>.
  60. /// </summary>
  61. public Style Style
  62. {
  63. get { return this.window.Style; }
  64. set { this.window.Style = value; }
  65. }
  66. /// <summary>
  67. /// Opens the <see cref="Window"/>.
  68. /// </summary>
  69. public void Show()
  70. {
  71. this.window.Show();
  72. }
  73. /// <summary>
  74. /// Closes the <see cref="Window"/>.
  75. /// </summary>
  76. public void Close()
  77. {
  78. this.window.Close();
  79. }
  80. }
  81. }