@@ -465,7 +465,52 @@ private void OnPreviewMouseMove(object sender, MouseEventArgs e)
465465
466466 private void OnMouseDown ( object sender , MouseButtonEventArgs e )
467467 {
468- if ( e . ChangedButton == MouseButton . Left ) DragMove ( ) ;
468+ if ( e . ChangedButton == MouseButton . Left )
469+ {
470+ try
471+ {
472+ if ( WindowState == WindowState . Maximized )
473+ {
474+ // 최대화된 창의 크기 기준으로 비율 계산
475+ double maxWidth = this . ActualWidth ;
476+ double maxHeight = this . ActualHeight ;
477+ var mousePos = e . GetPosition ( this ) ;
478+ double xRatio = mousePos . X / maxWidth ;
479+ double yRatio = mousePos . Y / maxHeight ;
480+
481+ // 현재 모니터 정보
482+ var screen = Screen . FromHandle ( new WindowInteropHelper ( this ) . Handle ) ;
483+ var workingArea = screen . WorkingArea ;
484+ var screenLeftTop = Win32Helper . TransformPixelsToDIP ( this , workingArea . X , workingArea . Y ) ;
485+
486+ // Normal로 전환
487+ WindowState = WindowState . Normal ;
488+
489+ Dispatcher . BeginInvoke ( new Action ( ( ) =>
490+ {
491+ double normalWidth = Width ;
492+ double normalHeight = Height ;
493+
494+ // 최대화된 창 크기와 Normal 창 크기 차이만큼 비율 적용
495+ Left = screenLeftTop . X + ( maxWidth - normalWidth ) * xRatio ;
496+ Top = screenLeftTop . Y + ( maxHeight - normalHeight ) * yRatio ;
497+
498+ if ( Mouse . LeftButton == MouseButtonState . Pressed )
499+ {
500+ DragMove ( ) ;
501+ }
502+ } ) , DispatcherPriority . ApplicationIdle ) ;
503+ }
504+ else
505+ {
506+ DragMove ( ) ;
507+ }
508+ }
509+ catch ( InvalidOperationException )
510+ {
511+ // 무시
512+ }
513+ }
469514 }
470515
471516 #endregion
0 commit comments