使用物理尺寸进行设置

This commit is contained in:
艾竹
2023-02-11 23:51:48 +08:00
parent 59bfed341d
commit f99fd93b3f
13 changed files with 333 additions and 231 deletions

View File

@@ -106,7 +106,22 @@ namespace AIStudio.Wpf.DiagramDesigner
}
set
{
SetProperty(ref _pageSize, value);
if (SetProperty(ref _pageSize, value))
{
RaisePropertyChanged(nameof(PhysicalPageSize));
}
}
}
public Size PhysicalPageSize
{
get
{
return new Size(ScreenHelper.WidthToMm(PageSize.Width), ScreenHelper.WidthToMm(PageSize.Height));
}
set
{
PageSize = new Size(ScreenHelper.MmToWidth(value.Width), ScreenHelper.MmToWidth(value.Height));
}
}
@@ -202,6 +217,7 @@ namespace AIStudio.Wpf.DiagramDesigner
set
{
_gridCellSize.Width = value;
RaisePropertyChanged(nameof(PhysicalGridCellWidth));
RaisePropertyChanged(nameof(GridCellSize));
}
}
@@ -214,11 +230,48 @@ namespace AIStudio.Wpf.DiagramDesigner
}
set
{
_gridCellSize.Height = value;
_gridCellSize.Height = value;
RaisePropertyChanged(nameof(PhysicalGridCellHeight));
RaisePropertyChanged(nameof(GridCellSize));
}
}
public Size PhysicalGridCellSize
{
get
{
return new Size(ScreenHelper.WidthToMm(GridCellSize.Width), ScreenHelper.WidthToMm(GridCellSize.Height));
}
set
{
GridCellSize = new Size(ScreenHelper.MmToWidth(value.Width), ScreenHelper.MmToWidth(value.Height));
}
}
public double PhysicalGridCellWidth
{
get
{
return ScreenHelper.WidthToMm(GridCellWidth);
}
set
{
GridCellWidth = ScreenHelper.MmToWidth(value);
}
}
public double PhysicalGridCellHeight
{
get
{
return ScreenHelper.WidthToMm(GridCellHeight);
}
set
{
GridCellHeight = ScreenHelper.MmToWidth(value);
}
}
private Color _pageBackground = Colors.White;
public Color PageBackground
{
@@ -297,6 +350,42 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public Size PhysicalGridMarginSize
{
get
{
return new Size(ScreenHelper.WidthToMm(GridMarginSize.Width), ScreenHelper.WidthToMm(GridMarginSize.Height));
}
set
{
GridMarginSize = new Size(ScreenHelper.MmToWidth(value.Width), ScreenHelper.MmToWidth(value.Height));
}
}
public double PhysicalGridMarginWidth
{
get
{
return ScreenHelper.WidthToMm(GridMarginWidth);
}
set
{
GridMarginWidth = ScreenHelper.MmToWidth(value);
}
}
public double PhysicalGridMarginHeight
{
get
{
return ScreenHelper.WidthToMm(GridMarginHeight);
}
set
{
GridMarginHeight = ScreenHelper.MmToWidth(value);
}
}
private double _zoomValue = 1;
[Browsable(false)]
public double ZoomValue
@@ -414,11 +503,6 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
} = new DiagramOption();
/// <summary>
/// 用于wpf大小与物理像素之间转换
/// </summary>
public double ScreenScale { get; set; } = 1;
private double OffsetX = 10;
private double OffsetY = 10;
#endregion
@@ -601,8 +685,6 @@ namespace AIStudio.Wpf.DiagramDesigner
private DoCommandManager DoCommandManager = new DoCommandManager();
public DiagramViewModel()
{
SetScreenScale();
CreateNewDiagramCommand = new SimpleCommand(ExecuteEnable, ExecuteCreateNewDiagramCommand);
AddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteAddItemCommand);
DirectAddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteDirectAddItemCommand);
@@ -645,7 +727,21 @@ namespace AIStudio.Wpf.DiagramDesigner
Items.CollectionChanged += Items_CollectionChanged;
}
public bool ExecuteEnable(object para)
public DiagramViewModel(DiagramItem diagramItem) :this()
{
DiagramType = diagramItem.DiagramType;
ShowGrid = diagramItem.ShowGrid;
PhysicalGridCellSize = diagramItem.PhysicalGridCellSize;
CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
CellVerticalAlignment = diagramItem.CellVerticalAlignment;
PageSizeOrientation = diagramItem.PageSizeOrientation;
PhysicalPageSize = diagramItem.PhysicalPageSize;
PageSizeType = diagramItem.PageSizeType;
PhysicalGridMarginSize = diagramItem.PhysicalGridMarginSize;
GridColor = diagramItem.GridColor;
}
public bool ExecuteEnable(object para)
{
return IsReadOnly == false;
}
@@ -1825,13 +1921,6 @@ namespace AIStudio.Wpf.DiagramDesigner
{
}
#region wpf大小与物理像素之间转换
public void SetScreenScale()
{
ScreenScale = ScreenHelper.ResetScreenScale();
}
#endregion
}