MVVM frame work done, under unit test
This commit is contained in:
@@ -1,31 +1,40 @@
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.GL;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Logic
|
||||
{
|
||||
public partial class ViewModelBase
|
||||
{
|
||||
private List<View> allView;
|
||||
private Dictionary<string,View> allView;
|
||||
|
||||
public View BuildNewView(
|
||||
ViewPortDesigner designer, (int x, int y, int z) unitCubeSize
|
||||
)
|
||||
public T BuildNewView<T>(string name,(int x, int y, int z) unitCubeSize)
|
||||
where T : View,new()
|
||||
{
|
||||
View ret = new View(this.viewPortDisplay, designer,unitCubeSize);
|
||||
allView.Add(ret);
|
||||
var ret = new T();
|
||||
ret.SelfName = name;
|
||||
ret.InternalInitialize(this);
|
||||
allView.Add(name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public T BuildRenderStream<T>(View view) where T : RenderStream
|
||||
{
|
||||
T ret = Activator.CreateInstance(typeof(T), view.Port, view.UnitCubeSize) as T ??
|
||||
throw new InvalidOperationException("Cannot build new render stream.");
|
||||
#nullable enable
|
||||
T? ret = Activator.CreateInstance(typeof(T), view.Port, view.UnitCubeSize) as T;
|
||||
#nullable restore
|
||||
if (ret == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Failed in creating a new {typeof(T).Name} instance when calling ShareContextWith."
|
||||
);
|
||||
}
|
||||
ret.timeProvider = this.frameTimeProvider;
|
||||
ret.InternalInit();
|
||||
ret.PlatformSpecifiedInit();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user