개정판 71bfd53e
issue #737 WindowState.Maximized 일 때 화면 이동이 안되는 현상 수정
KCOM/MainWindow.xaml | ||
---|---|---|
22 | 22 |
<RowDefinition Height="Auto"/> |
23 | 23 |
<RowDefinition Height="*"/> |
24 | 24 |
</Grid.RowDefinitions> |
25 |
<Border VerticalAlignment="Stretch" MouseLeftButtonDown="WindowDragEvent" Background="{DynamicResource KCOMColor_TopMenubackgroundBrush}"> |
|
25 |
<Border VerticalAlignment="Stretch" MouseLeftButtonDown="WindowDragEvent" Background="{DynamicResource KCOMColor_TopMenubackgroundBrush}" |
|
26 |
MouseLeftButtonUp="WindowDragEventUp" MouseMove="WindowDragEventMove"> |
|
26 | 27 |
<Grid> |
27 | 28 |
<StackPanel Orientation="Horizontal" Opacity="0.6" Margin="5,0" Visibility="Collapsed"> |
28 | 29 |
<telerik:RadRibbonButton SmallImage="/KCOM;component/Resources/Images/MenuImage/save.png" telerik:StyleManager.Theme="Office2016"/> |
KCOM/MainWindow.xaml.cs | ||
---|---|---|
5 | 5 |
using System.Collections.Generic; |
6 | 6 |
using System.IO; |
7 | 7 |
using System.Linq; |
8 |
using System.Runtime.InteropServices; |
|
8 | 9 |
using System.Text; |
9 | 10 |
using System.Windows; |
10 | 11 |
using System.Windows.Controls; |
... | ... | |
143 | 144 |
//this.dzMainMenu.SetView(App.ViewInfo); |
144 | 145 |
} |
145 | 146 |
|
147 |
|
|
148 |
bool restoreIfMove = false; |
|
149 |
|
|
146 | 150 |
private void WindowDragEvent(object sender, MouseButtonEventArgs e) |
147 | 151 |
{ |
148 |
if (e.ClickCount >= 2)
|
|
152 |
if (e.ClickCount == 2)
|
|
149 | 153 |
{ |
150 |
switch (this.WindowState) |
|
154 |
if ((ResizeMode == ResizeMode.CanResize) || |
|
155 |
(ResizeMode == ResizeMode.CanResizeWithGrip)) |
|
151 | 156 |
{ |
152 |
case WindowState.Normal: |
|
153 |
this.WindowState = WindowState.Maximized; |
|
154 |
break; |
|
155 |
case WindowState.Minimized: |
|
156 |
break; |
|
157 |
case WindowState.Maximized: |
|
158 |
this.WindowState = WindowState.Normal; |
|
159 |
break; |
|
160 |
default: |
|
161 |
break; |
|
157 |
SwitchState(); |
|
162 | 158 |
} |
163 | 159 |
} |
164 | 160 |
else |
165 | 161 |
{ |
162 |
if (WindowState == WindowState.Maximized) |
|
163 |
{ |
|
164 |
restoreIfMove = true; |
|
165 |
} |
|
166 |
|
|
166 | 167 |
this.DragMove(); |
167 | 168 |
} |
168 | 169 |
} |
169 | 170 |
|
171 |
private void WindowDragEventUp(object sender, MouseButtonEventArgs e) |
|
172 |
{ |
|
173 |
restoreIfMove = false; |
|
174 |
} |
|
175 |
|
|
176 |
private void WindowDragEventMove(object sender, MouseEventArgs e) |
|
177 |
{ |
|
178 |
if (restoreIfMove) |
|
179 |
{ |
|
180 |
if (Mouse.LeftButton == MouseButtonState.Pressed) |
|
181 |
{ |
|
182 |
//this.WindowState = WindowState.Normal; |
|
183 |
|
|
184 |
restoreIfMove = false; |
|
185 |
|
|
186 |
double percentHorizontal = e.GetPosition(this).X / ActualWidth; |
|
187 |
double targetHorizontal = RestoreBounds.Width * percentHorizontal; |
|
188 |
|
|
189 |
double percentVertical = e.GetPosition(this).Y / ActualHeight; |
|
190 |
double targetVertical = RestoreBounds.Height * percentVertical; |
|
191 |
|
|
192 |
POINT lMousePosition; |
|
193 |
GetCursorPos(out lMousePosition); |
|
194 |
|
|
195 |
Left = lMousePosition.X - targetHorizontal; |
|
196 |
Top = lMousePosition.Y - targetVertical; |
|
197 |
|
|
198 |
|
|
199 |
WindowState = WindowState.Normal; |
|
200 |
|
|
201 |
this.DragMove(); |
|
202 |
} |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
[DllImport("user32.dll")] |
|
207 |
[return: MarshalAs(UnmanagedType.Bool)] |
|
208 |
static extern bool GetCursorPos(out POINT lpPoint); |
|
209 |
|
|
210 |
[StructLayout(LayoutKind.Sequential)] |
|
211 |
public struct POINT |
|
212 |
{ |
|
213 |
public int X; |
|
214 |
public int Y; |
|
215 |
|
|
216 |
public POINT(int x, int y) |
|
217 |
{ |
|
218 |
this.X = x; |
|
219 |
this.Y = y; |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
private void SwitchState() |
|
224 |
{ |
|
225 |
switch (WindowState) |
|
226 |
{ |
|
227 |
case WindowState.Normal: |
|
228 |
{ |
|
229 |
WindowState = WindowState.Maximized; |
|
230 |
break; |
|
231 |
} |
|
232 |
case WindowState.Maximized: |
|
233 |
{ |
|
234 |
WindowState = WindowState.Normal; |
|
235 |
break; |
|
236 |
} |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
170 | 240 |
private void RadButton_Click(object sender, RoutedEventArgs e) |
171 | 241 |
{ |
172 | 242 |
Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton; |
내보내기 Unified diff