MVVM frame work done, under unit test

This commit is contained in:
Nitload
2024-07-25 04:41:24 +08:00
parent 924fe6eef7
commit da75200347
101 changed files with 8435 additions and 847 deletions
@@ -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;
}
}