Skip to content

Commit

Permalink
Fix a bug with visibleif and threading meaning that updates didnt get…
Browse files Browse the repository at this point in the history
… processed.

Stop the duplicate popups prompting to reload a document. You now only get prompted the next time you view that document.
Graph item positions are now saved relative to the first root item.
  • Loading branch information
Lyeeedar committed Jan 7, 2020
1 parent 5b52ef3 commit 8533781
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
7 changes: 6 additions & 1 deletion StructuredXmlEditor/Data/DataItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public bool IsVisibleFromBindings
{
if (VisibleIfStatements.Count == 0) return true;

UpdateVisibleIfBinding();
//UpdateVisibleIfBinding();

foreach (var group in VisibleIfStatements)
{
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions StructuredXmlEditor/Data/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Document> MultieditDocs { get; set; }
Expand Down
23 changes: 15 additions & 8 deletions StructuredXmlEditor/Data/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions StructuredXmlEditor/Definition/GraphCollectionDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions StructuredXmlEditor/Definition/GraphStructDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 8 additions & 0 deletions StructuredXmlEditor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8533781

Please sign in to comment.