annotate SilverlightGlimpse/FloatableWindow/FloatableWindow.cs @ 63:536498832a79

Latest version before changing bindings to Listbox
author Steven Hollidge <stevenhollidge@hotmail.com>
date Sun, 22 Apr 2012 13:33:42 +0100
parents 810116cd6b8e
children a0bcd783e612
rev   line source
62
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1 // This source is subject to the Microsoft Public License (Ms-PL).
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
2 // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
3 // All other rights reserved.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
4
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
5 using System.Collections;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
6 using System.ComponentModel;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
7 using System.Diagnostics;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
8 using System.Windows.Automation;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
9 using System.Windows.Automation.Peers;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
10 using System.Windows.Controls.Primitives;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
11 using System.Windows.Input;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
12 using System.Windows.Media;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
13 using System.Windows.Media.Animation;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
14
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
15 namespace System.Windows.Controls
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
16 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
17 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
18 /// Provides a window that can be displayed over a parent window and blocks
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
19 /// interaction with the parent window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
20 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
21 /// <QualityBand>Preview</QualityBand>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
22 [TemplatePart(Name = PART_Chrome, Type = typeof(FrameworkElement))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
23 [TemplatePart(Name = PART_CloseButton, Type = typeof(ButtonBase))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
24 [TemplatePart(Name = PART_ContentPresenter, Type = typeof(FrameworkElement))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
25 [TemplatePart(Name = PART_ContentRoot, Type = typeof(FrameworkElement))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
26 [TemplatePart(Name = PART_Overlay, Type = typeof(Panel))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
27 [TemplatePart(Name = PART_Root, Type = typeof(FrameworkElement))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
28 [TemplatePart(Name = PART_Resizer, Type = typeof(FrameworkElement))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
29 [TemplateVisualState(Name = VSMSTATE_StateClosed, GroupName = VSMGROUP_Window)]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
30 [TemplateVisualState(Name = VSMSTATE_StateOpen, GroupName = VSMGROUP_Window)]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
31 public class FloatableWindow : ContentControl
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
32 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
33 #region Static Fields and Constants
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
34
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
35 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
36 /// The name of the Chrome template part.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
37 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
38 private const string PART_Chrome = "Chrome";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
39
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
40 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
41 /// The name of the Resizer template part.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
42 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
43 private const string PART_Resizer = "Resizer";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
44
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
45 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
46 /// The name of the CloseButton template part.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
47 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
48 private const string PART_CloseButton = "CloseButton";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
49
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
50 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
51 /// The name of the ContentPresenter template part.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
52 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
53 private const string PART_ContentPresenter = "ContentPresenter";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
54
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
55 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
56 /// The name of the ContentRoot template part.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
57 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
58 private const string PART_ContentRoot = "ContentRoot";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
59
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
60 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
61 /// The name of the Overlay template part.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
62 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
63 private const string PART_Overlay = "Overlay";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
64
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
65 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
66 /// The name of the Root template part.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
67 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
68 private const string PART_Root = "Root";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
69
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
70 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
71 /// The name of the WindowStates VSM group.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
72 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
73 private const string VSMGROUP_Window = "WindowStates";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
74
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
75 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
76 /// The name of the Closing VSM state.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
77 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
78 private const string VSMSTATE_StateClosed = "Closed";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
79
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
80 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
81 /// The name of the Opening VSM state.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
82 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
83 private const string VSMSTATE_StateOpen = "Open";
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
84
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
85 #region public bool HasCloseButton
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
86
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
87 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
88 /// Gets or sets a value indicating whether the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
89 /// <see cref="T:System.Windows.Controls.FloatableWindow" /> has a close
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
90 /// button.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
91 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
92 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
93 /// True if the child window has a close button; otherwise, false. The
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
94 /// default is true.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
95 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
96 public bool HasCloseButton
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
97 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
98 get { return (bool)GetValue(HasCloseButtonProperty); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
99 set { SetValue(HasCloseButtonProperty, value); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
100 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
101
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
102 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
103 /// Identifies the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
104 /// <see cref="P:System.Windows.Controls.FloatableWindow.HasCloseButton" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
105 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
106 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
107 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
108 /// The identifier for the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
109 /// <see cref="P:System.Windows.Controls.FloatableWindow.HasCloseButton" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
110 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
111 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
112 public static readonly DependencyProperty HasCloseButtonProperty =
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
113 DependencyProperty.Register(
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
114 "HasCloseButton",
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
115 typeof(bool),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
116 typeof(FloatableWindow),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
117 new PropertyMetadata(true, OnHasCloseButtonPropertyChanged));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
118
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
119 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
120 /// HasCloseButtonProperty PropertyChangedCallback call back static function.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
121 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
122 /// <param name="d">FloatableWindow object whose HasCloseButton property is changed.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
123 /// <param name="e">DependencyPropertyChangedEventArgs which contains the old and new values.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
124 private static void OnHasCloseButtonPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
125 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
126 FloatableWindow cw = (FloatableWindow)d;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
127
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
128 if (cw.CloseButton != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
129 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
130 if ((bool)e.NewValue)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
131 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
132 cw.CloseButton.Visibility = Visibility.Visible;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
133 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
134 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
135 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
136 cw.CloseButton.Visibility = Visibility.Collapsed;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
137 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
138 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
139 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
140
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
141 #endregion public bool HasCloseButton
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
142
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
143 #region public Brush OverlayBrush
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
144
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
145 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
146 /// Gets or sets the visual brush that is used to cover the parent
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
147 /// window when the child window is open.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
148 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
149 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
150 /// The visual brush that is used to cover the parent window when the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
151 /// <see cref="T:System.Windows.Controls.FloatableWindow" /> is open. The
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
152 /// default is null.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
153 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
154 public Brush OverlayBrush
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
155 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
156 get { return (Brush)GetValue(OverlayBrushProperty); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
157 set { SetValue(OverlayBrushProperty, value); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
158 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
159
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
160 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
161 /// Identifies the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
162 /// <see cref="P:System.Windows.Controls.FloatableWindow.OverlayBrush" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
163 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
164 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
165 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
166 /// The identifier for the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
167 /// <see cref="P:System.Windows.Controls.FloatableWindow.OverlayBrush" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
168 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
169 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
170 public static readonly DependencyProperty OverlayBrushProperty =
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
171 DependencyProperty.Register(
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
172 "OverlayBrush",
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
173 typeof(Brush),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
174 typeof(FloatableWindow),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
175 new PropertyMetadata(OnOverlayBrushPropertyChanged));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
176
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
177 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
178 /// OverlayBrushProperty PropertyChangedCallback call back static function.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
179 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
180 /// <param name="d">FloatableWindow object whose OverlayBrush property is changed.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
181 /// <param name="e">DependencyPropertyChangedEventArgs which contains the old and new values.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
182 private static void OnOverlayBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
183 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
184 FloatableWindow cw = (FloatableWindow)d;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
185
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
186 if (cw.Overlay != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
187 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
188 cw.Overlay.Background = (Brush)e.NewValue;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
189 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
190 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
191
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
192 #endregion public Brush OverlayBrush
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
193
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
194 #region public double OverlayOpacity
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
195
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
196 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
197 /// Gets or sets the opacity of the overlay brush that is used to cover
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
198 /// the parent window when the child window is open.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
199 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
200 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
201 /// The opacity of the overlay brush that is used to cover the parent
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
202 /// window when the <see cref="T:System.Windows.Controls.FloatableWindow" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
203 /// is open. The default is 1.0.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
204 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
205 public double OverlayOpacity
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
206 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
207 get { return (double)GetValue(OverlayOpacityProperty); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
208 set { SetValue(OverlayOpacityProperty, value); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
209 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
210
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
211 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
212 /// Identifies the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
213 /// <see cref="P:System.Windows.Controls.FloatableWindow.OverlayOpacity" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
214 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
215 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
216 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
217 /// The identifier for the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
218 /// <see cref="P:System.Windows.Controls.FloatableWindow.OverlayOpacity" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
219 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
220 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
221 public static readonly DependencyProperty OverlayOpacityProperty =
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
222 DependencyProperty.Register(
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
223 "OverlayOpacity",
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
224 typeof(double),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
225 typeof(FloatableWindow),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
226 new PropertyMetadata(OnOverlayOpacityPropertyChanged));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
227
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
228 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
229 /// OverlayOpacityProperty PropertyChangedCallback call back static function.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
230 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
231 /// <param name="d">FloatableWindow object whose OverlayOpacity property is changed.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
232 /// <param name="e">DependencyPropertyChangedEventArgs which contains the old and new values.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
233 private static void OnOverlayOpacityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
234 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
235 FloatableWindow cw = (FloatableWindow)d;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
236
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
237 if (cw.Overlay != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
238 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
239 cw.Overlay.Opacity = (double)e.NewValue;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
240 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
241 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
242
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
243 #endregion public double OverlayOpacity
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
244
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
245 #region private static Control RootVisual
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
246
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
247 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
248 /// Gets the root visual element.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
249 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
250 private static Control RootVisual
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
251 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
252 get
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
253 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
254 return Application.Current == null ? null : (Application.Current.RootVisual as Control);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
255 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
256 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
257
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
258 #endregion private static Control RootVisual
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
259
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
260 #region public object Title
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
261
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
262 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
263 /// Gets or sets the title that is displayed in the frame of the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
264 /// <see cref="T:System.Windows.Controls.FloatableWindow" />.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
265 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
266 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
267 /// The title displayed at the top of the window. The default is null.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
268 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
269 public object Title
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
270 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
271 get { return GetValue(TitleProperty); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
272 set { SetValue(TitleProperty, value); }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
273 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
274
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
275 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
276 /// Identifies the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
277 /// <see cref="P:System.Windows.Controls.FloatableWindow.Title" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
278 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
279 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
280 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
281 /// The identifier for the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
282 /// <see cref="P:System.Windows.Controls.FloatableWindow.Title" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
283 /// dependency property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
284 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
285 public static readonly DependencyProperty TitleProperty =
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
286 DependencyProperty.Register(
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
287 "Title",
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
288 typeof(object),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
289 typeof(FloatableWindow),
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
290 null);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
291
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
292 #endregion public object Title
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
293
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
294 #endregion Static Fields and Constants
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
295
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
296 #region Member Fields
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
297 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
298 /// Set in the overloaded Show method. Offsets the Popup vertically from the top left corner of the browser window by this amount.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
299 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
300 private double _verticalOffset;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
301
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
302 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
303 /// Set in the overloaded Show method. Offsets the Popup horizontally from the top left corner of the browser window by this amount.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
304 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
305 private double _horizontalOffset;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
306
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
307 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
308 /// Private accessor for the Resizer.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
309 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
310 private FrameworkElement _resizer;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
311
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
312 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
313 /// Private accessor for the IsModal
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
314 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
315 [DefaultValue(false)]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
316 private bool _modal;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
317
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
318 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
319 /// Private accessor for the Chrome.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
320 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
321 private FrameworkElement _chrome;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
322
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
323 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
324 /// Private accessor for the click point on the chrome.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
325 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
326 private Point _clickPoint;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
327
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
328 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
329 /// Private accessor for the Closing storyboard.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
330 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
331 private Storyboard _closed;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
332
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
333 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
334 /// Private accessor for the ContentPresenter.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
335 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
336 private FrameworkElement _contentPresenter;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
337
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
338 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
339 /// Private accessor for the translate transform that needs to be applied on to the ContentRoot.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
340 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
341 private TranslateTransform _contentRootTransform;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
342
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
343 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
344 /// Content area desired width.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
345 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
346 private double _desiredContentWidth;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
347
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
348 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
349 /// Content area desired height.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
350 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
351 private double _desiredContentHeight;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
352
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
353 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
354 /// Desired margin for the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
355 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
356 private Thickness _desiredMargin;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
357
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
358 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
359 /// Private accessor for the Dialog Result property.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
360 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
361 private bool? _dialogresult;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
362
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
363 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
364 /// Private accessor for the FloatableWindow InteractionState.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
365 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
366 private WindowInteractionState _interactionState;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
367
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
368 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
369 /// Boolean value that specifies whether the application is exit or not.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
370 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
371 private bool _isAppExit;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
372
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
373 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
374 /// Boolean value that specifies whether the window is in closing state or not.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
375 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
376 private bool _isClosing;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
377
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
378 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
379 /// Boolean value that specifies whether the window is opened.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
380 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
381 private bool _isOpen;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
382
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
383 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
384 /// Private accessor for the Opening storyboard.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
385 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
386 private Storyboard _opened;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
387
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
388 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
389 /// Boolean value that specifies whether the mouse is captured or not.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
390 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
391 private bool _isMouseCaptured;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
392
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
393 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
394 /// Private accessor for the Root of the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
395 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
396 private FrameworkElement _root;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
397
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
398 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
399 /// Private accessor for the position of the window with respect to RootVisual.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
400 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
401 private Point _windowPosition;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
402
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
403 private static int z;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
404
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
405 #endregion Member Fields
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
406
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
407 #region Constructors
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
408
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
409 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
410 /// Initializes a new instance of the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
411 /// <see cref="T:System.Windows.Controls.FloatableWindow" /> class.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
412 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
413 public FloatableWindow()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
414 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
415 this.DefaultStyleKey = typeof(FloatableWindow);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
416 this.InteractionState = WindowInteractionState.NotResponding;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
417 this.ResizeMode = ResizeMode.CanResize;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
418 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
419
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
420 #endregion Constructors
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
421
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
422 #region Events
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
423
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
424 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
425 /// Occurs when the <see cref="T:System.Windows.Controls.FloatableWindow" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
426 /// is closed.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
427 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
428 public event EventHandler Closed;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
429
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
430 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
431 /// Occurs when the <see cref="T:System.Windows.Controls.FloatableWindow" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
432 /// is closing.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
433 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
434 public event EventHandler<CancelEventArgs> Closing;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
435
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
436 #endregion Events
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
437
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
438 #region Properties
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
439
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
440 public Panel ParentLayoutRoot
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
441 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
442 get;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
443 set;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
444 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
445
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
446 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
447 /// Gets the internal accessor for the ContentRoot of the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
448 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
449 internal FrameworkElement ContentRoot
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
450 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
451 get;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
452 private set;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
453 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
454
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
455 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
456 /// Setting for the horizontal positioning offset for start position
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
457 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
458 public double HorizontalOffset
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
459 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
460 get { return _horizontalOffset; }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
461 set { _horizontalOffset = value; }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
462 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
463
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
464 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
465 /// Setting for the vertical positioning offset for start position
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
466 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
467 public double VerticalOffset
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
468 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
469 get { return _verticalOffset; }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
470 set { _verticalOffset = value; }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
471 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
472
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
473 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
474 /// Gets the internal accessor for the modal of the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
475 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
476 public bool IsModal
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
477 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
478 get
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
479 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
480 return _modal;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
481 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
482 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
483
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
484 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
485 /// Gets or sets a value indicating whether the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
486 /// <see cref="T:System.Windows.Controls.FloatableWindow" /> was accepted or
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
487 /// canceled.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
488 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
489 /// <value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
490 /// True if the child window was accepted; false if the child window was
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
491 /// canceled. The default is null.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
492 /// </value>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
493 [TypeConverter(typeof(NullableBoolConverter))]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
494 public bool? DialogResult
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
495 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
496 get
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
497 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
498 return this._dialogresult;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
499 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
500
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
501 set
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
502 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
503 if (this._dialogresult != value)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
504 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
505 this._dialogresult = value;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
506 this.Close();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
507 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
508 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
509 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
510
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
511 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
512 /// Gets the internal accessor for the PopUp of the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
513 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
514 internal Popup ChildWindowPopup
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
515 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
516 get;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
517 private set;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
518 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
519
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
520 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
521 /// Gets the internal accessor for the close button of the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
522 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
523 internal ButtonBase CloseButton
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
524 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
525 get;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
526 private set;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
527 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
528
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
529 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
530 /// Gets the InteractionState for the FloatableWindow.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
531 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
532 internal WindowInteractionState InteractionState
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
533 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
534 get
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
535 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
536 return this._interactionState;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
537 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
538 private set
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
539 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
540 if (this._interactionState != value)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
541 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
542 WindowInteractionState oldValue = this._interactionState;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
543 this._interactionState = value;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
544 FloatableWindowAutomationPeer peer = FloatableWindowAutomationPeer.FromElement(this) as FloatableWindowAutomationPeer;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
545
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
546 if (peer != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
547 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
548 peer.RaiseInteractionStatePropertyChangedEvent(oldValue, this._interactionState);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
549 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
550 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
551 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
552 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
553
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
554 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
555 /// Gets a value indicating whether the PopUp is open or not.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
556 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
557 private bool IsOpen
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
558 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
559 get
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
560 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
561 return (this.ChildWindowPopup != null && this.ChildWindowPopup.IsOpen) ||
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
562 ((ParentLayoutRoot != null) && (ParentLayoutRoot.Children.Contains(this)));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
563 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
564 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
565
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
566 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
567 /// Gets the internal accessor for the overlay of the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
568 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
569 internal Panel Overlay
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
570 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
571 get;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
572 private set;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
573 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
574
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
575 public ResizeMode ResizeMode
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
576 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
577 get;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
578 set;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
579 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
580
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
581 #endregion Properties
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
582
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
583 #region Static Methods
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
584
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
585 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
586 /// Inverts the input matrix.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
587 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
588 /// <param name="matrix">The matrix values that is to be inverted.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
589 /// <returns>Returns a value indicating whether the inversion was successful or not.</returns>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
590 private static bool InvertMatrix(ref Matrix matrix)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
591 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
592 double determinant = (matrix.M11 * matrix.M22) - (matrix.M12 * matrix.M21);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
593
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
594 if (determinant == 0.0)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
595 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
596 return false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
597 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
598
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
599 Matrix matCopy = matrix;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
600 matrix.M11 = matCopy.M22 / determinant;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
601 matrix.M12 = -1 * matCopy.M12 / determinant;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
602 matrix.M21 = -1 * matCopy.M21 / determinant;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
603 matrix.M22 = matCopy.M11 / determinant;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
604 matrix.OffsetX = ((matCopy.OffsetY * matCopy.M21) - (matCopy.OffsetX * matCopy.M22)) / determinant;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
605 matrix.OffsetY = ((matCopy.OffsetX * matCopy.M12) - (matCopy.OffsetY * matCopy.M11)) / determinant;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
606
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
607 return true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
608 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
609
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
610 #endregion Static Methods
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
611
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
612 #region Methods
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
613
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
614 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
615 /// Executed when the application is exited.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
616 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
617 /// <param name="sender">The sender.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
618 /// <param name="e">Event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
619 internal void Application_Exit(object sender, EventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
620 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
621 if (this.IsOpen)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
622 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
623 this._isAppExit = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
624 try
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
625 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
626 this.Close();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
627 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
628 finally
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
629 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
630 this._isAppExit = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
631 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
632 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
633 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
634
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
635 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
636 /// Executed when focus is given to the window via a click. Attempts to bring current
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
637 /// window to the front in the event there are more windows.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
638 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
639 internal void BringToFront()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
640 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
641 z++;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
642 Canvas.SetZIndex(this, z);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
643 #if DEBUG
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
644 this.Title = z.ToString();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
645 #endif
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
646 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
647
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
648 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
649 /// Changes the visual state of the FloatableWindow.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
650 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
651 private void ChangeVisualState()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
652 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
653 if (this._isClosing)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
654 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
655 VisualStateManager.GoToState(this, VSMSTATE_StateClosed, true);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
656 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
657 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
658 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
659 VisualStateManager.GoToState(this, VSMSTATE_StateOpen, true);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
660 BringToFront();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
661 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
662 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
663
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
664 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
665 /// Executed when FloatableWindow size is changed.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
666 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
667 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
668 /// <param name="e">Size changed event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
669 private void ChildWindow_SizeChanged(object sender, SizeChangedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
670 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
671 if (_modal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
672 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
673 if (this.Overlay != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
674 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
675 if (e.NewSize.Height != this.Overlay.Height)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
676 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
677 this._desiredContentHeight = e.NewSize.Height;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
678 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
679
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
680 if (e.NewSize.Width != this.Overlay.Width)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
681 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
682 this._desiredContentWidth = e.NewSize.Width;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
683 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
684 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
685
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
686 if (this.IsOpen)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
687 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
688 this.UpdateOverlaySize();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
689 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
690 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
691 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
692
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
693 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
694 /// Closes a <see cref="T:System.Windows.Controls.FloatableWindow" />.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
695 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
696 public void Close()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
697 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
698 // AutomationPeer returns "Closing" when Close() is called
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
699 // but the window is not closed completely:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
700 this.InteractionState = WindowInteractionState.Closing;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
701 CancelEventArgs e = new CancelEventArgs();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
702 this.OnClosing(e);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
703
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
704 // On ApplicationExit, close() cannot be cancelled
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
705 if (!e.Cancel || this._isAppExit)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
706 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
707 if (RootVisual != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
708 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
709 RootVisual.IsEnabled = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
710 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
711
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
712 // Close Popup
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
713 if (this.IsOpen)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
714 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
715 if (this._closed != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
716 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
717 // Popup will be closed when the storyboard ends
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
718 this._isClosing = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
719 try
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
720 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
721 var sb = GetVisualStateStoryboard("WindowStates", "Closed");
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
722 sb.Completed += (s, args) =>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
723 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
724 this.ParentLayoutRoot.Children.Remove(this);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
725 this.OnClosed(EventArgs.Empty);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
726 this.UnSubscribeFromEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
727 this.UnsubscribeFromTemplatePartEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
728
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
729 if (Application.Current.RootVisual != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
730 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
731 Application.Current.RootVisual.GotFocus -= new RoutedEventHandler(this.RootVisual_GotFocus);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
732 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
733 };
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
734 this.ChangeVisualState();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
735 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
736 finally
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
737 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
738 this._isClosing = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
739 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
740 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
741 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
742 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
743 // If no closing storyboard is defined, close the Popup
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
744 this.ChildWindowPopup.IsOpen = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
745 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
746
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
747 if (!this._dialogresult.HasValue)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
748 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
749 // If close action is not happening because of DialogResult property change action,
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
750 // Dialogresult is always false:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
751 this._dialogresult = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
752 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
753
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
754 //this.OnClosed(EventArgs.Empty);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
755 //this.UnSubscribeFromEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
756 //this.UnsubscribeFromTemplatePartEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
757
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
758 //if (Application.Current.RootVisual != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
759 //{
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
760 // Application.Current.RootVisual.GotFocus -= new RoutedEventHandler(this.RootVisual_GotFocus);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
761 //}
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
762 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
763 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
764 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
765 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
766 // If the Close is cancelled, DialogResult should always be NULL:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
767 this._dialogresult = null;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
768 this.InteractionState = WindowInteractionState.Running;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
769 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
770 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
771
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
772 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
773 /// Brings the window to the front of others
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
774 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
775 /// <param name="sender"></param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
776 /// <param name="e"></param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
777 internal void ContentRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
778 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
779 BringToFront();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
780 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
781
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
782 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
783 /// Executed when the CloseButton is clicked.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
784 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
785 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
786 /// <param name="e">Routed event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
787 internal void CloseButton_Click(object sender, RoutedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
788 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
789 this.Close();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
790 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
791
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
792 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
793 /// Executed when the Closing storyboard ends.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
794 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
795 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
796 /// <param name="e">Event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
797 private void Closing_Completed(object sender, EventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
798 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
799 if (this.ChildWindowPopup != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
800 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
801 this.ChildWindowPopup.IsOpen = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
802 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
803
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
804 // AutomationPeer returns "NotResponding" when the FloatableWindow is closed:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
805 this.InteractionState = WindowInteractionState.NotResponding;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
806
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
807 if (this._closed != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
808 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
809 this._closed.Completed -= new EventHandler(this.Closing_Completed);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
810 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
811 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
812
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
813 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
814 /// Executed when the a key is presses when the window is open.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
815 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
816 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
817 /// <param name="e">Key event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
818 private void ChildWindow_KeyDown(object sender, KeyEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
819 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
820 FloatableWindow ew = sender as FloatableWindow;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
821 Debug.Assert(ew != null, "FloatableWindow instance is null.");
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
822
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
823 // Ctrl+Shift+F4 closes the FloatableWindow
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
824 if (e != null && !e.Handled && e.Key == Key.F4 &&
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
825 ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) &&
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
826 ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift))
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
827 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
828 ew.Close();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
829 e.Handled = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
830 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
831 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
832
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
833 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
834 /// Executed when the window loses focus.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
835 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
836 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
837 /// <param name="e">Routed event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
838 private void ChildWindow_LostFocus(object sender, RoutedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
839 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
840 // If the FloatableWindow loses focus but the popup is still open,
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
841 // it means another popup is opened. To get the focus back when the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
842 // popup is closed, we handle GotFocus on the RootVisual
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
843 // TODO: Something else could get focus and handle the GotFocus event right.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
844 // Try listening to routed events that were Handled (new SL 3 feature)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
845 // Blocked by Jolt bug #29419
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
846 if (this.IsOpen && Application.Current != null && Application.Current.RootVisual != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
847 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
848 this.InteractionState = WindowInteractionState.BlockedByModalWindow;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
849 Application.Current.RootVisual.GotFocus += new RoutedEventHandler(this.RootVisual_GotFocus);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
850 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
851 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
852
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
853 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
854 /// Executed when mouse left button is down on the chrome.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
855 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
856 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
857 /// <param name="e">Mouse button event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
858 private void Chrome_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
859 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
860 if (this._chrome != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
861 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
862 e.Handled = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
863
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
864 if (this.CloseButton != null && !this.CloseButton.IsTabStop)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
865 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
866 this.CloseButton.IsTabStop = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
867 try
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
868 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
869 this.Focus();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
870 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
871 finally
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
872 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
873 this.CloseButton.IsTabStop = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
874 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
875 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
876 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
877 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
878 this.Focus();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
879 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
880 this._chrome.CaptureMouse();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
881 this._isMouseCaptured = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
882 this._clickPoint = e.GetPosition(sender as UIElement);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
883 #if DEBUG
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
884 this.Title = string.Format("X:{0},Y:{1}", this._clickPoint.X.ToString(), this._clickPoint.Y.ToString());
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
885 #endif
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
886 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
887 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
888
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
889 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
890 /// Executed when mouse left button is up on the chrome.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
891 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
892 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
893 /// <param name="e">Mouse button event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
894 private void Chrome_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
895 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
896 if (this._chrome != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
897 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
898 //e.Handled = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
899 this._chrome.ReleaseMouseCapture();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
900 this._isMouseCaptured = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
901 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
902 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
903
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
904 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
905 /// Executed when mouse moves on the chrome.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
906 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
907 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
908 /// <param name="e">Mouse event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
909 private void Chrome_MouseMove(object sender, MouseEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
910 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
911 #region New ChildWindow Code not working
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
912 //if (this._isMouseCaptured && this.ContentRoot != null && Application.Current != null && Application.Current.RootVisual != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
913 //{
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
914 // Point position = e.GetPosition(Application.Current.RootVisual);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
915
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
916 // GeneralTransform gt = this.ContentRoot.TransformToVisual(Application.Current.RootVisual);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
917
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
918 // if (gt != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
919 // {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
920 // Point p = gt.Transform(this._clickPoint);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
921 // this._windowPosition = gt.Transform(new Point(0, 0));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
922
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
923 // if (position.X < 0)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
924 // {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
925 // double Y = FindPositionY(p, position, 0);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
926 // position = new Point(0, Y);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
927 // }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
928
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
929 // if (position.X > this.Width)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
930 // {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
931 // double Y = FindPositionY(p, position, this.Width);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
932 // position = new Point(this.Width, Y);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
933 // }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
934
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
935 // if (position.Y < 0)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
936 // {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
937 // double X = FindPositionX(p, position, 0);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
938 // position = new Point(X, 0);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
939 // }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
940
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
941 // if (position.Y > this.Height)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
942 // {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
943 // double X = FindPositionX(p, position, this.Height);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
944 // position = new Point(X, this.Height);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
945 // }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
946
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
947 // double x = position.X - p.X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
948 // double y = position.Y - p.Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
949 // UpdateContentRootTransform(x, y);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
950 // }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
951 //}
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
952 #endregion
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
953 if (this._isMouseCaptured && this.ContentRoot != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
954 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
955 // If the child window is dragged out of the page, return
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
956 if (Application.Current != null && Application.Current.RootVisual != null &&
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
957 (e.GetPosition(Application.Current.RootVisual).X < 0 || e.GetPosition(Application.Current.RootVisual).Y < 0))
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
958 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
959 return;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
960 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
961
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
962 TransformGroup transformGroup = this.ContentRoot.RenderTransform as TransformGroup;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
963
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
964 if (transformGroup == null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
965 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
966 transformGroup = new TransformGroup();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
967 transformGroup.Children.Add(this.ContentRoot.RenderTransform);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
968 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
969
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
970 TranslateTransform t = new TranslateTransform();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
971 t.X = e.GetPosition(this.ContentRoot).X - this._clickPoint.X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
972 t.Y = e.GetPosition(this.ContentRoot).Y - this._clickPoint.Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
973 if (transformGroup != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
974 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
975 transformGroup.Children.Add(t);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
976 this.ContentRoot.RenderTransform = transformGroup;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
977 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
978 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
979 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
980
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
981 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
982 /// Executed when the ContentPresenter size changes.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
983 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
984 /// <param name="sender">Content Presenter object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
985 /// <param name="e">SizeChanged event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
986 private void ContentPresenter_SizeChanged(object sender, SizeChangedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
987 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
988 // timheuer: not sure really why this is here?
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
989 //if (this.ContentRoot != null && Application.Current != null && Application.Current.RootVisual != null && _isOpen)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
990 //{
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
991 // GeneralTransform gt = this.ContentRoot.TransformToVisual(Application.Current.RootVisual);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
992
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
993 // if (gt != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
994 // {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
995 // Point p = gt.Transform(new Point(0, 0));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
996
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
997 // double x = this._windowPosition.X - p.X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
998 // double y = this._windowPosition.Y - p.Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
999 // UpdateContentRootTransform(x, y);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1000 // }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1001 //}
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1002
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1003 //RectangleGeometry rg = new RectangleGeometry();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1004 //rg.Rect = new Rect(0, 0, this._contentPresenter.ActualWidth, this._contentPresenter.ActualHeight);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1005 //this._contentPresenter.Clip = rg;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1006 //this.UpdatePosition();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1007 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1008
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1009 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1010 /// Finds the X coordinate of a point that is defined by a line.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1011 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1012 /// <param name="p1">Starting point of the line.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1013 /// <param name="p2">Ending point of the line.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1014 /// <param name="y">Y coordinate of the point.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1015 /// <returns>X coordinate of the point.</returns>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1016 private static double FindPositionX(Point p1, Point p2, double y)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1017 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1018 if (y == p1.Y || p1.X == p2.X)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1019 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1020 return p2.X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1021 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1022
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1023 Debug.Assert(p1.Y != p2.Y, "Unexpected equal Y coordinates");
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1024
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1025 return (((y - p1.Y) * (p1.X - p2.X)) / (p1.Y - p2.Y)) + p1.X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1026 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1027
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1028 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1029 /// Finds the Y coordinate of a point that is defined by a line.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1030 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1031 /// <param name="p1">Starting point of the line.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1032 /// <param name="p2">Ending point of the line.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1033 /// <param name="x">X coordinate of the point.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1034 /// <returns>Y coordinate of the point.</returns>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1035 private static double FindPositionY(Point p1, Point p2, double x)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1036 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1037 if (p1.Y == p2.Y || x == p1.X)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1038 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1039 return p2.Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1040 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1041
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1042 Debug.Assert(p1.X != p2.X, "Unexpected equal X coordinates");
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1043
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1044 return (((p1.Y - p2.Y) * (x - p1.X)) / (p1.X - p2.X)) + p1.Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1045 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1046
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1047 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1048 /// Builds the visual tree for the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1049 /// <see cref="T:System.Windows.Controls.FloatableWindow" /> control when a
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1050 /// new template is applied.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1051 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1052 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "No need to split the code into two parts.")]
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1053 public override void OnApplyTemplate()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1054 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1055 this.UnsubscribeFromTemplatePartEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1056
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1057 base.OnApplyTemplate();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1058
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1059 this.CloseButton = GetTemplateChild(PART_CloseButton) as ButtonBase;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1060
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1061 if (this.CloseButton != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1062 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1063 if (this.HasCloseButton)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1064 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1065 this.CloseButton.Visibility = Visibility.Visible;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1066 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1067 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1068 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1069 this.CloseButton.Visibility = Visibility.Collapsed;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1070 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1071 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1072
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1073 if (this._closed != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1074 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1075 this._closed.Completed -= new EventHandler(this.Closing_Completed);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1076 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1077
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1078 if (this._opened != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1079 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1080 this._opened.Completed -= new EventHandler(this.Opening_Completed);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1081 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1082
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1083 this._root = GetTemplateChild(PART_Root) as FrameworkElement;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1084 this._resizer = GetTemplateChild(PART_Resizer) as FrameworkElement;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1085
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1086 if (this._root != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1087 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1088 IList groups = VisualStateManager.GetVisualStateGroups(this._root);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1089
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1090 if (groups != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1091 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1092 IList states = null;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1093
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1094 foreach (VisualStateGroup vsg in groups)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1095 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1096 if (vsg.Name == FloatableWindow.VSMGROUP_Window)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1097 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1098 states = vsg.States;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1099 break;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1100 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1101 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1102
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1103 if (states != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1104 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1105 foreach (VisualState state in states)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1106 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1107 if (state.Name == FloatableWindow.VSMSTATE_StateClosed)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1108 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1109 this._closed = state.Storyboard;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1110 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1111
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1112 if (state.Name == FloatableWindow.VSMSTATE_StateOpen)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1113 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1114 this._opened = state.Storyboard;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1115 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1116 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1117 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1118 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1119 //TODO: Figure out why I can't wire up the event below in SubscribeToTemplatePartEvents
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1120 this._root.MouseLeftButtonDown += new MouseButtonEventHandler(this.ContentRoot_MouseLeftButtonDown);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1121
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1122 if (this.ResizeMode == ResizeMode.CanResize)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1123 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1124 this._resizer.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(Resizer_MouseLeftButtonDown);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1125 this._resizer.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(Resizer_MouseLeftButtonUp);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1126 this._resizer.MouseMove += new System.Windows.Input.MouseEventHandler(Resizer_MouseMove);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1127 this._resizer.MouseEnter += new MouseEventHandler(Resizer_MouseEnter);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1128 this._resizer.MouseLeave += new MouseEventHandler(Resizer_MouseLeave);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1129 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1130 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1131 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1132 this._resizer.Opacity = 0;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1133 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1134 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1135
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1136 this.ContentRoot = GetTemplateChild(PART_ContentRoot) as FrameworkElement;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1137
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1138 this._chrome = GetTemplateChild(PART_Chrome) as FrameworkElement;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1139
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1140 this.Overlay = GetTemplateChild(PART_Overlay) as Panel;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1141
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1142 this._contentPresenter = GetTemplateChild(PART_ContentPresenter) as FrameworkElement;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1143
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1144 this.SubscribeToTemplatePartEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1145 this.SubscribeToStoryBoardEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1146 this._desiredMargin = this.Margin;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1147 this.Margin = new Thickness(0);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1148
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1149 // Update overlay size
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1150 if (this.IsOpen && (this.ChildWindowPopup != null))
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1151 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1152 this._desiredContentHeight = this.Height;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1153 this._desiredContentWidth = this.Width;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1154 this.UpdateOverlaySize();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1155 this.UpdateRenderTransform();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1156 this.ChangeVisualState();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1157 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1158 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1159
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1160 void Resizer_MouseLeave(object sender, MouseEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1161 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1162 if (!this._isMouseCaptured)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1163 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1164 this._resizer.Opacity = .25;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1165 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1166 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1167
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1168 void Resizer_MouseEnter(object sender, MouseEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1169 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1170 if (!this._isMouseCaptured)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1171 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1172 this._resizer.Opacity = 1;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1173 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1174 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1175
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1176 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1177 /// Raises the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1178 /// <see cref="E:System.Windows.Controls.FloatableWindow.Closed" /> event.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1179 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1180 /// <param name="e">The event data.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1181 protected virtual void OnClosed(EventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1182 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1183 EventHandler handler = this.Closed;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1184
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1185 if (null != handler)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1186 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1187 handler(this, e);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1188 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1189
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1190 this._isOpen = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1191 if (!_modal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1192 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1193 this.ParentLayoutRoot.Children.Remove(this);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1194 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1195 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1196
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1197 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1198 /// Raises the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1199 /// <see cref="E:System.Windows.Controls.FloatableWindow.Closing" /> event.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1200 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1201 /// <param name="e">The event data.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1202 protected virtual void OnClosing(CancelEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1203 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1204 EventHandler<CancelEventArgs> handler = this.Closing;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1205
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1206 if (null != handler)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1207 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1208 handler(this, e);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1209 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1210 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1211
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1212 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1213 /// Returns a
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1214 /// <see cref="T:System.Windows.Automation.Peers.FloatableWindowAutomationPeer" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1215 /// for use by the Silverlight automation infrastructure.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1216 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1217 /// <returns>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1218 /// <see cref="T:System.Windows.Automation.Peers.FloatableWindowAutomationPeer" />
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1219 /// for the <see cref="T:System.Windows.Controls.FloatableWindow" /> object.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1220 /// </returns>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1221 protected override AutomationPeer OnCreateAutomationPeer()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1222 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1223 return new FloatableWindowAutomationPeer(this);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1224 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1225
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1226 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1227 /// This method is called every time a
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1228 /// <see cref="T:System.Windows.Controls.FloatableWindow" /> is displayed.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1229 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1230 protected virtual void OnOpened()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1231 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1232 this.UpdatePosition();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1233 this._isOpen = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1234
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1235 if (this.Overlay != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1236 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1237 this.Overlay.Opacity = this.OverlayOpacity;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1238 this.Overlay.Background = this.OverlayBrush;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1239 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1240
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1241 if (!this.Focus())
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1242 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1243 // If the Focus() fails it means there is no focusable element in the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1244 // FloatableWindow. In this case we set IsTabStop to true to have the keyboard functionality
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1245 this.IsTabStop = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1246 this.Focus();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1247 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1248 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1249
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1250 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1251 /// Executed when the opening storyboard finishes.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1252 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1253 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1254 /// <param name="e">Event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1255 private void Opening_Completed(object sender, EventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1256 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1257 if (this._opened != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1258 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1259 this._opened.Completed -= new EventHandler(this.Opening_Completed);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1260 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1261 // AutomationPeer returns "ReadyForUserInteraction" when the FloatableWindow
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1262 // is open and all animations have been completed.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1263 this.InteractionState = WindowInteractionState.ReadyForUserInteraction;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1264 this.OnOpened();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1265 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1266
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1267 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1268 /// Executed when the page resizes.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1269 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1270 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1271 /// <param name="e">Event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1272 private void Page_Resized(object sender, EventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1273 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1274 if (this.ChildWindowPopup != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1275 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1276 this.UpdateOverlaySize();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1277 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1278 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1279
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1280 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1281 /// Executed when the root visual gets focus.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1282 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1283 /// <param name="sender">Sender object.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1284 /// <param name="e">Routed event args.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1285 private void RootVisual_GotFocus(object sender, RoutedEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1286 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1287 this.Focus();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1288 this.InteractionState = WindowInteractionState.ReadyForUserInteraction;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1289 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1290
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1291 public void Show()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1292 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1293 ShowWindow(false);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1294 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1295
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1296 public void ShowDialog()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1297 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1298 _verticalOffset = 0;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1299 _horizontalOffset = 0;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1300 ShowWindow(true);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1301 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1302
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1303 public void Show(double horizontalOffset, double verticalOffset)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1304 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1305 _horizontalOffset = horizontalOffset;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1306 _verticalOffset = verticalOffset;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1307 ShowWindow(false);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1308 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1309
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1310 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1311 /// Opens a <see cref="T:System.Windows.Controls.FloatableWindow" /> and
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1312 /// returns without waiting for the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1313 /// <see cref="T:System.Windows.Controls.FloatableWindow" /> to close.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1314 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1315 /// <exception cref="T:System.InvalidOperationException">
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1316 /// The child window is already in the visual tree.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1317 /// </exception>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1318 internal void ShowWindow(bool isModal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1319 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1320 _modal = isModal;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1321
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1322 // AutomationPeer returns "Running" when Show() is called
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1323 // but the FloatableWindow is not ready for user interaction:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1324 this.InteractionState = WindowInteractionState.Running;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1325
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1326 this.SubscribeToEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1327 this.SubscribeToTemplatePartEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1328 this.SubscribeToStoryBoardEvents();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1329
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1330
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1331 // MaxHeight and MinHeight properties should not be overwritten:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1332 this.MaxHeight = double.PositiveInfinity;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1333 this.MaxWidth = double.PositiveInfinity;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1334
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1335 if (_modal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1336 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1337 if (this.ChildWindowPopup == null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1338 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1339 this.ChildWindowPopup = new Popup();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1340
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1341 try
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1342 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1343 this.ChildWindowPopup.Child = this;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1344 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1345 catch (ArgumentException)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1346 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1347 // If the FloatableWindow is already in the visualtree, we cannot set it to be the child of the popup
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1348 // we are throwing a friendlier exception for this case:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1349 this.InteractionState = WindowInteractionState.NotResponding;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1350 throw new InvalidOperationException(Properties.Resources.ChildWindow_InvalidOperation);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1351 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1352 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1353
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1354 if (this.ChildWindowPopup != null && Application.Current.RootVisual != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1355 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1356 this.ChildWindowPopup.IsOpen = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1357
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1358 this.ChildWindowPopup.HorizontalOffset = _horizontalOffset;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1359 this.ChildWindowPopup.VerticalOffset = _verticalOffset;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1360
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1361 // while the FloatableWindow is open, the DialogResult is always NULL:
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1362 this._dialogresult = null;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1363 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1364 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1365 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1366 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1367 if (ParentLayoutRoot != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1368 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1369 this.SetValue(Canvas.TopProperty, _verticalOffset);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1370 this.SetValue(Canvas.LeftProperty, _horizontalOffset);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1371 this.ParentLayoutRoot.Children.Add(this);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1372 this.BringToFront();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1373 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1374 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1375 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1376 throw new ArgumentNullException("ParentLayoutRoot", "You need to specify a root Panel element to add the window elements to.");
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1377 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1378 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1379
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1380 // disable the underlying UI
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1381 if (RootVisual != null && _modal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1382 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1383 RootVisual.IsEnabled = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1384 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1385
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1386 // if the template is already loaded, display loading visuals animation
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1387 if (this.ContentRoot == null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1388 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1389 this.Loaded += (s, args) =>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1390 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1391 if (this.ContentRoot != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1392 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1393 this.ChangeVisualState();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1394 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1395 };
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1396 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1397 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1398 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1399 this.ChangeVisualState();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1400 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1401 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1402
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1403 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1404 /// Subscribes to events when the FloatableWindow is opened.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1405 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1406 private void SubscribeToEvents()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1407 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1408 if (Application.Current != null && Application.Current.Host != null && Application.Current.Host.Content != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1409 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1410 Application.Current.Exit += new EventHandler(this.Application_Exit);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1411 Application.Current.Host.Content.Resized += new EventHandler(this.Page_Resized);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1412 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1413
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1414 this.KeyDown += new KeyEventHandler(this.ChildWindow_KeyDown);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1415 if (_modal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1416 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1417 this.LostFocus += new RoutedEventHandler(this.ChildWindow_LostFocus);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1418 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1419 this.SizeChanged += new SizeChangedEventHandler(this.ChildWindow_SizeChanged);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1420 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1421
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1422 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1423 /// Subscribes to events that are on the storyboards.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1424 /// Unsubscribing from these events happen in the event handlers individually.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1425 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1426 private void SubscribeToStoryBoardEvents()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1427 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1428 if (this._closed != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1429 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1430 this._closed.Completed += new EventHandler(this.Closing_Completed);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1431 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1432
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1433 if (this._opened != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1434 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1435 this._opened.Completed += new EventHandler(this.Opening_Completed);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1436 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1437 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1438
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1439 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1440 /// Subscribes to events on the template parts.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1441 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1442 private void SubscribeToTemplatePartEvents()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1443 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1444 if (this.CloseButton != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1445 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1446 this.CloseButton.Click += new RoutedEventHandler(this.CloseButton_Click);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1447 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1448
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1449 if (this._chrome != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1450 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1451 this._chrome.MouseLeftButtonDown += new MouseButtonEventHandler(this.Chrome_MouseLeftButtonDown);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1452 this._chrome.MouseLeftButtonUp += new MouseButtonEventHandler(this.Chrome_MouseLeftButtonUp);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1453 this._chrome.MouseMove += new MouseEventHandler(this.Chrome_MouseMove);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1454 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1455
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1456 if (this._contentPresenter != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1457 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1458 this._contentPresenter.SizeChanged += new SizeChangedEventHandler(this.ContentPresenter_SizeChanged);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1459 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1460 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1461
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1462 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1463 /// Unsubscribe from events when the FloatableWindow is closed.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1464 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1465 private void UnSubscribeFromEvents()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1466 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1467 if (Application.Current != null && Application.Current.Host != null && Application.Current.Host.Content != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1468 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1469 Application.Current.Exit -= new EventHandler(this.Application_Exit);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1470 Application.Current.Host.Content.Resized -= new EventHandler(this.Page_Resized);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1471 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1472
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1473 this.KeyDown -= new KeyEventHandler(this.ChildWindow_KeyDown);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1474 if (_modal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1475 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1476 this.LostFocus -= new RoutedEventHandler(this.ChildWindow_LostFocus);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1477 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1478 this.SizeChanged -= new SizeChangedEventHandler(this.ChildWindow_SizeChanged);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1479 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1480
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1481 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1482 /// Unsubscribe from the events that are subscribed on the template part elements.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1483 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1484 private void UnsubscribeFromTemplatePartEvents()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1485 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1486 if (this.CloseButton != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1487 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1488 this.CloseButton.Click -= new RoutedEventHandler(this.CloseButton_Click);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1489 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1490
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1491 if (this._chrome != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1492 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1493 this._chrome.MouseLeftButtonDown -= new MouseButtonEventHandler(this.Chrome_MouseLeftButtonDown);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1494 this._chrome.MouseLeftButtonUp -= new MouseButtonEventHandler(this.Chrome_MouseLeftButtonUp);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1495 this._chrome.MouseMove -= new MouseEventHandler(this.Chrome_MouseMove);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1496 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1497
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1498 if (this._contentPresenter != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1499 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1500 this._contentPresenter.SizeChanged -= new SizeChangedEventHandler(this.ContentPresenter_SizeChanged);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1501 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1502 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1503
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1504 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1505 /// Updates the size of the overlay of the window.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1506 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1507 private void UpdateOverlaySize()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1508 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1509 if (_modal)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1510 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1511 if (this.Overlay != null && Application.Current != null && Application.Current.Host != null && Application.Current.Host.Content != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1512 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1513 this.Height = Application.Current.Host.Content.ActualHeight;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1514 this.Width = Application.Current.Host.Content.ActualWidth;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1515 this.Overlay.Height = this.Height;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1516 this.Overlay.Width = this.Width;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1517
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1518 if (this.ContentRoot != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1519 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1520 this.ContentRoot.Width = this._desiredContentWidth;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1521 this.ContentRoot.Height = this._desiredContentHeight;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1522 this.ContentRoot.Margin = this._desiredMargin;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1523 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1524 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1525 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1526 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1527 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1528 if (this.Overlay != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1529 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1530 this.Overlay.Visibility = Visibility.Collapsed;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1531 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1532 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1533 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1534
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1535 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1536 /// Updates the position of the window in case the size of the content changes.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1537 /// This allows FloatableWindow only scale from right and bottom.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1538 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1539 private void UpdatePosition()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1540 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1541 if (this.ContentRoot != null && Application.Current != null && Application.Current.RootVisual != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1542 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1543 GeneralTransform gt = this.ContentRoot.TransformToVisual(Application.Current.RootVisual);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1544
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1545 if (gt != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1546 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1547 this._windowPosition = gt.Transform(new Point(0, 0));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1548 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1549 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1550 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1551
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1552 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1553 /// Updates the render transform applied on the overlay.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1554 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1555 private void UpdateRenderTransform()
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1556 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1557 if (this._root != null && this.ContentRoot != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1558 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1559 // The Overlay part should not be affected by the render transform applied on the
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1560 // FloatableWindow. In order to achieve this, we adjust an identity matrix to represent
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1561 // the _root's transformation, invert it, apply the inverted matrix on the _root, so that
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1562 // nothing is affected by the rendertransform, and apply the original transform only on the Content
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1563 GeneralTransform gt = this._root.TransformToVisual(null);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1564 if (gt != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1565 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1566 Point p10 = new Point(1, 0);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1567 Point p01 = new Point(0, 1);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1568 Point transform10 = gt.Transform(p10);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1569 Point transform01 = gt.Transform(p01);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1570
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1571 Matrix transformToRootMatrix = Matrix.Identity;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1572 transformToRootMatrix.M11 = transform10.X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1573 transformToRootMatrix.M12 = transform10.Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1574 transformToRootMatrix.M21 = transform01.X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1575 transformToRootMatrix.M22 = transform01.Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1576
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1577 MatrixTransform original = new MatrixTransform();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1578 original.Matrix = transformToRootMatrix;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1579
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1580 InvertMatrix(ref transformToRootMatrix);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1581 MatrixTransform mt = new MatrixTransform();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1582 mt.Matrix = transformToRootMatrix;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1583
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1584 TransformGroup tg = this._root.RenderTransform as TransformGroup;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1585
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1586 if (tg != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1587 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1588 tg.Children.Add(mt);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1589 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1590 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1591 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1592 this._root.RenderTransform = mt;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1593 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1594
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1595 tg = this.ContentRoot.RenderTransform as TransformGroup;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1596
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1597 if (tg != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1598 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1599 tg.Children.Add(original);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1600 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1601 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1602 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1603 this.ContentRoot.RenderTransform = original;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1604 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1605 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1606 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1607 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1608
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1609 /// <summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1610 /// Updates the ContentRootTranslateTransform.
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1611 /// </summary>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1612 /// <param name="X">X coordinate of the transform.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1613 /// <param name="Y">Y coordinate of the transform.</param>
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1614 private void UpdateContentRootTransform(double X, double Y)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1615 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1616 if (this._contentRootTransform == null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1617 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1618 this._contentRootTransform = new TranslateTransform();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1619 this._contentRootTransform.X = X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1620 this._contentRootTransform.Y = Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1621
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1622 TransformGroup transformGroup = this.ContentRoot.RenderTransform as TransformGroup;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1623
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1624 if (transformGroup == null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1625 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1626 transformGroup = new TransformGroup();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1627 transformGroup.Children.Add(this.ContentRoot.RenderTransform);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1628 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1629 transformGroup.Children.Add(this._contentRootTransform);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1630 this.ContentRoot.RenderTransform = transformGroup;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1631 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1632 else
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1633 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1634 this._contentRootTransform.X += X;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1635 this._contentRootTransform.Y += Y;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1636 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1637 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1638
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1639 private void Resizer_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1640 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1641 this._resizer.CaptureMouse();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1642 this._isMouseCaptured = true;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1643 this._clickPoint = e.GetPosition(sender as UIElement);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1644
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1645 #if DEBUG
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1646 this.Title = string.Format("X:{0},Y:{1}", this._clickPoint.X.ToString(), this._clickPoint.Y.ToString());
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1647 #endif
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1648 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1649
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1650 private void Resizer_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1651 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1652 this._resizer.ReleaseMouseCapture();
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1653 this._isMouseCaptured = false;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1654 this._resizer.Opacity = 0.25;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1655 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1656
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1657 private void Resizer_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1658 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1659 if (this._isMouseCaptured && this.ContentRoot != null)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1660 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1661 // If the child window is dragged out of the page, return
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1662 if (Application.Current != null && Application.Current.RootVisual != null &&
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1663 (e.GetPosition(Application.Current.RootVisual).X < 0 || e.GetPosition(Application.Current.RootVisual).Y < 0))
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1664 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1665 return;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1666 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1667
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1668 #if DEBUG
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1669 this.Title = string.Format("X:{0},Y:{1}", this._clickPoint.X.ToString(), this._clickPoint.Y.ToString());
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1670 #endif
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1671
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1672 Point p = e.GetPosition(this.ContentRoot);
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1673
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1674 if ((p.X > this._clickPoint.X) && (p.Y > this._clickPoint.Y))
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1675 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1676 this.Width = (double)(p.X - (12 - this._clickPoint.X));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1677 this.Height = (double)(p.Y - (12 - this._clickPoint.Y));
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1678 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1679 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1680 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1681
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1682 private Storyboard GetVisualStateStoryboard(string visualStateGroupName, string visualStateName)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1683 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1684 foreach (VisualStateGroup g in VisualStateManager.GetVisualStateGroups((FrameworkElement)this.ContentRoot.Parent))
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1685 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1686 if (g.Name != visualStateGroupName) continue;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1687 foreach (VisualState s in g.States)
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1688 {
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1689 if (s.Name != visualStateName) continue;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1690 return s.Storyboard;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1691 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1692 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1693 return null;
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1694 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1695
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1696 #endregion Methods
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1697 }
810116cd6b8e ErrorWindow working
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1698 }