CPF/CPF.ReoGrid/Rendering/PlatformUtility.cs

77 lines
1.8 KiB
C#
Raw Normal View History

2024-06-24 10:15:59 +08:00
using System;
using CPF.Drawing;
using CPF.ReoGrid.Drawing.Text;
using CPF.ReoGrid.Graphics;
namespace CPF.ReoGrid.Rendering
{
internal static class PlatformUtility
{
public static float GetDPI()
{
bool flag = PlatformUtility.lastGetDPI == 0f;
if (flag)
{
bool flag2 = PlatformUtility.lastGetDPI == 0f;
if (flag2)
{
PlatformUtility.lastGetDPI = 96f;
}
}
return PlatformUtility.lastGetDPI;
}
public static CPF.Drawing.FontStyles ToWPFFontStyle(CPF.ReoGrid.Drawing.Text.FontStyles textStyle)
{
bool flag = (textStyle & CPF.ReoGrid.Drawing.Text.FontStyles.Italic) == CPF.ReoGrid.Drawing.Text.FontStyles.Italic;
CPF.Drawing.FontStyles result;
if (flag)
{
result = CPF.Drawing.FontStyles.Italic;
}
else
{
result = CPF.Drawing.FontStyles.Regular;
}
return result;
}
public static TextDecoration ToWPFFontDecorations(CPF.ReoGrid.Drawing.Text.FontStyles textStyle)
{
TextDecoration result = default(TextDecoration);
bool flag = (textStyle & CPF.ReoGrid.Drawing.Text.FontStyles.Underline) == CPF.ReoGrid.Drawing.Text.FontStyles.Underline;
if (flag)
{
result.Location = TextDecorationLocation.Underline;
}
bool flag2 = (textStyle & CPF.ReoGrid.Drawing.Text.FontStyles.Strikethrough) == CPF.ReoGrid.Drawing.Text.FontStyles.Strikethrough;
if (flag2)
{
result.Location |= TextDecorationLocation.Underline;
}
return result;
}
public static CapStyles ToWPFLineCap(LineCapStyles capStyle)
{
CapStyles result;
switch (capStyle)
{
default:
result = CapStyles.Flat;
break;
case LineCapStyles.Arrow:
result = CapStyles.Triangle;
break;
case LineCapStyles.Ellipse:
case LineCapStyles.Round:
result = CapStyles.Round;
break;
}
return result;
}
private static float lastGetDPI;
}
}