优化了画布平移、缩放、改变尺寸

This commit is contained in:
fengjiayi
2024-09-10 11:49:56 +08:00
parent ce947d4472
commit ec6e09ced1
6 changed files with 92 additions and 178 deletions

View File

@@ -16,14 +16,6 @@
</StackPanel>
</Border>
<Thumb x:Name="ResizeTop" Cursor="SizeNS" Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Top"
DragDelta="ResizeTop_DragDelta"/>
<Thumb x:Name="ResizeBottom" Cursor="SizeNS" Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
DragDelta="ResizeBottom_DragDelta"/>
<Thumb x:Name="ResizeLeft" Cursor="SizeWE" Width="4" HorizontalAlignment="Left" VerticalAlignment="Stretch"
DragDelta="ResizeLeft_DragDelta"/>
<Thumb x:Name="ResizeRight" Cursor="SizeWE" Width="4" HorizontalAlignment="Right" VerticalAlignment="Stretch"
DragDelta="ResizeRight_DragDelta"/>
</Grid>
</local:NodeControlBase>

View File

@@ -16,7 +16,6 @@ namespace Serein.WorkBench.Node.View
private new readonly CompositeActionNode Node;
public ActionRegionControl() : base()
{
InitializeComponent();
}
@@ -27,38 +26,6 @@ namespace Serein.WorkBench.Node.View
base.Name = "动作组合节点";
}
#region
private void ResizeTop_DragDelta(object sender, DragDeltaEventArgs e)
{
double oldHeight = Height;
double newHeight = Math.Max(MinHeight, oldHeight - e.VerticalChange);
Height = newHeight;
Canvas.SetTop(this, Canvas.GetTop(this) + (oldHeight - newHeight));
}
private void ResizeBottom_DragDelta(object sender, DragDeltaEventArgs e)
{
double newHeight = Math.Max(MinHeight, Height + e.VerticalChange);
Height = newHeight;
}
private void ResizeLeft_DragDelta(object sender, DragDeltaEventArgs e)
{
double oldWidth = Width;
double newWidth = Math.Max(MinWidth, oldWidth - e.HorizontalChange);
Width = newWidth;
Canvas.SetLeft(this, Canvas.GetLeft(this) + (oldWidth - newWidth));
}
private void ResizeRight_DragDelta(object sender, DragDeltaEventArgs e)
{
double newWidth = Math.Max(MinWidth, Width + e.HorizontalChange);
Width = newWidth;
}
#endregion
public void AddAction(NodeControlBase node, bool isTask = false)
{
/*TextBlock actionText = new TextBlock

View File

@@ -20,14 +20,5 @@
<ListBox x:Name="ConditionsListBox" AllowDrop="True" Drop="ConditionsListBox_Drop"/>
</StackPanel>
</Border>
<Thumb x:Name="ResizeTop" Cursor="SizeNS" Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Top"
DragDelta="ResizeTop_DragDelta"/>
<Thumb x:Name="ResizeBottom" Cursor="SizeNS" Height="4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
DragDelta="ResizeBottom_DragDelta"/>
<Thumb x:Name="ResizeLeft" Cursor="SizeWE" Width="4" HorizontalAlignment="Left" VerticalAlignment="Stretch"
DragDelta="ResizeLeft_DragDelta"/>
<Thumb x:Name="ResizeRight" Cursor="SizeWE" Width="4" HorizontalAlignment="Right" VerticalAlignment="Stretch"
DragDelta="ResizeRight_DragDelta"/>
</Grid>
</local:NodeControlBase>

View File

@@ -23,36 +23,6 @@ namespace Serein.WorkBench.Node.View
InitializeComponent();
}
#region
private void ResizeTop_DragDelta(object sender, DragDeltaEventArgs e)
{
double oldHeight = Height;
double newHeight = Math.Max(MinHeight, oldHeight - e.VerticalChange);
Height = newHeight;
Canvas.SetTop(this, Canvas.GetTop(this) + (oldHeight - newHeight));
}
private void ResizeBottom_DragDelta(object sender, DragDeltaEventArgs e)
{
double newHeight = Math.Max(MinHeight, Height + e.VerticalChange);
Height = newHeight;
}
private void ResizeLeft_DragDelta(object sender, DragDeltaEventArgs e)
{
double oldWidth = Width;
double newWidth = Math.Max(MinWidth, oldWidth - e.HorizontalChange);
Width = newWidth;
Canvas.SetLeft(this, Canvas.GetLeft(this) + (oldWidth - newWidth));
}
private void ResizeRight_DragDelta(object sender, DragDeltaEventArgs e)
{
double newWidth = Math.Max(MinWidth, Width + e.HorizontalChange);
Width = newWidth;
}
#endregion
/// <summary>