diff --git a/StructuredXmlEditor/Core.xmldef b/StructuredXmlEditor/Core.xmldef index 760a80f..6e2b840 100644 --- a/StructuredXmlEditor/Core.xmldef +++ b/StructuredXmlEditor/Core.xmldef @@ -246,6 +246,7 @@ + @@ -263,6 +264,7 @@ + @@ -284,6 +286,7 @@ + @@ -301,6 +304,7 @@ + diff --git a/StructuredXmlEditor/Data/PairItem.cs b/StructuredXmlEditor/Data/PairItem.cs deleted file mode 100644 index e4004cd..0000000 --- a/StructuredXmlEditor/Data/PairItem.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using StructuredXmlEditor.Definition; -using System.ComponentModel; - -namespace StructuredXmlEditor.Data -{ - public class PairItem : ComplexDataItem - { - //----------------------------------------------------------------------- - protected override bool CanClear { get { return false; } } - - //----------------------------------------------------------------------- - protected override string EmptyString { get { return "ERROR"; } } - - //----------------------------------------------------------------------- - public PairItem(DataDefinition definition, UndoRedoManager undoRedo) : base(definition, undoRedo) - { - } - } -} diff --git a/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs b/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs index 83c0eab..0c1a3ca 100644 --- a/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs +++ b/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using System.Xml.Linq; namespace StructuredXmlEditor.Definition @@ -100,6 +101,26 @@ public override void Parse(XElement definition) FlattenData = TryParseBool(definition, "FlattenData", false); NodeStoreName = definition.Attribute("NodeStoreName")?.Value?.ToString() ?? "Nodes"; + var backgroundCol = definition.Attribute("Background")?.Value?.ToString(); + if (backgroundCol != null) + { + var split = backgroundCol.Split(new char[] { ',' }); + + byte r = 0; + byte g = 0; + byte b = 0; + byte a = 0; + + byte.TryParse(split[0], out r); + byte.TryParse(split[1], out g); + byte.TryParse(split[2], out b); + byte.TryParse(split[3], out a); + + var col = Color.FromArgb(a, r, g, b); + Background = new SolidColorBrush(col); + Background.Freeze(); + } + var childDefs = definition.Elements().Where(e => e.Name != "Attributes"); foreach (var childDef in childDefs) { diff --git a/StructuredXmlEditor/Definition/GraphNodeDefinition.cs b/StructuredXmlEditor/Definition/GraphNodeDefinition.cs index 907a35f..2173f2b 100644 --- a/StructuredXmlEditor/Definition/GraphNodeDefinition.cs +++ b/StructuredXmlEditor/Definition/GraphNodeDefinition.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; namespace StructuredXmlEditor.Definition { @@ -13,6 +14,8 @@ public abstract class GraphNodeDefinition : ComplexDataDefinition public bool FlattenData { get; set; } public string NodeStoreName { get; set; } + public Brush Background { get; set; } + public GraphNodeDefinition() { TextColour = Colours["Struct"]; diff --git a/StructuredXmlEditor/Definition/GraphReferenceDefinition.cs b/StructuredXmlEditor/Definition/GraphReferenceDefinition.cs index 81e526e..fdf2119 100644 --- a/StructuredXmlEditor/Definition/GraphReferenceDefinition.cs +++ b/StructuredXmlEditor/Definition/GraphReferenceDefinition.cs @@ -151,7 +151,7 @@ public override void RecursivelyResolve(Dictionary local { Definitions[key.Item1] = def as GraphNodeDefinition; } - else + else if (key.Item1 != "---") { Message.Show("Tried to add definition of type " + def.GetType() + " (key = " + key.Item1 + ") to graph reference!", "Reference Resolve Failed", "Ok"); } @@ -161,6 +161,17 @@ public override void RecursivelyResolve(Dictionary local Message.Show("Failed to find key " + key.Item1 + "!", "Reference Resolve Failed", "Ok"); } } + + if (Keys.Count == 0) + { + Keys.Add(new Tuple("---", "---")); + + ListCollectionView lcv = new ListCollectionView(Keys); + lcv.GroupDescriptions.Add(new PropertyGroupDescription("Item2")); + ItemsSource = lcv; + + Definitions["---"] = new GraphStructDefinition(); + } } public override bool IsDefault(DataItem item) diff --git a/StructuredXmlEditor/Definition/GraphStructDefinition.cs b/StructuredXmlEditor/Definition/GraphStructDefinition.cs index 853e629..e686ee1 100644 --- a/StructuredXmlEditor/Definition/GraphStructDefinition.cs +++ b/StructuredXmlEditor/Definition/GraphStructDefinition.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using System.Xml.Linq; namespace StructuredXmlEditor.Definition @@ -153,6 +154,26 @@ public override void Parse(XElement definition) FlattenData = TryParseBool(definition, "FlattenData", false); NodeStoreName = definition.Attribute("NodeStoreName")?.Value?.ToString() ?? "Nodes"; + var backgroundCol = definition.Attribute("Background")?.Value?.ToString(); + if (backgroundCol != null) + { + var split = backgroundCol.Split(new char[] { ',' }); + + byte r = 0; + byte g = 0; + byte b = 0; + byte a = 0; + + byte.TryParse(split[0], out r); + byte.TryParse(split[1], out g); + byte.TryParse(split[2], out b); + byte.TryParse(split[3], out a); + + var col = Color.FromArgb(a, r, g, b); + Background = new SolidColorBrush(col); + Background.Freeze(); + } + bool foundChildAsGUID = string.IsNullOrWhiteSpace(ChildAsGUID); foreach (var child in definition.Elements()) diff --git a/StructuredXmlEditor/Definition/ReferenceDefinition.cs b/StructuredXmlEditor/Definition/ReferenceDefinition.cs index 6b6afcf..7e8a269 100644 --- a/StructuredXmlEditor/Definition/ReferenceDefinition.cs +++ b/StructuredXmlEditor/Definition/ReferenceDefinition.cs @@ -135,11 +135,22 @@ public override void RecursivelyResolve(Dictionary local { Definitions[key.Item1] = defs[key.Item1.ToLower()]; } - else + else if (key.Item1 != "---") { Message.Show("Failed to find key " + key.Item1 + "!", "Reference Resolve Failed", "Ok"); } } + + if (Keys.Count == 0) + { + Keys.Add(new Tuple("---", "---")); + + ListCollectionView lcv = new ListCollectionView(Keys); + lcv.GroupDescriptions.Add(new PropertyGroupDescription("Item2")); + ItemsSource = lcv; + + Definitions["---"] = new DummyDefinition(); + } } public override bool IsDefault(DataItem item) diff --git a/StructuredXmlEditor/StructuredXmlEditor.csproj b/StructuredXmlEditor/StructuredXmlEditor.csproj index 1e611d0..2dfd560 100644 --- a/StructuredXmlEditor/StructuredXmlEditor.csproj +++ b/StructuredXmlEditor/StructuredXmlEditor.csproj @@ -98,7 +98,6 @@ - diff --git a/StructuredXmlEditor/View/CustomControls/Graph/GraphNode.cs b/StructuredXmlEditor/View/CustomControls/Graph/GraphNode.cs index 33e7785..fb0cddc 100644 --- a/StructuredXmlEditor/View/CustomControls/Graph/GraphNode.cs +++ b/StructuredXmlEditor/View/CustomControls/Graph/GraphNode.cs @@ -1,4 +1,5 @@ using StructuredXmlEditor.Data; +using StructuredXmlEditor.Definition; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -43,6 +44,12 @@ static GraphNode() //-------------------------------------------------------------------------- public List ParentNodes { get; } = new List(); + //-------------------------------------------------------------------------- + public Brush BackgroundBrush + { + get { return (GraphNodeItem.Definition as GraphNodeDefinition).Background; } + } + //-------------------------------------------------------------------------- public double X { diff --git a/StructuredXmlEditor/View/Styles/DataGridTemplates.xaml b/StructuredXmlEditor/View/Styles/DataGridTemplates.xaml index c12e8de..7581ed1 100644 --- a/StructuredXmlEditor/View/Styles/DataGridTemplates.xaml +++ b/StructuredXmlEditor/View/Styles/DataGridTemplates.xaml @@ -227,13 +227,6 @@ - - - - + Width="*" /> + + @@ -816,12 +817,6 @@ - - @@ -834,8 +829,6 @@ Width="20" /> - @@ -909,8 +902,16 @@ Width="16" /> + + @@ -921,12 +922,6 @@ - - diff --git a/StructuredXmlEditor/View/Styles/Graph.xaml b/StructuredXmlEditor/View/Styles/Graph.xaml index bc22776..0ea0b11 100644 --- a/StructuredXmlEditor/View/Styles/Graph.xaml +++ b/StructuredXmlEditor/View/Styles/Graph.xaml @@ -89,168 +89,174 @@ - - - - - - + Margin="2,1,2,1"> + + + + + + - + - + - + - + + - - - - - - - + Margin="2,1,2,1"> + + + + + + + - + - + - - - - - - - - - - - - - - - -