daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange
This commit is contained in:
@@ -28,8 +28,7 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Data;
|
||||
|
||||
using StgSharp.Data.Intrinsic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
@@ -45,50 +44,59 @@ namespace StgSharp.MVVM.ViewModel
|
||||
{
|
||||
#nullable enable
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate ref object BindingDataGetter();
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void BindingDataSetter(ref object value);
|
||||
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
|
||||
public delegate ref object BindingDataGetter();
|
||||
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
|
||||
public delegate void BindingDataSetter( ref object value );
|
||||
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
|
||||
public delegate bool MethodLookUpDelegate(
|
||||
string name,
|
||||
out Action callback );
|
||||
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
public bool MethodLookup(string methodName, out Action callback)
|
||||
|
||||
public bool MethodLookup( string methodName, out Action callback )
|
||||
{
|
||||
MethodInfo method = GetType().GetMethod(methodName);
|
||||
try
|
||||
{
|
||||
callback = (Action)Delegate.CreateDelegate(typeof(Action), this, methodName);
|
||||
MethodInfo method = GetType().GetMethod( methodName )!;
|
||||
if( method == null ) {
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
callback = ( Action )Delegate.CreateDelegate(
|
||||
typeof( Action ), this, methodName );
|
||||
return true;
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
catch( MissingMethodException ) {
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (MethodAccessException)
|
||||
{
|
||||
catch( MethodAccessException ) {
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
catch( Exception ) {
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct DataBindingEntry
|
||||
{
|
||||
[FieldOffset(0)] private M128 _mask;
|
||||
[FieldOffset(0)] private IntPtr getterPtr;
|
||||
[FieldOffset(8)] private IntPtr setterPtr;
|
||||
|
||||
[FieldOffset( 0 )] private IntPtr getterPtr;
|
||||
[FieldOffset( 8 )] private IntPtr setterPtr;
|
||||
[FieldOffset( 0 )] private M128 _mask;
|
||||
|
||||
public DataBindingEntry(
|
||||
[NotNull] BindingDataGetter gettingCallback,
|
||||
[NotNull] BindingDataSetter settingCallback)
|
||||
[NotNull] BindingDataSetter settingCallback )
|
||||
{
|
||||
getterPtr = Marshal.GetFunctionPointerForDelegate(gettingCallback);
|
||||
setterPtr = Marshal.GetFunctionPointerForDelegate(settingCallback);
|
||||
getterPtr = Marshal.GetFunctionPointerForDelegate( gettingCallback );
|
||||
setterPtr = Marshal.GetFunctionPointerForDelegate( settingCallback );
|
||||
}
|
||||
|
||||
public static DataBindingEntry NullBinding
|
||||
@@ -96,49 +104,54 @@ namespace StgSharp.MVVM.ViewModel
|
||||
get => new DataBindingEntry();
|
||||
}
|
||||
|
||||
public bool ExactEqual(DataBindingEntry other)
|
||||
public bool Equals( DataBindingEntry other )
|
||||
{
|
||||
return (getterPtr == other.getterPtr) && (setterPtr == other.setterPtr);
|
||||
return ( _mask == other._mask );
|
||||
}
|
||||
|
||||
public ref object GetValue()
|
||||
public override bool Equals( object obj )
|
||||
{
|
||||
return ref ((delegate* unmanaged[Cdecl]<ref object>)getterPtr)();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if( obj is not DataBindingEntry other ) {
|
||||
return false;
|
||||
}
|
||||
return Equals(other);
|
||||
return Equals( other );
|
||||
}
|
||||
|
||||
public bool ExactEqual( DataBindingEntry other )
|
||||
{
|
||||
return ( getterPtr == other.getterPtr ) && ( setterPtr == other.setterPtr );
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _mask.GetHashCode();
|
||||
}
|
||||
|
||||
public ref object GetValue()
|
||||
{
|
||||
return ref ( ( delegate* unmanaged[Cdecl]<ref object> )getterPtr )();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#nullable restore
|
||||
|
||||
@@ -28,8 +28,11 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.MVVM.View;
|
||||
using StgSharp.Threading;
|
||||
using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -40,6 +43,8 @@ namespace StgSharp.MVVM.ViewModel
|
||||
{
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
|
||||
private volatile bool _closed = true;
|
||||
private ViewBase _nextView, _currentView;
|
||||
|
||||
protected ViewBase CurrentView
|
||||
@@ -51,46 +56,91 @@ namespace StgSharp.MVVM.ViewModel
|
||||
/// <summary>
|
||||
/// CustomizeInit this form and render it on screen, and respond with operation
|
||||
/// </summary>
|
||||
public unsafe void UseViewModel(string viewEntryName)
|
||||
public unsafe void UseViewModel( string viewEntryName )
|
||||
{
|
||||
CustomizeInitialize();
|
||||
//BuildGlobalKeyControl();
|
||||
UseViewInNextFrame(viewEntryName);
|
||||
while (0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
||||
{
|
||||
ShowFrameOnce();
|
||||
UseViewInNextFrame( viewEntryName );
|
||||
TimeSpanAwaitingToken fpsCountingToken = fpsCountProvider.ParticipantSpanAwaiting(
|
||||
1 );
|
||||
fpsCountingToken.TimeSpanRefreshed += CountFps;
|
||||
fpsCountingToken.MissTimeSpanRefreshed += CountFps;
|
||||
if( _nextView != _currentView ) {
|
||||
Interlocked.Exchange( ref _currentView, _nextView );
|
||||
}
|
||||
Thread renderThread = new Thread(
|
||||
( token ) => {
|
||||
try {
|
||||
ProcessFrameWithoutEvent();
|
||||
}
|
||||
catch( Exception ex ) {
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Critical error when rendering:\n" + $"{ex}",
|
||||
LogType.Error );
|
||||
ShouldClose = true;
|
||||
}
|
||||
} );
|
||||
renderThread.Start();
|
||||
/**/
|
||||
using( TimeSpanAwaitingToken eventAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
|
||||
1 ) ) {
|
||||
while( _closed ) {
|
||||
if( _nextView != _currentView ) {
|
||||
Interlocked.Exchange( ref _currentView, _nextView );
|
||||
}
|
||||
InternalIO.glfwPollEvents();
|
||||
eventAwaitingToken.WaitNextSpan();
|
||||
_closed = !ShouldClose;
|
||||
}
|
||||
}
|
||||
/**/
|
||||
renderThread.Join();
|
||||
fpsCountingToken.Dispose();
|
||||
fpsCountProvider.StopSpanProviding();
|
||||
frameTimeProvider.StopSpanProviding();
|
||||
}
|
||||
|
||||
protected void UseViewInNextFrame(string name)
|
||||
protected void UseViewInNextFrame( string name )
|
||||
{
|
||||
if (!allView.TryGetValue(name, out ViewBase v))
|
||||
{
|
||||
throw new KeyNotFoundException($"{$"Cannot find View named {name} "}{$"in current View Model of {GetType().FullName}"}");
|
||||
if( !allView.TryGetValue( name, out ViewBase v ) ) {
|
||||
throw new KeyNotFoundException(
|
||||
$"{$"Cannot find View named {name} "}{$"in current View Model of {GetType().FullName}"}" );
|
||||
}
|
||||
CurrentView = v;
|
||||
}
|
||||
|
||||
private void CountFps( object sender, EventArgs e )
|
||||
{
|
||||
Interlocked.Exchange( ref _frameSpeed, _frameCount );
|
||||
Interlocked.Exchange( ref _frameCount, 0 );
|
||||
/**/
|
||||
Console.Clear();
|
||||
Console.WriteLine( FrameSpeed );
|
||||
/**/
|
||||
}
|
||||
|
||||
private unsafe void PrivateShow()
|
||||
{
|
||||
if (0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
||||
{
|
||||
if( 0 == InternalIO.glfwWindowShouldClose(
|
||||
this.viewPortDisplay.ViewPortID ) ) {
|
||||
CurrentView.Use();
|
||||
RenderStream.PollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowFrameOnce()
|
||||
private void ProcessFrameWithoutEvent()
|
||||
{
|
||||
viewPortDisplay.FlushSize();
|
||||
if (_nextView != _currentView)
|
||||
{
|
||||
Interlocked.Exchange(ref _currentView, _nextView);
|
||||
using( TimeSpanAwaitingToken renderAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
|
||||
1 ) ) {
|
||||
renderAwaitingToken.TimeSpanRefreshed += ( _, _ ) => { };
|
||||
while( _closed ) {
|
||||
foreach( ViewPort context in CurrentView.Render ) {
|
||||
context.FlushSize();
|
||||
}
|
||||
CurrentView.Use();
|
||||
renderAwaitingToken.WaitNextSpan();
|
||||
Interlocked.Add( ref _frameCount, 1 );
|
||||
}
|
||||
}
|
||||
CurrentView.Use();
|
||||
RenderStream.PollEvents();
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,13 +44,15 @@ namespace StgSharp.MVVM.ViewModel
|
||||
|
||||
private Dictionary<string, ViewBase> allView;
|
||||
|
||||
public T CreateAndBindView<T>(string name, (int x, int y, int z) unitCubeSize)
|
||||
where T : ViewBase, new()
|
||||
public T CreateAndBindView<T>(
|
||||
string name,
|
||||
(int x, int y, int z) unitCubeSize )
|
||||
where T: ViewBase, new()
|
||||
{
|
||||
T ret = new T();
|
||||
ret.SelfName = name;
|
||||
ret.InternalInitialize(name, unitCubeSize, this);
|
||||
allView.Add(name, ret);
|
||||
ret.InternalInitialize( name, unitCubeSize, this );
|
||||
allView.Add( name, ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.MVVM.View;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
using StgSharp.Threading;
|
||||
using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
@@ -51,6 +52,7 @@ namespace StgSharp.MVVM.ViewModel
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
|
||||
private FrameBufferSizeHandler _resizeCallback;
|
||||
private int _frameCount;
|
||||
private int _frameSpeed;
|
||||
private ViewPort viewPortDisplay;
|
||||
@@ -61,135 +63,72 @@ namespace StgSharp.MVVM.ViewModel
|
||||
internal TimeSpanProvider frameTimeProvider;
|
||||
internal Vector4 backgroundColor;
|
||||
|
||||
protected ViewModelBase(int frameSpeed)
|
||||
protected ViewModelBase( int frameSpeed )
|
||||
{
|
||||
viewPortDisplay = new ViewPort();
|
||||
allView = new();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
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
|
||||
);
|
||||
frameTimeProvider.SpanRefreshCallback =
|
||||
() =>
|
||||
{
|
||||
};
|
||||
|
||||
viewPortDisplay.FrameSizeCallback = (handle, width, height)
|
||||
=>
|
||||
{
|
||||
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
|
||||
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
|
||||
PrivateShow();
|
||||
};
|
||||
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
|
||||
=>
|
||||
{
|
||||
PrivateShow();
|
||||
};
|
||||
frameLength, TimeSpanProvider.DefaultProvider );
|
||||
FrameSizeCallback = DefaultFrameRewsizeCallback;
|
||||
}
|
||||
|
||||
protected ViewModelBase(float frameLength)
|
||||
protected ViewModelBase( float frameLength )
|
||||
{
|
||||
viewPortDisplay = new ViewPort();
|
||||
allView = new();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
fpsCountProvider = new TimeSpanProvider(
|
||||
1.0, TimeSpanProvider.DefaultProvider );
|
||||
_frameSpeed = 0;
|
||||
_frameCount = 0;
|
||||
fpsCountProvider.SpanRefreshCallback = CountFps;
|
||||
long _frameLength = (FrameSpeed > 0) ? ((long)(1000 * frameLength)) : 0;
|
||||
long _frameLength = ( FrameSpeed > 0 ) ?
|
||||
( ( long )( 1000 * frameLength ) ) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(
|
||||
_frameLength, TimeSpanProvider.DefaultProvider
|
||||
);
|
||||
frameTimeProvider.SpanRefreshCallback =
|
||||
() =>
|
||||
{
|
||||
};
|
||||
|
||||
viewPortDisplay.FrameSizeCallback = (handle, width, height)
|
||||
=>
|
||||
{
|
||||
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
|
||||
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
|
||||
PrivateShow();
|
||||
};
|
||||
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
|
||||
=>
|
||||
{
|
||||
PrivateShow();
|
||||
};
|
||||
_frameLength, TimeSpanProvider.DefaultProvider );
|
||||
FrameSizeCallback = DefaultFrameRewsizeCallback;
|
||||
}
|
||||
|
||||
public ViewModelBase(ViewPort vBinding, int frameSpeed)
|
||||
public ViewModelBase( ViewPort vBinding, int frameSpeed )
|
||||
{
|
||||
viewPortDisplay = vBinding;
|
||||
allView = new();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
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
|
||||
);
|
||||
frameTimeProvider.SpanRefreshCallback =
|
||||
() =>
|
||||
{
|
||||
};
|
||||
viewPortDisplay.FrameSizeCallback = (handle, width, height)
|
||||
=>
|
||||
{
|
||||
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
|
||||
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
|
||||
PrivateShow();
|
||||
};
|
||||
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
|
||||
=>
|
||||
{
|
||||
PrivateShow();
|
||||
};
|
||||
frameLength, TimeSpanProvider.DefaultProvider );
|
||||
FrameSizeCallback = DefaultFrameRewsizeCallback;
|
||||
}
|
||||
|
||||
public ViewModelBase(ViewPort vBinding, float frameLength)
|
||||
public ViewModelBase( ViewPort vBinding, float frameLength )
|
||||
{
|
||||
viewPortDisplay = vBinding;
|
||||
allView = new();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
fpsCountProvider = new TimeSpanProvider(
|
||||
1.0, TimeSpanProvider.DefaultProvider );
|
||||
_frameSpeed = 0;
|
||||
_frameCount = 0;
|
||||
fpsCountProvider.SpanRefreshCallback = CountFps;
|
||||
long _frameLength = (frameLength > 0) ? ((long)(1000 * frameLength)) : 0;
|
||||
long _frameLength = ( frameLength > 0 ) ?
|
||||
( ( long )( 1000 * frameLength ) ) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(
|
||||
_frameLength, TimeSpanProvider.DefaultProvider
|
||||
);
|
||||
frameTimeProvider.SpanRefreshCallback =
|
||||
() =>
|
||||
{
|
||||
};
|
||||
|
||||
viewPortDisplay.FrameSizeCallback = (handle, width, height)
|
||||
=>
|
||||
{
|
||||
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
|
||||
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
|
||||
PrivateShow();
|
||||
};
|
||||
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
|
||||
=>
|
||||
{
|
||||
PrivateShow();
|
||||
};
|
||||
_frameLength, TimeSpanProvider.DefaultProvider );
|
||||
FrameSizeCallback = DefaultFrameRewsizeCallback;
|
||||
}
|
||||
|
||||
public DataBindingEntry this[string name]
|
||||
public DataBindingEntry this[ string name ]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.TryGetObjectReference(name, out DataBindingEntry entry))
|
||||
{
|
||||
if( this.TryGetObjectReference(
|
||||
name, out DataBindingEntry entry ) ) {
|
||||
return entry;
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
@@ -198,8 +137,10 @@ namespace StgSharp.MVVM.ViewModel
|
||||
|
||||
public bool ShouldClose
|
||||
{
|
||||
get => InternalIO.glfwWindowShouldClose(viewPortDisplay.ViewPortID) != 0;
|
||||
set => InternalIO.glfwSetWindowShouldClose(viewPortDisplay.ViewPortID, value ? 1 : 0);
|
||||
get => InternalIO.glfwWindowShouldClose(
|
||||
viewPortDisplay.ViewPortID ) != 0;
|
||||
set => InternalIO.glfwSetWindowShouldClose(
|
||||
viewPortDisplay.ViewPortID, value ? 1 : 0 );
|
||||
}
|
||||
|
||||
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
|
||||
@@ -207,28 +148,19 @@ namespace StgSharp.MVVM.ViewModel
|
||||
public int FrameSpeed => _frameSpeed;
|
||||
|
||||
/// <summary>
|
||||
/// Height of this form, represent in <see cref="int"/>
|
||||
/// Height of this form, represent in <see cref="int" />
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
get => viewPortDisplay.Height;
|
||||
set { viewPortDisplay.Height = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width of this form, represent in <see cref="int"/>
|
||||
/// Width of this form, represent in <see cref="int" />
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
get => viewPortDisplay.Width;
|
||||
set
|
||||
{
|
||||
viewPortDisplay.Width = value;
|
||||
if (WindowID != IntPtr.Zero)
|
||||
{
|
||||
InternalIO.glfwSetWindowSize(viewPortDisplay.ViewPortID, Width, Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe IntPtr WindowID
|
||||
@@ -242,20 +174,11 @@ namespace StgSharp.MVVM.ViewModel
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width of this form, represent in <see cref="int"/>
|
||||
/// Width of this form, represent in <see cref="int" />
|
||||
/// </summary>
|
||||
public vec2d Size
|
||||
public Vec2 Size
|
||||
{
|
||||
get => new vec2d(Width, Height);
|
||||
set
|
||||
{
|
||||
Width = (int)value.X;
|
||||
Height = (int)value.Y;
|
||||
if (WindowID != IntPtr.Zero)
|
||||
{
|
||||
InternalIO.glfwSetWindowSize(viewPortDisplay.ViewPortID, Width, Height);
|
||||
}
|
||||
}
|
||||
get => new Vec2( Width, Height );
|
||||
}
|
||||
|
||||
public ViewPort ViewPortBinding
|
||||
@@ -263,79 +186,74 @@ namespace StgSharp.MVVM.ViewModel
|
||||
get => viewPortDisplay;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1044
|
||||
#pragma warning disable CA1044
|
||||
protected FrameBufferSizeHandler FrameSizeCallback
|
||||
{
|
||||
set
|
||||
{
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
||||
InternalIO.glfwSetFramebufferSizeCallback(viewPortDisplay.ViewPortID, handlerPtr);
|
||||
_resizeCallback = value;
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(
|
||||
value );
|
||||
InternalIO.glfwSetFramebufferSizeCallback(
|
||||
viewPortDisplay.ViewPortID, handlerPtr );
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1044
|
||||
|
||||
#pragma warning restore CA1044
|
||||
|
||||
public abstract void CustomizeInitialize();
|
||||
|
||||
/// <summary>
|
||||
/// Resize the current form
|
||||
/// </summary>
|
||||
/// <param name="size">
|
||||
/// A <see cref="vec2d"/> (width,height) representing the new size of current form
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetSize(vec2d size)
|
||||
{
|
||||
this.Size = size;
|
||||
InternalIO.glfwSetWindowSize(this.viewPortDisplay.ViewPortID, (int)size.X, (int)size.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the size limit of current form
|
||||
/// </summary>
|
||||
/// <param name="minSize">
|
||||
/// Minimum size of current form. In form of a <see cref="vec2d"/> of (width,height)
|
||||
/// Minimum size of current form. In form of a <see cref="Vec2" /> of (width,height)
|
||||
/// </param>
|
||||
/// <param name="maxSize">
|
||||
/// Maximum size of current form. In form of a <see cref="vec2d"/> of (width,height)
|
||||
/// Maximum size of current form. In form of a <see cref="Vec2" /> of (width,height)
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetSizeLimit(vec2d minSize, vec2d maxSize)
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void SetSizeLimit( Vec2 minSize, Vec2 maxSize )
|
||||
{
|
||||
ThreadHelper.MainThreadAssert();
|
||||
InternalIO.glfwSetWindowSizeLimits(
|
||||
this.viewPortDisplay.ViewPortID,
|
||||
(int)minSize.X,
|
||||
(int)minSize.Y,
|
||||
(int)maxSize.X,
|
||||
(int)maxSize.Y);
|
||||
this.viewPortDisplay.ViewPortID, ( int )minSize.X,
|
||||
( int )minSize.Y, ( int )maxSize.X, ( int )maxSize.Y );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the size limit of current form
|
||||
/// </summary>
|
||||
/// <param name="minWidth">Minimum width of current form</param>
|
||||
/// <param name="minHeight">Minimum height of current form</param>
|
||||
/// <param name="maxWidth">Maximum width of current form</param>
|
||||
/// <param name="maxHeight">Maximum height of current form</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
|
||||
/// <param name="minWidth"> Minimum width of current form </param>
|
||||
/// <param name="minHeight"> Minimum height of current form </param>
|
||||
/// <param name="maxWidth"> Maximum width of current form </param>
|
||||
/// <param name="maxHeight"> Maximum height of current form </param>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void SetSizeLimit(
|
||||
int minWidth,
|
||||
int minHeight,
|
||||
int maxWidth,
|
||||
int maxHeight )
|
||||
{
|
||||
//TODO 重做form的尺寸极限控制
|
||||
InternalIO.glfwSetWindowSizeLimits(this.viewPortDisplay.ViewPortID, minWidth, minHeight, maxWidth, maxHeight);
|
||||
ThreadHelper.MainThreadAssert();
|
||||
InternalIO.glfwSetWindowSizeLimits(
|
||||
this.viewPortDisplay.ViewPortID, minWidth, minHeight, maxWidth,
|
||||
maxHeight );
|
||||
}
|
||||
|
||||
public abstract bool TryGetObjectReference(string name, out DataBindingEntry entry);
|
||||
public abstract bool TryGetObjectReference(
|
||||
string name,
|
||||
out DataBindingEntry entry );
|
||||
|
||||
private void CountFps()
|
||||
private void DefaultFrameRewsizeCallback(
|
||||
IntPtr windowHandle,
|
||||
int width,
|
||||
int height )
|
||||
{
|
||||
/**/
|
||||
Console.Clear();
|
||||
Console.WriteLine(FrameSpeed);
|
||||
/**/
|
||||
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
||||
Interlocked.Exchange(ref _frameCount, 0);
|
||||
ViewPort.GetExistedViewPort( windowHandle, out ViewPort vp );
|
||||
vp.RequestFlushSizeInNextFrame( width, height );
|
||||
|
||||
//Console.WriteLine($"{width} {height}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user