■ Window 클래스를 사용해 윈도우 테두리를 제거하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
<Window Name="window" x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell" Width="800" Height="600" Title="윈도우 테두리 제거하기"> <shell:WindowChrome.WindowChrome> <shell:WindowChrome GlassFrameThickness="0" CornerRadius="0" CaptionHeight="0" ResizeBorderThickness="5" /> </shell:WindowChrome.WindowChrome> <Grid> <Grid.RowDefinitions> <RowDefinition Height="27" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Border x:Name="headerBorder"> <Border.Background> <LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1"> <GradientStop Color="#ff444749" Offset="0" /> <GradientStop Color="#ff0c0e0e" Offset="1" /> <GradientStop Color="#ff101012" Offset="0.504" /> </LinearGradientBrush> </Border.Background> <Grid> <StackPanel HorizontalAlignment="Left" Orientation="Horizontal"> <Grid Margin="10 0 0 0" Width="16" Height="16" Background="White"> <Rectangle Fill="Yellow" /> </Grid> <Label Margin="5 0 0 0" Foreground="White" Content="{Binding ElementName=window, Path=Title}" /> </StackPanel> <StackPanel Margin="0 0 5 0" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal"> <Button Width="20" Click="minimizedButton_Click"> <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid Width="16" Height="16"> <Border x:Name="border" Background="#ff2f2f2f" Opacity="0" SnapsToDevicePixels="True" /> <Rectangle x:Name="minimizedRectangle" Margin="0 10 0 0" VerticalAlignment="Center" Width="12" Height="2" Fill="#ff7b7776" SnapsToDevicePixels="True" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="true" /> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="minimizedRectangle" Property="Fill" Value="White" /> </Trigger> <Trigger Property="IsPressed" Value="true"> <Setter TargetName="minimizedRectangle" Property="Fill" Value="#ff8b8988" /> <Setter TargetName="minimizedRectangle" Property="Opacity" Value="0.7" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Opacity" Value="0.5" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Button.Style> </Button> <ToggleButton Width="20" Click="maximizedButton_Click"> <ToggleButton.Style> <Style TargetType="{x:Type ToggleButton}"> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ToggleButton}"> <Grid Width="16" Height="16" Background="Transparent"> <Border x:Name="border" Background="#002f2f2f" SnapsToDevicePixels="True" /> <Grid> <Path x:Name="path_max" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="12" Height="10" Fill="#ff7b7776" Stretch="Fill" Visibility="Visible" Data=" M 57.001 182.001 L 46.998 182.001 L 46.998 174.026 L 57.001 174.026 z M 46 183 L 58 183 L 58 173 L 46 173 z" /> <Path x:Name="path_max_Check" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="12" Height="10" Fill="#FF7B7776" Stretch="Fill" Visibility="Collapsed" Data=" M 0.99799991 4.0260001 L 0.99799991 9.0010005 8.0009999 9.0010005 8.0009999 4.0260001 z M 3.9999999 1.0000001 L 3.9999999 3.0000001 9 3.0000001 9 6.0000001 11 6.0000001 11 1.0000001 z M 3 0 L 12 0 12 7.0000001 9 7.0000001 9 10 0 10 0 3.0000001 3 3.0000001 z" /> </Grid> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="true" /> <Trigger Property="IsChecked" Value="true"> <Setter Property="Visibility" TargetName="path_max_Check" Value="Visible" /> <Setter Property="Visibility" TargetName="path_max" Value="Collapsed" /> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsChecked" Value="false" /> <Condition Property="IsMouseOver" Value="true" /> </MultiTrigger.Conditions> <Setter Property="Fill" TargetName="path_max" Value="White" /> </MultiTrigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsChecked" Value="true" /> <Condition Property="IsMouseOver" Value="true" /> </MultiTrigger.Conditions> <Setter Property="Fill" TargetName="path_max_Check" Value="#ff8b8988" /> </MultiTrigger> <Trigger Property="IsMouseOver" Value="True" /> <Trigger Property="IsPressed" Value="true"> <Setter Property="Fill" TargetName="path_max" Value="White" /> <Setter Property="Fill" TargetName="path_max_Check" Value="White" /> <Setter Property="Opacity" TargetName="path_max" Value="0.7" /> <Setter Property="Opacity" TargetName="path_max_Check" Value="0.7" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Opacity" Value="0.5" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ToggleButton.Style> </ToggleButton> <Button Width="20" Click="closeButton_Click"> <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid Width="16" Height="16"> <Border x:Name="border" Background="#FF2F2F2F" Opacity="0" SnapsToDevicePixels="True" /> <Path x:Name="path_Closed" HorizontalAlignment="Center" VerticalAlignment="Center" Width="11" Height="10" SnapsToDevicePixels="True" Fill="#ff7b7776" StrokeThickness="0" Stretch="Fill" Visibility="Visible" Data=" M 0.73200232 0 L 5.5 4.2873921 10.267998 0 11 0.76599883 6.2921877 4.9997287 11 9.2330017 10.268002 10 5.5 5.712142 0.73199838 10 0 9.2330017 4.7078123 4.9997287 0 0.76599883 z" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="true" /> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Fill" TargetName="path_Closed" Value="White" /> <Setter Property="Width" TargetName="path_Closed" Value="12" /> <Setter Property="Height" TargetName="path_Closed" Value="10" /> </Trigger> <Trigger Property="IsPressed" Value="true"> <Setter Property="Fill" TargetName="path_Closed" Value="#ff8b8988" /> <Setter Property="Opacity" TargetName="path_Closed" Value="0.7" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Opacity" Value="0.5" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Button.Style> </Button> </StackPanel> </Grid> </Border> <Border Grid.Row="1" BorderThickness="1" BorderBrush="Black"> <Ellipse Margin="10" Fill="RoyalBlue" /> </Border> </Grid> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
using System; using System.Diagnostics; using System.Windows; using System.Windows.Input; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); StateChanged += Window_StateChanged; this.headerBorder.MouseLeftButtonDown += headerBorder_MouseLeftButtonDown; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private //////////////////////////////////////////////////////////////////////////////// Event #region 윈도우 상태 변경시 처리하기 - Window_StateChanged(sender, e) /// <summary> /// 윈도우 상태 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void Window_StateChanged(object sender, EventArgs e) { switch(WindowState) { case WindowState.Maximized : SetMaximizedState(); break; case WindowState.Normal : case WindowState.Minimized : SetNormalOrMinimizedState(); break; } } #endregion #region 헤더 테두리 마우스 이동시 처리하기 - headerBorder_MouseMove(sender, e) /// <summary> /// 헤더 테두리 마우스 이동시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void headerBorder_MouseMove(object sender, MouseEventArgs e) { if(this.WindowState != WindowState.Maximized) { return; } if(Mouse.LeftButton != MouseButtonState.Pressed) { return; } this.WindowState = WindowState.Normal; this.Left = GetWindowLeft(); this.Top = 1; this.DragMove(); } #endregion #region 헤더 테두리 마우스 왼쪽 버튼 DOWN 처리하기 - headerBorder_MouseLeftButtonDown(sender, e) /// <summary> /// 헤더 테두리 마우스 왼쪽 버튼 DOWN 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void headerBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if(e.ClickCount == 2) { SwitchState(); } if((this.ResizeMode == ResizeMode.CanResize) || (this.ResizeMode == ResizeMode.CanResizeWithGrip)) { try { this.DragMove(); } catch(Exception exception) { Debug.WriteLine(exception); } } } #endregion #region 최소화 버튼 클릭시 처리하기 - minimizedButton_Click(sender, e) /// <summary> /// 최소화 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void minimizedButton_Click(object sender, RoutedEventArgs e) { this.WindowState = WindowState.Minimized; } #endregion #region 최대화 버튼 클릭시 처리하기 - maximizedButton_Click(sender, e) /// <summary> /// 최대화 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void maximizedButton_Click(object sender, RoutedEventArgs e) { if(WindowState == WindowState.Maximized) { WindowState = WindowState.Normal; } else { WindowState = WindowState.Maximized; } } #endregion #region 닫기 버튼 클릭시 처리하기 - closeButton_Click(sender, e) /// <summary> /// 닫기 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void closeButton_Click(object sender, RoutedEventArgs e) { Close(); } #endregion //////////////////////////////////////////////////////////////////////////////// Function #region 최대화 상태 설정하기 - SetMaximizedState() /// <summary> /// 최대화 상태 설정하기 /// </summary> private void SetMaximizedState() { this.headerBorder.MouseMove += headerBorder_MouseMove; } #endregion #region 일반 또는 최소화 상태 설정하기 - SetNormalOrMinimizedState() /// <summary> /// 일반 또는 최소화 상태 설정하기 /// </summary> private void SetNormalOrMinimizedState() { this.headerBorder.MouseMove -= headerBorder_MouseMove; } #endregion #region 윈도우 왼쪽 구하기 - GetWindowLeft() /// <summary> /// 윈도우 왼쪽 구하기 /// </summary> /// <returns>윈도우 왼쪽</returns> private double GetWindowLeft() { ScreenManager screenManager = ScreenManager.GetScreenManager(this); double leftBound = screenManager.DesktopArea.Left; double rightBound = screenManager.DesktopArea.Right; Point currentPoint = GetMousePosition(); double left = currentPoint.X - (this.Width / 2); if(left < leftBound) { return leftBound; } double right = currentPoint.X + (this.Width / 2); if(right > rightBound) { return rightBound - this.Width; } return left; } #endregion #region 마우스 위치 구하기 - GetMousePosition() /// <summary> /// 마우스 위치 구하기 /// </summary> /// <returns>마우스 위치</returns> private Point GetMousePosition() { System.Drawing.Point point = System.Windows.Forms.Control.MousePosition; return new Point(point.X, point.Y); } #endregion #region 상태 전화하기 - SwitchState() /// <summary> /// 상태 전화하기 /// </summary> private void SwitchState() { switch(WindowState) { case WindowState.Normal : WindowState = WindowState.Maximized; break; case WindowState.Maximized : WindowState = WindowState.Normal; break; } } #endregion } } |
▶ ScreenManager.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
using System; using System.Collections.Generic; using System.Drawing; using System.Windows; using System.Windows.Forms; using System.Windows.Interop; namespace TestProject { /// <summary> /// 화면 관리자 /// </summary> public class ScreenManager { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 화면 /// </summary> private readonly Screen screen; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Public #region 주 화면 관리자 - Primary /// <summary> /// 주 화면 관리자 /// </summary> public static ScreenManager Primary { get { return new ScreenManager(Screen.PrimaryScreen); } } #endregion ////////////////////////////////////////////////////////////////////////////////////////// Instance //////////////////////////////////////////////////////////////////////////////// Public #region 데스크톱 영역 - DesktopArea /// <summary> /// 데스크톱 영역 /// </summary> public Rect DesktopArea { get { return GetRect(this.screen.Bounds); } } #endregion #region 작업 영역 - WorkingArea /// <summary> /// 작업 영역 /// </summary> public Rect WorkingArea { get { return GetRect(this.screen.WorkingArea); } } #endregion #region 주 화면 여부 - IsPrimary /// <summary> /// 주 화면 여부 /// </summary> public bool IsPrimary { get { return this.screen.Primary; } } #endregion #region 장치명 - DeviceName /// <summary> /// 장치명 /// </summary> public string DeviceName { get { return this.screen.DeviceName; } } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Public #region 모든 화면 관리자들 구하기 - GetAllScreenManagers() /// <summary> /// 모든 화면 관리자들 구하기 /// </summary> /// <returns>모든 화면 관리자들</returns> public static IEnumerable<ScreenManager> GetAllScreenManagers() { foreach(Screen screen in Screen.AllScreens) { yield return new ScreenManager(screen); } } #endregion #region 화면 관리자 구하기 - GetScreenManager(window) /// <summary> /// 화면 관리자 구하기 /// </summary> /// <param name="window">윈도우</param> /// <returns>화면 관리자</returns> public static ScreenManager GetScreenManager(Window window) { WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window); Screen screen = Screen.FromHandle(windowInteropHelper.Handle); ScreenManager screenManager = new ScreenManager(screen); return screenManager; } #endregion #region 화면 관리자 구하기 - GetScreenManager(sourcePoint) /// <summary> /// 화면 관리자 구하기 /// </summary> /// <param name="sourcePoint">소스 포인트</param> /// <returns>화면 관리자</returns> public static ScreenManager GetScreenManager(System.Windows.Point sourcePoint) { int sourceX = (int)Math.Round(sourcePoint.X); int sourceY = (int)Math.Round(sourcePoint.Y); System.Drawing.Point targetPoint = new System.Drawing.Point(sourceX, sourceY); Screen screen = Screen.FromPoint(targetPoint); ScreenManager screenManager = new ScreenManager(screen); return screenManager; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Instance //////////////////////////////////////////////////////////////////////////////// Internal #region 생성자 - ScreenManager(screen) /// <summary> /// 생성자 /// </summary> /// <param name="screen">화면</param> internal ScreenManager(Screen screen) { this.screen = screen; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 윈도우 시작 위치 설정하기 - SetWindowStartupPosition(window) /// <summary> /// 윈도우 시작 위치 설정하기 /// </summary> /// <param name="window">윈도우</param> public static void SetWindowStartupPosition(Window window) { if(window.WindowStartupLocation == WindowStartupLocation.Manual) { return; } switch(window.WindowStartupLocation) { case WindowStartupLocation.CenterOwner : Window ownerWindow = window.Owner; if(ownerWindow == null) { return; } SetWindowCenterLocation(window, new Rect(ownerWindow.Left, ownerWindow.Top, ownerWindow.Width, ownerWindow.Height)); break; case WindowStartupLocation.CenterScreen : ScreenManager screenManager = ScreenManager.GetScreenManager(window); SetWindowCenterLocation(window, screenManager.WorkingArea); break; } window.Visibility = Visibility.Visible; } #endregion ////////////////////////////////////////////////////////////////////////////////////////// Private #region WPF 사각형 구하기 - GetRect(rectangle) /// <summary> /// WPF 사각형 구하기 /// </summary> /// <param name="rectangle">WinForm 사각형</param> /// <returns>WPF 사각형</returns> private Rect GetRect(Rectangle rectangle) { return new Rect { X = rectangle.X, Y = rectangle.Y, Width = rectangle.Width, Height = rectangle.Height }; } #endregion #region 윈도우 중앙 위치 설정하기 - SetWindowCenterLocation(window, sourceRect) /// <summary> /// 윈도우 중앙 위치 설정하기 /// </summary> /// <param name="window">윈도우</param> /// <param name="sourceRect">소스 사각형</param> private static void SetWindowCenterLocation(Window window, Rect sourceRect) { var centerLeft = sourceRect.X + (sourceRect.Width / 2); var centerTop = sourceRect.Y + (sourceRect.Height / 2); window.Left = centerLeft - (window.Width / 2); window.Top = centerTop - (window.Height / 2); } #endregion } } |