aboutsummaryrefslogtreecommitdiffstatsci
path: root/CrowIDE/src/ImlVisualEditor.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-27 18:18:42 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-27 18:18:42 +0100
commit508b53d725958e6a8c8be51db04033aeff1df0da (patch)
tree8495cf890a9cee3466aa8eaceb073f391fb5d628 /CrowIDE/src/ImlVisualEditor.cs
parentf4c05f6b4ddd426a87492b51aca5147d5def2bc5 (diff)
crowide wip, DesignIDS
Diffstat (limited to 'CrowIDE/src/ImlVisualEditor.cs')
-rw-r--r--CrowIDE/src/ImlVisualEditor.cs78
1 files changed, 36 insertions, 42 deletions
diff --git a/CrowIDE/src/ImlVisualEditor.cs b/CrowIDE/src/ImlVisualEditor.cs
index 3d59e9be..7989936a 100644
--- a/CrowIDE/src/ImlVisualEditor.cs
+++ b/CrowIDE/src/ImlVisualEditor.cs
@@ -43,7 +43,7 @@ namespace Crow.Coding
DesignInterface imlVE;
GraphicObject selectedItem;
- ImlProjectItem projectItem;
+ ImlProjectItem projFile;
Exception imlError = null;
bool drawGrid;
@@ -97,35 +97,27 @@ namespace Crow.Coding
[XmlIgnore]public List<LQIList> LQIs {
get { return imlVE.LQIs; }
}
-
- [XmlAttributeAttribute]
+
public ProjectNode ProjectNode {
- get { return projectItem; }
+ get { return projFile; }
set {
- if (projectItem == value)
+ if (projFile == value)
return;
+ if (projFile != null)
+ projFile.UnregisterEditor (this);
+
+ projFile = value as ImlProjectItem;
- if (projectItem != null)
- projectItem.ValueChanged -= ProjectItem_ValueChanged;
-
- projectItem = value as ImlProjectItem;
-
- if (projectItem != null)
- projectItem.ValueChanged += ProjectItem_ValueChanged;
+ imlVE.ProjFile = projFile;
- NotifyValueChanged ("ProjectNode", projectItem);
+ if (projFile != null)
+ projFile.RegisterEditor (this);
- reload ();
+ NotifyValueChanged ("ProjectNode", projFile);
}
}
- void ProjectItem_ValueChanged (object sender, ValueChangeEventArgs e)
- {
- if (e.MemberName == "Source")
- reload ();
- }
-
[XmlIgnore]public Exception IMLError {
get { return imlError; }
set {
@@ -140,24 +132,6 @@ namespace Crow.Coding
get { return imlError != null; }
}
- void reload(){
- if (projectItem == null)
- return;
-
- try {
- imlVE.ProjFile = projectItem;
- imlVE.Styling = projectItem.Project.solution.Styling;
- imlVE.DefaultTemplates = projectItem.Project.solution.DefaultTemplates;
- imlVE.Instantiators = new Dictionary<string, Instantiator>();
- imlVE.ClearInterface();
- imlVE.LoadIMLFragment(projectItem.Source);
- IMLError = null;
- } catch (Exception ex) {
- IMLError = ex.InnerException;
- Console.WriteLine (ex.ToString ());
- }
- }
-
public List<GraphicObject> GraphicTree {
get { return imlVE.GraphicTree; }
}
@@ -166,9 +140,29 @@ namespace Crow.Coding
{
while (true) {
try {
+ if (!projFile.RegisteredEditors[this]){
+ string selItemDesignID = null;
+ if (SelectedItem!=null)
+ selItemDesignID = SelectedItem.design_id;
+ imlVE.ClearInterface();
+ Instantiator.NextInstantiatorID = 0;
+ imlVE.Styling = projFile.Project.solution.Styling;
+ imlVE.DefaultTemplates = projFile.Project.solution.DefaultTemplates;
+ imlVE.Instantiators = new Dictionary<string, Instantiator>();
+ imlVE.LoadIMLFragment(projFile.Source);
+ projFile.Instance = imlVE.GraphicTree[0];
+ GraphicObject go = null;
+ if (selItemDesignID!=null)
+ projFile.Instance.FindByDesignID(selItemDesignID,out go);
+ SelectedItem = go;
+ IMLError = null;
+ projFile.RegisteredEditors[this] = true;
+ }else if ((bool)projFile.Instance?.HasChanged){
+ projFile.UpdateSource(this, projFile.Instance.GetIML());
+ }
imlVE.Update ();
} catch (Exception ex) {
- System.Diagnostics.Debug.WriteLine (ex.ToString ());
+ IMLError = ex.InnerException;
if (Monitor.IsEntered(imlVE.UpdateMutex))
Monitor.Exit (imlVE.UpdateMutex);
}
@@ -215,9 +209,9 @@ namespace Crow.Coding
//base.onMouseDown (sender, e);
SelectedItem = HoverWidget;
- if (SelectedItem != null && projectItem != null) {
- projectItem.CurrentLine = HoverWidget.design_line;
- projectItem.CurrentColumn = HoverWidget.design_column;
+ if (SelectedItem != null && projFile != null) {
+ projFile.CurrentLine = SelectedItem.design_line;
+ projFile.CurrentColumn = SelectedItem.design_column;
}
}