daily update on 20240901 by nitload youmu

This commit is contained in:
Nitload
2024-09-02 05:57:07 +08:00
parent 1ee4e4a42f
commit 0979123ac0
47 changed files with 869 additions and 707 deletions
@@ -28,13 +28,16 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
@@ -45,10 +48,40 @@ namespace StgSharp.MVVM.ViewModel
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate ref object BindingDataGetter();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void BindingDataSetter(ref object value);
public abstract partial class ViewModelBase
{
public bool MethodLookup(string methodName, out Action callback)
{
MethodInfo method = GetType().GetMethod(methodName);
try
{
callback = (Action)Delegate.CreateDelegate(typeof(Action), this, methodName);
return true;
}
catch (MissingMethodException)
{
callback = null!;
return false;
}
catch (MethodAccessException)
{
callback = null!;
return false;
}
catch (Exception)
{
throw;
}
}
}
[StructLayout(LayoutKind.Explicit)]
public unsafe struct DataBindingEntry
{
private IntPtr getterPtr, setterPtr;
[FieldOffset(0)] private M128 _mask;
[FieldOffset(0)] private IntPtr getterPtr;
[FieldOffset(8)] private IntPtr setterPtr;
public DataBindingEntry(
[NotNull] BindingDataGetter gettingCallback,
@@ -73,11 +106,39 @@ namespace StgSharp.MVVM.ViewModel
return ref ((delegate* unmanaged[Cdecl]<ref object>)getterPtr)();
}
public void SetData(ref object value)
public void SetValue(ref object value)
{
((delegate* unmanaged[Cdecl]<ref object, void>)setterPtr)(ref value);
}
public static bool operator ==(DataBindingEntry left, DataBindingEntry right)
{
return left._mask == right._mask;
}
public static bool operator !=(DataBindingEntry left, DataBindingEntry right)
{
return left._mask != right._mask;
}
public bool Equals(DataBindingEntry other)
{
return (_mask == other._mask);
}
public override bool Equals(object obj)
{
if (obj is not DataBindingEntry other)
{
return false;
}
return Equals(other);
}
public override int GetHashCode()
{
return _mask.GetHashCode();
}
}
#nullable restore
@@ -40,7 +40,6 @@ namespace StgSharp.MVVM.ViewModel
{
public abstract partial class ViewModelBase
{
private ViewBase _nextView, _currentView;
protected ViewBase CurrentView
+31 -11
View File
@@ -77,6 +77,19 @@ namespace StgSharp.MVVM.ViewModel
() =>
{
};
viewPortDisplay.FrameSizeCallback = (handle, width, height)
=>
{
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
PrivateShow();
};
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
=>
{
PrivateShow();
};
}
protected ViewModelBase(float frameLength)
@@ -95,17 +108,30 @@ namespace StgSharp.MVVM.ViewModel
() =>
{
};
viewPortDisplay.FrameSizeCallback = (handle, width, height)
=>
{
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
PrivateShow();
};
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
=>
{
PrivateShow();
};
}
public ViewModelBase(ViewPort vbinding, int framespeed)
public ViewModelBase(ViewPort vBinding, int frameSpeed)
{
viewPortDisplay = vbinding;
viewPortDisplay = vBinding;
allView = new();
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
_frameSpeed = 0;
_frameCount = 0;
fpsCountProvider.SpanRefreshCallback = CountFps;
long frameLength = (framespeed > 0) ? ((1000L * 1000L) / framespeed) : 0;
long frameLength = (frameSpeed > 0) ? ((1000L * 1000L) / frameSpeed) : 0;
frameTimeProvider = new TimeSpanProvider(
frameLength, TimeSpanProvider.DefaultProvider
);
@@ -127,9 +153,9 @@ namespace StgSharp.MVVM.ViewModel
};
}
public ViewModelBase(ViewPort vbinding, float frameLength)
public ViewModelBase(ViewPort vBinding, float frameLength)
{
viewPortDisplay = vbinding;
viewPortDisplay = vBinding;
allView = new();
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
_frameSpeed = 0;
@@ -251,12 +277,6 @@ namespace StgSharp.MVVM.ViewModel
public abstract void CustomizeInitialize();
public Action MethodLookup(string methodName)
{
MethodInfo method = GetType().GetMethod(methodName);
return (method != null) ? ((Action)Delegate.CreateDelegate(typeof(Action), this, method)) : null;
}
/// <summary>
/// Resize the current form
/// </summary>