Skip to content

Commit

Permalink
Merge pull request #620 from jeffu231/VIX-3592
Browse files Browse the repository at this point in the history
VIX-3592 Ensure the state definition name is available and editable i…
  • Loading branch information
jeffu231 authored Sep 6, 2024
2 parents 5f12f89 + 9fbd7e0 commit 82fb3f1
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ private void AssembleStates(CustomModel cm, Dictionary<int, ModelNode> modelNode
{
var stateItemGroup = PropModelServices.Instance().CreateNode($"{cm.Name} {{1}} - {stateInfo.Name} - S{stateItem.Index} - {stateItem.Name}", stateGroup);

stateItemGroup.StateDefinition = new StateDefinition{DefaultColor = stateItem.Color, Name = stateItem.Name, Index = stateItem.Index};
stateItemGroup.StateDefinition = new StateDefinition{StateDefinitionName = stateInfo.Name, DefaultColor = stateItem.Color, Name = stateItem.Name, Index = stateItem.Index};

var subModelRangeGroup = stateItemGroup;

Expand Down
31 changes: 30 additions & 1 deletion src/Vixen.Modules/App/CustomPropEditor/Model/StateDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,36 @@ public class StateDefinition: BindableBase
private Color _defaultColor;
private int _index;
private string _name;
private string _stateDefinitionName;

/// <summary>
/// State Definition defines a particular state of a group of nodes. They are grouped together by the StateDefinitionName property.
/// Each state can have a color and index assigned to it. Thus, a prop can have several parts grouped together and each part can have its own color and index.
/// </summary>
public StateDefinition()
{
Name = "Change Me!";
StateDefinitionName = "State Name 1";
Name = "Item 1";
DefaultColor = Color.White;
}

/// <summary>
/// The overall StateDefinitionName Key that this definition is grouped with.
/// </summary>
public string StateDefinitionName
{
get => _stateDefinitionName;
set
{
if (value == _stateDefinitionName) return;
_stateDefinitionName = value;
OnPropertyChanged(nameof(StateDefinitionName));
}
}

/// <summary>
/// The individual state definition item
/// </summary>
public string Name
{
get => _name;
Expand All @@ -27,6 +50,9 @@ public string Name
}
}

/// <summary>
/// The defined color of this state item
/// </summary>
public Color DefaultColor
{
get => _defaultColor;
Expand All @@ -38,6 +64,9 @@ public Color DefaultColor
}
}

/// <summary>
/// This is basically the row number when imported from an xModel. This is not used at this time.
/// </summary>
public int Index
{
get => _index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,34 +254,34 @@ public String FaceColor

#endregion

#region StateName property
#region StateDefinitionName property

/// <summary>
/// Gets or sets the StateDefinition Name value.
/// Gets or sets the StateDefinitionName value.
/// </summary>
[PropertyOrder(3)]
[DisplayName("State Name")]
[Description("Name of the State for this element.")]
public String StateName
[Description("State name for grouping state items together. This should be the same for any state items that are intended to work together.")]
public String StateDefinitionName
{
get => ElementModel.StateDefinition != null ? ElementModel.StateDefinition.Name:String.Empty;
get => ElementModel.StateDefinition != null ? ElementModel.StateDefinition.StateDefinitionName : String.Empty;
set
{
if (ElementModel.StateDefinition != null)
{
if (!string.IsNullOrEmpty(value))
{
ElementModel.StateDefinition.Name = value;
ElementModel.StateDefinition.StateDefinitionName = value;
IsDirty = true;
RaisePropertyChanged(nameof(StateName));
RaisePropertyChanged(nameof(StateDefinitionName));
}
else
{
ElementModel.StateDefinition = null;
IsDirty = true;
RaisePropertyChanged(nameof(StateColor));
RaisePropertyChanged(nameof(StateIndex));
RaisePropertyChanged(nameof(StateName));
RaisePropertyChanged(nameof(StateItemColor));
RaisePropertyChanged(nameof(StateItemName));
RaisePropertyChanged(nameof(StateDefinitionName));
}
}
else
Expand All @@ -291,94 +291,111 @@ public String StateName
Name = value
};
IsDirty = true;
RaisePropertyChanged(nameof(StateColor));
RaisePropertyChanged(nameof(StateIndex));
RaisePropertyChanged(nameof(StateName));
RaisePropertyChanged(nameof(StateItemColor));
RaisePropertyChanged(nameof(StateItemName));
RaisePropertyChanged(nameof(StateDefinitionName));
}

}
}

#endregion

#region StateColor property
#region StateDefinitionName property

/// <summary>
/// Gets or sets the StateDefinition Color value.
/// Gets or sets the State Item name value.
/// </summary>
[PropertyOrder(4)]
[DisplayName("State Color")]
[Description("Color in Hex (#FFFFFF) associated with the State of this element.")]
public String StateColor
[DisplayName("State Item")]
[Description("Name of the item state for this element/group. All associated state items should have the same State name.")]
public String StateItemName
{
get => ElementModel.StateDefinition != null ?
ElementModel.StateDefinition.DefaultColor.ToHex() :
String.Empty;
get => ElementModel.StateDefinition != null ? ElementModel.StateDefinition.Name:String.Empty;
set
{
var color = HexToColor(value);
if (ElementModel.StateDefinition != null)
{
ElementModel.StateDefinition.DefaultColor = color;
IsDirty = true;
RaisePropertyChanged(nameof(StateColor));
if (!string.IsNullOrEmpty(value))
{
ElementModel.StateDefinition.Name = value;
IsDirty = true;
RaisePropertyChanged(nameof(StateItemName));
}
else
{
ElementModel.StateDefinition = null;
IsDirty = true;
RaisePropertyChanged(nameof(StateItemColor));
RaisePropertyChanged(nameof(StateItemName));
RaisePropertyChanged(nameof(StateDefinitionName));
}
}
else
{
ElementModel.StateDefinition = new StateDefinition()
{
DefaultColor = color
Name = value
};
IsDirty = true;
RaisePropertyChanged(nameof(StateName));
RaisePropertyChanged(nameof(StateColor));
RaisePropertyChanged(nameof(StateIndex));
RaisePropertyChanged(nameof(StateItemColor));
RaisePropertyChanged(nameof(StateItemName));
RaisePropertyChanged(nameof(StateDefinitionName));
}

}
}

#endregion

#region StateIndex property
#region StateItemColor property

/// <summary>
/// Gets or sets the StateDefinition Index value.
/// Gets or sets the StateDefinition Color value.
/// </summary>
[PropertyOrder(5)]
[DisplayName("State Index")]
[Description("Index associated with the State of this element.")]
public string StateIndex
[DisplayName("State Item Color")]
[Description("Color in Hex (#FFFFFF) for this state item.")]
public String StateItemColor
{
get => ElementModel.StateDefinition != null ?
ElementModel.StateDefinition.Index.ToString() :
ElementModel.StateDefinition.DefaultColor.ToHex() :
String.Empty;
set
{
if (value.IsNumeric())
var color = HexToColor(value);
if (ElementModel.StateDefinition != null)
{
if (ElementModel.StateDefinition != null)
ElementModel.StateDefinition.DefaultColor = color;
IsDirty = true;
RaisePropertyChanged(nameof(StateItemColor));
}
else
{
ElementModel.StateDefinition = new StateDefinition()
{
ElementModel.StateDefinition.Index = Convert.ToInt32(value);
IsDirty = true;
RaisePropertyChanged(nameof(StateIndex));
}
DefaultColor = color
};
IsDirty = true;
RaisePropertyChanged(nameof(StateItemName));
RaisePropertyChanged(nameof(StateItemColor));
RaisePropertyChanged(nameof(StateDefinitionName));
}

}
}

#endregion


#region ChildCount property

/// <summary>
/// Gets or sets the ChildCount value.
/// </summary>
[DisplayName("Children")]
[Description("Number of child elements associated with this element.")]
[PropertyOrder(6)]
[PropertyOrder(7)]
public int ChildCount => ElementModel.Children.Count();

#endregion
Expand All @@ -390,7 +407,7 @@ public string StateIndex
/// </summary>
[DisplayName("Lights")]
[Description("Number of light elements under this element.")]
[PropertyOrder(7)]
[PropertyOrder(8)]
public int LightCount => ElementModel.GetLeafEnumerator().Count(x => x.IsLightNode);

#endregion
Expand Down

0 comments on commit 82fb3f1

Please sign in to comment.