// The Nova Project by Ken Beckett.
// Copyright (C) 2007-2012 Inevitable Software, all rights reserved.
// Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php
using System.Collections.Generic;
using System.Windows.Media;
using Nova.CodeDOM;
namespace Nova.UI
{
/// <summary>
/// The view model for a <see cref="CodeDOM.Switch"/>.
/// </summary>
public class SwitchVM : BlockStatementVM
{
#region /* STATICS */
internal static void AddViewModelMapping()
{
CreateViewModel.Add(typeof(Switch),
delegate(CodeObject codeObject, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary) { return new SwitchVM((Switch)codeObject, isDescription, dictionary); });
}
#endregion
#region /* FIELDS */
protected ExpressionVM _targetVM;
#endregion
#region /* CONSTRUCTORS */
/// <summary>
/// Create a view model instance for the specified <see cref="CodeDOM.Switch"/>.
/// </summary>
public SwitchVM(Switch @switch, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary)
: base(@switch, isDescription, dictionary)
{
_targetVM = (ExpressionVM)CreateVM(@switch.Target, isDescription, dictionary);
}
#endregion
#region /* PROPERTIES */
/// <summary>
/// The underlying <see cref="CodeDOM.Switch"/> model.
/// </summary>
public Switch Switch
{
get { return (Switch)CodeObject; }
}
/// <summary>
/// The target <see cref="ExpressionVM"/>.
/// </summary>
public ExpressionVM TargetVM
{
get { return _targetVM; }
}
#endregion
#region /* METHODS */
#endregion
#region /* RENDERING */
public override Brush BorderBrush
{
get { return Brushes.PaleTurquoise; }
}
public override Brush BackgroundBrush
{
get { return Brushes.LightCyan; }
}
protected override void RenderArgument(CodeRenderer renderer, RenderFlags flags)
{
_targetVM.Render(renderer, flags);
}
public override void UnRender()
{
_targetVM.UnRender();
base.UnRender();
}
#endregion
}
}