mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-22 17:58:33 +08:00
右键拖动画布
This commit is contained in:
@@ -309,7 +309,7 @@
|
||||
<Setter Property="Width"
|
||||
Value="{Binding ItemWidth}" />
|
||||
<Setter Property="Height"
|
||||
Value="{Binding ItemHeight}" />
|
||||
Value="{Binding ItemHeight}" />
|
||||
<Setter Property="SnapsToDevicePixels"
|
||||
Value="True" />
|
||||
<Setter Property="ContentTemplate">
|
||||
@@ -842,18 +842,18 @@
|
||||
<ControlTemplate>
|
||||
<Grid>
|
||||
<ItemsControl ItemsSource="{Binding Items}"
|
||||
ItemContainerStyleSelector="{x:Static dd:DesignerItemsControlItemStyleSelector.Instance}">
|
||||
ItemContainerStyleSelector="{x:Static dd:DesignerItemsControlItemStyleSelector.Instance}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<dd:DesignerCanvas
|
||||
Height="{Binding PageSize.Height}"
|
||||
Width="{Binding PageSize.Width}"
|
||||
ShowGrid="{Binding ShowGrid}"
|
||||
GridCellSize="{Binding GridCellSize}"
|
||||
GridMarginSize="{Binding GridMarginSize}"
|
||||
GridColor="{Binding GridColor}"
|
||||
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
|
||||
AllowDrop="{Binding AllowDrop}">
|
||||
Height="{Binding PageSize.Height}"
|
||||
Width="{Binding PageSize.Width}"
|
||||
ShowGrid="{Binding ShowGrid}"
|
||||
GridCellSize="{Binding GridCellSize}"
|
||||
GridMarginSize="{Binding GridMarginSize}"
|
||||
GridColor="{Binding GridColor}"
|
||||
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
|
||||
AllowDrop="{Binding AllowDrop}">
|
||||
<dd:DesignerCanvas.LayoutTransform>
|
||||
<ScaleTransform ScaleX="{Binding ZoomValue}" ScaleY="{Binding ZoomValue}" />
|
||||
</dd:DesignerCanvas.LayoutTransform>
|
||||
@@ -876,18 +876,18 @@
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl x:Name="diagram" ItemsSource="{Binding Items}"
|
||||
ItemContainerStyleSelector="{x:Static dd:DesignerItemsControlItemStyleSelector.Instance}">
|
||||
ItemContainerStyleSelector="{x:Static dd:DesignerItemsControlItemStyleSelector.Instance}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<dd:DesignerCanvas
|
||||
Height="{Binding PageSize.Height}"
|
||||
Width="{Binding PageSize.Width}"
|
||||
ShowGrid="{Binding ShowGrid}"
|
||||
GridCellSize="{Binding GridCellSize}"
|
||||
GridMarginSize="{Binding GridMarginSize}"
|
||||
GridColor="{Binding GridColor}"
|
||||
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
|
||||
AllowDrop="{Binding AllowDrop}">
|
||||
Height="{Binding PageSize.Height}"
|
||||
Width="{Binding PageSize.Width}"
|
||||
ShowGrid="{Binding ShowGrid}"
|
||||
GridCellSize="{Binding GridCellSize}"
|
||||
GridMarginSize="{Binding GridMarginSize}"
|
||||
GridColor="{Binding GridColor}"
|
||||
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
|
||||
AllowDrop="{Binding AllowDrop}">
|
||||
<dd:DesignerCanvas.LayoutTransform>
|
||||
<ScaleTransform ScaleX="{Binding ZoomValue}" ScaleY="{Binding ZoomValue}" />
|
||||
</dd:DesignerCanvas.LayoutTransform>
|
||||
|
||||
@@ -27,8 +27,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
this.Resources.MergedDictionaries.Add(ResourceDictionary);
|
||||
}
|
||||
|
||||
this.Focusable = true;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ResourceDictionaryProperty = DependencyProperty.Register(nameof(ResourceDictionary), typeof(ResourceDictionary), typeof(DiagramControl), new UIPropertyMetadata(null, OnResourceDictionaryChanged));
|
||||
@@ -64,28 +62,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnPreviewKeyDown(e);
|
||||
|
||||
e.Handled = DiagramViewModel.ExecuteShortcut(e);
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseWheel(e);
|
||||
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
|
||||
&& Keyboard.IsKeyDown(Key.RightCtrl) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newZoomValue = DiagramViewModel.ZoomValue + (e.Delta > 0 ? 0.1 : -0.1);
|
||||
|
||||
DiagramViewModel.ZoomValue = Math.Max(Math.Min(newZoomValue, DiagramViewModel.MaximumZoomValue), DiagramViewModel.MinimumZoomValue);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
HorizontalContentAlignment="{Binding FontViewModel.HorizontalAlignment}"
|
||||
VerticalContentAlignment="{Binding FontViewModel.VerticalAlignment}"
|
||||
TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"
|
||||
AcceptsReturn="True"
|
||||
AcceptsReturn="True"
|
||||
Focusable="False"
|
||||
dd:ControlAttachProperty.Watermark="{Binding Path=(dd:ControlAttachProperty.Watermark),RelativeSource={RelativeSource AncestorType={x:Type dd:TextControl}}}"
|
||||
Style="{StaticResource WaterTextBoxWithEffect}" Visibility="Collapsed">
|
||||
</TextBox>
|
||||
|
||||
</TextBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -18,15 +18,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
/// </summary>
|
||||
public partial class TextControl : UserControl
|
||||
{
|
||||
//public static readonly DependencyProperty DoubleEditProperty = DependencyProperty.Register(
|
||||
// nameof(DoubleEdit), typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(
|
||||
// true));
|
||||
|
||||
//public bool DoubleEdit
|
||||
//{
|
||||
// get => (bool)GetValue(DoubleEditProperty);
|
||||
// set => SetValue(DoubleEditProperty, value);
|
||||
//}
|
||||
|
||||
public TextControl()
|
||||
{
|
||||
@@ -62,6 +53,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (this.DataContext is ISelectable selectable)
|
||||
{
|
||||
selectable.IsEditing = PART_ShowText.IsVisible;
|
||||
PART_ShowText.Focusable = PART_ShowText.IsVisible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,39 +81,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
|
||||
//{
|
||||
// base.OnPreviewMouseDown(e);
|
||||
|
||||
// if (DoubleEdit == false)
|
||||
// {
|
||||
// PART_ShowText.Visibility = Visibility.Visible;
|
||||
// PART_TextBlock.Visibility = Visibility.Collapsed;
|
||||
// PART_ShowText.Focus();
|
||||
// if (!string.IsNullOrEmpty(PART_ShowText.Text))
|
||||
// {
|
||||
// PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e)
|
||||
//{
|
||||
// base.OnPreviewMouseDoubleClick(e);
|
||||
|
||||
// if (DoubleEdit == true)
|
||||
// {
|
||||
// PART_ShowText.Visibility = Visibility.Visible;
|
||||
// PART_TextBlock.Visibility = Visibility.Collapsed;
|
||||
// PART_ShowText.Focus();
|
||||
// if (!string.IsNullOrEmpty(PART_ShowText.Text))
|
||||
// {
|
||||
// PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public class ControlAttachProperty
|
||||
|
||||
Reference in New Issue
Block a user