MVVM frame work done, under unit test
This commit is contained in:
@@ -9,40 +9,35 @@ namespace StgSharp.Logic
|
||||
{
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
public void ShowViewPort()
|
||||
{
|
||||
private View _nextView, _currentView;
|
||||
|
||||
protected View CurrentView
|
||||
{
|
||||
get => _currentView;
|
||||
set => _nextView = value;
|
||||
}
|
||||
|
||||
private Blueprint renderLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Render logic for every frame with no relation to <see cref="View"/>.
|
||||
/// </summary>
|
||||
public Blueprint GeneralRenderLogic
|
||||
protected void UseViewInNextFrame(string name)
|
||||
{
|
||||
get => renderLogic;
|
||||
set => renderLogic = value;
|
||||
if (allView.TryGetValue(name, out View v))
|
||||
{
|
||||
throw new KeyNotFoundException($"Cannot find View named {name} " +
|
||||
$"in current View Model of {this.GetType().FullName}");
|
||||
}
|
||||
CurrentView = v;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init 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 Show()
|
||||
{
|
||||
BuildGlobalKeyControl();
|
||||
CustomizeInitialize();
|
||||
//BuildGlobalKeyControl();
|
||||
while(0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
||||
{
|
||||
viewPortDisplay.FlushSize();
|
||||
foreach (var item in this._globalKeyAction)
|
||||
{
|
||||
if (InternalIO.glfwGetKey(this.viewPortDisplay.ViewPortID, (int)item.Key.TargetKeyOrButtonID)
|
||||
== item.Key.TriggeredStatus)
|
||||
{
|
||||
item.Value();
|
||||
}
|
||||
}
|
||||
BlueprintRunner.Run(renderLogic, ()=>ShouldClose);
|
||||
CurrentView.Use();
|
||||
RenderStream.PollEvents();
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
@@ -53,36 +48,10 @@ namespace StgSharp.Logic
|
||||
{
|
||||
if(0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
||||
{
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
viewPortDisplay.FlushSize();
|
||||
foreach (var item in this._globalKeyAction)
|
||||
{
|
||||
if (InternalIO.glfwGetKey(this.viewPortDisplay.ViewPortID, (int)item.Key.TargetKeyOrButtonID)
|
||||
== item.Key.TriggeredStatus)
|
||||
{
|
||||
item.Value();
|
||||
}
|
||||
}
|
||||
BlueprintRunner.Run(renderLogic, () => ShouldClose);
|
||||
CurrentView.Use();
|
||||
RenderStream.PollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public T BuildNewRenderStream<T>(View arg, (int x, int y, int z) unitCubeSize) where T : RenderStream
|
||||
{
|
||||
if (arg.ContextName == this.Name)
|
||||
{
|
||||
|
||||
}
|
||||
T? ret = Activator.CreateInstance(typeof(T), arg) as T;
|
||||
if (ret == null)
|
||||
{
|
||||
throw new InvalidOperationException("Failed in building a new RenderStream when calling AsMainStreamOf");
|
||||
}
|
||||
ret!.InternalInit();
|
||||
ret.timeProvider = this.frameTimeProvider;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user