mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-06-28 13:34:09 +08:00
修改版本号和Path增加 Stretch属性
This commit is contained in:
parent
4e23e93d9d
commit
c2c6d5a602
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>0.9.6.5</Version>
|
<Version>0.9.6.6</Version>
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
|
||||||
<Authors>QQ:761716178</Authors>
|
<Authors>QQ:761716178</Authors>
|
||||||
<Company>QQ:761716178</Company>
|
<Company>QQ:761716178</Company>
|
||||||
<Product>QQ:761716178 跨平台UI框架</Product>
|
<Product>QQ:761716178 跨平台UI框架</Product>
|
||||||
@ -13,7 +12,6 @@
|
|||||||
<PackageId>Xhm.CPF.Linux</PackageId>
|
<PackageId>Xhm.CPF.Linux</PackageId>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<SignAssembly>false</SignAssembly>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<Product>QQ:761716178 跨平台UI框架</Product>
|
<Product>QQ:761716178 跨平台UI框架</Product>
|
||||||
<Version>0.9.6.5</Version>
|
<Version>0.9.6.6</Version>
|
||||||
<SignAssembly>false</SignAssembly>
|
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
|
||||||
<PackageId>Xhm.CPF.Mac</PackageId>
|
<PackageId>Xhm.CPF.Mac</PackageId>
|
||||||
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
||||||
<Copyright>Copyright (c) 2020 by http://cpf.cskin.net/</Copyright>
|
<Copyright>Copyright (c) 2020 by http://cpf.cskin.net/</Copyright>
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Product>QQ:761716178 跨平台UI框架</Product>
|
<Product>QQ:761716178 跨平台UI框架</Product>
|
||||||
<Version>0.9.6.5</Version>
|
<Version>0.9.6.6</Version>
|
||||||
<SignAssembly>false</SignAssembly>
|
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
|
||||||
<PackageId>Xhm.CPF.Skia</PackageId>
|
<PackageId>Xhm.CPF.Skia</PackageId>
|
||||||
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
||||||
<Copyright>Copyright (c) 2020 by http://cpf.cskin.net/</Copyright>
|
<Copyright>Copyright (c) 2020 by http://cpf.cskin.net/</Copyright>
|
||||||
|
@ -37,6 +37,10 @@ namespace CPF.Skia
|
|||||||
var size = new PixelSize((int)Math.Round(cSize.Width * Root.RenderScaling), (int)Math.Round(cSize.Height * Root.RenderScaling));
|
var size = new PixelSize((int)Math.Round(cSize.Width * Root.RenderScaling), (int)Math.Round(cSize.Height * Root.RenderScaling));
|
||||||
var skia = dc as SkiaDrawingContext;
|
var skia = dc as SkiaDrawingContext;
|
||||||
var _gl = skia.GlContext;
|
var _gl = skia.GlContext;
|
||||||
|
if (_gl == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (paint == null)
|
if (paint == null)
|
||||||
{
|
{
|
||||||
paint = new SKPaint();
|
paint = new SKPaint();
|
||||||
@ -52,8 +56,8 @@ namespace CPF.Skia
|
|||||||
|
|
||||||
_gl.BindTexture(GlConsts.GL_TEXTURE_2D, ColorBuffer);
|
_gl.BindTexture(GlConsts.GL_TEXTURE_2D, ColorBuffer);
|
||||||
|
|
||||||
_gl.TexParameteri(GlConsts.GL_TEXTURE_2D, GlConsts.GL_TEXTURE_MIN_FILTER, (int)GlConsts.GL_LINEAR);
|
_gl.TexParameter(GlConsts.GL_TEXTURE_2D, GlConsts.GL_TEXTURE_MIN_FILTER, (int)GlConsts.GL_LINEAR);
|
||||||
_gl.TexParameteri(GlConsts.GL_TEXTURE_2D, GlConsts.GL_TEXTURE_MAG_FILTER, GlConsts.GL_LINEAR);
|
_gl.TexParameter(GlConsts.GL_TEXTURE_2D, GlConsts.GL_TEXTURE_MAG_FILTER, GlConsts.GL_LINEAR);
|
||||||
|
|
||||||
_gl.BindTexture(GlConsts.GL_TEXTURE_2D, 0);
|
_gl.BindTexture(GlConsts.GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net40;netstandard2.0;net5</TargetFrameworks>
|
<TargetFrameworks>net40;netstandard2.0;net5</TargetFrameworks>
|
||||||
<Product>QQ:761716178 跨平台UI框架</Product>
|
<Product>QQ:761716178 跨平台UI框架</Product>
|
||||||
<Version>0.9.6.5</Version>
|
<Version>0.9.6.6</Version>
|
||||||
<SignAssembly>false</SignAssembly>
|
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
|
||||||
<PackageId>Xhm.CPF.Windows</PackageId>
|
<PackageId>Xhm.CPF.Windows</PackageId>
|
||||||
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
||||||
<PackageProjectUrl>http://cpf.cskin.net/</PackageProjectUrl>
|
<PackageProjectUrl>http://cpf.cskin.net/</PackageProjectUrl>
|
||||||
|
@ -6,11 +6,8 @@
|
|||||||
<Company>QQ:761716178</Company>
|
<Company>QQ:761716178</Company>
|
||||||
<Product>QQ:761716178 跨平台UI框架</Product>
|
<Product>QQ:761716178 跨平台UI框架</Product>
|
||||||
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
<Description>CPF(Cross platform UI framework) QQ:761716178 跨平台UI框架 http://cpf.cskin.net/</Description>
|
||||||
<Version>0.9.6.5</Version>
|
<Version>0.9.6.6</Version>
|
||||||
<LangVersion>9.0</LangVersion>
|
<LangVersion>9.0</LangVersion>
|
||||||
<SignAssembly>false</SignAssembly>
|
|
||||||
<DelaySign>false</DelaySign>
|
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
|
||||||
<PackageId>Xhm.CPF</PackageId>
|
<PackageId>Xhm.CPF</PackageId>
|
||||||
<PackageProjectUrl></PackageProjectUrl>
|
<PackageProjectUrl></PackageProjectUrl>
|
||||||
<Copyright>Copyright (c) 2020 by http://cpf.cskin.net/</Copyright>
|
<Copyright>Copyright (c) 2020 by http://cpf.cskin.net/</Copyright>
|
||||||
|
@ -393,7 +393,7 @@ namespace CPF.Controls
|
|||||||
{
|
{
|
||||||
// Move Thumb to the Mouse location
|
// Move Thumb to the Mouse location
|
||||||
|
|
||||||
Point pt = e.MouseDevice.GetPosition(Track);
|
Point pt = MouseDevice.GetPosition(Track);
|
||||||
var newValue = Track.ValueFromPoint(pt);
|
var newValue = Track.ValueFromPoint(pt);
|
||||||
if (FloatUtil.IsFloatFinite(newValue))
|
if (FloatUtil.IsFloatFinite(newValue))
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ namespace CPF.Input
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="element"></param>
|
/// <param name="element"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Point GetPosition(UIElement element)
|
public static Point GetPosition(UIElement element)
|
||||||
{
|
{
|
||||||
if (element.Root == null)
|
if (element.Root == null)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using CPF.Drawing;
|
using CPF.Drawing;
|
||||||
|
|
||||||
namespace CPF.OpenGL
|
namespace CPF.OpenGL
|
||||||
@ -32,7 +33,7 @@ namespace CPF.OpenGL
|
|||||||
IntPtr GetProcAddress(string name);
|
IntPtr GetProcAddress(string name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class OpenglEx
|
public static unsafe class OpenglEx
|
||||||
{
|
{
|
||||||
static bool loaded;
|
static bool loaded;
|
||||||
public static void Load(IGlContext context)
|
public static void Load(IGlContext context)
|
||||||
@ -332,10 +333,64 @@ namespace CPF.OpenGL
|
|||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public delegate void GlTexSubImage2D(uint target, int level, int xoffset, int yoffset, int width, int height, uint format, uint type, IntPtr pixels);
|
||||||
|
[GlImport("glTexSubImage2D")]
|
||||||
|
static GlTexSubImage2D texSubImage2D;
|
||||||
|
public static void TexSubImage2D(this IGlContext context, uint target, int level, int xoffset, int yoffset, int width, int height, uint format, uint type, IntPtr pixels)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlBufferData(int target, int size, IntPtr data, int usage);
|
||||||
|
[GlImport("glBufferData")]
|
||||||
|
static GlBufferData bufferData;
|
||||||
|
public static void BufferData(this IGlContext context, int target, int size, IntPtr data, int usage)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
bufferData(target, size, data, usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlBindBuffer(int target, int buffer);
|
||||||
|
[GlImport("glBindBuffer")]
|
||||||
|
static GlBindBuffer bindBuffer;
|
||||||
|
public static void BindBuffer(this IGlContext context, int target, int buffer)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
bindBuffer(target, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlUniform1i(int location, int v0);
|
||||||
|
[GlImport("glUniform1i")]
|
||||||
|
static GlUniform1i uniform1i;
|
||||||
|
public static void Uniform1(this IGlContext context, int location, int v0)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
uniform1i(location, v0);
|
||||||
|
}
|
||||||
|
public delegate void GlUniform1f(int location, float v0);
|
||||||
|
[GlImport("glUniform1f")]
|
||||||
|
static GlUniform1f uniform1f;
|
||||||
|
public static void Uniform1(this IGlContext context, int location, float v0)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
uniform1f(location, v0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlBufferSubData(int target, IntPtr offset, int size, IntPtr data);
|
||||||
|
[GlImport("glBufferSubData")]
|
||||||
|
static GlBufferSubData bufferSubData;
|
||||||
|
public static void BufferSubData(this IGlContext context, int target, IntPtr offset, int size, IntPtr data)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
bufferSubData(target, offset, size, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public delegate void GlTexParameteri(int target, int name, int value);
|
public delegate void GlTexParameteri(int target, int name, int value);
|
||||||
[GlImport("glTexParameteri")]
|
[GlImport("glTexParameteri")]
|
||||||
static GlTexParameteri texParameteri;
|
static GlTexParameteri texParameteri;
|
||||||
public static void TexParameteri(this IGlContext context, int target, int name, int value)
|
public static void TexParameter(this IGlContext context, int target, int name, int value)
|
||||||
{
|
{
|
||||||
Load(context);
|
Load(context);
|
||||||
texParameteri(target, name, value);
|
texParameteri(target, name, value);
|
||||||
@ -356,10 +411,347 @@ namespace CPF.OpenGL
|
|||||||
public delegate int GlCreateShader(int shaderType);
|
public delegate int GlCreateShader(int shaderType);
|
||||||
[GlImport("glCreateShader")]
|
[GlImport("glCreateShader")]
|
||||||
static GlCreateShader createShader;
|
static GlCreateShader createShader;
|
||||||
public static void CreateShader(this IGlContext context, int shaderType)
|
public static int CreateShader(this IGlContext context, int shaderType)
|
||||||
{
|
{
|
||||||
Load(context);
|
Load(context);
|
||||||
createShader(shaderType);
|
return createShader(shaderType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlShaderSource(int shader, int count, IntPtr str, int* length);
|
||||||
|
[GlImport("glCreateShader")]
|
||||||
|
static GlShaderSource shaderSource;
|
||||||
|
public static void ShaderSource(this IGlContext context, int shader, string source)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
|
||||||
|
int length = source.Length;
|
||||||
|
IntPtr intPtr = MarshalStringArrayToPtr(new string[] { source });
|
||||||
|
shaderSource(shader, 1, intPtr, &length);
|
||||||
|
FreeStringArrayPtr(intPtr, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static IntPtr MarshalStringArrayToPtr(string[] str_array)
|
||||||
|
{
|
||||||
|
IntPtr intPtr = IntPtr.Zero;
|
||||||
|
if (str_array != null && str_array.Length != 0)
|
||||||
|
{
|
||||||
|
intPtr = Marshal.AllocHGlobal(str_array.Length * IntPtr.Size);
|
||||||
|
if (intPtr == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new OutOfMemoryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (i = 0; i < str_array.Length; i++)
|
||||||
|
{
|
||||||
|
IntPtr val = MarshalStringToPtr(str_array[i]);
|
||||||
|
Marshal.WriteIntPtr(intPtr, i * IntPtr.Size, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OutOfMemoryException)
|
||||||
|
{
|
||||||
|
for (i--; i >= 0; i--)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(Marshal.ReadIntPtr(intPtr, i * IntPtr.Size));
|
||||||
|
}
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal(intPtr);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return intPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static IntPtr MarshalStringToPtr(string str)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
{
|
||||||
|
return IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
int num = Encoding.UTF8.GetMaxByteCount(str.Length) + 1;
|
||||||
|
IntPtr intPtr = Marshal.AllocHGlobal(num);
|
||||||
|
if (intPtr == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new OutOfMemoryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed (char* chars = str)
|
||||||
|
{
|
||||||
|
int bytes = Encoding.UTF8.GetBytes(chars, str.Length, (byte*)(void*)intPtr, num);
|
||||||
|
Marshal.WriteByte(intPtr, bytes, 0);
|
||||||
|
return intPtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void FreeStringArrayPtr(IntPtr ptr, int length)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(Marshal.ReadIntPtr(ptr, i * IntPtr.Size));
|
||||||
|
}
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public delegate int GlCreateProgram();
|
||||||
|
[GlImport("glCreateProgram")]
|
||||||
|
static GlCreateProgram createProgram;
|
||||||
|
public static int CreateProgram(this IGlContext context)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
return createProgram();
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlAttachShader(int program, int shader);
|
||||||
|
[GlImport("glAttachShader")]
|
||||||
|
static GlAttachShader attachShader;
|
||||||
|
public static void AttachShader(this IGlContext context, int program, int shader)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
attachShader(program, shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlDetachShader(int program, int shader);
|
||||||
|
[GlImport("glDetachShader")]
|
||||||
|
static GlDetachShader detachShader;
|
||||||
|
public static void DetachShader(this IGlContext context, int program, int shader)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
detachShader(program, shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlGetProgramiv(int program, int pname, int* @params);
|
||||||
|
[GlImport("glGetProgramiv")]
|
||||||
|
static GlGetProgramiv getProgramiv;
|
||||||
|
public static void GetProgram(this IGlContext context, int program, int pname, out int @params)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
fixed (int* ptr = &@params)
|
||||||
|
{
|
||||||
|
getProgramiv(program, pname, ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlGetProgramInfoLog(uint program, int bufSize, int* length, IntPtr infoLog);
|
||||||
|
[GlImport("glGetProgramInfoLog")]
|
||||||
|
static GlGetProgramInfoLog getProgramInfoLog;
|
||||||
|
public static string GetProgramInfoLog(this IGlContext context, uint program)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
GetProgram(context, (int)program, GlConsts.GL_INFO_LOG_LENGTH, out var @params);
|
||||||
|
if (@params == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
int bufSize = @params * 2;
|
||||||
|
IntPtr intPtr = Marshal.AllocHGlobal((IntPtr)(bufSize + 1));
|
||||||
|
getProgramInfoLog(program, bufSize, &@params, intPtr);
|
||||||
|
var infoLog = MarshalPtrToString(intPtr);
|
||||||
|
Marshal.FreeHGlobal(intPtr);
|
||||||
|
return infoLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetActiveUniform(this IGlContext context, int program, int uniformIndex, out int size, out int type)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
GetProgram(context, program, GlConsts.GL_ACTIVE_UNIFORM_MAX_LENGTH, out var @params);
|
||||||
|
GetActiveUniform(program, uniformIndex, (@params == 0) ? 1 : @params, out @params, out size, out type, out var name);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlGetActiveUniform(int program, int index, int bufSize, int* length, int* size, int* type, IntPtr name);
|
||||||
|
[GlImport("glGetActiveUniform")]
|
||||||
|
static GlGetActiveUniform getActiveUniform;
|
||||||
|
static void GetActiveUniform(int program, int index, int bufSize, out int length, out int size, out int type, out string name)
|
||||||
|
{
|
||||||
|
fixed (int* ptr = &length)
|
||||||
|
{
|
||||||
|
fixed (int* ptr2 = &size)
|
||||||
|
{
|
||||||
|
fixed (int* ptr3 = &type)
|
||||||
|
{
|
||||||
|
IntPtr intPtr = Marshal.AllocHGlobal((IntPtr)(bufSize + 1));
|
||||||
|
getActiveUniform(program, index, bufSize, ptr, ptr2, ptr3, intPtr);
|
||||||
|
name = MarshalPtrToString(intPtr);
|
||||||
|
Marshal.FreeHGlobal(intPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unsafe static string MarshalPtrToString(IntPtr ptr)
|
||||||
|
{
|
||||||
|
if (ptr == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("ptr");
|
||||||
|
}
|
||||||
|
|
||||||
|
sbyte* ptr2 = (sbyte*)(void*)ptr;
|
||||||
|
int num = 0;
|
||||||
|
for (; *ptr2 != 0; ptr2++)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new string((sbyte*)(void*)ptr, 0, num, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate int GlGetUniformLocation(int program, IntPtr name);
|
||||||
|
[GlImport("glGetUniformLocation")]
|
||||||
|
static GlGetUniformLocation getUniformLocation;
|
||||||
|
public static int GetUniformLocation(this IGlContext context, int program, string name)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
IntPtr intPtr = MarshalStringToPtr(name);
|
||||||
|
var result = getUniformLocation(program, intPtr);
|
||||||
|
FreeStringPtr(intPtr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
static void FreeStringPtr(IntPtr ptr)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlCompileShader(int shader);
|
||||||
|
[GlImport("glCompileShader")]
|
||||||
|
static GlCompileShader compileShader;
|
||||||
|
public static void CompileShader(this IGlContext context, int shader)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
compileShader(shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlGetShaderiv(int shader, int pname, int* @params);
|
||||||
|
[GlImport("glGetShaderiv")]
|
||||||
|
static GlGetShaderiv getShaderiv;
|
||||||
|
public static void GetShader(this IGlContext context, int shader, int pname, out int @params)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
fixed (int* ptr = &@params)
|
||||||
|
{
|
||||||
|
getShaderiv(shader, pname, ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetShaderInfoLog(this IGlContext context, int shader)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
GetShaderInfoLog(context, shader, out var info);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe static void GetShaderInfoLog(IGlContext context, int shader, out string info)
|
||||||
|
{
|
||||||
|
GetShader(context, shader, GlConsts.GL_INFO_LOG_LENGTH, out var @params);
|
||||||
|
if (@params == 0)
|
||||||
|
{
|
||||||
|
info = string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetShaderInfoLog((uint)shader, @params * 2, &@params, out info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public delegate void GlGetShaderInfoLog(uint shader, int bufSize, int* length, IntPtr infoLog);
|
||||||
|
[GlImport("glGetShaderInfoLog")]
|
||||||
|
static GlGetShaderInfoLog getShaderInfoLog;
|
||||||
|
static void GetShaderInfoLog(uint shader, int bufSize, [Out] int* length, out string infoLog)
|
||||||
|
{
|
||||||
|
IntPtr intPtr = Marshal.AllocHGlobal((IntPtr)(bufSize + 1));
|
||||||
|
getShaderInfoLog(shader, bufSize, length, intPtr);
|
||||||
|
infoLog = MarshalPtrToString(intPtr);
|
||||||
|
Marshal.FreeHGlobal(intPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlLinkProgram(int program);
|
||||||
|
[GlImport("glLinkProgram")]
|
||||||
|
static GlLinkProgram linkProgram;
|
||||||
|
public static void LinkProgram(this IGlContext context, int program)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
linkProgram(program);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate int GlGetAttribLocation(int program, IntPtr name);
|
||||||
|
[GlImport("glGetAttribLocation")]
|
||||||
|
static GlGetAttribLocation getAttribLocation;
|
||||||
|
public static int GetAttribLocation(this IGlContext context, int program, string name)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
IntPtr intPtr = MarshalStringToPtr(name);
|
||||||
|
int result = getAttribLocation(program, intPtr);
|
||||||
|
FreeStringPtr(intPtr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlUseProgram(int program);
|
||||||
|
[GlImport("glUseProgram")]
|
||||||
|
static GlUseProgram useProgram;
|
||||||
|
public static void UseProgram(this IGlContext context, int program)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
useProgram(program);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlGenVertexArrays(int num, uint* arrays);
|
||||||
|
[GlImport("glGenVertexArrays")]
|
||||||
|
static GlGenVertexArrays genVertexArrays;
|
||||||
|
public static int GenVertexArray(this IGlContext context)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
int result = default(int);
|
||||||
|
genVertexArrays(1, (uint*)(&result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlBindVertexArray(int array);
|
||||||
|
[GlImport("glBindVertexArray")]
|
||||||
|
static GlBindVertexArray bindVertexArray;
|
||||||
|
public static void BindVertexArray(this IGlContext context, int array)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
bindVertexArray(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlGenBuffers(int num, uint* buffer);
|
||||||
|
[GlImport("glGenBuffers")]
|
||||||
|
static GlGenBuffers genBuffers;
|
||||||
|
public static int GenBuffer(this IGlContext context)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
int result = default(int);
|
||||||
|
genBuffers(1, (uint*)(&result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlEnableVertexAttribArray(int index);
|
||||||
|
[GlImport("glEnableVertexAttribArray")]
|
||||||
|
static GlEnableVertexAttribArray enableVertexAttribArray;
|
||||||
|
public static void EnableVertexAttribArray(this IGlContext context, int index)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
enableVertexAttribArray(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlVertexAttribPointer(uint index, int size, int type, bool normalized, int stride, IntPtr pointer);
|
||||||
|
[GlImport("glVertexAttribPointer")]
|
||||||
|
static GlVertexAttribPointer vertexAttribPointer;
|
||||||
|
public static void VertexAttribPointer(this IGlContext context, uint index, int size, int type, bool normalized, int stride, int pointer)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
vertexAttribPointer(index, size, type, normalized, stride, (IntPtr)pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void GlDrawArrays(int mode, int first, int count);
|
||||||
|
[GlImport("glDrawArrays")]
|
||||||
|
static GlDrawArrays drawArrays;
|
||||||
|
public static void DrawArrays(this IGlContext context, int mode, int first, int count)
|
||||||
|
{
|
||||||
|
Load(context);
|
||||||
|
drawArrays(mode, first, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void GlEnable(int what);
|
public delegate void GlEnable(int what);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using CPF.Controls;
|
||||||
using CPF.Drawing;
|
using CPF.Drawing;
|
||||||
|
|
||||||
namespace CPF.Shapes
|
namespace CPF.Shapes
|
||||||
@ -28,9 +29,25 @@ namespace CPF.Shapes
|
|||||||
{
|
{
|
||||||
Data = path;
|
Data = path;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置 Stretch 模式,该模式确定内容适应可用空间的方式。
|
||||||
|
/// </summary>
|
||||||
|
[Description("获取或设置 Stretch 模式,该模式确定内容适应可用空间的方式。")]
|
||||||
|
[UIPropertyMetadata(Stretch.None, UIPropertyOptions.AffectsMeasure | UIPropertyOptions.AffectsRender)]
|
||||||
|
public Stretch Stretch
|
||||||
|
{
|
||||||
|
get { return GetValue<Stretch>(); }
|
||||||
|
set { SetValue(value); }
|
||||||
|
}
|
||||||
|
|
||||||
bool disposeGeometryOnInvalidateGeometry = false;
|
[PropertyChanged(nameof(Stretch))]
|
||||||
protected override bool DisposeGeometryOnInvalidateGeometry => disposeGeometryOnInvalidateGeometry;
|
void OnStretch(object newValue, object oldValue, PropertyMetadataAttribute propertyTabAttribute)
|
||||||
|
{
|
||||||
|
InvalidateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
//bool disposeGeometryOnInvalidateGeometry = false;
|
||||||
|
//protected override bool DisposeGeometryOnInvalidateGeometry => disposeGeometryOnInvalidateGeometry;
|
||||||
|
|
||||||
protected override CPF.Drawing.PathGeometry CreateDefiningGeometry()
|
protected override CPF.Drawing.PathGeometry CreateDefiningGeometry()
|
||||||
{
|
{
|
||||||
@ -39,15 +56,78 @@ namespace CPF.Shapes
|
|||||||
{
|
{
|
||||||
return new Drawing.PathGeometry();
|
return new Drawing.PathGeometry();
|
||||||
}
|
}
|
||||||
return data;
|
var clone = data.Clone();
|
||||||
|
|
||||||
|
var pathBounds = data.GetBounds();
|
||||||
|
|
||||||
|
Matrix transform;
|
||||||
|
|
||||||
|
if (this.Stretch == Stretch.None)
|
||||||
|
{
|
||||||
|
transform = Matrix.Identity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transform = Matrix.Identity;
|
||||||
|
var calculatedWidth = (float)(this.Width.Value / pathBounds.Width);
|
||||||
|
var calculatedHeight = (float)(this.Height.Value / pathBounds.Height);
|
||||||
|
var widthScale = float.IsNaN(calculatedWidth) ? 1 : calculatedWidth;
|
||||||
|
var heightScale = float.IsNaN(calculatedHeight) ? 1 : calculatedHeight;
|
||||||
|
|
||||||
|
switch (Stretch)
|
||||||
|
{
|
||||||
|
case Stretch.None:
|
||||||
|
break;
|
||||||
|
case Stretch.Fill:
|
||||||
|
transform.Scale(widthScale, heightScale);
|
||||||
|
transform.TranslatePrepend(
|
||||||
|
(float)(-pathBounds.Left),
|
||||||
|
(float)(-pathBounds.Top));
|
||||||
|
break;
|
||||||
|
case Stretch.Uniform:
|
||||||
|
var minScale = Math.Min(widthScale, heightScale);
|
||||||
|
transform.Scale(minScale, minScale);
|
||||||
|
var l = -pathBounds.Left;
|
||||||
|
var t = -pathBounds.Top;
|
||||||
|
transform.TranslatePrepend(l, t);
|
||||||
|
if (!Width.IsAuto && Width.Unit == Unit.Default)
|
||||||
|
{
|
||||||
|
l = (float)((this.Width.Value - minScale * pathBounds.Width) / 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l = 0;
|
||||||
|
}
|
||||||
|
if (!Height.IsAuto && Width.Unit == Unit.Default)
|
||||||
|
{
|
||||||
|
t = (float)((this.Height.Value - minScale * pathBounds.Height) / 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t = 0;
|
||||||
|
}
|
||||||
|
transform.Translate(l, t);
|
||||||
|
break;
|
||||||
|
case Stretch.UniformToFill:
|
||||||
|
var maxScale = Math.Max(widthScale, heightScale);
|
||||||
|
transform.Scale(maxScale, maxScale);
|
||||||
|
transform.TranslatePrepend((float)(-pathBounds.Left), (float)(-pathBounds.Top));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!transform.IsIdentity)
|
||||||
|
clone.Transform(transform);
|
||||||
|
|
||||||
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
//[PropertyChanged(nameof(Data))]
|
//[PropertyChanged(nameof(Data))]
|
||||||
//void OnData(object newValue, object oldValue, PropertyMetadataAttribute propertyTabAttribute)
|
//void OnData(object newValue, object oldValue, PropertyMetadataAttribute propertyTabAttribute)
|
||||||
//{
|
//{
|
||||||
// disposeGeometryOnInvalidateGeometry = true;
|
// //disposeGeometryOnInvalidateGeometry = true;
|
||||||
// InvalidateGeometry();
|
// //InvalidateGeometry();
|
||||||
// disposeGeometryOnInvalidateGeometry = false;
|
// //disposeGeometryOnInvalidateGeometry = false;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ namespace CPF.Styling
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("加载网页失败:" + e.Message);
|
Debug.WriteLine("加载网页失败:" + path + " " + e.Message);
|
||||||
}
|
}
|
||||||
action(text);
|
action(text);
|
||||||
}, null);
|
}, null);
|
||||||
@ -358,7 +358,7 @@ namespace CPF.Styling
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("读取文本失败:" + e.Message);
|
Debug.WriteLine("读取文本失败:" + path + " " + e.Message);
|
||||||
}
|
}
|
||||||
action(text);
|
action(text);
|
||||||
return;
|
return;
|
||||||
@ -381,7 +381,7 @@ namespace CPF.Styling
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("加载文本失败:" + e.Message);
|
Debug.WriteLine("加载文本失败:" + path + " " + e.Message);
|
||||||
}
|
}
|
||||||
action(text);
|
action(text);
|
||||||
return;
|
return;
|
||||||
@ -396,19 +396,22 @@ namespace CPF.Styling
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Task<string> GetText(string path)
|
public static Task<string> GetText(string path)
|
||||||
{
|
{
|
||||||
var task = Task.Factory.StartNew(() =>
|
//var task = Task.Factory.StartNew(() =>
|
||||||
{
|
//{
|
||||||
var invokeMre = new ManualResetEvent(false);
|
//var invokeMre = new ManualResetEvent(false);
|
||||||
string result = null;
|
//string result = null;
|
||||||
|
TaskCompletionSource<string> completionSource = new TaskCompletionSource<string>();
|
||||||
GetText(path, a =>
|
GetText(path, a =>
|
||||||
{
|
{
|
||||||
result = a;
|
completionSource.SetResult(a);
|
||||||
invokeMre.Set();
|
//result = a;
|
||||||
|
//invokeMre.Set();
|
||||||
});
|
});
|
||||||
invokeMre.WaitOne();
|
//invokeMre.WaitOne();
|
||||||
return result;
|
//return result;
|
||||||
});
|
return completionSource.Task;
|
||||||
return task;
|
//});
|
||||||
|
//return task;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 读取文件或者内嵌或者网络的图片,弱引用缓存
|
/// 读取文件或者内嵌或者网络的图片,弱引用缓存
|
||||||
|
@ -40,9 +40,9 @@ namespace ConsoleApp1
|
|||||||
#else
|
#else
|
||||||
(OperatingSystemType.Windows, new WindowsPlatform(false), new SkiaDrawingFactory
|
(OperatingSystemType.Windows, new WindowsPlatform(false), new SkiaDrawingFactory
|
||||||
{
|
{
|
||||||
#if NETCOREAPP3_1_OR_GREATER
|
//#if NETCOREAPP3_1_OR_GREATER
|
||||||
UseGPU=true
|
UseGPU = true
|
||||||
#endif
|
//#endif
|
||||||
})
|
})
|
||||||
, (OperatingSystemType.OSX, new CPF.Mac.MacPlatform(), new SkiaDrawingFactory { UseGPU = false })
|
, (OperatingSystemType.OSX, new CPF.Mac.MacPlatform(), new SkiaDrawingFactory { UseGPU = false })
|
||||||
, (OperatingSystemType.Linux, new CPF.Linux.LinuxPlatform(), new SkiaDrawingFactory { UseGPU = true })
|
, (OperatingSystemType.Linux, new CPF.Linux.LinuxPlatform(), new SkiaDrawingFactory { UseGPU = true })
|
||||||
|
@ -77,7 +77,7 @@ namespace ConsoleApp1
|
|||||||
{
|
{
|
||||||
MaximizeBox = true,
|
MaximizeBox = true,
|
||||||
});
|
});
|
||||||
LoadStyleFile("res://ConsoleApp1.Stylesheet1.css");
|
LoadStyleFile("res://ConsoleApp1/Stylesheet1.css");
|
||||||
//加载样式文件,文件需要设置为内嵌资源
|
//加载样式文件,文件需要设置为内嵌资源
|
||||||
|
|
||||||
if (!DesignMode)//设计模式下不执行
|
if (!DesignMode)//设计模式下不执行
|
||||||
|
@ -1342,7 +1342,8 @@ namespace ConsoleApp1
|
|||||||
nameof(Model.Insert)
|
nameof(Model.Insert)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Foreground="#fff"
|
Foreground="#fff",
|
||||||
|
//[nameof(Button.IsMouseOver)]=new TriggerDescribe((nameof(Button.Background),"rgb(236,245,255)"),(nameof(Button.Foreground),"rgb(64,158,255)"))
|
||||||
},
|
},
|
||||||
new Button
|
new Button
|
||||||
{
|
{
|
||||||
@ -1386,17 +1387,17 @@ namespace ConsoleApp1
|
|||||||
Width="100%",
|
Width="100%",
|
||||||
FontSize=22,
|
FontSize=22,
|
||||||
Tag=this,
|
Tag=this,
|
||||||
Template=(e,c)=>{
|
//Template=(e,c)=>{
|
||||||
c.Add(new Border
|
// c.Add(new Border
|
||||||
{
|
// {
|
||||||
Background="#f00",
|
// Background="#f00",
|
||||||
Height = "100%",
|
// Height = "100%",
|
||||||
Width = "100%",
|
// Width = "100%",
|
||||||
BorderFill = null,
|
// BorderFill = null,
|
||||||
Name = "contentPresenter",
|
// Name = "contentPresenter",
|
||||||
PresenterFor = this
|
// PresenterFor = this
|
||||||
});
|
// });
|
||||||
}
|
//}
|
||||||
},
|
},
|
||||||
Bindings=
|
Bindings=
|
||||||
{
|
{
|
||||||
|
@ -1071,6 +1071,17 @@ namespace ConsoleApp1
|
|||||||
Height = 172,
|
Height = 172,
|
||||||
Width = 167,
|
Width = 167,
|
||||||
},
|
},
|
||||||
|
new Path
|
||||||
|
{
|
||||||
|
IsAntiAlias = true,
|
||||||
|
Width = 205,
|
||||||
|
Height = 130,
|
||||||
|
MarginLeft = 461,
|
||||||
|
MarginTop = 78,
|
||||||
|
Fill = "#FFFF00",
|
||||||
|
Stretch = Stretch.Uniform,
|
||||||
|
Data="M224.94 813.36c-6.69 0-13.47-1.41-19.96-4.32-19.04-8.52-30.23-27.44-28.53-48.19 0.19-2.37 0.41-4.08 0.51-4.83 1.36-12.07 7.44-54.68 29.59-112.4 14.46-37.62 32.71-72.58 54.26-103.93 27.38-39.65 59.92-73.91 96.77-101.88 9.34-7.73 76.59-61.43 170.59-86.98v-59.34c0-22.02 12.57-41.09 32.82-49.77s42.72-4.63 58.67 10.56l199.82 190.34c15.82 15.07 24.53 35.4 24.53 57.24 0 21.85-8.71 42.17-24.53 57.24L619.65 747.48c-15.95 15.19-38.43 19.24-58.67 10.56-20.24-8.67-32.82-27.74-32.82-49.77v-47.71c-20.67 4.04-40.97 8.95-60.6 14.66-40.38 11.77-77.42 26.68-110.06 44.3-36.29 19.66-64.79 41.98-92.29 72.3-0.9 1.15-2.82 3.56-5.59 6.47-9.38 9.87-21.85 15.07-34.68 15.07z m39.93-21.15c-0.02 0.02-0.04 0.04-0.06 0.07 0.01-0.03 0.03-0.05 0.06-0.07z m-48.27-30.89s-0.15 1.09-0.29 2.81c-0.42 5.17 2.96 7.49 5.01 8.41 1.99 0.89 5.85 1.84 9.3-1.79 1.6-1.69 2.68-3.05 3.26-3.79 0.36-0.46 0.74-0.94 1.26-1.51 30.39-33.6 63.23-59.37 103.33-81.1 35.14-18.97 74.81-34.96 117.91-47.52 28.51-8.29 58.31-14.98 88.58-19.89 5.79-0.94 11.7 0.71 16.16 4.51 4.47 3.8 7.04 9.37 7.04 15.23v71.6c0 8.42 5.99 11.89 8.57 13 2.58 1.1 9.23 3.05 15.33-2.76l199.82-190.34c7.81-7.44 12.12-17.49 12.12-28.28 0-10.79-4.3-20.83-12.12-28.28L592.06 281.27c-6.09-5.81-12.75-3.86-15.33-2.76s-8.57 4.58-8.57 13v74.93c0 9.32-6.44 17.4-15.52 19.49-94.41 21.72-162.4 76.72-169.84 82.92-0.24 0.2-0.48 0.39-0.73 0.58-33.6 25.44-63.32 56.72-88.34 92.96-19.75 28.73-36.54 60.89-49.86 95.57-20.59 53.67-26.03 92.21-27.2 102.74-0.02 0.21-0.04 0.41-0.07 0.62z m0 0z"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3456,12 +3467,11 @@ new TabItemTemplate{
|
|||||||
{
|
{
|
||||||
MaximizeBox = true,
|
MaximizeBox = true,
|
||||||
ShadowBlur = 10,
|
ShadowBlur = 10,
|
||||||
#if !DesignMode
|
#if !DesignMode
|
||||||
//Effect = effect
|
//Effect = effect
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
//#if !Net4 && !NETCOREAPP3_0
|
||||||
//#if !Net4 && !NETCOREAPP3_0
|
|
||||||
// Children.Add(new GLView
|
// Children.Add(new GLView
|
||||||
// {
|
// {
|
||||||
// Height = "30%",
|
// Height = "30%",
|
||||||
|
Loading…
Reference in New Issue
Block a user