MVVM frame work done, under unit test
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Controls;
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// ViewDesigner provides descriptions of various controls in the view,
|
||||
/// binds the controls to specific user actions and behaviors,
|
||||
/// and describes the layout and interactions of each control.
|
||||
/// </summary>
|
||||
public abstract class ViewDesigner<TView> where TView:View
|
||||
{
|
||||
protected TView _binding;
|
||||
|
||||
private KeyboardButtonGroup currentButtonGroup;
|
||||
|
||||
private List<ControllingItem> _controlList;
|
||||
|
||||
public ViewDesigner()
|
||||
{
|
||||
_controlList = new List<ControllingItem>();
|
||||
}
|
||||
|
||||
protected TView Binding
|
||||
{
|
||||
get => _binding;
|
||||
}
|
||||
|
||||
public TButtonGroup CreateKeyboardButtonGroup<TButtonGroup>(
|
||||
ITrigger leftBidning,
|
||||
ITrigger rightBinding,
|
||||
ITrigger upBinding,
|
||||
ITrigger downBinding,
|
||||
ITrigger confirmBinding
|
||||
)
|
||||
where TButtonGroup : KeyboardButtonGroup,new()
|
||||
{
|
||||
var ret = new TButtonGroup();
|
||||
_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;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TriggerButton CreateKeyboardButton(
|
||||
Rectangle bonding, TextureProvider defaultAnimation, bool isEnable
|
||||
)
|
||||
{
|
||||
var ret = new TriggerButton();
|
||||
ret.BoundingBox = bonding;
|
||||
if (isEnable)
|
||||
{
|
||||
ret.IsDisabled = false;
|
||||
ret.Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.IsDisabled = true;
|
||||
ret.Disable();
|
||||
}
|
||||
currentButtonGroup.AddButton(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public CharacterLineIndexImage CreateCharacterLine(
|
||||
int length, char blankFilling, PlainGeometryMesh tittle, IEnumerable<(char,PlainGeometryMesh)> charList
|
||||
)
|
||||
{
|
||||
var ret = new CharacterLineIndexImage(length, blankFilling,tittle,charList);
|
||||
_controlList.Add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public abstract void CustomizedInitialize();
|
||||
|
||||
public abstract bool ValidateInitializing();
|
||||
|
||||
}//---------------------------------- End of Class -----------------------------------------
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user