diff --git a/CPF.Skia/GlView.cs b/CPF.Skia/GlView.cs
index e2aa4a3..4038d16 100644
--- a/CPF.Skia/GlView.cs
+++ b/CPF.Skia/GlView.cs
@@ -18,19 +18,27 @@ namespace CPF.Skia
int DepthRenderBuffer;
Size oldSize;
SKImage image;
+ SKPaint paint;
+ GRBackendTexture backendTexture;
//IGlContext context;
protected unsafe override void OnRender(DrawingContext dc)
{
- var size1 = ActualSize;
- if (size1.Width <= 0 || size1.Height <= 0 || DesignMode)
+ var cSize = ActualSize;
+ if (cSize.Width <= 0 || cSize.Height <= 0 || DesignMode)
{
return;
}
- var size = new PixelSize((int)Math.Round(size1.Width * Root.RenderScaling), (int)Math.Round(size1.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 _gl = skia.GlContext;
+ if (paint == null)
+ {
+ paint = new SKPaint();
+ }
+ paint.IsAntialias = IsAntiAlias;
+ paint.FilterQuality = IsAntiAlias ? SKFilterQuality.Medium : SKFilterQuality.None;
if (Id == 0)
{
@@ -48,9 +56,9 @@ namespace CPF.Skia
OnGLLoaded(_gl);
}
- if (size1 != oldSize)
+ if (cSize != oldSize)
{
- oldSize = size1;
+ oldSize = cSize;
_gl.BindTexture(GlConsts.GL_TEXTURE_2D, ColorBuffer);
_gl.TexImage2D(GlConsts.GL_TEXTURE_2D, 0, GlConsts.GL_RGBA, (int)size.Width, (int)size.Height, 0, GlConsts.GL_RGB, GlConsts.GL_UNSIGNED_BYTE, IntPtr.Zero);
@@ -73,7 +81,11 @@ namespace CPF.Skia
{
image.Dispose();
}
- GRBackendTexture backendTexture = new GRBackendTexture((int)(size.Width / Root.RenderScaling), (int)(size.Height / Root.RenderScaling), false, new GRGlTextureInfo(0x0DE1, (uint)ColorBuffer, SKColorType.Rgba8888.ToGlSizedFormat()));
+ if (backendTexture != null)
+ {
+ backendTexture.Dispose();
+ }
+ backendTexture = new GRBackendTexture((int)(size.Width), (int)(size.Height), false, new GRGlTextureInfo(0x0DE1, (uint)ColorBuffer, SKColorType.Rgba8888.ToGlSizedFormat()));
image = SKImage.FromTexture((GRContext)skia.GlContext.GRContext, backendTexture, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
}
@@ -84,7 +96,9 @@ namespace CPF.Skia
_gl.Viewport(0, 0, (int)size.Width, (int)size.Height);
OnGLRender(_gl);
_gl.Viewport((int)vp[0], (int)vp[1], (int)vp[2], (int)vp[3]);
- skia.SKCanvas.DrawImage(image, 0, 0);
+ _gl.BindFramebuffer(GlConsts.GL_FRAMEBUFFER, 0);
+ //_gl.Flush();
+ skia.SKCanvas.DrawImage(image, new SKRect(0, 0, size.Width, size.Height), new SKRect(0, 0, cSize.Width, cSize.Height), paint);
}
@@ -117,12 +131,23 @@ namespace CPF.Skia
OpenglEx.DeleteFramebuffers(null, 1, new int[] { Id });
OpenglEx.DeleteTextures(null, 1, new int[] { ColorBuffer });
OpenglEx.DeleteRenderbuffers(null, 1, new int[] { DepthRenderBuffer });
+ Id = 0;
}
if (image != null)
{
image.Dispose();
image = null;
}
+ if (paint != null)
+ {
+ paint.Dispose();
+ paint = null;
+ }
+ if (backendTexture != null)
+ {
+ backendTexture.Dispose();
+ backendTexture = null;
+ }
base.Dispose(disposing);
}
}
@@ -133,6 +158,6 @@ namespace CPF.Skia
{
Context = gl;
}
- public IGlContext Context { get;private set; }
+ public IGlContext Context { get; private set; }
}
}
diff --git a/CPF.Skia/SkiaDrawingContext.cs b/CPF.Skia/SkiaDrawingContext.cs
index 772167c..6e34ae6 100644
--- a/CPF.Skia/SkiaDrawingContext.cs
+++ b/CPF.Skia/SkiaDrawingContext.cs
@@ -156,6 +156,11 @@ namespace CPF.Skia
surface.Dispose();
surface = null;
}
+ if (gRContext != null)
+ {
+ //gRContext.Flush();
+ gRContext.ResetContext();
+ }
//if (grContext != null)
//{
// //grContext.Flush();
@@ -729,7 +734,7 @@ namespace CPF.Skia
}
lines = newText.Split('\n');
var ws = paint.Paint.MeasureAllChar(lines[0]);
-
+
var wsEnd = new List<(string, float)>();
for (int i = ws.Count - 1; i >= 0; i--)
{
@@ -742,7 +747,7 @@ namespace CPF.Skia
{
//lenEnd = (lenEnd.Item1, lenEnd.Item2, newText.Substring(newText.Length - lenEnd.Item1, lenEnd.Item1));
lenEnd.Item3 = newText.Substring(newText.Length - lenEnd.Item1, lenEnd.Item1);
- if (lenEnd.Item3.Length>2)
+ if (lenEnd.Item3.Length > 2)
{
lenEnd.Item3 = lenEnd.Item3.Substring(1, lenEnd.Item3.Length - 1);
}
diff --git a/CPF/Binding.cs b/CPF/Binding.cs
index b529cf2..f58af5c 100644
--- a/CPF/Binding.cs
+++ b/CPF/Binding.cs
@@ -226,15 +226,31 @@ namespace CPF
BindingMode = bindingMode;
}
internal Binding() { }
-
+ ///
+ /// 多级绑定的属性集合
+ ///
+ string[] sourcePropertyNames;
internal bool IsDataContext = true;
+
+ string sourcePropertyName;
///
/// 数据源字段名
///
public string SourcePropertyName
{
- get;
- internal set;
+ get { return sourcePropertyName; }
+ internal set
+ {
+ sourcePropertyName = value;
+ if (value != null)
+ {
+ sourcePropertyNames = SourcePropertyName.Split('.');
+ }
+ else
+ {
+ sourcePropertyNames = null;
+ }
+ }
}
///
/// 链式绑定下标
@@ -362,7 +378,7 @@ namespace CPF
current.Push(this);
try
{
-
+
if (Source == null || !Source.IsAlive)
{
if (Owner.HasProperty(TargetPropertyName))
@@ -389,8 +405,9 @@ namespace CPF
value = Source.Target.GetPropretyValue(SourcePropertyName);
}*/
value = GetPropertySource(SourcePropertyName, Source.Target);
- if (value != null) {
- value = value.GetPropretyValue(SourcePropertyName.Split('.').LastOrDefault());
+ if (value != null)
+ {
+ value = value.GetPropretyValue(sourcePropertyNames.LastOrDefault());
}
if (Convert != null)
{
@@ -456,7 +473,7 @@ namespace CPF
{
if (!b.SetValue(nv, SourcePropertyName))
{
- /*var SourcePropertyNames = SourcePropertyName.Split('.');
+ /*var SourcePropertyNames = sourcePropertyNames;
if (SourcePropertyNames.Length == 1)
{
b.SetValue(SourcePropertyName, nv);
@@ -466,12 +483,13 @@ namespace CPF
{
Target = Target.GetPropretyValue(SourcePropertyNames[i]) as CpfObject;
}*/
- var SourcePropertyNames = SourcePropertyName.Split('.');
+ var SourcePropertyNames = sourcePropertyNames;
var Target = GetPropertySource(SourcePropertyName, b);
- if (Target != null) {
+ if (Target != null)
+ {
Target.SetValue(SourcePropertyNames.LastOrDefault(), nv);
}
-
+
//b.Type.GetProperty(SourcePropertyName).FastSetValue(b, nv);
}
}
@@ -551,7 +569,7 @@ namespace CPF
}
void PropertyChanged(object sender, PropertyChangedEventArgs e)
{
- var Temp_SourcePropertyName = SourcePropertyName.Split('.').LastOrDefault();
+ var Temp_SourcePropertyName = sourcePropertyNames.LastOrDefault();
if (Temp_SourcePropertyName == e.PropertyName)
{
//CPFObject s = sender as CPFObject;
@@ -576,11 +594,11 @@ namespace CPF
}
}
}
- internal object GetPropertySource(string SourcePropertyName,object Source)
+ internal object GetPropertySource(string SourcePropertyName, object Source)
{
try
{
- var SourcePropertyNames = SourcePropertyName.Split('.');
+ var SourcePropertyNames = sourcePropertyNames;
if (SourcePropertyNames.Length == 1)
{
return Source;
@@ -610,7 +628,7 @@ namespace CPF
BindingMode == BindingMode.OneWay ||
BindingMode == BindingMode.OneTime)
{
- var SourcePropertyNames = SourcePropertyName.Split('.');
+ var SourcePropertyNames = sourcePropertyNames;
var Temp_Target = GetPropertySource(SourcePropertyName, Source.Target);
var data = (Temp_Target as CpfObject)?.GetValue(SourcePropertyNames.LastOrDefault());
Owner.SetPropretyValue(TargetPropertyName, data);
@@ -624,7 +642,7 @@ namespace CPF
//{
// throw new Exception("错误");
//}
- var SourcePropertyNames = SourcePropertyName.Split('.');
+ var SourcePropertyNames = sourcePropertyNames;
if (SourcePropertyNames.Length == 1)
{
RegisterPropertyChanged(notify, PropertyChanged);
diff --git a/ConsoleApp1/GLView.cs b/ConsoleApp1/GLView.cs
index 766807e..1047285 100644
--- a/ConsoleApp1/GLView.cs
+++ b/ConsoleApp1/GLView.cs
@@ -72,7 +72,7 @@ namespace ConsoleApp1
_gl.DeleteShader(vertexShader);
_gl.DeleteShader(fragmentShader);
- base.OnGLLoaded(gl);
+ //base.OnGLLoaded(gl);
}
@@ -82,14 +82,13 @@ namespace ConsoleApp1
_gl.Clear(Silk.NET.OpenGLES.ClearBufferMask.ColorBufferBit | Silk.NET.OpenGLES.ClearBufferMask.DepthBufferBit | Silk.NET.OpenGLES.ClearBufferMask.StencilBufferBit);
_gl.UseProgram(shaderProgram);
-
_gl.BindVertexArray(vao);
_gl.DrawArrays(Silk.NET.OpenGLES.GLEnum.Triangles, 0, 3);
_gl.BindVertexArray(0);
_gl.UseProgram(0);
- base.OnGLRender(gl);
+ //base.OnGLRender(gl);
}
#endif
diff --git a/ConsoleApp1/Window2.cs b/ConsoleApp1/Window2.cs
index 2f9d4eb..7ad5f38 100644
--- a/ConsoleApp1/Window2.cs
+++ b/ConsoleApp1/Window2.cs
@@ -472,6 +472,7 @@ namespace ConsoleApp1
},
new ScrollViewer
{
+ Background = "url(res://ConsoleApp1/icon.png) Tile None 0,0,0,0",
MarginLeft = 421,//HorizontalScrollBarVisibility= ScrollBarVisibility.Disabled,
//VerticalScrollBarVisibility= ScrollBarVisibility.Visible,
Commands =
@@ -505,8 +506,9 @@ namespace ConsoleApp1
{
Height = 336,
Width = 421,
+ IsAntiAlias=true,
},
-#else
+ #else
new WrapPanel
{
Width="100%",
@@ -570,7 +572,7 @@ namespace ConsoleApp1
},
}
},
-#endif
+ #endif
Height=300,
MarginTop=19,
MarginRight=29
@@ -625,7 +627,7 @@ namespace ConsoleApp1
Value=0.001,
Bindings =
{
-
+
}
},
new Button
@@ -1967,7 +1969,7 @@ namespace ConsoleApp1
},
new Separator
{
-
+
},
new MenuItem
{
@@ -2465,8 +2467,6 @@ new TabItemTemplate{
Content="删除对象",
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
{
- data a = new data();
- a.test.test.Name = "666666";
(DataContext as MainModel).Test1.test.test = null;
})
},
@@ -2476,7 +2476,7 @@ new TabItemTemplate{
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
{
data a = new data();
- a.test.test.Name = "666666";
+ a.test.test.Name = "8888";
(DataContext as MainModel).Test1.test.test = a;
})
},
@@ -3456,10 +3456,19 @@ new TabItemTemplate{
{
MaximizeBox = true,
ShadowBlur = 10,
- #if !DesignMode
+#if !DesignMode
//Effect = effect
#endif
});
+
+//#if !Net4 && !NETCOREAPP3_0
+// Children.Add(new GLView
+// {
+// Height = "30%",
+// Width = "30%",
+// IsAntiAlias = true,
+// });
+//#endif
LoadStyleFile("res://ConsoleApp1/Stylesheet3.css");
//加载样式文件,文件需要设置为内嵌资源
Console.WriteLine(testBtn[DockPanel.Dock]);