<LogicalName>Crow.TreeExpandable.template</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="ui\ProjectTree.template" />
- <EmbeddedResource Include="ui\MembersItem.template" />
<EmbeddedResource Include="ui\EditPane.template">
<LogicalName>Crow.Coding.EditPane.template</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="ui\Options.crow" />
<EmbeddedResource Include="ui\IMLEdit.itemp" />
<EmbeddedResource Include="ui\SrcEdit.itemp" />
+ <EmbeddedResource Include="ui\IcoBut.template" />
+ <EmbeddedResource Include="ui\MembersItem.template" />
</ItemGroup>
<ItemGroup>
<None Include="ui\test.crow">
{
public class EditPane : TemplatedGroup
{
- public EditPane () : base()
- {
- }
+ public EditPane () {}
object selectedItemElement = null;
DesignInterface imlVE;
GraphicObject selectedItem;
- ImlProjectItem projectItem;
+ ImlProjectItem projFile;
Exception imlError = null;
bool drawGrid;
[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 {
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; }
}
{
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);
}
//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;
}
}
public class MembersView : ListBox
{
object instance;
+ ImlProjectItem projFile;
+
+ public MembersView () : base() {}
+
+ //cache property containers per type
+ Dictionary<string,PropertyContainer[]> propContainersCache = new Dictionary<string, PropertyContainer[]>();
[XmlAttributeAttribute][DefaultValue(null)]
public virtual object Instance {
set {
if (instance == value)
return;
+ object lastInst = instance;
+
instance = value;
NotifyValueChanged ("Instance", instance);
- if (Instance is GraphicObject)
- NotifyValueChanged ("SelectedItemName", (Instance as GraphicObject).Name);
- else
+
+ if (Instance is GraphicObject) {
+ NotifyValueChanged ("SelectedItemName", Instance.GetType().Name + (Instance as GraphicObject).design_id
+ + ":" + (Instance as GraphicObject).design_imlPath );
+ }else
NotifyValueChanged ("SelectedItemName", "");
- if (instance == null) {
+ if (instance == null) {
Data = null;
return;
+ }
+
+ Type it = instance.GetType ();
+ if (!propContainersCache.ContainsKey (it.FullName)) {
+ MemberInfo[] members = it.GetMembers (BindingFlags.Public | BindingFlags.Instance);
+ List<PropertyContainer> props = new List<PropertyContainer> ();
+ foreach (MemberInfo m in members) {
+ if (m.MemberType == MemberTypes.Property) {
+ PropertyInfo pi = m as PropertyInfo;
+ if (!pi.CanWrite)
+ continue;
+ if (pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)) != null)
+ continue;
+ props.Add (new PropertyContainer (this, pi));
+ }
+ }
+ propContainersCache.Add (it.FullName, props.OrderBy (p => p.Name).ToArray ());
}
- MemberInfo[] members = instance.GetType ().GetMembers (BindingFlags.Public | BindingFlags.Instance);
+ Data = propContainersCache [it.FullName];
- List<PropertyContainer> props = new List<PropertyContainer> ();
- foreach (MemberInfo m in members) {
- if (m.MemberType == MemberTypes.Property) {
- PropertyInfo pi = m as PropertyInfo;
- if (!pi.CanWrite)
- continue;
- if (pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)) != null)
- continue;
- props.Add (new PropertyContainer (pi, instance));
+ if (lastInst != instance) {
+ foreach (PropertyContainer pc in propContainersCache [it.FullName]) {
+ pc.NotifyValueChanged ("Value", pc.Value);
}
}
- Data = props.OrderBy(p=>p.Name).ToArray ();
}
}
- public MembersView () : base()
- {
+ public ImlProjectItem ProjectNode {
+ get { return projFile; }
+ set {
+ if (projFile == value)
+ return;
+
+// if (projFile != null)
+// projFile.UnregisterEditor (this);
+
+ projFile = value;
+
+// if (projFile != null)
+// projFile.RegisterEditor (this);
+
+ NotifyValueChanged ("ProjectNode", projFile);
+ }
+ }
+
+ public void updateSource () {
+ if (projFile == null)
+ return;
+ projFile.UpdateSource (this, (Instance as GraphicObject).GetIML ());
}
// public override void Paint (ref Context ctx)
using System.Xml;
using System.IO;
using Crow;
+using System.Threading;
namespace Crow.Coding
{
public ProjectNode (Project project, ItemType _type, string _name) : this(project){
type = _type;
name = _name;
+ initCommands ();
}
public ProjectNode (Project project){
Project = project;
+ initCommands ();
}
#endregion
+ void initCommands () {
+ Commands = new List<Crow.Command> ();
+ }
+
ItemType type;
string name;
List<ProjectNode> childNodes = new List<ProjectNode>();
public Project Project;
+ public List<Crow.Command> Commands;//list of command available for that node
public virtual ItemType Type {
get { return type; }
}
public class ProjectFile : ProjectItem {
- bool isOpened = false;
+ protected bool isOpened = false;
DateTime accessTime;
string source;
string origSource;
object selectedItem;
+ int curLine, curColumn;
+
+ internal ReaderWriterLockSlim srcEditMtx = new ReaderWriterLockSlim();
+
+ public Dictionary<object, bool> RegisteredEditors = new Dictionary<object, bool>();
+
+ Crow.Command cmdSave, cmdOpen;
- public List<Crow.Command> Commands;
+ public ProjectFile (ProjectItem pi)
+ : base (pi.Project, pi.node) {
- public ProjectFile (ProjectItem pi) : base (pi.Project, pi.node){
- Commands = new List<Crow.Command> (new Crow.Command[] {
- new Crow.Command(new Action(() => Open()))
- { Caption = "Open", Icon = new SvgPicture("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false},
- new Crow.Command(new Action(() => Save()))
- { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false},
- });
+ cmdSave = new Crow.Command (new Action (() => Save ()))
+ { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false };
+ cmdOpen = new Crow.Command (new Action (() => Open ()))
+ { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false };
+
+ Commands.Insert (0, cmdOpen);
+ Commands.Insert (1, cmdSave);
}
public string ResourceID {
return node.SelectSingleNode ("LogicalName")?.InnerText;
}
}
+
+ public void UnregisterEditor (object editor){
+ lock(RegisteredEditors){
+ RegisteredEditors.Remove (editor);
+ }
+ }
+ public void RegisterEditor (object editor) {
+ lock(RegisteredEditors){
+ RegisteredEditors.Add (editor, false);
+ }
+ }
+ public void UpdateSource (object sender, string newSrc){
+ System.Diagnostics.Debug.WriteLine ("update source by {0}", sender);
+ Source = newSrc;
+ lock (RegisteredEditors) {
+ object[] keys = RegisteredEditors.Keys.ToArray ();
+ foreach (object editor in keys) {
+ if (editor != sender)
+ RegisteredEditors [editor] = false;
+ }
+ }
+ }
public string Source {
get {
if (!isOpened)
set {
if (source == value)
return;
+
+ srcEditMtx.EnterWriteLock ();
+
source = value;
NotifyValueChanged ("Source", source);
NotifyValueChanged ("IsDirty", IsDirty);
+
+ srcEditMtx.ExitWriteLock ();
}
}
public bool IsDirty {
get { return source != origSource; }
}
- int curLine, curColumn;
public int CurrentColumn{
get { return curColumn; }
set {
NotifyValueChanged ("CurrentLine", curLine);
}
}
-// public bool IsSelected {
-// get { return isSelected; }
-// set {
-// if (isSelected == value)
-// return;
-// isSelected = value;
-// NotifyValueChanged ("IsSelected", isSelected);
-// }
-// }
public object SelectedItem {
get { return selectedItem; }
public CopyToOutputState CopyToOutputDirectory {
get {
XmlNode xn = node.SelectSingleNode ("CopyToOutputDirectory");
-// if (xn == null)
-// return CopyToOutputState.Never;
-// CopyToOutputState tmp = (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);
-// return tmp;
return xn == null ? CopyToOutputState.Never :
(CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);
}
}
public void OnQueryClose (object sender, EventArgs e){
+ if (IsDirty)
+ Console.WriteLine ("closing unsaved file");
Project.solution.CloseItem (this);
}
}
}
#endregion
+ GraphicObject instance;
+
+ /// <summary>
+ /// instance created with an instantiator from the source by a DesignInterface,
+ /// for now, the one in ImlVisualEditor
+ /// </summary>
+ public GraphicObject Instance {
+ get { return instance; }
+ set {
+ if (instance == value)
+ return;
+ instance = value;
+ NotifyValueChanged ("Instance", instance);
+ }
+ }
}
}
using System;
using System.Reflection;
using System.Linq;
+using System.Collections.Generic;
+using System.Diagnostics;
namespace Crow.Coding
{
}
#endregion
+ public List<Crow.Command> Commands;
PropertyInfo pi;
- object instance;
- GraphicObject go;
+ MembersView mview;
+// object instance;
+// GraphicObject go;
+
+ public PropertyContainer(MembersView mv, PropertyInfo prop){
+ mview = mv;
+ pi = prop;
+// instance = _instance;
+// go = instance as GraphicObject;
+
+ Commands = new List<Crow.Command> (new Crow.Command[] {
+ new Crow.Command(new Action(() => Reset())) { Caption = "Reset to default"},
+ });
+ }
public string Name { get { return pi.Name; }}
public object Value {
- get { return go.design_members.ContainsKey(Name) ?
- go.design_members[Name] : pi.GetValue(instance); }
+ get {
+ return pi.GetValue(mview.ProjectNode.SelectedItem);
+// GraphicObject inst = mview.ProjectNode.SelectedItem as GraphicObject;
+// Debug.WriteLine("read {0}.{1}", inst.Name, Name);
+// if (!inst.design_members.ContainsKey (Name))
+// return pi.GetValue (inst);
+//
+// if (inst.design_members [Name].StartsWith ("{"))
+// return inst.design_members [Name];
+// else
+// return pi.GetValue (inst);
+ }
set {
- if (go.design_members.ContainsKey (Name)) {
- if (go.design_members [Name] == (string)value)
- return;
+ try {
+ GraphicObject inst = mview.ProjectNode.SelectedItem as GraphicObject;
+ string valstr = null;
+ if (value != null)
+ valstr = value.ToString();
+ if (inst.design_members.ContainsKey (Name)) {
+ if (inst.design_members [Name] == valstr)
+ return;
+ Debug.WriteLine("update {0} : {1} = {2}", inst.Name, Name, valstr);
+ inst.design_members [Name] = value.ToString();
+ } else {
+ Debug.WriteLine("add {0} : {1} = {2}", inst.Name, Name, valstr);
+ inst.design_members.Add (Name, value.ToString());
+ }
+
+ if (!pi.PropertyType.IsAssignableFrom(value.GetType()) && pi.PropertyType != typeof(string)){
+ if (pi.PropertyType.IsEnum) {
+ if (value is string) {
+ pi.SetValue (inst, Enum.Parse (pi.PropertyType, (string)value));
+ }else
+ pi.SetValue (inst, value);
+ } else {
+ MethodInfo me = pi.PropertyType.GetMethod
+ ("Parse", BindingFlags.Static | BindingFlags.Public,
+ System.Type.DefaultBinder, new Type [] {typeof (string)},null);
+ pi.SetValue (inst, me.Invoke (null, new object[] { value }), null);
+ }
+ }else
+ pi.SetValue(inst, value);
+
+ mview.ProjectNode.Instance.HasChanged = true;
+ NotifyValueChanged ("Value", value);
+ NotifyValueChanged ("LabForeground", LabForeground);
+ } catch (Exception ex) {
+ System.Diagnostics.Debug.WriteLine ("Error setting property:"+ ex.ToString());
}
- go.design_members [Name] = (string)value;
-// try {
-// if (!pi.PropertyType.IsAssignableFrom(value.GetType()) && pi.PropertyType != typeof(string)){
-// if (pi.PropertyType.IsEnum) {
-// if (value is string) {
-// pi.SetValue (instance, Enum.Parse (pi.PropertyType, (string)value));
-// }else
-// pi.SetValue (instance, value);
-// } else {
-// MethodInfo me = pi.PropertyType.GetMethod
-// ("Parse", BindingFlags.Static | BindingFlags.Public,
-// System.Type.DefaultBinder, new Type [] {typeof (string)},null);
-// pi.SetValue (instance, me.Invoke (null, new object[] { value }), null);
-// }
-// }else
-// pi.SetValue(instance, value);
-// } catch (Exception ex) {
-// System.Diagnostics.Debug.WriteLine ("Error setting property:"+ ex.ToString());
-// }
- NotifyValueChanged ("Value", value);
+ //
}
}
+ /// <summary>
+ /// for style attribute which is a string, return Style as type
+ /// </summary>
public string Type { get { return pi.PropertyType.IsEnum ?
"System.Enum"
- : pi.PropertyType.FullName; }}
+ : pi.Name == "Style" ? "Style" : pi.PropertyType.FullName; }}
+
public object[] Choices {
get {
return Enum.GetValues (pi.PropertyType).Cast<object>().ToArray();
}
public Fill LabForeground {
- get { return go.design_members.ContainsKey(Name) ? Color.Black : Color.DimGray;}
+ get { return (mview.ProjectNode.SelectedItem as GraphicObject).design_members.ContainsKey(Name) ? Color.Black : Color.DimGray;}
}
- public PropertyContainer(PropertyInfo prop, object _instance){
- pi = prop;
- instance = _instance;
- go = instance as GraphicObject;
+ /// <summary>
+ /// reset to default value
+ /// </summary>
+ public void Reset () {
+ GraphicObject inst = mview.ProjectNode.SelectedItem as GraphicObject;
+ if (!inst.design_members.ContainsKey (Name))
+ return;
+ inst.design_members.Remove (Name);
+ //NotifyValueChanged ("Value", Value);
+ mview.ProjectNode.Instance.HasChanged = true;
+ //should reinstantiate to get default
}
+
+
}
}
string oldSource = "";
void updateSourceThreadFunc (){
while (true) {
- if (projNode != null && buffer != null) {
- string newSrc = buffer.FullText;
- if (projNode.Source != newSrc)
- projNode.Source = newSrc;
+ if (projFile != null && buffer != null) {
+ if (!projFile.RegisteredEditors [this]) {
+ loadSource ();
+ isDirty = false;
+ oldSource = projFile.Source;
+ projFile.RegisteredEditors [this] = true;
+ }
+ if (Monitor.TryEnter (buffer.EditMutex)) {
+ string newsrc = "";
+ bool wasDirty = false;
+ if (isDirty) {
+ isDirty = false;
+ wasDirty = true;
+ newsrc = buffer.FullText;
+ }
+ Monitor.Exit (buffer.EditMutex);
+ if (wasDirty)
+ projFile.UpdateSource (this, newsrc);
+ }
}
Thread.Sleep (100);
}
#region private and protected fields
bool foldingEnabled = true;
- ProjectFile projNode = null;
+ ProjectFile projFile = null;
int leftMargin = 0; //margin used to display line numbers, folding errors,etc...
int visibleLines = 1;
int visibleColumns = 1;
buffer.ToogleFolding (line);
}
+ volatile bool isDirty = false;
+
#region Buffer events handlers
void Buffer_BufferCleared (object sender, EventArgs e)
{
PrintedLines = null;
RegisterForGraphicUpdate ();
notifyPositionChanged ();
+ isDirty = true;
}
void Buffer_LineAdditionEvent (object sender, CodeBufferEventArgs e)
{
updateMaxScrollY ();
RegisterForGraphicUpdate ();
notifyPositionChanged ();
+ isDirty = true;
}
void Buffer_LineRemoveEvent (object sender, CodeBufferEventArgs e)
{
updateMaxScrollY ();
RegisterForGraphicUpdate ();
notifyPositionChanged ();
+ isDirty = true;
}
void Buffer_LineUpadateEvent (object sender, CodeBufferEventArgs e)
{
RegisterForGraphicUpdate ();
notifyPositionChanged ();
+ isDirty = true;
}
void Buffer_PositionChanged (object sender, EventArgs e)
{
public ProjectFile ProjectNode
{
get {
- return projNode;
+ return projFile;
}
set
{
- if (projNode == value)
+ if (projFile == value)
return;
- projNode = value;
+ if (projFile != null)
+ projFile.UnregisterEditor (this);
- NotifyValueChanged ("ProjectNode", projNode);
+ projFile = value;
+ NotifyValueChanged ("ProjectNode", projFile);
- if (projNode == null)
- return;
-
- if (!File.Exists (projNode.AbsolutePath))
+ if (projFile == null)
return;
- parser = getParserFromExt (System.IO.Path.GetExtension (projNode.Extension));
+ parser = getParserFromExt (System.IO.Path.GetExtension (projFile.Extension));
- try {
- buffer.Load (projNode.Source);
- oldSource = projNode.Source;
- } catch (Exception ex) {
- Debug.WriteLine (ex.ToString ());
- }
-
- updateMaxScrollY ();
- MaxScrollX = Math.Max (0, buffer.longestLineCharCount - visibleColumns);
- updatePrintedLines ();
+ projFile.RegisterEditor (this);
- RegisterForGraphicUpdate ();
}
}
+ void loadSource () {
+
+ try {
+ buffer.Load (projFile.Source);
+ } catch (Exception ex) {
+ Debug.WriteLine (ex.ToString ());
+ }
+
+ projFile.RegisteredEditors [this] = true;
+
+ updateMaxScrollY ();
+ MaxScrollX = Math.Max (0, buffer.longestLineCharCount - visibleColumns);
+ updatePrintedLines ();
+
+ RegisterForGraphicUpdate ();
+ }
+
[XmlAttributeAttribute][DefaultValue("BlueGray")]
public virtual Color SelectionBackground {
get { return selBackground; }
Data="{Projects}" SelectedItemChanged="onSelectedItemChanged"
ItemTemplate="#Crow.Coding.ui.ProjectTree.template"/>
<Splitter/>
- <MembersView Instance="{SelectedItemElement}" DataTest="Type"
+ <MembersView ProjectNode="{SelectedItem}"
+ Instance="{SelectedItemElement}" DataTest="Type"
ItemTemplate="#Crow.Coding.ui.MembersItem.template"/>
</VerticalStack>
</HorizontalStack>
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0"?>
<ItemTemplate>
<TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
<Label Text="Error" Background="Red"/>
</TabItem>
</ItemTemplate>
-<ItemTemplate DataType=".svg" DataTest="Extension">
+<ItemTemplate DataType=".svg">
<TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
<Image Path="{AbsolutePath}"/>
</TabItem>
</ItemTemplate>
-<ItemTemplate Path="#Crow.Coding.ui.SrcEdit.itemp" DataType=".cs" DataTest="Extension"/>
-<ItemTemplate Path="#Crow.Coding.ui.SrcEdit.itemp" DataType=".style" DataTest="Extension"/>
-<ItemTemplate Path="#Crow.Coding.ui.IMLEdit.itemp" DataType=".crow" DataTest="Extension"/>
-<ItemTemplate Path="#Crow.Coding.ui.IMLEdit.itemp" DataType=".template" DataTest="Extension"/>
+<ItemTemplate Path="#Crow.Coding.ui.SrcEdit.itemp" DataType=".cs"/>
+<ItemTemplate Path="#Crow.Coding.ui.SrcEdit.itemp" DataType=".style"/>
+<ItemTemplate Path="#Crow.Coding.ui.IMLEdit.itemp" DataType=".crow"/>
+<ItemTemplate Path="#Crow.Coding.ui.IMLEdit.itemp" DataType=".template"/>
MouseEnter={Background=UnitedNationsBlue};
MouseLeave={Background=Transparent};
}
+
+IcoBut {
+ Template = #Crow.Coding.ui.IcoBut.template;
+ MinimumSize = 10,10;
+ Width = 8;
+ Height = 14;
+ Background = White;
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<Border Background="{./Background}" Name="Content"
+ BorderWidth="1" BorderStyle="Normal"
+ MouseDown="{BorderStyle=Sunken}"
+ MouseUp="{BorderStyle=Normal}">
+ <Image Margin="1" Path="#Crow.Coding.ui.icons.blank-file.svg" />
+</Border>
-<?xml version="1.0"?>
+<?xml version="1.0"?>
<ItemTemplate>
- <HorizontalStack Style="MemberViewHStack" >
+ <HorizontalStack Style="MemberViewHStack" ContextCommands="{Commands}">
<Label Style="MemberViewLabel" Text="{Name}" Foreground = "{LabForeground}"/>
<TextBox Margin="1" Text="{²Value}" Height="Fit" Foreground = "{LabForeground}"/>
</HorizontalStack>
</ItemTemplate>
-<ItemTemplate DataType="System.Boolean">
- <HorizontalStack Style="MemberViewHStack" >
+<ItemTemplate DataType="System.Boolean" >
+ <HorizontalStack Style="MemberViewHStack" ContextCommands="{Commands}">
<Label Style="MemberViewLabel" Text="{Name}" Foreground = "{LabForeground}"/>
<CheckBox Background="White" Foreground = "{LabForeground}" Height="Stretched" Caption="" IsChecked="{²Value}"/>
</HorizontalStack>
</ItemTemplate>
<ItemTemplate DataType="System.Enum">
- <HorizontalStack Style="MemberViewHStack" >
+ <HorizontalStack Style="MemberViewHStack" ContextCommands="{Commands}">
<Label Style="MemberViewLabel" Text="{Name}" Foreground = "{LabForeground}"/>
<ComboBox Margin="0" Height="Stretched" Width="50%" Data="{Choices}"
SelectedItem="{²Value}">
Text="{../../../../../SelectedItem}"/>
<Button Width="12" Height="12" Focusable="false"
Template="#Crow.Templates.ArrowBut.template">
- <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
+ <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
</Button>
</HorizontalStack>
</Border>
</HorizontalStack>
</ItemTemplate>
<ItemTemplate DataType="Crow.Fill">
- <HorizontalStack Style="MemberViewHStack" >
+ <HorizontalStack Style="MemberViewHStack" ContextCommands="{Commands}">
<Label Style="MemberViewLabel" Text="{Name}" Foreground = "{LabForeground}"/>
- <Popper Background="White" Margin="0" Height="Stretched" Caption="{Value}">
+ <Popper Height="Stretched" Caption="{Value}">
<Template>
- <CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}" Background="{./Background}">
+ <CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}">
<Template>
- <HorizontalStack Spacing="3" Height="Fit" Background="{./Background}">
- <Border Foreground="{LabForeground}" Width="16" Height="10" CornerRadius="3"
+ <HorizontalStack Margin="1" Height="Stretched" Spacing="3" Background="White">
+ <Border Foreground="{LabForeground}" Width="18" Height="12" CornerRadius="3"
Background="{Value}">
</Border>
- <Label Text="{./Caption}" Foreground="{LabForeground}"/>
+ <Label Width="Stretched" Text="{./Caption}" Foreground="{LabForeground}"/>
</HorizontalStack>
</Template>
</CheckBox>
<?xml version="1.0"?>
<VerticalStack>
<Border Height="Fit">
- <Label TextAlignment="Left" Text="{../../../SelectedItemName}" Width="Stretched"/>
+ <Label TextAlignment="Left" Text="{./SelectedItemName}" Width="Stretched"/>
</Border>
<HorizontalStack>
<Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim();
#if DESIGN_MODE
+ public volatile bool HasChanged = false;
+ public string design_id;
public int design_line;
public int design_column;
public string design_imlPath;
public Dictionary<string,string> design_members = new Dictionary<string, string>();
public bool design_isTGItem = false;
+ public virtual bool FindByDesignID(string designID, out GraphicObject go){
+ go = null;
+ if (this.design_id == designID){
+ go = this;
+ return true;
+ }
+ return false;
+ }
+
public string GetIML(){
XmlDocument doc = new XmlDocument( );
getIML (doc, (XmlNode)doc);
doc.WriteTo (xtw);
}
+ this.HasChanged = false;
return sw.ToString ();
}
}
public class Group : GraphicObject
{
#if DESIGN_MODE
+ public override bool FindByDesignID(string designID, out GraphicObject go){
+ go = null;
+ if (base.FindByDesignID (designID, out go))
+ return true;
+ childrenRWLock.EnterReadLock ();
+ foreach (GraphicObject w in Children) {
+ if (!w.FindByDesignID (designID, out go))
+ continue;
+ childrenRWLock.ExitReadLock ();
+ return true;
+ }
+ childrenRWLock.ExitReadLock ();
+ return false;
+ }
public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem)
{
if (this.design_isTGItem)
public PrivateContainer (Interface iface) : base(iface){}
#endregion
+ #if DESIGN_MODE
+ public override bool FindByDesignID(string designID, out GraphicObject go){
+ go = null;
+ if (base.FindByDesignID (designID, out go))
+ return true;
+ return (bool)child?.FindByDesignID (designID, out go);
+ }
+ #endif
protected GraphicObject child;
protected virtual void SetChild(GraphicObject _child)
internal string sourcePath;
+ #if DESIGN_MODE
+ public static int NextInstantiatorID = 0;
+ public int currentInstantiatorID = 0;
+ int currentDesignID = 0;
+ internal string NextDesignID { get { return string.Format ("{0}_{1}",currentInstantiatorID, currentDesignID++); }}
+ #endif
+
#region CTOR
/// <summary>
/// Initializes a new instance of the Instantiator class.
/// </summary>
public Instantiator (Interface _iface, Stream stream, string srcPath = null)
{
+ #if DESIGN_MODE
+ currentInstantiatorID = NextInstantiatorID++;
+ #endif
iface = _iface;
sourcePath = srcPath;
#if DEBUG_LOAD
/// positionned on the start tag inside the itemTemplate
/// </summary>
public Instantiator (Interface _iface, XmlReader itr){
+ #if DESIGN_MODE
+ currentInstantiatorID = NextInstantiatorID++;
+ #endif
iface = _iface;
parseIML (itr);
}
//TODO:check if still used
public Instantiator (Interface _iface, Type _root, InstanciatorInvoker _loader)
{
+ #if DESIGN_MODE
+ currentInstantiatorID = NextInstantiatorID++;
+ #endif
iface = _iface;
RootType = _root;
loader = _loader;
#if DESIGN_MODE
IXmlLineInfo li = (IXmlLineInfo)reader;
ctx.il.Emit (OpCodes.Ldloc_0);
+ ctx.il.Emit (OpCodes.Ldstr, this.NextDesignID);
+ ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_id"));
+ ctx.il.Emit (OpCodes.Ldloc_0);
ctx.il.Emit (OpCodes.Ldc_I4, ctx.curLine + li.LineNumber);
ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_line"));
ctx.il.Emit (OpCodes.Ldloc_0);