实际尺寸之间转换

This commit is contained in:
艾竹
2023-02-11 22:20:24 +08:00
parent 86082cb788
commit 59bfed341d
14 changed files with 487 additions and 265 deletions

View File

@@ -206,7 +206,7 @@ namespace AIStudio.Wpf.Logical
if (connector.SourceConnectorInfo.DataItem is LogicalGateItemViewModelBase) if (connector.SourceConnectorInfo.DataItem is LogicalGateItemViewModelBase)
{ {
input.Value.ConnectorValue = connector.SourceConnectorInfo.ConnectorValue; input.Value.ConnectorValue = (connector.SourceConnectorInfo as LogicalConnectorInfo).ConnectorValue;
input.Value.ColorViewModel.FillColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color; input.Value.ColorViewModel.FillColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color;
connector.ColorViewModel.LineColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color; connector.ColorViewModel.LineColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color;

View File

@@ -59,7 +59,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
{ {
if (this.AutoSize) if (this.AutoSize)
{ {
return (double)(Unit == Unit.Cm ? DipHelper.DipToCm(this.ActualWidth) : DipHelper.DipToInch(this.ActualWidth)) / this.Zoom; return (double)(Unit == Unit.Cm ? ScreenHelper.WidthToCm(this.ActualWidth) : ScreenHelper.WidthToInch(this.ActualWidth)) / this.Zoom;
} }
else else
{ {
@@ -255,9 +255,9 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
var rect = new Rect(0, 0, RenderSize.Width, RenderSize.Height); var rect = new Rect(0, 0, RenderSize.Width, RenderSize.Height);
drawingContext.DrawRectangle(Background, null, rect); drawingContext.DrawRectangle(Background, null, rect);
double xDest = (Unit == Unit.Cm ? DipHelper.CmToDip(Length) : DipHelper.InchToDip(Length)) * this.Zoom; double xDest = (Unit == Unit.Cm ? ScreenHelper.CmToWidth(Length) : ScreenHelper.InchToWidth(Length)) * this.Zoom;
drawingContext.DrawRectangle(null, BorderPen, new Rect(new Point(0.0, 0.0), new Point(xDest, Height))); drawingContext.DrawRectangle(null, BorderPen, new Rect(new Point(0.0, 0.0), new Point(xDest, Height)));
double chip = Unit == Unit.Cm ? DipHelper.CmToDip(Chip) : DipHelper.InchToDip(Chip); double chip = Unit == Unit.Cm ? ScreenHelper.CmToWidth(Chip) : ScreenHelper.InchToWidth(Chip);
drawingContext.DrawLine(RedPen, new Point(chip, 0), new Point(chip, Height)); drawingContext.DrawLine(RedPen, new Point(chip, 0), new Point(chip, Height));
//画偏移位置之前的 //画偏移位置之前的
@@ -268,21 +268,21 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
double d; double d;
if (Unit == Unit.Cm) if (Unit == Unit.Cm)
{ {
d = DipHelper.CmToDip(dUnit) * this.Zoom; d = ScreenHelper.CmToWidth(dUnit) * this.Zoom;
if (dUnit < Length) if (dUnit < Length)
{ {
for (int i = 1; i <= 9; i++) for (int i = 1; i <= 9; i++)
{ {
if (i != 5) if (i != 5)
{ {
double dMm = DipHelper.CmToDip(dUnit + 0.1 * i) * this.Zoom; double dMm = ScreenHelper.CmToWidth(dUnit + 0.1 * i) * this.Zoom;
if (Marks == MarksLocation.Up) if (Marks == MarksLocation.Up)
drawingContext.DrawLine(ThinPen, new Point(dMm, 0), new Point(dMm, SegmentHeight / 3.0)); drawingContext.DrawLine(ThinPen, new Point(dMm, 0), new Point(dMm, SegmentHeight / 3.0));
else else
drawingContext.DrawLine(ThinPen, new Point(dMm, Height), new Point(dMm, Height - SegmentHeight / 3.0)); drawingContext.DrawLine(ThinPen, new Point(dMm, Height), new Point(dMm, Height - SegmentHeight / 3.0));
} }
} }
double dMiddle = DipHelper.CmToDip(dUnit + 0.5) * this.Zoom; double dMiddle = ScreenHelper.CmToWidth(dUnit + 0.5) * this.Zoom;
if (Marks == MarksLocation.Up) if (Marks == MarksLocation.Up)
drawingContext.DrawLine(p, new Point(dMiddle, 0), new Point(dMiddle, SegmentHeight * 2.0 / 3.0)); drawingContext.DrawLine(p, new Point(dMiddle, 0), new Point(dMiddle, SegmentHeight * 2.0 / 3.0));
else else
@@ -291,30 +291,30 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
} }
else else
{ {
d = DipHelper.InchToDip(dUnit) * this.Zoom; d = ScreenHelper.InchToWidth(dUnit) * this.Zoom;
if (dUnit < Length) if (dUnit < Length)
{ {
if (Marks == MarksLocation.Up) if (Marks == MarksLocation.Up)
{ {
double dQuarter = DipHelper.InchToDip(dUnit + 0.25) * this.Zoom; double dQuarter = ScreenHelper.InchToWidth(dUnit + 0.25) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(dQuarter, 0), drawingContext.DrawLine(ThinPen, new Point(dQuarter, 0),
new Point(dQuarter, SegmentHeight / 3.0)); new Point(dQuarter, SegmentHeight / 3.0));
double dMiddle = DipHelper.InchToDip(dUnit + 0.5) * this.Zoom; double dMiddle = ScreenHelper.InchToWidth(dUnit + 0.5) * this.Zoom;
drawingContext.DrawLine(p, new Point(dMiddle, 0), drawingContext.DrawLine(p, new Point(dMiddle, 0),
new Point(dMiddle, SegmentHeight * 2D / 3D)); new Point(dMiddle, SegmentHeight * 2D / 3D));
double d3Quarter = DipHelper.InchToDip(dUnit + 0.75) * this.Zoom; double d3Quarter = ScreenHelper.InchToWidth(dUnit + 0.75) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(d3Quarter, 0), drawingContext.DrawLine(ThinPen, new Point(d3Quarter, 0),
new Point(d3Quarter, SegmentHeight / 3.0)); new Point(d3Quarter, SegmentHeight / 3.0));
} }
else else
{ {
double dQuarter = DipHelper.InchToDip(dUnit + 0.25) * this.Zoom; double dQuarter = ScreenHelper.InchToWidth(dUnit + 0.25) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(dQuarter, Height), drawingContext.DrawLine(ThinPen, new Point(dQuarter, Height),
new Point(dQuarter, Height - SegmentHeight / 3.0)); new Point(dQuarter, Height - SegmentHeight / 3.0));
double dMiddle = DipHelper.InchToDip(dUnit + 0.5) * this.Zoom; double dMiddle = ScreenHelper.InchToWidth(dUnit + 0.5) * this.Zoom;
drawingContext.DrawLine(p, new Point(dMiddle, Height), drawingContext.DrawLine(p, new Point(dMiddle, Height),
new Point(dMiddle, Height - SegmentHeight * 2D / 3D)); new Point(dMiddle, Height - SegmentHeight * 2D / 3D));
double d3Quarter = DipHelper.InchToDip(dUnit + 0.75) * this.Zoom; double d3Quarter = ScreenHelper.InchToWidth(dUnit + 0.75) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(d3Quarter, Height), drawingContext.DrawLine(ThinPen, new Point(d3Quarter, Height),
new Point(d3Quarter, Height - SegmentHeight / 3.0)); new Point(d3Quarter, Height - SegmentHeight / 3.0));
} }
@@ -333,7 +333,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
CultureInfo.CurrentCulture, CultureInfo.CurrentCulture,
FlowDirection.LeftToRight, FlowDirection.LeftToRight,
new Typeface("Arial"), new Typeface("Arial"),
DipHelper.PtToDip(6), 9,
Brushes.DimGray); Brushes.DimGray);
ft.SetFontWeight(FontWeights.Regular); ft.SetFontWeight(FontWeights.Regular);
ft.TextAlignment = TextAlignment.Center; ft.TextAlignment = TextAlignment.Center;
@@ -353,21 +353,21 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
double d; double d;
if (Unit == Unit.Cm) if (Unit == Unit.Cm)
{ {
d = DipHelper.CmToDip(dUnit) * this.Zoom; d = ScreenHelper.CmToWidth(dUnit) * this.Zoom;
if (dUnit < Length) if (dUnit < Length)
{ {
for (int i = 1; i <= 9; i++) for (int i = 1; i <= 9; i++)
{ {
if (i != 5) if (i != 5)
{ {
double dMm = DipHelper.CmToDip(dUnit + 0.1 * i) * this.Zoom; double dMm = ScreenHelper.CmToWidth(dUnit + 0.1 * i) * this.Zoom;
if (Marks == MarksLocation.Up) if (Marks == MarksLocation.Up)
drawingContext.DrawLine(ThinPen, new Point(dMm, 0), new Point(dMm, SegmentHeight / 3.0)); drawingContext.DrawLine(ThinPen, new Point(dMm, 0), new Point(dMm, SegmentHeight / 3.0));
else else
drawingContext.DrawLine(ThinPen, new Point(dMm, Height), new Point(dMm, Height - SegmentHeight / 3.0)); drawingContext.DrawLine(ThinPen, new Point(dMm, Height), new Point(dMm, Height - SegmentHeight / 3.0));
} }
} }
double dMiddle = DipHelper.CmToDip(dUnit + 0.5) * this.Zoom; double dMiddle = ScreenHelper.CmToWidth(dUnit + 0.5) * this.Zoom;
if (Marks == MarksLocation.Up) if (Marks == MarksLocation.Up)
drawingContext.DrawLine(p, new Point(dMiddle, 0), new Point(dMiddle, SegmentHeight * 2.0 / 3.0)); drawingContext.DrawLine(p, new Point(dMiddle, 0), new Point(dMiddle, SegmentHeight * 2.0 / 3.0));
else else
@@ -376,30 +376,30 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
} }
else else
{ {
d = DipHelper.InchToDip(dUnit) * this.Zoom; d = ScreenHelper.InchToWidth(dUnit) * this.Zoom;
if (dUnit < Length) if (dUnit < Length)
{ {
if (Marks == MarksLocation.Up) if (Marks == MarksLocation.Up)
{ {
double dQuarter = DipHelper.InchToDip(dUnit + 0.25) * this.Zoom; double dQuarter = ScreenHelper.InchToWidth(dUnit + 0.25) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(dQuarter, 0), drawingContext.DrawLine(ThinPen, new Point(dQuarter, 0),
new Point(dQuarter, SegmentHeight / 3.0)); new Point(dQuarter, SegmentHeight / 3.0));
double dMiddle = DipHelper.InchToDip(dUnit + 0.5) * this.Zoom; double dMiddle = ScreenHelper.InchToWidth(dUnit + 0.5) * this.Zoom;
drawingContext.DrawLine(p, new Point(dMiddle, 0), drawingContext.DrawLine(p, new Point(dMiddle, 0),
new Point(dMiddle, SegmentHeight * 2D / 3D)); new Point(dMiddle, SegmentHeight * 2D / 3D));
double d3Quarter = DipHelper.InchToDip(dUnit + 0.75) * this.Zoom; double d3Quarter = ScreenHelper.InchToWidth(dUnit + 0.75) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(d3Quarter, 0), drawingContext.DrawLine(ThinPen, new Point(d3Quarter, 0),
new Point(d3Quarter, SegmentHeight / 3.0)); new Point(d3Quarter, SegmentHeight / 3.0));
} }
else else
{ {
double dQuarter = DipHelper.InchToDip(dUnit + 0.25) * this.Zoom; double dQuarter = ScreenHelper.InchToWidth(dUnit + 0.25) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(dQuarter, Height), drawingContext.DrawLine(ThinPen, new Point(dQuarter, Height),
new Point(dQuarter, Height - SegmentHeight / 3.0)); new Point(dQuarter, Height - SegmentHeight / 3.0));
double dMiddle = DipHelper.InchToDip(dUnit + 0.5) * this.Zoom; double dMiddle = ScreenHelper.InchToWidth(dUnit + 0.5) * this.Zoom;
drawingContext.DrawLine(p, new Point(dMiddle, Height), drawingContext.DrawLine(p, new Point(dMiddle, Height),
new Point(dMiddle, Height - SegmentHeight * 2D / 3D)); new Point(dMiddle, Height - SegmentHeight * 2D / 3D));
double d3Quarter = DipHelper.InchToDip(dUnit + 0.75) * this.Zoom; double d3Quarter = ScreenHelper.InchToWidth(dUnit + 0.75) * this.Zoom;
drawingContext.DrawLine(ThinPen, new Point(d3Quarter, Height), drawingContext.DrawLine(ThinPen, new Point(d3Quarter, Height),
new Point(d3Quarter, Height - SegmentHeight / 3.0)); new Point(d3Quarter, Height - SegmentHeight / 3.0));
} }
@@ -418,7 +418,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
CultureInfo.CurrentCulture, CultureInfo.CurrentCulture,
FlowDirection.LeftToRight, FlowDirection.LeftToRight,
new Typeface("Arial"), new Typeface("Arial"),
DipHelper.PtToDip(6), 9,
Brushes.DimGray); Brushes.DimGray);
ft.SetFontWeight(FontWeights.Regular); ft.SetFontWeight(FontWeights.Regular);
ft.TextAlignment = TextAlignment.Center; ft.TextAlignment = TextAlignment.Center;
@@ -442,11 +442,11 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
//Size desiredSize; //Size desiredSize;
//if (Unit == Unit.Cm) //if (Unit == Unit.Cm)
//{ //{
// desiredSize = new Size(DipHelper.CmToDip(Length), Height); // desiredSize = new Size(ScreenHelper.CmToWidth(Length), Height);
//} //}
//else //else
//{ //{
// desiredSize = new Size(DipHelper.InchToDip(Length), Height); // desiredSize = new Size(ScreenHelper.InchToWidth(Length), Height);
//} //}
//return desiredSize; //return desiredSize;
} }
@@ -474,145 +474,145 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
Up, Down Up, Down
} }
/// <summary> ///// <summary>
/// A helper class for DIP (Device Independent Pixels) conversion and scaling operations. ///// A helper class for DIP (Device Independent Pixels) conversion and scaling operations.
/// </summary> ///// </summary>
public static class DipHelper //public static class DipHelper
{ //{
/// <summary> // /// <summary>
/// Converts millimeters to DIP (Device Independant Pixels). // /// Converts millimeters to DIP (Device Independant Pixels).
/// </summary> // /// </summary>
/// <param name="mm">A millimeter value.</param> // /// <param name="mm">A millimeter value.</param>
/// <returns>A DIP value.</returns> // /// <returns>A DIP value.</returns>
public static double MmToDip(double mm) // public static double MmToDip(double mm)
{ // {
return CmToDip(mm / 10.0); // return CmToDip(mm / 10.0);
} // }
/// <summary> // /// <summary>
/// Converts centimeters to DIP (Device Independant Pixels). // /// Converts centimeters to DIP (Device Independant Pixels).
/// </summary> // /// </summary>
/// <param name="cm">A centimeter value.</param> // /// <param name="cm">A centimeter value.</param>
/// <returns>A DIP value.</returns> // /// <returns>A DIP value.</returns>
public static double CmToDip(double cm) // public static double CmToDip(double cm)
{ // {
return (cm * 96.0 / 2.54); // return (cm * 96.0 / 2.54);
} // }
/// <summary> // /// <summary>
/// Converts inches to DIP (Device Independant Pixels). // /// Converts inches to DIP (Device Independant Pixels).
/// </summary> // /// </summary>
/// <param name="inch">An inch value.</param> // /// <param name="inch">An inch value.</param>
/// <returns>A DIP value.</returns> // /// <returns>A DIP value.</returns>
public static double InchToDip(double inch) // public static double InchToDip(double inch)
{ // {
return (inch * 96.0); // return (inch * 96.0);
} // }
public static double DipToInch(double dip) // public static double DipToInch(double dip)
{ // {
return dip / 96D; // return dip / 96D;
} // }
/// <summary> // /// <summary>
/// Converts font points to DIP (Device Independant Pixels). // /// Converts font points to DIP (Device Independant Pixels).
/// </summary> // /// </summary>
/// <param name="pt">A font point value.</param> // /// <param name="pt">A font point value.</param>
/// <returns>A DIP value.</returns> // /// <returns>A DIP value.</returns>
public static double PtToDip(double pt) // public static double PtToDip(double pt)
{ // {
return (pt * 96.0 / 72.0); // return (pt * 96.0 / 72.0);
} // }
/// <summary> // /// <summary>
/// Converts DIP (Device Independant Pixels) to centimeters. // /// Converts DIP (Device Independant Pixels) to centimeters.
/// </summary> // /// </summary>
/// <param name="dip">A DIP value.</param> // /// <param name="dip">A DIP value.</param>
/// <returns>A centimeter value.</returns> // /// <returns>A centimeter value.</returns>
public static double DipToCm(double dip) // public static double DipToCm(double dip)
{ // {
return (dip * 2.54 / 96.0); // return (dip * 2.54 / 96.0);
} // }
/// <summary> // /// <summary>
/// Converts DIP (Device Independant Pixels) to millimeters. // /// Converts DIP (Device Independant Pixels) to millimeters.
/// </summary> // /// </summary>
/// <param name="dip">A DIP value.</param> // /// <param name="dip">A DIP value.</param>
/// <returns>A millimeter value.</returns> // /// <returns>A millimeter value.</returns>
public static double DipToMm(double dip) // public static double DipToMm(double dip)
{ // {
return DipToCm(dip) * 10.0; // return DipToCm(dip) * 10.0;
} // }
/// <summary> // /// <summary>
/// Gets the system DPI scale factor (compared to 96 dpi). // /// Gets the system DPI scale factor (compared to 96 dpi).
/// From http://blogs.msdn.com/jaimer/archive/2007/03/07/getting-system-dpi-in-wpf-app.aspx // /// From http://blogs.msdn.com/jaimer/archive/2007/03/07/getting-system-dpi-in-wpf-app.aspx
/// Should not be called before the Loaded event (else XamlException mat throw) // /// Should not be called before the Loaded event (else XamlException mat throw)
/// </summary> // /// </summary>
/// <returns>A Point object containing the X- and Y- scale factor.</returns> // /// <returns>A Point object containing the X- and Y- scale factor.</returns>
private static Point GetSystemDpiFactor() // private static Point GetSystemDpiFactor()
{ // {
PresentationSource source = PresentationSource.FromVisual(Application.Current.MainWindow); // PresentationSource source = PresentationSource.FromVisual(Application.Current.MainWindow);
Matrix m = source.CompositionTarget.TransformToDevice; // Matrix m = source.CompositionTarget.TransformToDevice;
return new Point(m.M11, m.M22); // return new Point(m.M11, m.M22);
} // }
private const double DpiBase = 96.0; // private const double DpiBase = 96.0;
/// <summary> // /// <summary>
/// Gets the system configured DPI. // /// Gets the system configured DPI.
/// </summary> // /// </summary>
/// <returns>A Point object containing the X- and Y- DPI.</returns> // /// <returns>A Point object containing the X- and Y- DPI.</returns>
public static Point GetSystemDpi() // public static Point GetSystemDpi()
{ // {
Point sysDpiFactor = GetSystemDpiFactor(); // Point sysDpiFactor = GetSystemDpiFactor();
return new Point( // return new Point(
sysDpiFactor.X * DpiBase, // sysDpiFactor.X * DpiBase,
sysDpiFactor.Y * DpiBase); // sysDpiFactor.Y * DpiBase);
} // }
/// <summary> // /// <summary>
/// Gets the physical pixel density (DPI) of the screen. // /// Gets the physical pixel density (DPI) of the screen.
/// </summary> // /// </summary>
/// <param name="diagonalScreenSize">Size - in inch - of the diagonal of the screen.</param> // /// <param name="diagonalScreenSize">Size - in inch - of the diagonal of the screen.</param>
/// <returns>A Point object containing the X- and Y- DPI.</returns> // /// <returns>A Point object containing the X- and Y- DPI.</returns>
public static Point GetPhysicalDpi(double diagonalScreenSize) // public static Point GetPhysicalDpi(double diagonalScreenSize)
{ // {
Point sysDpiFactor = GetSystemDpiFactor(); // Point sysDpiFactor = GetSystemDpiFactor();
double pixelScreenWidth = SystemParameters.PrimaryScreenWidth * sysDpiFactor.X; // double pixelScreenWidth = SystemParameters.PrimaryScreenWidth * sysDpiFactor.X;
double pixelScreenHeight = SystemParameters.PrimaryScreenHeight * sysDpiFactor.Y; // double pixelScreenHeight = SystemParameters.PrimaryScreenHeight * sysDpiFactor.Y;
double formatRate = pixelScreenWidth / pixelScreenHeight; // double formatRate = pixelScreenWidth / pixelScreenHeight;
double inchHeight = diagonalScreenSize / Math.Sqrt(formatRate * formatRate + 1.0); // double inchHeight = diagonalScreenSize / Math.Sqrt(formatRate * formatRate + 1.0);
double inchWidth = formatRate * inchHeight; // double inchWidth = formatRate * inchHeight;
double xDpi = Math.Round(pixelScreenWidth / inchWidth); // double xDpi = Math.Round(pixelScreenWidth / inchWidth);
double yDpi = Math.Round(pixelScreenHeight / inchHeight); // double yDpi = Math.Round(pixelScreenHeight / inchHeight);
return new Point(xDpi, yDpi); // return new Point(xDpi, yDpi);
} // }
/// <summary> // /// <summary>
/// Converts a DPI into a scale factor (compared to system DPI). // /// Converts a DPI into a scale factor (compared to system DPI).
/// </summary> // /// </summary>
/// <param name="dpi">A Point object containing the X- and Y- DPI to convert.</param> // /// <param name="dpi">A Point object containing the X- and Y- DPI to convert.</param>
/// <returns>A Point object containing the X- and Y- scale factor.</returns> // /// <returns>A Point object containing the X- and Y- scale factor.</returns>
public static Point DpiToScaleFactor(Point dpi) // public static Point DpiToScaleFactor(Point dpi)
{ // {
Point sysDpi = GetSystemDpi(); // Point sysDpi = GetSystemDpi();
return new Point( // return new Point(
dpi.X / sysDpi.X, // dpi.X / sysDpi.X,
dpi.Y / sysDpi.Y); // dpi.Y / sysDpi.Y);
} // }
/// <summary> // /// <summary>
/// Gets the scale factor to apply to a WPF application // /// Gets the scale factor to apply to a WPF application
/// so that 96 DIP always equals 1 inch on the screen (whatever the system DPI). // /// so that 96 DIP always equals 1 inch on the screen (whatever the system DPI).
/// </summary> // /// </summary>
/// <param name="diagonalScreenSize">Size - in inch - of the diagonal of the screen</param> // /// <param name="diagonalScreenSize">Size - in inch - of the diagonal of the screen</param>
/// <returns>A Point object containing the X- and Y- scale factor.</returns> // /// <returns>A Point object containing the X- and Y- scale factor.</returns>
public static Point GetScreenIndependentScaleFactor(double diagonalScreenSize) // public static Point GetScreenIndependentScaleFactor(double diagonalScreenSize)
{ // {
return DpiToScaleFactor(GetPhysicalDpi(diagonalScreenSize)); // return DpiToScaleFactor(GetPhysicalDpi(diagonalScreenSize));
} // }
} //}
} }

View File

@@ -25,12 +25,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Converters
if (parameter?.ToString() == "Y") if (parameter?.ToString() == "Y")
{ {
var value = 0 - (unit == Unit.Cm? DipHelper.DipToCm(vector.Y - 20) : DipHelper.DipToInch(vector.Y - 20))/ zoomValue; var value = 0 - (unit == Unit.Cm? ScreenHelper.WidthToCm(vector.Y - 20) : ScreenHelper.WidthToInch(vector.Y - 20))/ zoomValue;
return value; return value;
} }
else else
{ {
var value = 0 - (unit == Unit.Cm ? DipHelper.DipToCm(vector.X - 20) : DipHelper.DipToInch(vector.X - 20)) / zoomValue; var value = 0 - (unit == Unit.Cm ? ScreenHelper.WidthToCm(vector.X - 20) : ScreenHelper.WidthToInch(vector.X - 20)) / zoomValue;
return value; return value;
} }
} }

View File

@@ -25,6 +25,7 @@
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SvgPathProperties" Version="1.1.2" /> <PackageReference Include="SvgPathProperties" Version="1.1.2" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="System.Reactive" Version="5.0.0" /> <PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="WpfAnimatedGif" Version="2.0.0" /> <PackageReference Include="WpfAnimatedGif" Version="2.0.0" />
</ItemGroup> </ItemGroup>

View File

@@ -6,32 +6,7 @@ using System.Text;
namespace AIStudio.Wpf.DiagramDesigner namespace AIStudio.Wpf.DiagramDesigner
{ {
public enum PageSizeType public enum PageSizeType
{ {
[Description("Letter,8.5英寸*11英寸")]//612*792
Letter,
[Description("Folio,8.5英寸*13英寸")]//612*936
Folio,
[Description("Folio,8.5英寸*14英寸")]//612*1008
Legal,
[Description("Folio,7.25英寸*10.5英寸")]//522*756
Executive,
[Description("Folio,5.5英寸*8.5英寸")]//396*612
Statement,
[Description("#10 Envelope,4.125英寸*9.5英寸")]//297*684
Envelope,
[Description("Monarch Envelope,3.875英寸*7.5英寸")]//279*540
MonarchEnvelope,
[Description("Tabloid,11英寸*17英寸")]//792*1224
Tabloid,
[Description("Letter Small,8 1/2英寸*11英寸")]//612*792
LetterSmall,
[Description("C Sheet,17英寸*22英寸")]//1224*1584
CSheet,
[Description("D Sheet,22英寸*34英寸")]//1584*2448
DSheet,
[Description("E Sheet,34英寸*44英寸")]//2448*3168
ESheet,
[Description("A3 sheet,297毫米*420毫米")]//842*1191 [Description("A3 sheet,297毫米*420毫米")]//842*1191
A3, A3,
[Description("A4 sheet,210毫米*297毫米")]//595*842 [Description("A4 sheet,210毫米*297毫米")]//595*842
@@ -68,6 +43,30 @@ namespace AIStudio.Wpf.DiagramDesigner
//JapanesePostcard, //JapanesePostcard,
//[Description("Double Japanese Postcard")]//420*566 //[Description("Double Japanese Postcard")]//420*566
//DoubleJapanesePostcard, //DoubleJapanesePostcard,
[Description("Letter,8.5英寸*11英寸")]//612*792
Letter,
[Description("Folio,8.5英寸*13英寸")]//612*936
Folio,
[Description("Folio,8.5英寸*14英寸")]//612*1008
Legal,
[Description("Folio,7.25英寸*10.5英寸")]//522*756
Executive,
[Description("Folio,5.5英寸*8.5英寸")]//396*612
Statement,
[Description("#10 Envelope,4.125英寸*9.5英寸")]//297*684
Envelope,
[Description("Monarch Envelope,3.875英寸*7.5英寸")]//279*540
MonarchEnvelope,
[Description("Tabloid,11英寸*17英寸")]//792*1224
Tabloid,
[Description("Letter Small,8 1/2英寸*11英寸")]//612*792
LetterSmall,
[Description("C Sheet,17英寸*22英寸")]//1224*1584
CSheet,
[Description("D Sheet,22英寸*34英寸")]//1584*2448
DSheet,
[Description("E Sheet,34英寸*44英寸")]//2448*3168
ESheet,
[Description("自定义")] [Description("自定义")]
Custom, Custom,
} }

View File

@@ -1,11 +1,23 @@
using System; using Microsoft.Win32;
using System.Drawing; using System.Collections.Generic;
using System;
using System.Management;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Drawing;
namespace AIStudio.Wpf.DiagramDesigner namespace AIStudio.Wpf.DiagramDesigner
{ {
public static class ScreenHelper public static class ScreenHelper
{ {
public static double ScreenScale;
public static double MmToPixelsWidth;
static ScreenHelper()
{
ScreenScale = ResetScreenScale();
MmToPixelsWidth = MillimetersToPixelsWidth(1);
}
[DllImport("user32.dll", EntryPoint = "ReleaseDC")] [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
public static extern IntPtr ReleaseDC( public static extern IntPtr ReleaseDC(
IntPtr hWnd, IntPtr hWnd,
@@ -44,5 +56,94 @@ namespace AIStudio.Wpf.DiagramDesigner
return physicalScreenWidth * 1.0000 / System.Windows.SystemParameters.PrimaryScreenWidth; return physicalScreenWidth * 1.0000 / System.Windows.SystemParameters.PrimaryScreenWidth;
} }
} }
//public static List<string> GetMonitorPnpDeviceId()
//{
// List<string> rt = new List<string>();
// using (ManagementClass mc = new ManagementClass("Win32_DesktopMonitor"))
// {
// using (ManagementObjectCollection moc = mc.GetInstances())
// {
// foreach (var o in moc)
// {
// var each = (ManagementObject)o;
// object obj = each.Properties["PNPDeviceID"].Value;
// if (obj == null)
// continue;
// rt.Add(each.Properties["PNPDeviceID"].Value.ToString());
// }
// }
// }
// return rt;
//}
//public static byte[] GetMonitorEdid(string monitorPnpDevId)
//{
// return (byte[])Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\" + monitorPnpDevId + @"\Device Parameters", "EDID", new byte[] { });
//}
////获取显示器物理尺寸(cm)
//public static SizeF GetMonitorPhysicalSize(string monitorPnpDevId)
//{
// byte[] edid = GetMonitorEdid(monitorPnpDevId);
// if (edid.Length < 23)
// return SizeF.Empty;
// return new SizeF(edid[21], edid[22]);
//}
//通过屏显示器理尺寸转换为显示器大小(inch)
public static float MonitorScaler(SizeF moniPhySize)
{
double mDSize = Math.Sqrt(Math.Pow(moniPhySize.Width, 2) + Math.Pow(moniPhySize.Height, 2)) / 2.54d;
return (float)Math.Round(mDSize, 1);
}
public static double MillimetersToPixelsWidth(double length) //length是毫米1厘米=10毫米
{
//System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(IntPtr.Zero);
IntPtr hdc = g.GetHdc();
int width = GetDeviceCaps(hdc, 4); // HORZRES
int pixels = GetDeviceCaps(hdc, 8); // BITSPIXEL
g.ReleaseHdc(hdc);
return (((double)pixels / (double)width) * (double)length);
}
public static double MmToWidth(double length) //length是毫米1厘米=10毫米
{
return MmToPixelsWidth * length / ScreenScale;
}
public static double WidthToMm(double length)
{
return ScreenScale * length / MmToPixelsWidth;
}
public static double CmToWidth(double length) //length是毫米1厘米=10毫米
{
return MmToPixelsWidth * length * 10d/ ScreenScale;
}
public static double WidthToCm(double length)
{
return ScreenScale * length / (MmToPixelsWidth * 10d);
}
public static double InchToWidth(double length) //length是英寸1英寸=2.54cm
{
return MmToPixelsWidth * length * 10d * 2.54d / ScreenScale;
}
public static double WidthToInch(double length) //length是英寸1英寸=2.54cm
{
return ScreenScale * length / (MmToPixelsWidth * 10d * 2.54d);
}
} }
} }

View File

@@ -22,21 +22,20 @@ namespace AIStudio.Wpf.DiagramDesigner
public ConnectorInfoItemBase(ConnectorInfoBase viewmodel) : base(viewmodel) public ConnectorInfoItemBase(ConnectorInfoBase viewmodel) : base(viewmodel)
{ {
ConnectorWidth = viewmodel.ConnectorWidth; PhysicalConnectorWidth = viewmodel.PhysicalConnectorWidth;
ConnectorHeight = viewmodel.ConnectorHeight; PhysicalConnectorHeight = viewmodel.PhysicalConnectorHeight;
Orientation = viewmodel.Orientation; Orientation = viewmodel.Orientation;
ConnectorValue = viewmodel.ConnectorValue;
} }
[XmlAttribute] [XmlAttribute]
public double ConnectorWidth public double PhysicalConnectorWidth
{ {
get; set; get; set;
} }
[XmlAttribute] [XmlAttribute]
public double ConnectorHeight public double PhysicalConnectorHeight
{ {
get; set; get; set;
} }
@@ -47,11 +46,7 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set; get; set;
} }
[XmlAttribute]
public double ConnectorValue
{
get; set;
}
} }

View File

@@ -21,6 +21,7 @@ namespace AIStudio.Wpf.DiagramDesigner
public LogicalConnectorInfoItem(LogicalConnectorInfo viewmodel) : base(viewmodel) public LogicalConnectorInfoItem(LogicalConnectorInfo viewmodel) : base(viewmodel)
{ {
ValueTypePoint = viewmodel.ValueTypePoint; ValueTypePoint = viewmodel.ValueTypePoint;
ConnectorValue = viewmodel.ConnectorValue;
} }
[XmlAttribute] [XmlAttribute]
@@ -28,6 +29,12 @@ namespace AIStudio.Wpf.DiagramDesigner
{ {
get; set; get; set;
} }
[XmlAttribute]
public double ConnectorValue
{
get; set;
}
} }

View File

@@ -20,13 +20,13 @@ namespace AIStudio.Wpf.DiagramDesigner
public DesignerItemBase(DesignerItemViewModelBase viewmodel, string reserve = null) : base(viewmodel) public DesignerItemBase(DesignerItemViewModelBase viewmodel, string reserve = null) : base(viewmodel)
{ {
this.Left = viewmodel.Left; this.PhysicalLeft = viewmodel.PhysicalLeft;
this.Top = viewmodel.Top; this.PhysicalTop = viewmodel.PhysicalTop;
this.Angle = viewmodel.Angle; this.Angle = viewmodel.Angle;
this.ScaleX = viewmodel.ScaleX; this.ScaleX = viewmodel.ScaleX;
this.ScaleY = viewmodel.ScaleY; this.ScaleY = viewmodel.ScaleY;
this.ItemWidth = viewmodel.ItemWidth; this.PhysicalItemWidth = viewmodel.PhysicalItemWidth;
this.ItemHeight = viewmodel.ItemHeight; this.PhysicalItemHeight = viewmodel.PhysicalItemHeight;
this.Icon = viewmodel.Icon; this.Icon = viewmodel.Icon;
this.ItemTypeName = viewmodel.GetType().FullName; this.ItemTypeName = viewmodel.GetType().FullName;
this.Margin = viewmodel.Margin; this.Margin = viewmodel.Margin;
@@ -34,37 +34,70 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
[XmlAttribute] [XmlAttribute]
public double Left { get; set; } public double PhysicalLeft
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public double Top { get; set; } public double PhysicalTop
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public double Angle { get; set; } public double Angle
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public double ScaleX { get; set; } public double ScaleX
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public double ScaleY { get; set; } public double ScaleY
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public double Margin { get; set; } public double Margin
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public double ItemWidth { get; set; } public double PhysicalItemWidth
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public double ItemHeight { get; set; } public double PhysicalItemHeight
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public string Icon { get; set; } public string Icon
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public string Reserve { get; set; } public string Reserve
{
get; set;
}
[XmlAttribute] [XmlAttribute]
public string ItemTypeName { get; set; } public string ItemTypeName
{
get; set;
}
} }

View File

@@ -53,10 +53,9 @@ namespace AIStudio.Wpf.DiagramDesigner
if (designerbase is ConnectorInfoItemBase designer) if (designerbase is ConnectorInfoItemBase designer)
{ {
ConnectorWidth = designer.ConnectorWidth; PhysicalConnectorWidth = designer.PhysicalConnectorWidth;
ConnectorHeight = designer.ConnectorHeight; PhysicalConnectorHeight = designer.PhysicalConnectorHeight;
Orientation = designer.Orientation; Orientation = designer.Orientation;
ConnectorValue = designer.ConnectorValue;
} }
} }
@@ -87,44 +86,61 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
} }
private double connectorWidth = 8; private double _connectorWidth = 8;
public double ConnectorWidth public double ConnectorWidth
{ {
get get
{ {
return connectorWidth; return _connectorWidth;
} }
set set
{ {
connectorWidth = value; if (SetProperty(ref _connectorWidth, value))
{
RaisePropertyChanged(nameof(PhysicalConnectorWidth));
}
} }
} }
private double connectorHeight = 8; private double _connectorHeight = 8;
public double ConnectorHeight public double ConnectorHeight
{ {
get get
{ {
return connectorHeight; return _connectorHeight;
} }
set set
{ {
connectorHeight = value; if (SetProperty(ref _connectorHeight, value))
{
RaisePropertyChanged(nameof(PhysicalConnectorHeight));
}
} }
} }
public double _connectorValue; public double PhysicalConnectorWidth
public double ConnectorValue
{ {
get get
{ {
return _connectorValue; return ConnectorWidth * (Root?.ScreenScale ?? 1d);
} }
set set
{ {
SetProperty(ref _connectorValue, value); ConnectorWidth = value / (Root?.ScreenScale ?? 1d);
} }
} }
public double PhysicalConnectorHeight
{
get
{
return ConnectorHeight * (Root?.ScreenScale ?? 1d);
}
set
{
ConnectorHeight = value / (Root?.ScreenScale ?? 1d);
}
}
#endregion #endregion
} }
} }

View File

@@ -36,10 +36,24 @@ namespace AIStudio.Wpf.DiagramDesigner
if (designerbase is LogicalConnectorInfoItem designer) if (designerbase is LogicalConnectorInfoItem designer)
{ {
ConnectorValue = designer.ConnectorValue;
ValueTypePoint = designer.ValueTypePoint; ValueTypePoint = designer.ValueTypePoint;
} }
} }
public double _connectorValue;
public double ConnectorValue
{
get
{
return _connectorValue;
}
set
{
SetProperty(ref _connectorValue, value);
}
}
public ValueTypePoint _valueTypePoint; public ValueTypePoint _valueTypePoint;
public ValueTypePoint ValueTypePoint public ValueTypePoint ValueTypePoint
{ {

View File

@@ -51,13 +51,13 @@ namespace AIStudio.Wpf.DiagramDesigner
if (designerbase is DesignerItemBase designer) if (designerbase is DesignerItemBase designer)
{ {
this.Left = designer.Left; this.PhysicalLeft = designer.PhysicalLeft;
this.Top = designer.Top; this.PhysicalTop = designer.PhysicalTop;
this.Angle = designer.Angle; this.Angle = designer.Angle;
this.ScaleX = designer.ScaleX; this.ScaleX = designer.ScaleX;
this.ScaleY = designer.ScaleY; this.ScaleY = designer.ScaleY;
this.ItemWidth = designer.ItemWidth; this.PhysicalItemWidth = designer.PhysicalItemWidth;
this.ItemHeight = designer.ItemHeight; this.PhysicalItemHeight = designer.PhysicalItemHeight;
this.Icon = designer.Icon; this.Icon = designer.Icon;
} }
} }
@@ -191,12 +191,10 @@ namespace AIStudio.Wpf.DiagramDesigner
set set
{ {
if (value <= 0) return; if (value <= 0) return;
if (SetProperty(ref _itemWidth, value))
if (this is GroupDesignerItemViewModel && value < 70)
{ {
RaisePropertyChanged(nameof(PhysicalItemWidth));
} }
SetProperty(ref _itemWidth, value);
} }
} }
@@ -212,7 +210,36 @@ namespace AIStudio.Wpf.DiagramDesigner
set set
{ {
if (value <= 0) return; if (value <= 0) return;
SetProperty(ref _itemHeight, value); if (SetProperty(ref _itemHeight, value))
{
RaisePropertyChanged(nameof(PhysicalItemHeight));
}
}
}
[Browsable(true)]
public double PhysicalItemWidth
{
get
{
return ItemWidth * (Root?.ScreenScale ?? 1d);
}
set
{
ItemWidth = value / (Root?.ScreenScale ?? 1d);
}
}
[Browsable(true)]
public double PhysicalItemHeight
{
get
{
return ItemHeight * (Root?.ScreenScale ?? 1d);
}
set
{
ItemHeight = value / (Root?.ScreenScale ?? 1d);
} }
} }
@@ -310,6 +337,32 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
} }
[Browsable(true)]
public double PhysicalLeft
{
get
{
return Left * (Root?.ScreenScale ?? 1d);
}
set
{
Left = value / (Root?.ScreenScale ?? 1d);
}
}
[Browsable(true)]
public double PhysicalTop
{
get
{
return Top * (Root?.ScreenScale ?? 1d);
}
set
{
Top = value / (Root?.ScreenScale ?? 1d);
}
}
public PointBase Position public PointBase Position
{ {
get get

View File

@@ -112,38 +112,40 @@ namespace AIStudio.Wpf.DiagramDesigner
public Size GetPageSize() public Size GetPageSize()
{ {
Size size = _pageSize;
switch (PageSizeType) switch (PageSizeType)
{ {
case PageSizeType.Letter: return new Size(612, 792); case PageSizeType.A3: size = new Size(297, 420); break;
case PageSizeType.Folio: return new Size(612, 936); case PageSizeType.A4: size = new Size(210, 297); break;
case PageSizeType.Legal: return new Size(612, 1008); case PageSizeType.A5: size = new Size(148, 210); break;
case PageSizeType.Executive: return new Size(522, 756); case PageSizeType.B4: size = new Size(257, 364); break;
case PageSizeType.Statement: return new Size(396, 612); case PageSizeType.B5: size = new Size(176, 250); break;
case PageSizeType.Envelope: return new Size(297, 684); case PageSizeType.DLEnvelope: size = new Size(110, 220); break;
case PageSizeType.MonarchEnvelope: return new Size(279, 540); case PageSizeType.C5Envelope: size = new Size(162, 229); break;
case PageSizeType.Tabloid: return new Size(792, 1224); case PageSizeType.Quarto: size = new Size(215, 275); break;
case PageSizeType.LetterSmall: return new Size(612, 792); case PageSizeType.C6Quarto: size = new Size(114, 162); break;
case PageSizeType.CSheet: return new Size(1224, 1584); case PageSizeType.B5Quarto: size = new Size(176, 250); break;
case PageSizeType.DSheet: return new Size(1584, 2448); case PageSizeType.ItalyQuarto: size = new Size(110, 230); break;
case PageSizeType.ESheet: return new Size(2448, 3168); case PageSizeType.A4small: size = new Size(210, 297); break;
case PageSizeType.A3: return new Size(842, 1191); case PageSizeType.GermanStdFanfold: size = new Size(215.9, 304.8); break;
case PageSizeType.A4: return new Size(595, 842); case PageSizeType.GermanLegalFanfold: size = new Size(203.2, 330.2); break;
case PageSizeType.A5: return new Size(420, 595); case PageSizeType.PRC16K: size = new Size(146, 215); break;
case PageSizeType.B4: return new Size(709, 1003); case PageSizeType.PRC32K: size = new Size(97, 151); break;
case PageSizeType.B5: return new Size(516, 729); case PageSizeType.Letter: size = new Size(215.9, 279.4); break;
case PageSizeType.DLEnvelope: return new Size(312, 624); case PageSizeType.Folio: size = new Size(215.9, 330.2); break;
case PageSizeType.C5Envelope: return new Size(459, 649); case PageSizeType.Legal: size = new Size(215.9, 355.6); break;
case PageSizeType.Quarto: return new Size(609, 780); case PageSizeType.Executive: size = new Size(184.15, 266.7); break;
case PageSizeType.C6Quarto: return new Size(323, 459); case PageSizeType.Statement: size = new Size(139.7, 215.9); break;
case PageSizeType.B5Quarto: return new Size(499, 709); case PageSizeType.Envelope: size = new Size(104.77, 241.3); break;
case PageSizeType.ItalyQuarto: return new Size(312, 652); case PageSizeType.MonarchEnvelope: size = new Size(98.425, 190.5); break;
case PageSizeType.A4small: return new Size(595, 842); case PageSizeType.Tabloid: size = new Size(279.4, 431.8); break;
case PageSizeType.GermanStdFanfold: return new Size(612, 864); case PageSizeType.LetterSmall: size = new Size(215.9, 279.4); break;
case PageSizeType.GermanLegalFanfold: return new Size(576, 936); case PageSizeType.CSheet: size = new Size(431.8, 558.8); break;
case PageSizeType.PRC16K: return new Size(414, 609); case PageSizeType.DSheet: size = new Size(558.8, 863.6); break;
case PageSizeType.PRC32K: return new Size(275, 428); case PageSizeType.ESheet: size = new Size(863.6, 1117.6); break;
default: return _pageSize;
} }
return new Size(ScreenHelper.MmToWidth(size.Width), ScreenHelper.MmToWidth(size.Height));
} }
private PageSizeOrientation _pageSizeOrientation; private PageSizeOrientation _pageSizeOrientation;
@@ -599,6 +601,8 @@ namespace AIStudio.Wpf.DiagramDesigner
private DoCommandManager DoCommandManager = new DoCommandManager(); private DoCommandManager DoCommandManager = new DoCommandManager();
public DiagramViewModel() public DiagramViewModel()
{ {
SetScreenScale();
CreateNewDiagramCommand = new SimpleCommand(ExecuteEnable, ExecuteCreateNewDiagramCommand); CreateNewDiagramCommand = new SimpleCommand(ExecuteEnable, ExecuteCreateNewDiagramCommand);
AddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteAddItemCommand); AddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteAddItemCommand);
DirectAddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteDirectAddItemCommand); DirectAddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteDirectAddItemCommand);
@@ -1464,7 +1468,7 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
} }
OffsetX += 10; OffsetX += 10;
OffsetY += 10; OffsetY += 10;
@@ -1511,7 +1515,7 @@ namespace AIStudio.Wpf.DiagramDesigner
System.Windows.MessageBox.Show(e.StackTrace, e.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); System.Windows.MessageBox.Show(e.StackTrace, e.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
} }
} }
} }
private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector) private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector)
{ {

View File

@@ -32,7 +32,6 @@ namespace AIStudio.Wpf.Flowchart.Controls
public FlowchartEditor() public FlowchartEditor()
{ {
_diagramViewModel = new DiagramViewModel(); _diagramViewModel = new DiagramViewModel();
_diagramViewModel.SetScreenScale();
_diagramViewModel.ShowGrid = true; _diagramViewModel.ShowGrid = true;
_diagramViewModel.GridCellSize = new SizeBase(125 / _diagramViewModel.ScreenScale, 125 / _diagramViewModel.ScreenScale); _diagramViewModel.GridCellSize = new SizeBase(125 / _diagramViewModel.ScreenScale, 125 / _diagramViewModel.ScreenScale);
_diagramViewModel.GridMarginSize = new Size(0, 0); _diagramViewModel.GridMarginSize = new Size(0, 0);