增加ResponsivePanel 调整绘图API

This commit is contained in:
小红帽
2023-12-19 22:11:21 +08:00
parent fb9b04e7a0
commit 906c865964
97 changed files with 1327 additions and 16705 deletions

View File

@@ -341,31 +341,58 @@ namespace CPF.GDIPlus
}
if (drawLine)
{
var ly = y;
switch (decoration.Location)
var lw = drawingFactory.g.MeasureString(sub, f.Font).Width;
if (decoration.Location.HasFlag(TextDecorationLocation.Underline))
{
case TextDecorationLocation.Underline:
ly = y + fHeight;
break;
case TextDecorationLocation.OverLine:
break;
case TextDecorationLocation.Strikethrough:
ly = y + fHeight / 2;
break;
var ly = y;
ly = y + fHeight;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
if (decoration.Location.HasFlag(TextDecorationLocation.OverLine))
{
var ly = y;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
if (decoration.Location.HasFlag(TextDecorationLocation.Strikethrough))
{
var ly = y;
ly = y + fHeight / 2;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
var lw = drawingFactory.g.MeasureString(sub, f.Font).Width;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
y += fHeight;
@@ -524,31 +551,58 @@ namespace CPF.GDIPlus
}
if (drawLine)
{
var ly = y;
switch (decoration.Location)
var lw = drawingFactory.g.MeasureString(sub, f.Font).Width;
if (decoration.Location.HasFlag(TextDecorationLocation.Underline))
{
case TextDecorationLocation.Underline:
ly = y + fHeight;
break;
case TextDecorationLocation.OverLine:
break;
case TextDecorationLocation.Strikethrough:
ly = y + fHeight / 2;
break;
var ly = y;
ly = y + fHeight;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
if (decoration.Location.HasFlag(TextDecorationLocation.OverLine))
{
var ly = y;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
if (decoration.Location.HasFlag(TextDecorationLocation.Strikethrough))
{
var ly = y;
ly = y + fHeight / 2;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
var lw = drawingFactory.g.MeasureString(sub, f.Font).Width;
var lx = x;
switch (textAlignment)
{
case TextAlignment.Right:
lx = x + mw - lw;
break;
case TextAlignment.Center:
lx = x + (mw - lw) / 2;
break;
}
g.DrawLine(pen, lx, ly, lx + lw, ly);
}
y += fHeight;

View File

@@ -232,10 +232,31 @@ namespace CPF.GDIPlus
}
}
public override float GetDefaultLineHeight(in Drawing.Font font)
public override float GetLineHeight(in Drawing.Font font)
{
//var f = (FontStruct)font.AdapterFont;
//return f.Height;
var f = (FontStruct)font.AdapterFont;
float emHeight = f.Font.FontFamily.GetEmHeight(f.Font.Style);
var lineSpacing = f.Font.FontFamily.GetLineSpacing(f.Font.Style) * f.Font.Size / emHeight;
return lineSpacing;
}
public override float GetAscent(in Drawing.Font font)
{
var f = (FontStruct)font.AdapterFont;
return f.Height;
float emHeight = f.Font.FontFamily.GetEmHeight(f.Font.Style);
//var lineSpacing = f.Font.FontFamily.GetLineSpacing(f.Font.Style) * f.Font.Size / emHeight;
float ascent = f.Font.FontFamily.GetCellAscent(f.Font.Style) * f.Font.Size / emHeight;
return ascent;
}
public override float GetDescent(in Drawing.Font font)
{
var f = (FontStruct)font.AdapterFont;
float emHeight = f.Font.FontFamily.GetEmHeight(f.Font.Style);
float descent = f.Font.FontFamily.GetCellDescent(f.Font.Style) * f.Font.Size / emHeight;
return descent;
}
///// <summary>

View File

@@ -272,6 +272,11 @@ namespace CPF.GDIPlus
return new GDIPlusPath(p);
}
public void Reset()
{
path.Reset();
}
~GDIPlusPath()
{
Dispose();

View File

@@ -51,19 +51,18 @@ namespace CPF.Windows.OpenGL
//Wgl.WGL_ALPHA_BITS_ARB, 8,
////Wgl.WGL_SAMPLE_BUFFERS_ARB, 1, // MSAA on,开启多重采样
////Wgl.WGL_SAMPLES_ARB, 4, // 4x MSAA ,多重采样样本数量为4
//0, 0
//}, new float[] { 0, 0 }, 1, nPixelFormat, out var f);
//Wgl.SetPixelFormat(dc, nPixelFormat[0], ref pfd);
//r= Wgl.SetPixelFormat(dc, nPixelFormat[0], ref pfd);
//rc = Wgl.WglCreateContextAttribsArb(dc, IntPtr.Zero,
//new[]
//{
// // major
// WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
// // minor
// WGL_CONTEXT_MINOR_VERSION_ARB, 0,
// WGL_CONTEXT_MINOR_VERSION_ARB, 3,
// // core profile
// WGL_CONTEXT_PROFILE_MASK_ARB, 1,
// //WGL_CONTEXT_PROFILE_MASK_ARB, 0,
// // debug
// // WGL_CONTEXT_FLAGS_ARB, 1,
// // end
@@ -73,6 +72,7 @@ namespace CPF.Windows.OpenGL
if (rc == IntPtr.Zero)
{
Console.WriteLine("无法创建OpenGLContext DC:" + dc + " Handle:" + handle);
System.Diagnostics.Debug.WriteLine("无法创建OpenGLContext DC:" + dc + " Handle:" + handle);
}
else
{