|
3 | 3 | using System.Collections.Specialized; |
4 | 4 | using System.ComponentModel; |
5 | 5 | using System.Linq; |
| 6 | +using System.Runtime.InteropServices; |
6 | 7 | using System.Windows; |
7 | 8 | using System.Windows.Controls; |
8 | 9 | using System.Windows.Input; |
| 10 | +using System.Windows.Interop; |
9 | 11 | using System.Windows.Media; |
10 | 12 | using System.Xml; |
11 | 13 | using Dynamo.Configuration; |
@@ -50,6 +52,16 @@ public partial class ScriptEditorWindow : ModelessChildWindow |
50 | 52 | // Reasonable max and min font size values for zooming limits |
51 | 53 | private const double FONT_MAX_SIZE = 60d; |
52 | 54 | private const double FONT_MIN_SIZE = 5d; |
| 55 | + // Win32 system command and hit-test constants used for resizing |
| 56 | + private const int WM_SYSCOMMAND = 0x0112; |
| 57 | + private const int SC_SIZE = 0xF000; |
| 58 | + private const int HTBOTTOMRIGHT = 0x0008; |
| 59 | + |
| 60 | + /// <summary> |
| 61 | + /// Sends a Win32 message to forward a system resize command when the custom resize grip is clicked |
| 62 | + /// </summary> |
| 63 | + [DllImport("user32.dll")] |
| 64 | + private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); |
53 | 65 |
|
54 | 66 | private const double pythonZoomScalingSliderMaximum = 300d; |
55 | 67 | private const double pythonZoomScalingSliderMinimum = 25d; |
@@ -239,6 +251,7 @@ internal void DockWindow() |
239 | 251 | editor.IsModified = !IsSaved; |
240 | 252 |
|
241 | 253 | dynamoView.DockWindowInSideBar(this, NodeModel, titleBar); |
| 254 | + WindowResizeHandle.Visibility = Visibility.Collapsed; |
242 | 255 |
|
243 | 256 | Analytics.TrackEvent( |
244 | 257 | Actions.Dock, |
@@ -676,11 +689,13 @@ private void ToggleButtons(bool toggle) |
676 | 689 | { |
677 | 690 | this.MaximizeButton.Visibility = Visibility.Collapsed; |
678 | 691 | this.NormalizeButton.Visibility = Visibility.Visible; |
| 692 | + this.WindowResizeHandle.Visibility = Visibility.Collapsed; |
679 | 693 | } |
680 | 694 | else |
681 | 695 | { |
682 | 696 | this.MaximizeButton.Visibility = Visibility.Visible; |
683 | 697 | this.NormalizeButton.Visibility = Visibility.Collapsed; |
| 698 | + this.WindowResizeHandle.Visibility = Visibility.Visible; |
684 | 699 | } |
685 | 700 | } |
686 | 701 |
|
@@ -796,6 +811,17 @@ private void EditText_OnPreviewKeyDown(object sender, KeyEventArgs e) |
796 | 811 | IsEnterHit = false; |
797 | 812 | } |
798 | 813 | } |
799 | | - #endregion |
| 814 | + |
| 815 | + // Handles clicks on the custom resize grip and forwards them as a Win32 bottom-right resize command |
| 816 | + private void WindowResizeHandle_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
| 817 | + { |
| 818 | + if (WindowState != WindowState.Normal) |
| 819 | + return; |
| 820 | + |
| 821 | + var helper = new WindowInteropHelper(this); |
| 822 | + SendMessage(helper.Handle, WM_SYSCOMMAND, (IntPtr)(SC_SIZE + HTBOTTOMRIGHT), IntPtr.Zero); |
| 823 | + e.Handled = true; |
| 824 | + } |
| 825 | + #endregion |
800 | 826 | } |
801 | 827 | } |
0 commit comments