Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-06-18 05:17:14 +08:00
parent 74c01effe4
commit c624a8ca38
300 changed files with 12227 additions and 4303 deletions
+35 -38
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ViewBase.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -46,15 +46,16 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading;
namespace StgSharp.MVVM.View
namespace StgSharp.MVVM
{
/// <summary>
/// ViewBase is the base type for all view types, providing context binding and control element
/// binding. A complete view should contain one complete <see cref="ViewDesigner{T}" />, <see
/// cref="ViewRender{TView}" />, and <see cref="ViewResponder" />, which provide layout
/// descriptions of control elements, user responses, and rendering implementations in the view.
/// Data between instances of <see cref="ViewDesigner{T}" />, <see cref="ViewRender{TView}" />,
/// and <see cref="ViewResponder{T}" /> is shared through <see cref="ViewBase" />.
/// ViewBase is the base type for all view types, providing context binding and control
/// element binding. A complete view should contain one complete <see cref="ViewDesigner{T}"
/// />, <see cref="ViewRender{TView}" />, and <see cref="ViewResponder" />, which provide
/// layout descriptions of control elements, user responses, and rendering implementations in
/// the view. Data between instances of <see cref="ViewDesigner{T}" />, <see
/// cref="ViewRender{TView}" />, and <see cref="ViewResponder{T}" /> is shared through <see
/// cref="ViewBase" />.
/// </summary>
public abstract unsafe partial class ViewBase
@@ -72,9 +73,7 @@ namespace StgSharp.MVVM.View
private ViewPort context;
private delegate bool GetDataBindingEntryDelegate(
string name,
out DataBindingEntry entry );
private delegate bool GetDataBindingEntryDelegate( string name, out DataBindingEntry entry );
public DataBindingEntry this[ string name ]
{
@@ -95,11 +94,7 @@ namespace StgSharp.MVVM.View
get => unitCubeSize;
}
public bool Activated
{
get;
internal set;
}
public bool Activated { get; internal set; }
public int Height
{
@@ -113,7 +108,7 @@ namespace StgSharp.MVVM.View
public IntPtr Monitor => context.Monitor;
public IntPtr ViewHandle => context.ViewPortID;
public IntPtr ViewHandle => context.ViewPortHandle;
public IViewDesigner<ViewBase> Designer
{
@@ -123,11 +118,7 @@ namespace StgSharp.MVVM.View
public string ContextName => context.Name;
public string SelfName
{
get;
set;
}
public string SelfName { get; set; }
public ViewPort Port
{
@@ -151,24 +142,27 @@ namespace StgSharp.MVVM.View
set => _responder = value;
}
public abstract void CustomizedInitialize(
[NotNull]ViewModelBase viewModelBinding );
public abstract void CustomizedInitialize( [NotNull]ViewModelBase viewModelBinding );
/// <summary>
/// Get the status of a certain key on the keyboard.
/// Get the status of a certain key on the keyboard.
/// </summary>
/// <param _name="key"></param>
/// <returns><see cref="KeyStatus" /> representing if a key is pressed or released. </returns>
/// <param _label="key">
///
/// </param>
/// <returns>
/// <see cref="KeyStatus" /> representing if a key is pressed or released.
/// </returns>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public KeyStatus GetKeyStatus( KeyboardKey key )
{
return InternalIO.glfwGetKey( context.ViewPortID, ( int )key );
return InternalIO.glfwGetKey( context.ViewPortHandle, ( int )key );
}
public void InternalInitialize(
string name,
(int, int, int) cubeSize,
[NotNull]ViewModelBase viewModelBinding )
string name,
(int, int, int) cubeSize,
[NotNull]ViewModelBase viewModelBinding )
{
SelfName = name;
unitCubeSize = cubeSize;
@@ -179,13 +173,12 @@ namespace StgSharp.MVVM.View
CustomizedInitialize( viewModelBinding );
}
public abstract bool TryGetObjectReference(
string name,
out DataBindingEntry entry );
public abstract bool TryGetObjectReference( string name, out DataBindingEntry entry );
public void Use()
{
if( usedFrame == 0 ) {
if( usedFrame == 0 )
{
if( !ValidateInitialization() ) {
throw new InvalidOperationException(
"This view is not correctly initialized before rendering." );
@@ -197,9 +190,13 @@ namespace StgSharp.MVVM.View
public bool ValidateInitialization()
{
return ( _design != null ) && ( _render != null ) && ( getDataBindingEntry != null ) && ( _responder != null ) && _design.ValidateInitializing(
) && _responder.ValidateInitializing() && _render.ValidateInitializing(
);
return ( _design != null ) &&
( _render != null ) &&
( getDataBindingEntry != null ) &&
( _responder != null ) &&
_design.ValidateInitializing() &&
_responder.ValidateInitializing() &&
_render.ValidateInitializing();
}
protected abstract void Show();
+22 -21
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ViewDesigner.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -40,7 +40,7 @@ using System.Collections.Generic;
using System.Net;
using System.Text;
namespace StgSharp.MVVM.View
namespace StgSharp.MVVM
{
public abstract partial class ViewBase
{
@@ -57,12 +57,11 @@ namespace StgSharp.MVVM.View
}
/// <summary>
/// ViewDesigner provides descriptions of various controls in the view, binds the controls
/// to specific user actions and behaviors, and describes the layout and interactions of
/// each control.
/// ViewDesigner provides descriptions of various controls in the view, binds the
/// controls to specific user actions and behaviors, and describes the layout and
/// interactions of each control.
/// </summary>
public abstract class ViewDesigner<TView> : IViewDesigner<TView>
where TView: ViewBase
public abstract class ViewDesigner<TView> : IViewDesigner<TView> where TView: ViewBase
{
private KeyboardButtonGroup currentButtonGroup;
@@ -82,10 +81,10 @@ namespace StgSharp.MVVM.View
}
public CharacterLineIndexImage CreateCharacterLine(
int length,
char blankFilling,
PlainGeometryMesh tittle,
IEnumerable<(char, PlainGeometryMesh)> charList )
int length,
char blankFilling,
PlainGeometryMesh tittle,
IEnumerable<(char, PlainGeometryMesh)> charList )
{
CharacterLineIndexImage ret = new CharacterLineIndexImage(
length, blankFilling, tittle, charList );
@@ -94,17 +93,19 @@ namespace StgSharp.MVVM.View
}
public TriggerButton CreateKeyboardButton(
Rectangle bonding,
TextureProvider defaultAnimation,
bool isEnable )
Rectangle bonding,
TextureProvider defaultAnimation,
bool isEnable )
{
TriggerButton ret = new TriggerButton();
ret.BoundingBox = bonding;
ret.Texture = defaultAnimation;
if( isEnable ) {
if( isEnable )
{
ret.IsDisabled = false;
ret.Enable();
} else {
} else
{
ret.IsDisabled = true;
ret.Disable();
}
@@ -113,11 +114,11 @@ namespace StgSharp.MVVM.View
}
public TButtonGroup CreateKeyboardButtonGroup<TButtonGroup>(
IClickTrigger leftBidning,
IClickTrigger rightBinding,
IClickTrigger upBinding,
IClickTrigger downBinding,
IClickTrigger confirmBinding )
IClickTrigger leftBidning,
IClickTrigger rightBinding,
IClickTrigger upBinding,
IClickTrigger downBinding,
IClickTrigger confirmBinding )
where TButtonGroup: KeyboardButtonGroup, new()
{
TButtonGroup ret = new TButtonGroup();
+11 -17
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ViewRender.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.HighPerformance;
@@ -37,19 +36,15 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.MVVM.View
namespace StgSharp.MVVM
{
public abstract partial class ViewBase
{
protected internal interface IViewRender<out TView>
where TView: ViewBase
protected internal interface IViewRender<out TView> where TView: ViewBase
{
RenderStream this[ DataLabel renderName ]
{
get;
}
RenderStream this[ DataLabel renderName ] { get; }
void CustomizedInitialize();
@@ -61,8 +56,7 @@ namespace StgSharp.MVVM.View
}
protected abstract class ViewRender<TView> : IViewRender<TView>
where TView: ViewBase
protected abstract class ViewRender<TView> : IViewRender<TView> where TView: ViewBase
{
protected ViewRender( TView binding )
@@ -73,14 +67,15 @@ namespace StgSharp.MVVM.View
public RenderStream this[ DataLabel renderName ]
{
get => _render.TryGetValue(
renderName, out RenderStream stream ) ?
get => _render.TryGetValue( renderName, out RenderStream stream ) ?
stream : ( null! );
protected set
{
if( _render.ContainsKey( renderName ) ) {
if( _render.ContainsKey( renderName ) )
{
_render[ renderName ] = value;
} else {
} else
{
_render.Add( renderName, value );
}
}
@@ -106,8 +101,7 @@ namespace StgSharp.MVVM.View
return ret;
}
public T CreateRenderStream<T>( ViewPort vp )
where T: RenderStream, new()
public T CreateRenderStream<T>( ViewPort vp ) where T: RenderStream, new()
{
T ret = new T();
ret.Initialize( vp, Binding.TimeProvider );
+23 -29
View File
@@ -37,7 +37,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.MVVM.View
namespace StgSharp.MVVM
{
public partial class ViewBase
{
@@ -45,14 +45,9 @@ namespace StgSharp.MVVM.View
protected interface IViewResponder<out TVIew> where TVIew: ViewBase
{
Action? this[ IClickTrigger trigger ]
{
get;
set;
}
Action? this[ IClickTrigger trigger ] { get; set; }
void CustomizedInitialize(
Func<IClickTrigger, string, Action> keyRegister );
void CustomizedInitialize( Func<IClickTrigger, string, Action> keyRegister );
void Initialize( MethodLookUpDelegate methodGetter );
@@ -62,8 +57,7 @@ namespace StgSharp.MVVM.View
}
protected abstract class ViewResponder<TView> : IViewResponder<TView>
where TView: ViewBase
protected abstract class ViewResponder<TView> : IViewResponder<TView> where TView: ViewBase
{
private bool _isInitialized;
@@ -82,20 +76,17 @@ namespace StgSharp.MVVM.View
public Action? this[ IClickTrigger trigger ]
#pragma warning restore CA1043
{
get => keyCallbackIndex.TryGetValue(
trigger, out Action callback ) ?
callback : null;
get => keyCallbackIndex.TryGetValue( trigger, out Action callback ) ?
callback : null;
set
{
if( keyCallbackIndex.TryGetValue(
trigger, out Action callback ) ) {
if( keyCallbackIndex.TryGetValue( trigger, out Action callback ) )
{
callback += value;
} else {
} else
{
keyCallbackIndex.Add(
trigger,
value ??
throw new ArgumentNullException(
nameof( value ) ) );
trigger, value ?? throw new ArgumentNullException( nameof( value ) ) );
}
}
}
@@ -103,7 +94,7 @@ namespace StgSharp.MVVM.View
protected TView Binding => _binding;
public abstract void CustomizedInitialize(
Func<IClickTrigger, string, Action> keyRegister );
Func<IClickTrigger, string, Action> keyRegister );
public void Initialize( MethodLookUpDelegate methodGetter )
{
@@ -112,11 +103,13 @@ namespace StgSharp.MVVM.View
}
CustomizedInitialize(
( trigger, name ) => {
if( !nameToCallbackMap.TryGetValue(
name, out Action ret ) ) {
if( methodGetter( name, out Action lookup ) ) {
if( !nameToCallbackMap.TryGetValue( name, out Action ret ) )
{
if( methodGetter( name, out Action lookup ) )
{
this[ trigger ] = lookup;
} else {
} else
{
throw new InvalidOperationException(
$"Cannot find method named {name} in binded view model" );
}
@@ -127,10 +120,11 @@ namespace StgSharp.MVVM.View
public void ProcessUserInput()
{
foreach( KeyValuePair<IClickTrigger, Action> pair in keyCallbackIndex ) {
if( InternalIO.glfwGetKey(
_binding.ViewHandle,
pair.Key.TargetKeyOrButtonID ) == pair.Key.TriggeredStatus ) {
foreach( KeyValuePair<IClickTrigger, Action> pair in keyCallbackIndex )
{
if( InternalIO.glfwGetKey( _binding.ViewHandle,
pair.Key.TargetKeyOrButtonID ) ==
pair.Key.TriggeredStatus ) {
pair.Value();
}
}
+18 -21
View File
@@ -40,14 +40,12 @@ namespace StgSharp.MVVM.ViewModel
{
#nullable enable
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
[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 delegate bool MethodLookUpDelegate( string name, out Action callback );
public abstract partial class ViewModelBase
{
@@ -55,24 +53,28 @@ namespace StgSharp.MVVM.ViewModel
public bool MethodLookup( string methodName, out Action callback )
{
MethodInfo method = GetType().GetMethod( methodName )!;
if( method == null ) {
if( method == null )
{
callback = null!;
return false;
}
try {
callback = ( Action )Delegate.CreateDelegate(
typeof( Action ), this, methodName );
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;
}
}
@@ -88,8 +90,8 @@ namespace StgSharp.MVVM.ViewModel
[FieldOffset( 0 )] private M128 _mask;
public DataBindingEntry(
[NotNull] BindingDataGetter gettingCallback,
[NotNull] BindingDataSetter settingCallback )
[NotNull] BindingDataGetter gettingCallback,
[NotNull] BindingDataSetter settingCallback )
{
getterPtr = Marshal.GetFunctionPointerForDelegate( gettingCallback );
setterPtr = Marshal.GetFunctionPointerForDelegate( settingCallback );
@@ -130,20 +132,15 @@ namespace StgSharp.MVVM.ViewModel
public void SetValue( ref object value )
{
( ( delegate* unmanaged[Cdecl]<ref object, void> )setterPtr )(
ref value );
( ( delegate* unmanaged[Cdecl]<ref object, void> )setterPtr )( ref value );
}
public static bool operator !=(
DataBindingEntry left,
DataBindingEntry right )
public static bool operator !=( DataBindingEntry left, DataBindingEntry right )
{
return left._mask != right._mask;
}
public static bool operator ==(
DataBindingEntry left,
DataBindingEntry right )
public static bool operator ==( DataBindingEntry left, DataBindingEntry right )
{
return left._mask == right._mask;
}
+20 -19
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ShowViewPort.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------
using StgSharp.Controls;
using StgSharp.Graphics;
using StgSharp.MVVM.View;
using StgSharp.MVVM;
using StgSharp.Threading;
using StgSharp.Timing;
@@ -54,14 +54,13 @@ namespace StgSharp.MVVM.ViewModel
}
/// <summary>
/// CustomizeInit this form and render it on screen, and respond with operation
/// CustomizeInit this form and render it on screen, and respond with operation
/// </summary>
public unsafe void UseViewModel( string viewEntryName )
{
CustomizeInitialize();
UseViewInNextFrame( viewEntryName );
TimeSpanAwaitingToken fpsCountingToken = fpsCountProvider.ParticipantSpanAwaiting(
1 );
TimeSpanAwaitingToken fpsCountingToken = fpsCountProvider.ParticipantSpanAwaiting( 1 );
fpsCountingToken.TimeSpanRefreshed += CountFps;
fpsCountingToken.MissTimeSpanRefreshed += CountFps;
if( _nextView != _currentView ) {
@@ -69,21 +68,25 @@ namespace StgSharp.MVVM.ViewModel
}
Thread renderThread = new Thread(
( token ) => {
try {
try
{
ProcessFrameWithoutEvent();
}
catch( Exception ex ) {
catch( Exception ex )
{
InternalIO.InternalWriteLog(
$"Critical error when rendering:\n" + $"{ex}",
LogType.Error );
$"Critical error when rendering:\n" + $"{ex}", LogType.Error );
ShouldClose = true;
throw;
}
} );
renderThread.Start();
/**/
using( TimeSpanAwaitingToken eventAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
1 ) ) {
while( _closed ) {
1 ) )
{
while( _closed )
{
if( _nextView != _currentView ) {
Interlocked.Exchange( ref _currentView, _nextView );
}
@@ -112,16 +115,12 @@ namespace StgSharp.MVVM.ViewModel
{
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.ViewPortHandle ) )
{
CurrentView.Use();
RenderStream.PollEvents();
}
@@ -130,9 +129,11 @@ namespace StgSharp.MVVM.ViewModel
private void ProcessFrameWithoutEvent()
{
using( TimeSpanAwaitingToken renderAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
1 ) ) {
1 ) )
{
renderAwaitingToken.TimeSpanRefreshed += ( _, _ ) => { };
while( _closed ) {
while( _closed )
{
foreach( ViewPort context in CurrentView.Render ) {
context.FlushSize();
}
+2 -4
View File
@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using StgSharp.MVVM.View;
using StgSharp.MVVM;
using System;
using System.Collections.Generic;
@@ -44,9 +44,7 @@ namespace StgSharp.MVVM.ViewModel
private Dictionary<string, ViewBase> allView;
public T CreateAndBindView<T>(
string name,
(int x, int y, int z) unitCubeSize )
public T CreateAndBindView<T>( string name, (int x, int y, int z) unitCubeSize )
where T: ViewBase, new()
{
T ret = new T();
+43 -56
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ViewModel.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -32,7 +32,7 @@ using StgSharp.Controlling.UsrActivity;
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using StgSharp.Math;
using StgSharp.MVVM.View;
using StgSharp.MVVM;
using StgSharp.MVVM.ViewModel;
using StgSharp.Threading;
using StgSharp.Timing;
@@ -69,12 +69,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = new ViewPort();
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long frameLength = ( FrameSpeed > 0 ) ?
( ( 1000L * 1000L ) / FrameSpeed ) : 0;
long frameLength = ( FrameSpeed > 0 ) ? ( ( 1000L * 1000L ) / FrameSpeed ) : 0;
frameTimeProvider = new TimeSpanProvider(
frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -84,12 +82,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = new ViewPort();
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long _frameLength = ( FrameSpeed > 0 ) ?
( ( long )( 1000 * frameLength ) ) : 0;
long _frameLength = ( FrameSpeed > 0 ) ? ( ( long )( 1000 * frameLength ) ) : 0;
frameTimeProvider = new TimeSpanProvider(
_frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -99,12 +95,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = vBinding;
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long frameLength = ( frameSpeed > 0 ) ?
( ( 1000L * 1000L ) / frameSpeed ) : 0;
long frameLength = ( frameSpeed > 0 ) ? ( ( 1000L * 1000L ) / frameSpeed ) : 0;
frameTimeProvider = new TimeSpanProvider(
frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -114,12 +108,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = vBinding;
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long _frameLength = ( frameLength > 0 ) ?
( ( long )( 1000 * frameLength ) ) : 0;
long _frameLength = ( frameLength > 0 ) ? ( ( long )( 1000 * frameLength ) ) : 0;
frameTimeProvider = new TimeSpanProvider(
_frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -129,8 +121,7 @@ namespace StgSharp.MVVM.ViewModel
{
get
{
if( this.TryGetObjectReference(
name, out DataBindingEntry entry ) ) {
if( this.TryGetObjectReference( name, out DataBindingEntry entry ) ) {
return entry;
}
throw new KeyNotFoundException();
@@ -139,10 +130,9 @@ namespace StgSharp.MVVM.ViewModel
public bool ShouldClose
{
get => InternalIO.glfwWindowShouldClose(
viewPortDisplay.ViewPortID ) != 0;
get => InternalIO.glfwWindowShouldClose( viewPortDisplay.ViewPortHandle ) != 0;
set => InternalIO.glfwSetWindowShouldClose(
viewPortDisplay.ViewPortID, value ? 1 : 0 );
viewPortDisplay.ViewPortHandle, value ? 1 : 0 );
}
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
@@ -150,7 +140,7 @@ 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
{
@@ -158,7 +148,7 @@ 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 int Width
{
@@ -167,7 +157,7 @@ namespace StgSharp.MVVM.ViewModel
public unsafe IntPtr WindowID
{
get => viewPortDisplay.ViewPortID;
get => viewPortDisplay.ViewPortHandle;
}
public string Name
@@ -176,7 +166,7 @@ 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 Vec2 Size
{
@@ -194,10 +184,9 @@ namespace StgSharp.MVVM.ViewModel
set
{
_resizeCallback = value;
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(
value );
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate( value );
InternalIO.glfwSetFramebufferSizeCallback(
viewPortDisplay.ViewPortID, handlerPtr );
viewPortDisplay.ViewPortHandle, handlerPtr );
}
}
#pragma warning restore CA1044
@@ -205,51 +194,49 @@ namespace StgSharp.MVVM.ViewModel
public abstract void CustomizeInitialize();
/// <summary>
/// Set the size limit of current form
/// Set the size limit of current form
/// </summary>
/// <param _name="minSize">
/// Minimum size of current form. In form of a <see cref="Vec2" /> of (width,height)
/// <param _label="minSize">
/// 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="Vec2" /> of (width,height)
/// <param _label="maxSize">
/// Maximum size of current form. In form of a <see cref="Vec2" /> of (width,height)
/// </param>
[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.ViewPortHandle, ( int )minSize.X, ( int )minSize.Y,
( int )maxSize.X, ( int )maxSize.Y );
}
/// <summary>
/// Set the size limit of current form
/// 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>
/// <param _label="minWidth">
/// Minimum width of current form
/// </param>
/// <param _label="minHeight">
/// Minimum height of current form
/// </param>
/// <param _label="maxWidth">
/// Maximum width of current form
/// </param>
/// <param _label="maxHeight">
/// Maximum height of current form
/// </param>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public void SetSizeLimit(
int minWidth,
int minHeight,
int maxWidth,
int maxHeight )
public void SetSizeLimit( int minWidth, int minHeight, int maxWidth, int maxHeight )
{
ThreadHelper.MainThreadAssert();
InternalIO.glfwSetWindowSizeLimits(
this.viewPortDisplay.ViewPortID, minWidth, minHeight, maxWidth,
maxHeight );
this.viewPortDisplay.ViewPortHandle, minWidth, minHeight, maxWidth, maxHeight );
}
public abstract bool TryGetObjectReference(
string name,
out DataBindingEntry entry );
public abstract bool TryGetObjectReference( string name, out DataBindingEntry entry );
private void DefaultFrameRewsizeCallback(
IntPtr windowHandle,
int width,
int height )
private void DefaultFrameRewsizeCallback( IntPtr windowHandle, int width, int height )
{
ViewPort.GetExistedViewPort( windowHandle, out ViewPort vp );
vp.RequestFlushSizeInNextFrame( width, height );
+18 -39
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ViewPort.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -31,6 +31,7 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
@@ -53,31 +54,27 @@ namespace StgSharp.MVVM
Name = new StackFrame( 1, false ).
GetMethod()!.DeclaringType!.Name;
Monitor = IntPtr.Zero;
ViewPortID = InternalIO.glfwCreateWindow(
_newWidth, _newHeight, Encoding.UTF8.GetBytes( Name ), Monitor,
IntPtr.Zero );
if( ViewPortID == IntPtr.Zero ) {
throw new InvalidOperationException(
"Unable to create viewport handle." );
ViewPortHandle = InternalIO.glfwCreateWindow(
_newWidth, _newHeight, Encoding.UTF8.GetBytes( Name ), Monitor, IntPtr.Zero );
if( ViewPortHandle == IntPtr.Zero ) {
throw new InvalidOperationException( "Unable to create viewport handle." );
}
_handleToViewPortIndex.TryAdd( ViewPortID, this );
_handleToViewPortIndex.TryAdd( ViewPortHandle, this );
}
public ViewPort(int width, int height, string name, IntPtr monitor )
public ViewPort( int width, int height, string name, IntPtr monitor )
{
_newWidth = width;
_newHeight = height;
FlushSize();
Name = name;
Monitor = monitor;
ViewPortID = InternalIO.glfwCreateWindow(
_newWidth, _newHeight, Encoding.UTF8.GetBytes( Name ), Monitor,
IntPtr.Zero );
if( ViewPortID == IntPtr.Zero ) {
throw new InvalidOperationException(
"Unable to create viewport handle." );
ViewPortHandle = InternalIO.glfwCreateWindow(
_newWidth, _newHeight, Encoding.UTF8.GetBytes( Name ), Monitor, IntPtr.Zero );
if( ViewPortHandle == IntPtr.Zero ) {
throw new InvalidOperationException( "Unable to create viewport handle." );
}
_handleToViewPortIndex.TryAdd( ViewPortID, this );
_handleToViewPortIndex.TryAdd( ViewPortHandle, this );
}
public unsafe int Height
@@ -92,35 +89,17 @@ namespace StgSharp.MVVM
internal set { Interlocked .Exchange( ref _width, value ); }
}
public IntPtr GraphicHandle
{
get;
internal set;
}
public IntPtr GraphicHandle { get; internal set; }
public IntPtr Monitor
{
get;
internal set;
}
public IntPtr Monitor { get; internal set; }
public IntPtr ViewPortID
{
get;
private set;
}
public IntPtr ViewPortHandle { get; private set; }
public string Name
{
get;
set;
}
public string Name { get; set; }
//[BlueprintNodeExecution]
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public static bool GetExistedViewPort(
IntPtr handle,
out ViewPort port )
public static bool GetExistedViewPort( IntPtr handle, out ViewPort port )
{
return _handleToViewPortIndex.TryGetValue( handle, out port );
}