/// 現在編集中のレイアウト要素のクリッピング領域/Fitオプションを変更する private void CommonAreaSelect(bool changeWindowType = false, WindowTypes nextWindowType = WindowTypes.Normal) { if (!App.Profile.Current.IsWindowValid) { Debug.WriteLine("Invalid Window", "Area.CommonAreaSelect"); return; } //----------------------------------------------------------------- // ダイアログの準備 //----------------------------------------------------------------- var dialog = new AreaSelectWindow(); // サイズ(DPI補正) var screenRect = App.Profile.Current.ScreenClippingRectWithFit; var wpfLeftTop = this.DeviceToWPFPoint(new Point(screenRect.X, screenRect.Y)); var wpfRightBottom = this.DeviceToWPFPoint(new Point(screenRect.Right, screenRect.Bottom)); dialog.Left = wpfLeftTop.X; dialog.Top = wpfLeftTop.Y; dialog.Width = wpfRightBottom.X - wpfLeftTop.X; dialog.Height = wpfRightBottom.Y - wpfLeftTop.Y; // カラーの変更 Brush border, background; this.GetWindowTypesBrushes( App.Profile.Current.WindowType, nextWindowType, out border, out background); dialog.WindowBorder.BorderBrush = border; dialog.WindowGrid.Background = background; // ダイアログの表示 var result = dialog.ShowDialog(); if (!result.HasValue || !(bool)result) { return; } // 結果をScreenRectにまとめる(DPI補正) var deviceLeftTop = this.WPFToDevicePoint(new Point(dialog.Left, dialog.Top)); var deviceRightBottom = this.WPFToDevicePoint(new Point(dialog.Left + dialog.Width, dialog.Top + dialog.Height)); var nextScreenRect = new ScreenRect( (int)deviceLeftTop.X, (int)deviceLeftTop.Y, (int)(deviceRightBottom.X - deviceLeftTop.X), (int)(deviceRightBottom.Y - deviceLeftTop.Y)); // Profile更新 App.Profile.Open(); if (changeWindowType) { switch (nextWindowType) { case WindowTypes.DXGI: { App.Profile.Current.SetWindowToDXGI(); break; } case WindowTypes.Desktop: { App.Profile.Current.SetWindowToDesktop(); break; } default: Debug.Fail("switch"); throw new System.ArgumentException(); } } App.Profile.Current.SetClippingRectByScreenRect(nextScreenRect); App.Profile.Current.ClearBackupParameters(); App.Profile.Close(); //----------------------------------------------------------------- // Notify self this.OnCurrentLayoutElementChanged(); // Notify other controls if (changeWindowType) { Commands.TargetWindowChanged.Execute(null, this); } else { // TargetWindowの更新は必要ないのでプレビューのみ更新 Commands.CurrentLayoutElementVisualChanged.Execute(null, this); } //----------------------------------------------------------------- }
/// 現在編集中のレイアウト要素のクリッピング領域/Fitオプションを変更する private void CommonAreaSelect(bool changeWindowType = false, WindowTypes nextWindowType = WindowTypes.Normal) { if (!App.Profile.Current.IsWindowValid) { Debug.WriteLine("Invalid Window", "Area.CommonAreaSelect"); return; } //----------------------------------------------------------------- // ダイアログの準備 //----------------------------------------------------------------- var dialog = new AreaSelectWindow(); // サイズ var screenRect = App.Profile.Current.ScreenClippingRectWithFit; dialog.Left = screenRect.X; dialog.Top = screenRect.Y; dialog.Width = screenRect.Width; dialog.Height = screenRect.Height; // カラーの変更 Brush border, background; this.GetWindowTypesBrushes( App.Profile.Current.WindowType, nextWindowType, out border, out background); dialog.WindowBorder.BorderBrush = border; dialog.WindowGrid.Background = background; // ダイアログの表示 var result = dialog.ShowDialog(); if (!result.HasValue || !(bool)result) return; // 結果をScreenRectにまとめる var nextScreenRect = new ScreenRect( (int)dialog.Left, (int)dialog.Top, (int)dialog.Width, (int)dialog.Height); // Profile更新 App.Profile.Open(); if (changeWindowType) { switch (nextWindowType) { case WindowTypes.DXGI: { App.Profile.Current.SetWindowToDXGI(); break; } case WindowTypes.Desktop: { App.Profile.Current.SetWindowToDesktop(); break; } default: Debug.Fail("switch"); throw new System.ArgumentException(); } } App.Profile.Current.SetClippingRectByScreenRect(nextScreenRect); App.Profile.Current.ClearBackupParameters(); App.Profile.Close(); //----------------------------------------------------------------- // Notify self this.OnCurrentLayoutElementChanged(); // Notify other controls if (changeWindowType) { Commands.TargetWindowChanged.Execute(null, this); } else { // TargetWindowの更新は必要ないのでプレビューのみ更新 Commands.CurrentLayoutElementVisualChanged.Execute(null, this); } //----------------------------------------------------------------- }