<Compile Include="src\CrowIDE.cs" />
<Compile Include="src\ImlVisualEditor.cs" />
<Compile Include="src\MembersView.cs" />
+ <Compile Include="src\Extensions.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="ui\" />
<EmbeddedResource Include="ui\MembersView.template">
<LogicalName>CrowIDE.MembersView.template</LogicalName>
</EmbeddedResource>
+ <EmbeddedResource Include="ui\bindingExplorer.crow" />
+ <EmbeddedResource Include="ui\bindingExpITemp.crow" />
+ <EmbeddedResource Include="ui\LQIsExplorer.crow" />
</ItemGroup>
<ItemGroup>
<None Include="ui\test.crow">
using OpenTK;
using OpenTK.Graphics.OpenGL;
using Crow;
+using System.Reflection;
+using System.Collections.Generic;
+using System.Collections;
namespace CrowIDE
{
: base(1024, 800,"UIEditor")
{
}
+ ImlVisualEditor imlVE;
+ GraphicObject bindingExp, lqisExp;
protected override void OnLoad (EventArgs e)
{
base.OnLoad (e);
+ this.KeyDown += CrowIDE_KeyDown;
+
//this.CrowInterface.LoadInterface ("#CrowIDE.ui.imlEditor.crow").DataSource = this;
//GraphicObject go = this.CrowInterface.LoadInterface (@"ui/test.crow");
GraphicObject go = this.CrowInterface.LoadInterface (@"#CrowIDE.ui.imlEditor.crow");
+ imlVE = go.FindByName ("crowContainer") as ImlVisualEditor;
go.DataSource = this;
}
+
+ void CrowIDE_KeyDown (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
+ {
+ if (e.Key == OpenTK.Input.Key.Escape) {
+ Quit (null, null);
+ return;
+ } else if (e.Key == OpenTK.Input.Key.F5) {
+ if (bindingExp != null) {
+ CrowInterface.DeleteWidget (bindingExp);
+ }
+ bindingExp = CrowInterface.LoadInterface ("#CrowIDE.ui.bindingExplorer.crow");
+ bindingExp.DataSource = imlVE;
+ return;
+ } else if (e.Key == OpenTK.Input.Key.F6) {
+ if (lqisExp != null) {
+ CrowInterface.DeleteWidget (lqisExp);
+ }
+ lqisExp = CrowInterface.LoadInterface ("#CrowIDE.ui.LQIsExplorer.crow");
+ lqisExp.DataSource = imlVE;
+ return;
+ }
+ }
protected void onCommandSave(object sender, MouseButtonEventArgs e){
System.Diagnostics.Debug.WriteLine("save");
}
--- /dev/null
+//
+// Extensions.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Collections.Generic;
+
+namespace Crow
+{
+ public static class Extensions
+ {
+ public static List<GraphicObject> GetChildren(this GraphicObject go){
+ if (go is Group)
+ return (go as Group).Children;
+ if (go is Container)
+ return new List<GraphicObject>( new GraphicObject[] { (go as Container).Child });
+ return new List<GraphicObject>();
+ }
+ }
+}
using System.Xml.Serialization;
using System.ComponentModel;
using System.IO;
+using System.Collections.Generic;
namespace CrowIDE
{
bool drawGrid;
int gridSpacing;
+ [XmlIgnore]public List<LQIList> LQIs {
+ get { return imlVE.LQIs; }
+ }
[XmlIgnore]public string ImlSource {
get { return imlSource; }
set {
--- /dev/null
+<?xml version="1.0"?>
+<Window Width="50%" Height="50%" Background="DimGray">
+ <TreeView IsRoot="true" Name="treeView" Data="{LQIs}">
+ <ItemTemplate DataType="Crow.LayoutingQueueItem" Data="triggeredLQIs">
+ <Expandable>
+ <Template>
+ <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+ <VerticalStack Fit="true" Margin="3" Background="Onyx"
+ HorizontalAlignment="Left"
+ MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+ MouseLeave="{Background=Onyx}">
+ <Label Text="{FullName}" Font="droid, 8" Background="LightGray" Foreground="Black"/>
+ <HorizontalStack Fit="true" Spacing="10">
+ <Label Text="{LayoutingTries}" Foreground="SkyBlue"/>
+ <Label Text="{DiscardCount}" Foreground="Red"/>
+ <Label Text="{Name}" Font="droid bold"/>
+ <Label Text="{LayoutType}" Foreground="Maize"/>
+ <Label Text="{Width}"/>
+ <Label Text="{Height}"/>
+ </HorizontalStack>
+
+ <HorizontalStack Fit="true">
+ <Label Text="{Slot}"/>
+ <Label Text=" => "/>
+ <Label Text="{NewSlot}"/>
+ </HorizontalStack>
+ <GraphicObject Background="Mantis" Height="3" Visible="{HasTriggeredLQIs}"/>
+ </VerticalStack>
+ <Container Name="Content" Visible="false" HorizontalAlignment="Left"
+ Fit="true"/>
+ </VerticalStack>
+ </Template>
+ <HorizontalStack Height="Fit" Width="Fit">
+ <GraphicObject Width="20" Height="10"/>
+ <TreeView Name="List" Height="Fit" Width="Fit"
+ Template="#Crow.Templates.treeList.crow" />
+ </HorizontalStack>
+ </Expandable>
+ </ItemTemplate>
+ <ItemTemplate DataType="Crow.LQIList" Data="GetRootLQIs">
+ <Expandable Caption="{}" >
+ <Template>
+ <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+ <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}"
+ MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+ MouseLeave="{Background=Transparent}">
+ <Image Margin="2" Width="12" Height="12"
+
+ Path="{./Image}"
+ SvgSub="{./IsExpanded}"/>
+ <Label Text="{./Caption}" Width="{./WidthPolicy}"/>
+ </HorizontalStack>
+ <Container Name="Content" Visible="false"
+ Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
+ </VerticalStack>
+ </Template>
+ <HorizontalStack Height="Fit" Width="{./WidthPolicy}">
+ <GraphicObject Width="12" Height="10"/>
+ <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}"
+ Template="#Crow.Templates.treeList.crow" />
+ </HorizontalStack>
+ </Expandable>
+ </ItemTemplate>
+ </TreeView>
+</Window>
--- /dev/null
+<?xml version="1.0"?>
+<Expandable Caption="{Name}" >
+ <Template>
+ <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+ <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}"
+ MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+ MouseLeave="{Background=Transparent}">
+ <Image Margin="2" Width="12" Height="12"
+ Visible="{./HasContent}"
+ Path="{./Image}"
+ SvgSub="{./IsExpanded}"/>
+ <Label Text="{./Caption}" Width="{./WidthPolicy}"/>
+ </HorizontalStack>
+ <Container Name="Content" Visible="false"
+ Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
+ </VerticalStack>
+ </Template>
+ <HorizontalStack Height="Fit" Width="{./WidthPolicy}">
+ <GraphicObject Width="12" Height="10"/>
+ <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}"
+ Template="#Crow.Templates.treeList.crow" />
+ </HorizontalStack>
+</Expandable>
--- /dev/null
+<?xml version="1.0"?>
+<Window Width="50%" Height="50%" Background="DimGray">
+ <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}">
+ <ItemTemplate DataType="Crow.GraphicObject">
+ <Label Text="{Name}" Width="Stretched"
+ MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+ MouseLeave="{Background=Transparent}"/>
+ </ItemTemplate>
+ <ItemTemplate DataType="Crow.Container" Data="GetChildren"
+ Path="#CrowIDE.ui.bindingExpITemp.crow"/>
+ <ItemTemplate DataType="Crow.Group" Data="GetChildren"
+ Path="#CrowIDE.ui.bindingExpITemp.crow"/>
+ </TreeView>
+</Window>
MouseLeave="{Background=Transparent}"/>
</HorizontalStack>
</ItemTemplate>
- <ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetFileSystemInfos">
+ <ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetFileSystemInfos">
<Expandable Caption="{Name}" >
<Template>
<VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
<?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
+<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}"
+ Background="{./Background}"
+ Height="{./HeightPolicy}" Width="{./WidthPolicy}"
MouseEnter="./onBorderMouseEnter"
MouseLeave="./onBorderMouseLeave">
<VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}" Spacing="0">
#region Layouting
- #if DEBUG_LAYOUTING
- public List<LayoutingQueueItem> CurrentDrawLQIs = null;
- public List<List<LayoutingQueueItem>> LQIs = new List<List<LayoutingQueueItem>>();
- #endif
/// <summary> return size of content + margins </summary>
protected virtual int measureRawSize (LayoutingType lt) {
return lt == LayoutingType.Width ?
public virtual void OnLayoutChanges(LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- LayoutingQueueItem.currentLQI.Slot = LastSlots;
- LayoutingQueueItem.currentLQI.NewSlot = Slot;
+ CurrentInterface.currentLQI.Slot = LastSlots;
+ CurrentInterface.currentLQI.NewSlot = Slot;
#endif
switch (layoutType) {
return;
LastPaintedSlot = Slot;
- #if DEBUG_LAYOUTING
- if (CurrentDrawLQIs != null){
- LQIs.Add (CurrentDrawLQIs);
- CurrentDrawLQIs = null;
- }
- #endif
if (cacheEnabled) {
if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
public override void OnLayoutChanges (LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- LayoutingQueueItem.currentLQI.Slot = LastSlots;
- LayoutingQueueItem.currentLQI.Slot = Slot;
+ CurrentInterface.currentLQI.Slot = LastSlots;
+ CurrentInterface.currentLQI.Slot = Slot;
#endif
switch (layoutType) {
}
#endregion
-
+ #if DEBUG_LAYOUTING
+ public List<LQIList> LQIsTries = new List<LQIList>();
+ public LQIList curLQIsTries = new LQIList();
+ public List<LQIList> LQIs = new List<LQIList>();
+ public LQIList curLQIs = new LQIList();
+// public static LayoutingQueueItem[] MultipleRunsLQIs {
+// get { return curUpdateLQIs.Where(l=>l.LayoutingTries>2 || l.DiscardCount > 0).ToArray(); }
+// }
+ public LayoutingQueueItem currentLQI = null;
+ #endif
public void Update(){
if (mouseRepeatCount > 0) {
int mc = mouseRepeatCount;
processLayouting ();
+ #if DEBUG_LAYOUTING
+ if (curLQIsTries.Count > 0){
+ LQIsTries.Add(curLQIsTries);
+ curLQIsTries = new LQIList();
+ LQIs.Add(curLQIs);
+ curLQIs = new LQIList();
+ }
+ #endif
+
clippingRegistration ();
processDrawing ();
LayoutingQueueItem lqi = null;
while (LayoutingQueue.Count > 0) {
lqi = LayoutingQueue.Dequeue ();
+ #if DEBUG_LAYOUTING
+ currentLQI = lqi;
+ curLQIsTries.Add(currentLQI);
+ #endif
lqi.ProcessLayouting ();
+ #if DEBUG_LAYOUTING
+ currentLQI = null;
+ #endif
}
LayoutingQueue = DiscardQueue;
}
g.ClearBinding ();
GraphicTree.RemoveAt (0);
}
+ #if DEBUG_LAYOUTING
+ LQIsTries = new List<LQIList>();
+ curLQIsTries = new LQIList();
+ LQIs = new List<LQIList>();
+ curLQIs = new LQIList();
+ #endif
}
public GraphicObject FindByName (string nameToFind)
{
#endregion
public void CreateExpandDelegate (TemplatedControl host){
- Type dataType = Type.GetType(strDataType);
Type hostType = typeof(TemplatedControl);//not sure is the best place to put the dyn method
Type evtType = typeof(EventHandler);
Type listBoxType = typeof(ListBox);
il.Emit (OpCodes.Ldarg_1);//get the dataSource of the sender
il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetProperty("DataSource").GetGetMethod ());
- emitGetSubData(il, dataType);
+ if (fetchMethodName != "self"){//special keyword self allows the use of recurent list<<<
+ Type dataType = Type.GetType(strDataType);
+ emitGetSubData(il, dataType);
+ }
//set 'return' from the fetch method as 'data' of the list
il.Emit (OpCodes.Callvirt, piListData.GetSetMethod ());
if (miGetDatas == null) {//in last resort, search among properties
PropertyInfo piDatas = dataType.GetProperty (fetchMethodName);
- if (piDatas == null)
- throw new Exception ("Fetch data member not found in ItemTemplate: " + fetchMethodName);
+ if (piDatas == null) {
+ FieldInfo fiDatas = dataType.GetField (fetchMethodName);
+ if (fiDatas == null)//and among fields
+ throw new Exception ("Fetch data member not found in ItemTemplate: " + fetchMethodName);
+ il.Emit (OpCodes.Ldfld, fiDatas);
+ return;
+ }
miGetDatas = piDatas.GetGetMethod ();
if (miGetDatas == null)
throw new Exception ("Read only property for fetching data in ItemTemplate: " + fetchMethodName);
public int LayoutingTries, DiscardCount;
#if DEBUG_LAYOUTING
- public static List<LayoutingQueueItem> processedLQIs = new List<LayoutingQueueItem>();
- public static LayoutingQueueItem[] MultipleRunsLQIs {
- get { return processedLQIs.Where(l=>l.LayoutingTries>2 || l.DiscardCount > 0).ToArray(); }
- }
- public static LayoutingQueueItem currentLQI = null;
public Stopwatch LQITime = new Stopwatch();
- public List<LayoutingQueueItem> triggeredLQIs = new List<LayoutingQueueItem>();
+ public LQIList triggeredLQIs = new LQIList();
public LayoutingQueueItem wasTriggeredBy = null;
public GraphicObject graphicObject {
get { return Layoutable as GraphicObject; }
}
+ public string Name {
+ get { return graphicObject.Name; }
+ }
+ public string FullName {
+ get { return graphicObject.ToString(); }
+ }
+ public Measure Width {
+ get { return graphicObject.Width; }
+ }
+ public Measure Height {
+ get { return graphicObject.Height; }
+ }
+ public bool HasTriggeredLQIs { get { return triggeredLQIs.Count > 0; }}
public Rectangle Slot, NewSlot;
#endif
Layoutable = _graphicObject;
Layoutable.RegisteredLayoutings |= LayoutType;
#if DEBUG_LAYOUTING
- if (graphicObject.CurrentDrawLQIs == null)
- graphicObject.CurrentDrawLQIs = new List<LayoutingQueueItem>();
- graphicObject.CurrentDrawLQIs.Add(this);
- if (currentLQI != null){
- wasTriggeredBy = currentLQI;
- currentLQI.triggeredLQIs.Add(this);
+ GraphicObject g = graphicObject;
+ g.CurrentInterface.curLQIs.Add(this);
+ if (g.CurrentInterface.currentLQI != null){
+ wasTriggeredBy = g.CurrentInterface.currentLQI;
+ g.CurrentInterface.currentLQI.triggeredLQIs.Add(this);
}
#endif
}
return;
}
#if DEBUG_LAYOUTING
- currentLQI = this;
- processedLQIs.Add(this);
LQITime.Start();
#endif
+ LayoutingTries++;
if (!Layoutable.UpdateLayout (LayoutType)) {
if (LayoutingTries < Interface.MaxLayoutingTries) {
- LayoutingTries++;
Layoutable.RegisteredLayoutings |= LayoutType;
(Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this);
} else if (DiscardCount < Interface.MaxDiscardCount) {
#endif
}
#if DEBUG_LAYOUTING
- currentLQI = null;
LQITime.Stop();
#endif
}
#endif
}
}
+ #if DEBUG_LAYOUTING
+ public class LQIList : List<LayoutingQueueItem>{
+ public List<LayoutingQueueItem> GetRootLQIs(){
+ return this.Where (lqi => lqi.wasTriggeredBy == null).ToList ();
+ }
+ }
+ #endif
}