Skip to content

Commit

Permalink
Fix crash when swapping away from the AsciiGrid.
Browse files Browse the repository at this point in the history
Fix issue where structs cant be created if they have attributes.
Fix copy/paste crash with multiline string items.
Fix project view missing some file changes.
Fix project view forgetting the expanded status of items.
  • Loading branch information
Lyeeedar committed Jan 21, 2017
1 parent 131c776 commit c697479
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion StructuredXmlEditor/Data/ComplexDataItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class ComplexDataItem : DataItem
protected abstract string EmptyString { get; }

//-----------------------------------------------------------------------
public bool HasContent { get { return Children.Count > 0 || Attributes.Count != 0; } }
public virtual bool HasContent { get { return Children.Count > 0 || Attributes.Count != 0; } }

//-----------------------------------------------------------------------
public override string Description
Expand Down
26 changes: 26 additions & 0 deletions StructuredXmlEditor/Data/MultilineStringItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace StructuredXmlEditor.Data
{
Expand Down Expand Up @@ -76,5 +77,30 @@ public MultilineStringItem(DataDefinition definition, UndoRedoManager undoRedo)
{

}

//-----------------------------------------------------------------------
public override void ResetToDefault()
{
Value = (Definition as MultilineStringDefinition).Default;
}

//-----------------------------------------------------------------------
public override void Copy()
{
var asString = Value;

Clipboard.SetData(CopyKey, asString);
}

//-----------------------------------------------------------------------
public override void Paste()
{
if (Clipboard.ContainsData(CopyKey))
{
var asString = Clipboard.GetData(CopyKey) as string;

Value = asString;
}
}
}
}
3 changes: 3 additions & 0 deletions StructuredXmlEditor/Data/StructItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class StructItem : ComplexDataItem
//-----------------------------------------------------------------------
protected override string EmptyString { get { return "null"; } }

//-----------------------------------------------------------------------
public override bool HasContent { get { return Children.Count == (Definition as StructDefinition).Children.Count; } }

//-----------------------------------------------------------------------
public StructItem(DataDefinition definition, UndoRedoManager undoRedo) : base(definition, undoRedo)
{
Expand Down
2 changes: 2 additions & 0 deletions StructuredXmlEditor/Data/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ public void SetupFileChangeHandlers()
Open(path);
}
}

ProjectViewTool.Instance.Add(path);
};

FileCreated += (path) =>
Expand Down
12 changes: 8 additions & 4 deletions StructuredXmlEditor/Tools/ProjectView/ProjectItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ public IEnumerable<ProjectItem> Items

public bool IsExpanded
{
get { return m_isExpanded; }
get { return Tool.ExpansionMap[Path]; }
set
{
if (m_isExpanded != value)
if (IsExpanded != value)
{
m_isExpanded = value;
Tool.ExpansionMap[Path] = value;

RaisePropertyChangedEvent("IsExpanded");
Tool.DeferredRefresh();
}
}
}
private bool m_isExpanded = false;

//-----------------------------------------------------------------------
public Command<object> ExpandAllCMD { get { return new Command<object>((e) => Tool.Root.SetExpand(true)); } }
Expand All @@ -74,6 +73,11 @@ public ProjectItem(Workspace workspace, ProjectItem parent, ProjectViewTool tool
this.Tool = tool;
this.Name = name;

if (!tool.ExpansionMap.ContainsKey(Path))
{
tool.ExpansionMap[Path] = false;
}

if (!skipLoadAndAdd)
{
if (IsDirectory)
Expand Down
18 changes: 16 additions & 2 deletions StructuredXmlEditor/Tools/ProjectView/ProjectViewTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace StructuredXmlEditor.Tools
{
public class ProjectViewTool : ToolBase
{
//-----------------------------------------------------------------------
public Dictionary<string, bool> ExpansionMap { get; } = new Dictionary<string, bool>();

//-----------------------------------------------------------------------
public static ProjectViewTool Instance;

Expand Down Expand Up @@ -160,8 +163,19 @@ public void Add(string path)
{
if (part == parts.Last())
{
new ProjectItem(Workspace, current, this, part);
current.UpdateChildFolders();
if (ext != String.Empty)
{
new ProjectItem(Workspace, current, this, part);
current.UpdateChildFolders();
}
else
{
var folder = current.ChildFolders[part];
current.Children.Remove(folder);

new ProjectItem(Workspace, current, this, part);
current.UpdateChildFolders();
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions StructuredXmlEditor/View/CustomControls/AsciiGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ private void OnPropertyChange(object sender, PropertyChangedEventArgs args)
//-----------------------------------------------------------------------
protected override void OnRender(DrawingContext drawingContext)
{
if (Item == null) return;

if (selectionBackBrush == null)
{
selectionBackBrush = new SolidColorBrush(Color.FromScRgb(0.1f, SelectedColour.ScR, SelectedColour.ScG, SelectedColour.ScB));
Expand Down

0 comments on commit c697479

Please sign in to comment.