Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Width="600"
MinWidth="500"
MinHeight="450"
ResizeMode="CanResizeWithGrip"
ResizeMode="CanResize"
Style="{DynamicResource DynamoWindowStyle}"
AllowsTransparency="True"
Background="Transparent"
Expand Down Expand Up @@ -457,6 +457,33 @@
</Grid>
</Border>
</Grid>
<Border x:Name="WindowResizeHandle"
Grid.Row="4"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="11"
Height="11"
Margin="0 0 3 3"
Cursor="SizeNWSE"
Background="Transparent"
MouseLeftButtonDown="WindowResizeHandle_OnMouseLeftButtonDown">
<Canvas HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="11"
Height="11"
Margin="0">
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9" Canvas.Top="3"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9" Canvas.Top="6"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9" Canvas.Top="9"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="6" Canvas.Top="3"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="6" Canvas.Top="6"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="6" Canvas.Top="9"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="3" Canvas.Top="6"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="3" Canvas.Top="9"/>
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Top="9"/>
</Canvas>
</Border>
</Grid>
</Border>
</Grid>
Expand Down
28 changes: 27 additions & 1 deletion src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Xml;
using Dynamo.Configuration;
Expand Down Expand Up @@ -50,6 +52,16 @@ public partial class ScriptEditorWindow : ModelessChildWindow
// Reasonable max and min font size values for zooming limits
private const double FONT_MAX_SIZE = 60d;
private const double FONT_MIN_SIZE = 5d;
// Win32 system command and hit-test constants used for resizing
private const int WM_SYSCOMMAND = 0x0112;
private const int SC_SIZE = 0xF000;
private const int HTBOTTOMRIGHT = 0x0008;
Comment on lines +56 to +58
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant names follow Win32 convention but are not sufficiently descriptive for C# code. Consider renaming to WindowsMessageSystemCommand, SystemCommandSize, and HitTestBottomRight respectively, or add XML documentation comments explaining what these magic values represent.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are standard Win32 names. I've added comment above to clarify their use


/// <summary>
/// Sends a Win32 message to forward a system resize command when the custom resize grip is clicked
/// </summary>
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

private const double pythonZoomScalingSliderMaximum = 300d;
private const double pythonZoomScalingSliderMinimum = 25d;
Expand Down Expand Up @@ -230,6 +242,7 @@ internal void DockWindow()
editor.IsModified = !IsSaved;

dynamoView.DockWindowInSideBar(this, NodeModel, titleBar);
WindowResizeHandle.Visibility = Visibility.Collapsed;

Analytics.TrackEvent(
Actions.Dock,
Expand Down Expand Up @@ -677,11 +690,13 @@ private void ToggleButtons(bool toggle)
{
this.MaximizeButton.Visibility = Visibility.Collapsed;
this.NormalizeButton.Visibility = Visibility.Visible;
this.WindowResizeHandle.Visibility = Visibility.Collapsed;
}
else
{
this.MaximizeButton.Visibility = Visibility.Visible;
this.NormalizeButton.Visibility = Visibility.Collapsed;
this.WindowResizeHandle.Visibility = Visibility.Visible;
}
}

Expand Down Expand Up @@ -797,6 +812,17 @@ private void EditText_OnPreviewKeyDown(object sender, KeyEventArgs e)
IsEnterHit = false;
}
}
#endregion

// Handles clicks on the custom resize grip and forwards them as a Win32 bottom-right resize command
private void WindowResizeHandle_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (WindowState != WindowState.Normal)
return;

var helper = new WindowInteropHelper(this);
SendMessage(helper.Handle, WM_SYSCOMMAND, (IntPtr)(SC_SIZE + HTBOTTOMRIGHT), IntPtr.Zero);
e.Handled = true;
}
#endregion
}
}
Loading