58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using StgSharp.Graphics;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading;
|
|
|
|
namespace StgSharp.Logic
|
|
{
|
|
public abstract partial class ViewModelBase
|
|
{
|
|
private View _nextView, _currentView;
|
|
|
|
protected View CurrentView
|
|
{
|
|
get => _currentView;
|
|
set => _nextView = value;
|
|
}
|
|
|
|
protected void UseViewInNextFrame(string name)
|
|
{
|
|
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>
|
|
/// CustomizeInit this form and render it on screen, and respond with operation
|
|
/// </summary>
|
|
public unsafe void Show()
|
|
{
|
|
CustomizeInitialize();
|
|
//BuildGlobalKeyControl();
|
|
while(0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
|
{
|
|
viewPortDisplay.FlushSize();
|
|
CurrentView.Use();
|
|
RenderStream.PollEvents();
|
|
frameTimeProvider.WaitNextSpan();
|
|
Interlocked.Add(ref _frameCount, 1);
|
|
}
|
|
}
|
|
|
|
private unsafe void PrivateShow()
|
|
{
|
|
if(0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
|
{
|
|
CurrentView.Use();
|
|
RenderStream.PollEvents();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|