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:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user