diff --git a/StructuredXmlEditor/Data/DataItem.cs b/StructuredXmlEditor/Data/DataItem.cs index 33b9e78..24cedb1 100644 --- a/StructuredXmlEditor/Data/DataItem.cs +++ b/StructuredXmlEditor/Data/DataItem.cs @@ -162,7 +162,7 @@ public bool IsVisibleFromBindings { if (VisibleIfStatements.Count == 0) return true; - UpdateVisibleIfBinding(); + //UpdateVisibleIfBinding(); foreach (var group in VisibleIfStatements) { @@ -567,6 +567,11 @@ public void UpdateVisibleIfBinding() if (Definition.VisibleIf != null) { + if (Definition.VisibleIf.Contains('(')) + { + throw new Exception("VisibleIf doesnt support brackets yet"); + } + // decompose into or groups var orgroups = Definition.VisibleIf.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries); foreach (var orgroup in orgroups) diff --git a/StructuredXmlEditor/Data/Document.cs b/StructuredXmlEditor/Data/Document.cs index e4a15ff..7b0075e 100644 --- a/StructuredXmlEditor/Data/Document.cs +++ b/StructuredXmlEditor/Data/Document.cs @@ -21,6 +21,7 @@ public class Document : NotifyPropertyChanged public UndoRedoManager UndoRedo { get; set; } = new UndoRedoManager(); public Workspace Workspace { get; set; } public bool IsBackup { get; set; } + public bool NeedsReload { get; set; } //----------------------------------------------------------------------- public List MultieditDocs { get; set; } diff --git a/StructuredXmlEditor/Data/Workspace.cs b/StructuredXmlEditor/Data/Workspace.cs index 6387001..b7e4371 100644 --- a/StructuredXmlEditor/Data/Workspace.cs +++ b/StructuredXmlEditor/Data/Workspace.cs @@ -37,6 +37,20 @@ public Document Current set { m_current = value; + + if (m_current != null && m_current.NeedsReload) + { + m_current.NeedsReload = false; + + string response = Message.Show("This document changed on disk, do you want to reload it? Clicking Yes will discard any local changes.", "Document Changed On Disk", "Yes", "No"); + + if (response == "Yes") + { + m_current.Close(true); + Current = Open(m_current.Path); + } + } + RaisePropertyChangedEvent(); } } @@ -258,14 +272,7 @@ public void SetupFileChangeHandlers() var open = Documents.FirstOrDefault(e => e.Path == path); if (open != null) { - Current = open; - string response = Message.Show("This document changed on disk, do you want to reload it? Clicking Yes will discard any local changes.", "Document Changed On Disk", "Yes", "No"); - - if (response == "Yes") - { - open.Close(true); - Open(path); - } + open.NeedsReload = true; } ProjectViewTool.Instance.Add(path); diff --git a/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs b/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs index 9a528f9..17d8f3f 100644 --- a/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs +++ b/StructuredXmlEditor/Definition/GraphCollectionDefinition.cs @@ -164,8 +164,10 @@ public override void DoSaveData(XElement parent, DataItem item) XElement root = new XElement(Name); - root.Add(new XAttribute(MetaNS + "X", ci.X)); - root.Add(new XAttribute(MetaNS + "Y", ci.Y)); + var relativeToNode = item.DataModel.RootItems.First(e => e.Definition is GraphNodeDefinition) as GraphNodeItem; + + root.Add(new XAttribute(MetaNS + "X", ci.X - relativeToNode.X)); + root.Add(new XAttribute(MetaNS + "Y", ci.Y - relativeToNode.Y)); if (ci.Comment != null) root.Add(new XAttribute(MetaNS + "Comment", ci.Comment)); if (ci.LinkParents.Count > 1 || ci.DataModel.FlattenData) diff --git a/StructuredXmlEditor/Definition/GraphStructDefinition.cs b/StructuredXmlEditor/Definition/GraphStructDefinition.cs index 2621483..da48798 100644 --- a/StructuredXmlEditor/Definition/GraphStructDefinition.cs +++ b/StructuredXmlEditor/Definition/GraphStructDefinition.cs @@ -226,8 +226,10 @@ public override void DoSaveData(XElement parent, DataItem item) var el = new XElement(name); parent.Add(el); - el.Add(new XAttribute(MetaNS + "X", si.X)); - el.Add(new XAttribute(MetaNS + "Y", si.Y)); + var relativeToNode = item.DataModel.RootItems.First(e => e.Definition is GraphNodeDefinition) as GraphNodeItem; + + el.Add(new XAttribute(MetaNS + "X", si.X - relativeToNode.X)); + el.Add(new XAttribute(MetaNS + "Y", si.Y - relativeToNode.Y)); if (si.Comment != null) el.Add(new XAttribute(MetaNS + "Comment", si.Comment)); if (string.IsNullOrWhiteSpace(ChildAsGUID) && (si.LinkParents.Count > 1 || si.DataModel.FlattenData)) diff --git a/StructuredXmlEditor/MainWindow.xaml.cs b/StructuredXmlEditor/MainWindow.xaml.cs index 426ef9d..1af1066 100644 --- a/StructuredXmlEditor/MainWindow.xaml.cs +++ b/StructuredXmlEditor/MainWindow.xaml.cs @@ -55,6 +55,14 @@ public MainWindow() VersionInfo.CheckForUpdates(Workspace); })); }; + + Activated += (e, args) => + { + if (Workspace != null) + { + Workspace.Current = Workspace.Current; + } + }; } protected override void OnPreviewKeyDown(KeyEventArgs e)