mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-26 03:07:55 +08:00
Flowchart
This commit is contained in:
@@ -6,6 +6,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static class EnumExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts to enum.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="str">The string.</param>
|
||||
/// <returns></returns>
|
||||
public static T ToEnum<T>(this string str)
|
||||
{
|
||||
return (T)Enum.Parse(typeof(T), str);
|
||||
}
|
||||
|
||||
public static string GetDescription(this Enum value)
|
||||
{
|
||||
FieldInfo field = value.GetType().GetField(value.ToString());
|
||||
|
||||
48
AIStudio.Wpf.DiagramDesigner/Helpers/ScreenHelper.cs
Normal file
48
AIStudio.Wpf.DiagramDesigner/Helpers/ScreenHelper.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static class ScreenHelper
|
||||
{
|
||||
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
|
||||
public static extern IntPtr ReleaseDC(
|
||||
IntPtr hWnd,
|
||||
IntPtr hDc
|
||||
);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern int GetDeviceCaps(
|
||||
IntPtr hdc, // handle to DC
|
||||
int nIndex // index of capability
|
||||
);
|
||||
|
||||
public static System.Drawing.Size GetPhysicalDisplaySize()
|
||||
{
|
||||
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
|
||||
IntPtr desktop = g.GetHdc();
|
||||
int physicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.Desktopvertres);
|
||||
int physicalScreenWidth = GetDeviceCaps(desktop, (int)DeviceCap.Desktophorzres);
|
||||
ReleaseDC(IntPtr.Zero, desktop);
|
||||
g.Dispose();
|
||||
return new System.Drawing.Size(physicalScreenWidth, physicalScreenHeight);
|
||||
}
|
||||
|
||||
public enum DeviceCap
|
||||
{
|
||||
Desktopvertres = 117,
|
||||
Desktophorzres = 118
|
||||
}
|
||||
|
||||
public static double ResetScreenScale()
|
||||
{
|
||||
using (var g = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
IntPtr desktop = g.GetHdc();
|
||||
int physicalScreenWidth = GetDeviceCaps(desktop, (int)DeviceCap.Desktophorzres);
|
||||
return physicalScreenWidth * 1.0000 / System.Windows.SystemParameters.PrimaryScreenWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Helpers
|
||||
{
|
||||
@@ -13,16 +14,18 @@ namespace AIStudio.Wpf.DiagramDesigner.Helpers
|
||||
public IColorViewModel ColorViewModel { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
public Size? DesiredSize{ get; set; }
|
||||
|
||||
public object Addition { get; set; }
|
||||
|
||||
public ToolBoxData(string text, string icon, Type type, double width, double height)
|
||||
public ToolBoxData(string text, string icon, Type type, double width, double height, Size? desiredSize = null)
|
||||
{
|
||||
this.Text = text;
|
||||
this.Icon = icon;
|
||||
this.Type = type;
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
this.Height = height;
|
||||
this.DesiredSize = desiredSize;
|
||||
this.ColorViewModel = new ColorViewModel();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user