code clean up
This commit is contained in:
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="OpenGLControllingItemRender.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="OpenGLControllingItemRender"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
using System;
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ViewBase.cs"
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewBase"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
@@ -73,16 +70,16 @@ namespace StgSharp.MVVM
|
||||
|
||||
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 ]
|
||||
public DataBindingEntry this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if( getDataBindingEntry( name, out DataBindingEntry entry ) ) {
|
||||
if (getDataBindingEntry(name, out DataBindingEntry entry)) {
|
||||
return entry;
|
||||
}
|
||||
if( TryGetObjectReference( name, out entry ) ) {
|
||||
if (TryGetObjectReference(name, out entry)) {
|
||||
return entry;
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
@@ -142,7 +139,7 @@ namespace StgSharp.MVVM
|
||||
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.
|
||||
@@ -153,16 +150,13 @@ namespace StgSharp.MVVM
|
||||
/// <returns>
|
||||
/// <see cref="KeyStatus" /> representing if a key is pressed or released.
|
||||
/// </returns>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public KeyStatus GetKeyStatus( KeyboardKey key )
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public KeyStatus GetKeyStatus(KeyboardKey key)
|
||||
{
|
||||
return InternalIO.glfwGetKey( context.ViewPortHandle, ( int )key );
|
||||
return InternalIO.glfwGetKey(context.ViewPortHandle, (int)key);
|
||||
}
|
||||
|
||||
public void InternalInitialize(
|
||||
string name,
|
||||
(int, int, int) cubeSize,
|
||||
[NotNull]ViewModelBase viewModelBinding )
|
||||
public void InternalInitialize(string name, (int, int, int) cubeSize, [NotNull]ViewModelBase viewModelBinding)
|
||||
{
|
||||
SelfName = name;
|
||||
unitCubeSize = cubeSize;
|
||||
@@ -170,18 +164,18 @@ namespace StgSharp.MVVM
|
||||
context = viewModelBinding.ViewPortBinding;
|
||||
time = viewModelBinding.frameTimeProvider;
|
||||
|
||||
CustomizedInitialize( viewModelBinding );
|
||||
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() ) {
|
||||
if (!ValidateInitialization()) {
|
||||
throw new InvalidOperationException(
|
||||
"This view is not correctly initialized before rendering." );
|
||||
"This view is not correctly initialized before rendering.");
|
||||
}
|
||||
}
|
||||
Show();
|
||||
@@ -190,10 +184,10 @@ namespace StgSharp.MVVM
|
||||
|
||||
public bool ValidateInitialization()
|
||||
{
|
||||
return ( _design != null ) &&
|
||||
( _render != null ) &&
|
||||
( getDataBindingEntry != null ) &&
|
||||
( _responder != null ) &&
|
||||
return (_design != null) &&
|
||||
(_render != null) &&
|
||||
(getDataBindingEntry != null) &&
|
||||
(_responder != null) &&
|
||||
_design.ValidateInitializing() &&
|
||||
_responder.ValidateInitializing() &&
|
||||
_render.ValidateInitializing();
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ViewDesigner.cs"
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewDesigner"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
@@ -69,7 +66,7 @@ namespace StgSharp.MVVM
|
||||
private List<ControllingItem> _controlList;
|
||||
protected TView _binding;
|
||||
|
||||
public ViewDesigner( TView binding )
|
||||
public ViewDesigner(TView binding)
|
||||
{
|
||||
_binding = binding;
|
||||
_controlList = new List<ControllingItem>();
|
||||
@@ -84,23 +81,23 @@ namespace StgSharp.MVVM
|
||||
int length,
|
||||
char blankFilling,
|
||||
PlainGeometryMesh tittle,
|
||||
IEnumerable<(char, PlainGeometryMesh)> charList )
|
||||
IEnumerable<(char, PlainGeometryMesh)> charList)
|
||||
{
|
||||
CharacterLineIndexImage ret = new CharacterLineIndexImage(
|
||||
length, blankFilling, tittle, charList );
|
||||
_controlList.Add( ret );
|
||||
length, blankFilling, tittle, charList);
|
||||
_controlList.Add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TriggerButton CreateKeyboardButton(
|
||||
Rectangle bonding,
|
||||
TextureProvider defaultAnimation,
|
||||
bool isEnable )
|
||||
bool isEnable)
|
||||
{
|
||||
TriggerButton ret = new TriggerButton();
|
||||
ret.BoundingBox = bonding;
|
||||
ret.Texture = defaultAnimation;
|
||||
if( isEnable )
|
||||
if (isEnable)
|
||||
{
|
||||
ret.IsDisabled = false;
|
||||
ret.Enable();
|
||||
@@ -109,7 +106,7 @@ namespace StgSharp.MVVM
|
||||
ret.IsDisabled = true;
|
||||
ret.Disable();
|
||||
}
|
||||
currentButtonGroup.AddButton( ret );
|
||||
currentButtonGroup.AddButton(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -118,17 +115,17 @@ namespace StgSharp.MVVM
|
||||
IClickTrigger rightBinding,
|
||||
IClickTrigger upBinding,
|
||||
IClickTrigger downBinding,
|
||||
IClickTrigger confirmBinding )
|
||||
IClickTrigger confirmBinding)
|
||||
where TButtonGroup: KeyboardButtonGroup, new()
|
||||
{
|
||||
TButtonGroup ret = new TButtonGroup();
|
||||
_controlList.Add( ret );
|
||||
_controlList.Add(ret);
|
||||
currentButtonGroup = ret;
|
||||
_binding.Responder[ leftBidning ] = ret.MoveLeft;
|
||||
_binding.Responder[ rightBinding ] = ret.MoveRight;
|
||||
_binding.Responder[ upBinding ] = ret.MoveUp;
|
||||
_binding.Responder[ downBinding ] = ret.MoveDown;
|
||||
_binding.Responder[ confirmBinding ] = ret.Confirm;
|
||||
_binding.Responder[leftBidning] = ret.MoveLeft;
|
||||
_binding.Responder[rightBinding] = ret.MoveRight;
|
||||
_binding.Responder[upBinding] = ret.MoveUp;
|
||||
_binding.Responder[downBinding] = ret.MoveDown;
|
||||
_binding.Responder[confirmBinding] = ret.Confirm;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ViewRender.cs"
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewRender"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Graphics;
|
||||
|
||||
using StgSharp.HighPerformance;
|
||||
@@ -44,7 +41,7 @@ namespace StgSharp.MVVM
|
||||
protected internal interface IViewRender<out TView> where TView: ViewBase
|
||||
{
|
||||
|
||||
RenderStream this[ DataLabel renderName ] { get; }
|
||||
RenderStream this[DataLabel renderName] { get; }
|
||||
|
||||
void CustomizedInitialize();
|
||||
|
||||
@@ -59,24 +56,23 @@ namespace StgSharp.MVVM
|
||||
protected abstract class ViewRender<TView> : IViewRender<TView> where TView: ViewBase
|
||||
{
|
||||
|
||||
protected ViewRender( TView binding )
|
||||
protected ViewRender(TView binding)
|
||||
{
|
||||
_binding = binding;
|
||||
_render = new Dictionary<DataLabel, RenderStream>();
|
||||
}
|
||||
|
||||
public RenderStream this[ DataLabel renderName ]
|
||||
public RenderStream this[DataLabel renderName]
|
||||
{
|
||||
get => _render.TryGetValue( renderName, out RenderStream stream ) ?
|
||||
stream : ( null! );
|
||||
get => _render.TryGetValue(renderName, out RenderStream stream) ? stream : (null!);
|
||||
protected set
|
||||
{
|
||||
if( _render.ContainsKey( renderName ) )
|
||||
if (_render.ContainsKey(renderName))
|
||||
{
|
||||
_render[ renderName ] = value;
|
||||
_render[renderName] = value;
|
||||
} else
|
||||
{
|
||||
_render.Add( renderName, value );
|
||||
_render.Add(renderName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,26 +81,26 @@ namespace StgSharp.MVVM
|
||||
|
||||
protected ViewPort ContextBinding => _binding.context;
|
||||
|
||||
protected ViewDesigner<TView> Design => ( _binding.Designer as ViewDesigner<TView> )!;
|
||||
protected ViewDesigner<TView> Design => (_binding.Designer as ViewDesigner<TView>)!;
|
||||
|
||||
protected Dictionary<DataLabel, RenderStream> Render
|
||||
{
|
||||
get => _render;
|
||||
}
|
||||
|
||||
protected ViewResponder<TView> Responder => ( _binding.Responder as ViewResponder<TView> )!;
|
||||
protected ViewResponder<TView> Responder => (_binding.Responder as ViewResponder<TView>)!;
|
||||
|
||||
public T CreateRenderStream<T>() where T: RenderStream, new()
|
||||
{
|
||||
T ret = new T();
|
||||
ret.Initialize( _binding.context, Binding.TimeProvider );
|
||||
ret.Initialize(_binding.context, Binding.TimeProvider);
|
||||
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 );
|
||||
ret.Initialize(vp, Binding.TimeProvider);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -112,7 +108,7 @@ namespace StgSharp.MVVM
|
||||
|
||||
public IEnumerator<ViewPort> GetEnumerator()
|
||||
{
|
||||
foreach( RenderStream item in Render.Values ) {
|
||||
foreach (RenderStream item in Render.Values) {
|
||||
yield return item.BindedViewPortContext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ViewResponder.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewResponder"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.MVVM.ViewModel;
|
||||
|
||||
@@ -45,11 +42,11 @@ namespace StgSharp.MVVM
|
||||
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 );
|
||||
void Initialize(MethodLookUpDelegate methodGetter);
|
||||
|
||||
void ProcessUserInput();
|
||||
|
||||
@@ -65,7 +62,7 @@ namespace StgSharp.MVVM
|
||||
private Dictionary<string, Action> nameToCallbackMap;
|
||||
private TView _binding;
|
||||
|
||||
protected ViewResponder( TView binding )
|
||||
protected ViewResponder(TView binding)
|
||||
{
|
||||
keyCallbackIndex = new Dictionary<IClickTrigger, Action>();
|
||||
nameToCallbackMap = new Dictionary<string, Action>();
|
||||
@@ -73,58 +70,54 @@ namespace StgSharp.MVVM
|
||||
}
|
||||
|
||||
#pragma warning disable CA1043
|
||||
public Action? this[ IClickTrigger trigger ]
|
||||
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
|
||||
{
|
||||
keyCallbackIndex.Add(
|
||||
trigger, value ?? throw new ArgumentNullException( nameof( value ) ) );
|
||||
trigger, value ?? throw new ArgumentNullException(nameof(value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected TView Binding => _binding;
|
||||
|
||||
public abstract void CustomizedInitialize(
|
||||
Func<IClickTrigger, string, Action> keyRegister );
|
||||
public abstract void CustomizedInitialize(Func<IClickTrigger, string, Action> keyRegister);
|
||||
|
||||
public void Initialize( MethodLookUpDelegate methodGetter )
|
||||
public void Initialize(MethodLookUpDelegate methodGetter)
|
||||
{
|
||||
if( _isInitialized ) {
|
||||
if (_isInitialized) {
|
||||
return;
|
||||
}
|
||||
CustomizedInitialize(
|
||||
( trigger, name ) => {
|
||||
if( !nameToCallbackMap.TryGetValue( name, out Action ret ) )
|
||||
CustomizedInitialize((trigger, name) => {
|
||||
if (!nameToCallbackMap.TryGetValue(name, out Action ret))
|
||||
{
|
||||
if (methodGetter(name, out Action lookup))
|
||||
{
|
||||
if( methodGetter( name, out Action lookup ) )
|
||||
{
|
||||
this[ trigger ] = lookup;
|
||||
} else
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Cannot find method named {name} in binded view model" );
|
||||
}
|
||||
this[trigger] = lookup;
|
||||
} else
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Cannot find method named {name} in binded view model");
|
||||
}
|
||||
return ret;
|
||||
} );
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
public void ProcessUserInput()
|
||||
{
|
||||
foreach( KeyValuePair<IClickTrigger, Action> pair in keyCallbackIndex )
|
||||
foreach (KeyValuePair<IClickTrigger, Action> pair in keyCallbackIndex)
|
||||
{
|
||||
if( InternalIO.glfwGetKey( _binding.ViewHandle,
|
||||
pair.Key.TargetKeyOrButtonID ) ==
|
||||
pair.Key.TriggeredStatus ) {
|
||||
if (InternalIO.glfwGetKey(_binding.ViewHandle,
|
||||
pair.Key.TargetKeyOrButtonID) == pair.Key.TriggeredStatus) {
|
||||
pair.Value();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="DataBinding.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="DataBinding"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance;
|
||||
|
||||
using System;
|
||||
@@ -40,40 +37,40 @@ 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 );
|
||||
[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 )!;
|
||||
if( method == null )
|
||||
MethodInfo method = GetType().GetMethod(methodName)!;
|
||||
if (method == null)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
callback = ( Action )Delegate.CreateDelegate( typeof( Action ), this, methodName );
|
||||
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;
|
||||
}
|
||||
@@ -81,20 +78,20 @@ namespace StgSharp.MVVM.ViewModel
|
||||
|
||||
}
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public unsafe struct DataBindingEntry
|
||||
{
|
||||
|
||||
[FieldOffset( 0 )] private IntPtr getterPtr;
|
||||
[FieldOffset( 8 )] private IntPtr setterPtr;
|
||||
[FieldOffset( 0 )] private M128 _mask;
|
||||
[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
|
||||
@@ -102,22 +99,22 @@ namespace StgSharp.MVVM.ViewModel
|
||||
get => new DataBindingEntry();
|
||||
}
|
||||
|
||||
public bool Equals( DataBindingEntry other )
|
||||
public bool Equals(DataBindingEntry other)
|
||||
{
|
||||
return ( _mask == other._mask );
|
||||
return (_mask == other._mask);
|
||||
}
|
||||
|
||||
public override bool Equals( object obj )
|
||||
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 )
|
||||
public bool ExactEqual(DataBindingEntry other)
|
||||
{
|
||||
return ( getterPtr == other.getterPtr ) && ( setterPtr == other.setterPtr );
|
||||
return (getterPtr == other.getterPtr) && (setterPtr == other.setterPtr);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
@@ -127,20 +124,20 @@ namespace StgSharp.MVVM.ViewModel
|
||||
|
||||
public ref object GetValue()
|
||||
{
|
||||
return ref ( ( delegate* unmanaged[Cdecl]<ref object> )getterPtr )();
|
||||
return ref ((delegate* unmanaged[Cdecl]<ref object>)getterPtr)();
|
||||
}
|
||||
|
||||
public void SetValue( ref object value )
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ShowViewPort.cs"
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ShowViewPort"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.MVVM;
|
||||
@@ -56,39 +53,38 @@ 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();
|
||||
UseViewInNextFrame( viewEntryName );
|
||||
TimeSpanAwaitingToken fpsCountingToken = fpsCountProvider.ParticipantSpanAwaiting( 1 );
|
||||
UseViewInNextFrame(viewEntryName);
|
||||
TimeSpanAwaitingToken fpsCountingToken = fpsCountProvider.ParticipantSpanAwaiting(1);
|
||||
fpsCountingToken.TimeSpanRefreshed += CountFps;
|
||||
fpsCountingToken.MissTimeSpanRefreshed += CountFps;
|
||||
if( _nextView != _currentView ) {
|
||||
Interlocked.Exchange( ref _currentView, _nextView );
|
||||
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;
|
||||
throw;
|
||||
}
|
||||
} );
|
||||
Thread renderThread = new Thread((token) => {
|
||||
try
|
||||
{
|
||||
ProcessFrameWithoutEvent();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Critical error when rendering:\n" + $"{ex}", LogType.Error);
|
||||
ShouldClose = true;
|
||||
throw;
|
||||
}
|
||||
});
|
||||
renderThread.Start();
|
||||
/**/
|
||||
using( TimeSpanAwaitingToken eventAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
|
||||
1 ) )
|
||||
using (TimeSpanAwaitingToken eventAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
|
||||
1))
|
||||
{
|
||||
while( _closed )
|
||||
while (_closed)
|
||||
{
|
||||
if( _nextView != _currentView ) {
|
||||
Interlocked.Exchange( ref _currentView, _nextView );
|
||||
if (_nextView != _currentView) {
|
||||
Interlocked.Exchange(ref _currentView, _nextView);
|
||||
}
|
||||
InternalIO.glfwPollEvents();
|
||||
eventAwaitingToken.WaitNextSpan();
|
||||
@@ -102,24 +98,24 @@ namespace StgSharp.MVVM.ViewModel
|
||||
frameTimeProvider.StopSpanProviding();
|
||||
}
|
||||
|
||||
protected void UseViewInNextFrame( string name )
|
||||
protected void UseViewInNextFrame(string name)
|
||||
{
|
||||
if( !allView.TryGetValue( name, out ViewBase v ) ) {
|
||||
if (!allView.TryGetValue(name, out ViewBase v)) {
|
||||
throw new KeyNotFoundException(
|
||||
$"{$"Cannot find View named {name} "}{$"in current View Model of {GetType().FullName}"}" );
|
||||
$"{$"Cannot find View named {name} "}{$"in current View Model of {GetType().FullName}"}");
|
||||
}
|
||||
CurrentView = v;
|
||||
}
|
||||
|
||||
private void CountFps( object sender, EventArgs e )
|
||||
private void CountFps(object sender, EventArgs e)
|
||||
{
|
||||
Interlocked.Exchange( ref _frameSpeed, _frameCount );
|
||||
Interlocked.Exchange( ref _frameCount, 0 );
|
||||
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
||||
Interlocked.Exchange(ref _frameCount, 0);
|
||||
}
|
||||
|
||||
private unsafe void PrivateShow()
|
||||
{
|
||||
if( 0 == InternalIO.glfwWindowShouldClose( this.viewPortDisplay.ViewPortHandle ) )
|
||||
if (0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortHandle))
|
||||
{
|
||||
CurrentView.Use();
|
||||
RenderStream.PollEvents();
|
||||
@@ -128,18 +124,18 @@ namespace StgSharp.MVVM.ViewModel
|
||||
|
||||
private void ProcessFrameWithoutEvent()
|
||||
{
|
||||
using( TimeSpanAwaitingToken renderAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
|
||||
1 ) )
|
||||
using (TimeSpanAwaitingToken renderAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
|
||||
1))
|
||||
{
|
||||
renderAwaitingToken.TimeSpanRefreshed += ( _, _ ) => { };
|
||||
while( _closed )
|
||||
renderAwaitingToken.TimeSpanRefreshed += (_, _) => { };
|
||||
while (_closed)
|
||||
{
|
||||
foreach( ViewPort context in CurrentView.Render ) {
|
||||
foreach (ViewPort context in CurrentView.Render) {
|
||||
context.FlushSize();
|
||||
}
|
||||
CurrentView.Use();
|
||||
renderAwaitingToken.WaitNextSpan();
|
||||
Interlocked.Add( ref _frameCount, 1 );
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ViewManage.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewManage"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.MVVM;
|
||||
@@ -44,13 +41,12 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewModel"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ViewPort.cs"
|
||||
// file="ViewPort"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -77,17 +74,17 @@ namespace StgSharp.MVVM
|
||||
|
||||
public unsafe int Height
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _height;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal set => Interlocked.Exchange(ref _height, value);
|
||||
}
|
||||
|
||||
public unsafe int Width
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _width;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal set => Interlocked.Exchange(ref _width, value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user