<Compile Include="src\IML\EventBinding.cs" />
<Compile Include="src\PerformanceMeasure.cs" />
<Compile Include="src\IML\BindingMember.cs" />
+ <Compile Include="src\CrowThread.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<EmbeddedResource Include="Default.style" />
<EmbeddedResource Include="ui\GTreeExplorer.crow" />
<EmbeddedResource Include="ui\GTreeExpITemp.crow" />
+ <EmbeddedResource Include="ui\MemberView.crow" />
</ItemGroup>
<ItemGroup>
<None Include="ui\test.crow">
{
}
ImlVisualEditor imlVE;
- GraphicObject bindingExp, lqisExp;
protected override void OnLoad (EventArgs e)
{
if (e.Key == OpenTK.Input.Key.Escape) {
Quit (null, null);
return;
+ } else if (e.Key == OpenTK.Input.Key.F4) {
+ loadWindow ("#CrowIDE.ui.MemberView.crow");
} else if (e.Key == OpenTK.Input.Key.F5) {
- if (bindingExp != null) {
- CrowInterface.DeleteWidget (bindingExp);
- }
- bindingExp = CrowInterface.LoadInterface ("#CrowIDE.ui.GTreeExplorer.crow");
- bindingExp.DataSource = imlVE;
- return;
+ loadWindow ("#CrowIDE.ui.GTreeExplorer.crow");
} 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;
+ loadWindow ("#CrowIDE.ui.LQIsExplorer.crow");
}
}
+ void loadWindow(string path){
+ try {
+ GraphicObject g = CrowInterface.FindByName (path);
+ if (g != null)
+ return;
+ g = CrowInterface.LoadInterface (path);
+ g.Name = path;
+ g.DataSource = imlVE;
+ } catch (Exception ex) {
+ System.Diagnostics.Debug.WriteLine (ex.ToString ());
+ }
+ }
+ void closeWindow (string path){
+ GraphicObject g = CrowInterface.FindByName (path);
+ if (g != null)
+ CrowInterface.DeleteWidget (g);
+ }
protected void onCommandSave(object sender, MouseButtonEventArgs e){
System.Diagnostics.Debug.WriteLine("save");
}
Interface imlVE;
Instantiator itor;
string imlSource;
+ GraphicObject selectedItem;
bool drawGrid;
int gridSpacing;
+ [XmlAttributeAttribute][DefaultValue(true)]
+ public bool DrawGrid {
+ get { return drawGrid; }
+ set {
+ if (drawGrid == value)
+ return;
+ drawGrid = value;
+ NotifyValueChanged ("DrawGrid", drawGrid);
+ RegisterForRedraw ();
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue(10)]
+ public int GridSpacing {
+ get { return gridSpacing; }
+ set {
+ if (gridSpacing == value)
+ return;
+ gridSpacing = value;
+ NotifyValueChanged ("GridSpacing", gridSpacing);
+ RegisterForRedraw ();
+ }
+ }
+ [XmlAttributeAttribute]public GraphicObject SelectedItem {
+ get { return selectedItem; }
+ set {
+ if (selectedItem == value)
+ return;
+ selectedItem = value;
+ NotifyValueChanged ("SelectedItem", selectedItem);
+ RegisterForRedraw ();
+ }
+ }
[XmlIgnore]public List<LQIList> LQIs {
get { return imlVE.LQIs; }
}
using (StreamReader sr = new StreamReader (imlPath)) {
ImlSource = sr.ReadToEnd ();
}
+ NotifyValueChanged ("GraphicTree", null);
NotifyValueChanged ("GraphicTree", GraphicTree);
+ SelectedItem = null;
}
void reload_iTor(Instantiator new_iTot){
itor = new_iTot;
}
}
- [XmlAttributeAttribute()][DefaultValue(true)]
- public bool DrawGrid {
- get { return drawGrid; }
- set {
- if (drawGrid == value)
- return;
- drawGrid = value;
- NotifyValueChanged ("DrawGrid", drawGrid);
- RegisterForRedraw ();
- }
- }
- [XmlAttributeAttribute()][DefaultValue(10)]
- public int GridSpacing {
- get { return gridSpacing; }
- set {
- if (gridSpacing == value)
- return;
- gridSpacing = value;
- NotifyValueChanged ("GridSpacing", gridSpacing);
- RegisterForRedraw ();
- }
- }
- [XmlIgnore]public object SelectedItem {
- get { return imlVE.HoverWidget; }
- }
void interfaceThread()
{
while (true) {
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
base.onMouseDown (sender, e);
- NotifyValueChanged ("SelectedItem", imlVE.HoverWidget);
+ SelectedItem = imlVE.HoverWidget;
}
protected override void onDraw (Cairo.Context gr)
{
imlVE.IsDirty = false;
}
- if (imlVE.HoverWidget == null)
- return;
-
- Rectangle hr = imlVE.HoverWidget.ScreenCoordinates(imlVE.HoverWidget.getSlot ());
+ Rectangle hr;
+ if (imlVE.HoverWidget != null) {
+ hr = imlVE.HoverWidget.ScreenCoordinates (imlVE.HoverWidget.getSlot ());
+// gr.SetSourceColor (Color.LightGray);
+// gr.DrawCote (new Cairo.PointD (hr.X, hr.Center.Y), new Cairo.PointD (hr.Right, hr.Center.Y));
+// gr.DrawCote (new Cairo.PointD (hr.Center.X, hr.Y), new Cairo.PointD (hr.Center.X, hr.Bottom));
+ //hr.Inflate (2);
+ gr.SetSourceColor (Color.LightGray);
+ gr.SetDash (new double[]{ 3.0, 3.0 }, 0.0);
+ gr.Rectangle (hr, 1.0);
+ }
- gr.SetSourceColor (Color.LightGray);
- gr.DrawCote (new Cairo.PointD (hr.X, hr.Center.Y), new Cairo.PointD (hr.Right, hr.Center.Y));
- gr.DrawCote (new Cairo.PointD (hr.Center.X, hr.Y), new Cairo.PointD (hr.Center.X, hr.Bottom));
- hr.Inflate (2);
- gr.SetSourceColor (Color.LightGray);
- gr.SetDash (new double[]{ 3.0, 3.0 },0.0);
+ if (SelectedItem == null)
+ return;
+ hr = SelectedItem.ScreenCoordinates(SelectedItem.getSlot ());
+ hr.Inflate (1);
+ gr.SetSourceColor (Color.Yellow);
+ gr.SetDash (new double[]{ 5.0, 3.0 },0.0);
gr.Rectangle (hr, 1.0);
-
}
#endregion
MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
e.Mouse = imlVE.Mouse;
- if (imlVE.activeWidget != null) {
+ if (imlVE.ActiveWidget != null) {
//TODO, ensure object is still in the graphic tree
//send move evt even if mouse move outside bounds
- imlVE.activeWidget.onMouseMove (this, e);
+ imlVE.ActiveWidget.onMouseMove (this, e);
return true;
}
}
imlVE.HoverWidget = null;
return false;
+
+ }
+
+ void GTView_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
+ {
+ SelectedItem = e.NewValue as GraphicObject;
}
}
}
{
public class PropertyContainer : IValueChange
{
- #region IValueChange implementation
+ #region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
public virtual void NotifyValueChanged(string MemberName, object _value)
{
<Expandable Caption="{Name}" >
<Template>
<VerticalStack>
- <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand"
- MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
- MouseLeave="{Background=Transparent}">
+ <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand" Background="{./Background}">
<Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
MouseEnter="{Background=LightGray}"
MouseLeave="{Background=Transparent}">
</Container>
<Image Margin="2" Width="14" Height="14"
Path="#Crow.Images.Icons.folder.svg"/>
- <Label Text="{./Caption}"/>
+ <Label Text="{./Caption}"
+ MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+ MouseLeave="{Background=Transparent}"/>
</HorizontalStack>
<Container Name="Content" Visible="false"/>
</VerticalStack>
<?xml version="1.0"?>
-<Window Title="Graphic Tree" Width="20%" Height="90%" Background="DimGray" AlwaysOnTop="true">
- <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}" Background="Jet">
- <ItemTemplate>
- <Label Text="{Name}" Width="Stretched"
- MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
- MouseLeave="{Background=Transparent}"/>
- </ItemTemplate>
- <ItemTemplate DataType="Crow.Group" Data="GetChildren"
- Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
- <ItemTemplate DataType="Crow.Container" Data="GetChildren"
- Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
- <ItemTemplate DataType="Crow.TemplatedContainer" Data="GetChildren"
- Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
- <ItemTemplate DataType="Crow.TemplatedGroup" Data="GetChildren"
- Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
- </TreeView>
+<Window Title="Graphic Tree" Width="20%" Height="70%" AlwaysOnTop="true">
+ <VerticalStack>
+ <Button Caption="Expand All" MouseClick="../treeView.onExpandAll_MouseClick"/>
+ <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}"
+ SelectedItemChanged="GTView_SelectedItemChanged">
+<!-- <Template>
+ <HorizontalStack>
+ <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
+ Background="{./Background}"
+ ScrollY="{../scrollbar1.Value}">
+ <VerticalStack
+ Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+ </Scroller>
+ <ScrollBar
+ Name="scrollbar1"
+ Value="{../scroller1.ScrollY}"
+ Maximum="{../scroller1.MaximumScroll}"
+ Width="12" Orientation="Vertical"/>
+ </HorizontalStack>
+ </Template>-->
+ <ItemTemplate>
+ <HorizontalStack Width="Stretched" Focusable="true">
+ <Label Text="{Name}"
+ MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+ MouseLeave="{Background=Transparent}"/>
+ </HorizontalStack>
+ </ItemTemplate>
+ <ItemTemplate DataType="Crow.Group" Data="GetChildren"
+ Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+ <ItemTemplate DataType="Crow.Container" Data="GetChildren"
+ Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+ <ItemTemplate DataType="Crow.TemplatedContainer" Data="GetChildren"
+ Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+ <ItemTemplate DataType="Crow.TemplatedGroup" Data="GetChildren"
+ Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+ </TreeView>
+ </VerticalStack>
</Window>
--- /dev/null
+<?xml version="1.0"?>
+<Window Title="Member View" Width="30%" Height="50%" Background="DimGray" AlwaysOnTop="true">
+ <MembersView Instance="{SelectedItem}" DataTest="Type">
+ <!-- <Template>
+ <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
+ ValueChanged="./_scroller_ValueChanged">
+ <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
+ Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+ </Scroller>
+ </Template>-->
+ <ItemTemplate>
+ <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
+ MouseEnter="{Background=UnitedNationsBlue}"
+ MouseLeave="{Background=Transparent}" >
+ <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+ <TextBox Margin="1" Text="{²Value}" Height="Fit" Width="50%"/>
+ </HorizontalStack>
+ </ItemTemplate>
+ <ItemTemplate DataType="System.Boolean">
+ <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
+ MouseEnter="{Background=UnitedNationsBlue}"
+ MouseLeave="{Background=Transparent}" >
+ <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+ <CheckBox Background="White" Margin="1" Caption="" IsChecked="{²Value}"/>
+ </HorizontalStack>
+ </ItemTemplate>
+ <ItemTemplate DataType="System.Enum">
+ <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
+ MouseEnter="{Background=UnitedNationsBlue}"
+ MouseLeave="{Background=Transparent}" >
+ <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+ <ComboBox Margin="1" Height="Fit" Width="50%" Data="{Choices}"
+ SelectedIndex="{²Value}">
+ <Template>
+ <Popper Name="popper" PopDirection="Bottom">
+ <Template>
+ <Border CornerRadius="0" Foreground="LightGray" Background="White">
+ <HorizontalStack Margin="0" Spacing="1">
+ <Label Width="Stretched" MinimumSize="80,10" Margin="1" Foreground="Black" Background="White"
+ Text="{../../../../SelectedItem}"/>
+ <Button Width="12" Height="12" Focusable="false"
+ Template="#Crow.Templates.ArrowButTemplate.crow">
+ <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
+ </Button>
+ </HorizontalStack>
+ </Border>
+ </Template>
+ <Border Background="White" BorderWidth="1" Margin="1" Foreground="Black"
+ MinimumSize="{../../MinimumPopupSize}" Fit="true">
+ <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
+ MaximumSize="0,200"
+ HorizontalAlignment="Left"
+ ValueChanged="../../../_scroller_ValueChanged">
+ <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
+ MouseClick="../../../onMouseClick" Focusable="True"
+ Height="Fit" Name="ItemsContainer" Margin="0"
+ HorizontalAlignment="Left"
+ VerticalAlignment="Top"/>
+ </Scroller>
+ </Border>
+ </Popper>
+ </Template>
+ <ItemTemplate>
+ <Container Fit="true" Margin="0" Focusable="true"
+ HorizontalAlignment="Left"
+ MouseEnter="{Background=SteelBlue}"
+ MouseLeave="{Background=Transparent}">
+ <Label Text="{}" Foreground="Black"/>
+ </Container>
+ </ItemTemplate>
+ </ComboBox>
+ </HorizontalStack>
+ </ItemTemplate>
+ <ItemTemplate DataType="Crow.Fill">
+ <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
+ MouseEnter="{Background=UnitedNationsBlue}"
+ MouseLeave="{Background=Transparent}" >
+ <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+ <Popper Background="White" Margin="1" Caption="{Value}">
+ <Template>
+ <HorizontalStack Spacing="3" Height="Fit" Background="{./Background}">
+ <Border Foreground="Black" Width="16" Height="10" CornerRadius="3"
+ Background="{Value}">
+ </Border>
+ <Label Text="{./Caption}" Foreground="Black"/>
+ </HorizontalStack>
+ </Template>
+ <ColorPicker SelectedColor="{²Value}" Background="Onyx" Margin="5" Fit="True" />
+ </Popper>
+ </HorizontalStack>
+ </ItemTemplate>
+
+ </MembersView>
+</Window>
\ No newline at end of file
<?xml version="1.0"?>
-<Border BorderWidth="1" Margin="1" MinimumSize="10,10" Height="{./HeightPolicy}" Width="{./WidthPolicy}" >
- <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"
- ValueChanged="./_scroller_ValueChanged">
- <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
- Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
- </Scroller>
+<Border BorderWidth="5" Margin="1" MinimumSize="10,10">
+ <VerticalStack>
+ <Label Text="{./Instance}"/>
+ <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
+ ValueChanged="./_scroller_ValueChanged">
+ <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
+ Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+ </Scroller>
+ </VerticalStack>
</Border>
\ No newline at end of file
</Border>
<HorizontalStack>
<DirectoryView Name="dv" CurrentDirectory="./" SelectedItemChanged="Tv_SelectedItemChanged"
- Width="20%" Height="100%" Margin="10"/>
+ Width="20%" Height="100%" Margin="0"/>
<Splitter/>
<VerticalStack Width="Stretched">
<ImlVisualEditor Height="60%" Margin="0" MinimumSize="10,10" Foreground="SkyBlue"
- ImlPath="{../../../dv.SelectedItem}"
+ ImlPath="{../../../dv.SelectedItem}" SelectedItem="{²SelectedItem}"
Name="crowContainer" Background="Onyx"/>
<Splitter/>
<HorizontalStack Margin="10" MinimumSize="10,1">
</HorizontalStack>
</VerticalStack>
<Splitter/>
- <MembersView Width="20%" Instance="{../crowContainer.SelectedItem}" DataTest="Type">
- <Template>
- <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
- ValueChanged="./_scroller_ValueChanged">
- <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
- Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
- </Scroller>
- </Template>
- <ItemTemplate>
- <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
- MouseEnter="{Background=UnitedNationsBlue}"
- MouseLeave="{Background=Transparent}" >
- <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
- <TextBox Margin="1" Text="{²Value}" Height="Fit" Width="50%"/>
- </HorizontalStack>
- </ItemTemplate>
- <ItemTemplate DataType="System.Boolean">
- <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
- MouseEnter="{Background=UnitedNationsBlue}"
- MouseLeave="{Background=Transparent}" >
- <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
- <CheckBox Background="White" Margin="1" Caption="" IsChecked="{²Value}"/>
- </HorizontalStack>
- </ItemTemplate>
- <ItemTemplate DataType="System.Enum">
- <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
- MouseEnter="{Background=UnitedNationsBlue}"
- MouseLeave="{Background=Transparent}" >
- <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
- <ComboBox Margin="1" Height="Fit" Width="50%" Data="{Choices}"
- SelectedIndex="{²Value}">
- <Template>
- <Popper Name="popper" PopDirection="Bottom">
- <Template>
- <Border CornerRadius="0" Foreground="LightGray" Background="White">
- <HorizontalStack Margin="0" Spacing="1">
- <Label Width="Stretched" MinimumSize="80,10" Margin="1" Foreground="Black" Background="White"
- Text="{../../../../SelectedItem}"/>
- <Button Width="12" Height="12" Focusable="false"
- Template="#Crow.Templates.ArrowButTemplate.crow">
- <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
- </Button>
- </HorizontalStack>
- </Border>
- </Template>
- <Border Background="White" BorderWidth="1" Margin="1" Foreground="Black"
- MinimumSize="{../../MinimumPopupSize}" Fit="true">
- <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
- MaximumSize="0,200"
- HorizontalAlignment="Left"
- ValueChanged="../../../_scroller_ValueChanged">
- <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
- MouseClick="../../../onMouseClick" Focusable="True"
- Height="Fit" Name="ItemsContainer" Margin="0"
- HorizontalAlignment="Left"
- VerticalAlignment="Top"/>
- </Scroller>
- </Border>
- </Popper>
- </Template>
- <ItemTemplate>
- <Container Fit="true" Margin="0" Focusable="true"
- HorizontalAlignment="Left"
- MouseEnter="{Background=SteelBlue}"
- MouseLeave="{Background=Transparent}">
- <Label Text="{}" Foreground="Black"/>
- </Container>
- </ItemTemplate>
- </ComboBox>
- </HorizontalStack>
- </ItemTemplate>
- <ItemTemplate DataType="Crow.Fill">
- <HorizontalStack Focusable="true" Height="Fit" Spacing="0"
- MouseEnter="{Background=UnitedNationsBlue}"
- MouseLeave="{Background=Transparent}" >
- <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
- <Popper Background="White" Margin="1" Caption="{Value}">
- <Template>
- <HorizontalStack Spacing="3" Height="Fit" Background="{./Background}">
- <Border Foreground="Black" Width="16" Height="10" CornerRadius="3"
- Background="{Value}">
- </Border>
- <Label Text="{./Caption}" Foreground="Black"/>
- </HorizontalStack>
- </Template>
- <ColorPicker SelectedColor="{²Value}" Background="Onyx" Margin="5" Fit="True" />
- </Popper>
- </HorizontalStack>
- </ItemTemplate>
-
- </MembersView>
</HorizontalStack>
</VerticalStack>
</Window>
--- /dev/null
+//
+// CrowThread.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2017 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.Threading;
+
+namespace Crow
+{
+ /// <summary>
+ /// Thread monitored by current interface with Finished event when state==Stopped
+ /// </summary>
+ public class CrowThread {
+ Thread thread;
+ public event EventHandler Finished;
+ public GraphicObject Host;
+ public CrowThread (GraphicObject host, ThreadStart start){
+ thread = new Thread (start);
+ thread.IsBackground = true;
+ Host = host;
+ lock (Host.CurrentInterface.CrowThreads)
+ Host.CurrentInterface.CrowThreads.Add (this);
+ }
+ public void CheckState(){
+ if (thread.ThreadState != ThreadState.Stopped)
+ return;
+ Finished.Raise (Host, null);
+ lock (Host.CurrentInterface.CrowThreads)
+ Host.CurrentInterface.CrowThreads.Remove (this);
+ }
+ public void Start() { thread.Start();}
+ public void Cancel(){
+ if (thread.IsAlive){
+ //cancelLoading = true;
+ thread.Join ();
+ //cancelLoading = false;
+ }
+ Host.CurrentInterface.CrowThreads.Remove (this);
+ }
+ }
+}
+
return;
_spacing = value;
NotifyValueChanged ("Spacing", Spacing);
+ RegisterForLayouting (LayoutingType.Sizing|LayoutingType.ArrangeChildren);
}
}
[XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
isVisible = value;
//ensure main win doesn't keep hidden childrens ref
- if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
- CurrentInterface.HoverWidget = null;
+ if (CurrentInterface.HoverWidget != null) {
+ if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
+ CurrentInterface.HoverWidget = null;
+ }
if (isVisible)
RegisterForLayouting (LayoutingType.Sizing);
currentInterface.clickTimer.Restart();
CurrentInterface.eligibleForDoubleClick = null;
- if (CurrentInterface.activeWidget == null)
- CurrentInterface.activeWidget = this;
+ if (CurrentInterface.ActiveWidget == null)
+ CurrentInterface.ActiveWidget = this;
if (this.Focusable && !Interface.FocusOnHover) {
BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
if (be.Focused == null) {
if (Content != null) {
Content.Visible = true;
if (Content.Parent == null)
- CurrentInterface.AddWidget (Content);
- CurrentInterface.PutOnTop (Content);
+ CurrentInterface.AddWidget (Content, true);
+ CurrentInterface.PutOnTop (Content, true);
_content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
}
Pop.Raise (this, e);
}
public virtual void onUnpop(object sender, EventArgs e)
{
- if (Content != null)
+ if (Content != null) {
Content.Visible = false;
+ }
Unpop.Raise (this, e);
}
}
#region events
public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
+ public event EventHandler Loaded;
#endregion
IList data;
Color selBackground, selForeground;
int itemPerPage = 50;
- Thread loadingThread = null;
+ CrowThread loadingThread = null;
volatile bool cancelLoading = false;
#region Templating
if (data == null)
return;
- loadingThread = new Thread (loading);
- loadingThread.IsBackground = true;
+ loadingThread = new CrowThread (this, loading);
+ loadingThread.Finished += (object sender, EventArgs e) => (sender as TemplatedGroup).Loaded.Raise (sender, e);
loadingThread.Start ();
//loadPage(1);
}
}
void cancelLoadingThread(){
- if (loadingThread == null)
- return;
- if (!loadingThread.IsAlive)
- return;
- cancelLoading = true;
- loadingThread.Join ();
- cancelLoading = false;
+ if (loadingThread != null)
+ loadingThread.Cancel ();
}
void loadPage(int pageNum)
{
}
}
protected void loadItem(int i, Group page){
+ if (data [i] == null)//TODO:surely a threading sync problem
+ return;
GraphicObject g = null;
ItemTemplate iTemp = null;
Type dataType = data [i].GetType ();
NotifyValueChanged ("IsRoot", isRoot);
}
}
-
[XmlIgnore]public override object SelectedItem {
get {
return selectedItemContainer == null ?
NotifyValueChanged ("SelectedItem", SelectedItem);
raiseSelectedItemChanged ();
}
+
+ void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e)
+ {
+ ExpandAll ();
+ }
+
+ public void ExpandAll(){
+ foreach (Group grp in items.Children) {
+ foreach (GraphicObject go in grp.Children) {
+ Expandable exp = go as Expandable;
+ if (exp == null)
+ continue;
+ TreeView subTV = exp.FindByName ("List") as TreeView;
+ if (subTV == null)
+ continue;
+ EventHandler handler = null;
+ handler = delegate(object sender, EventArgs e) {
+ TreeView tv = sender as TreeView;
+ tv.Loaded -= handler;
+ tv.ExpandAll ();
+ };
+ subTV.Loaded += handler;
+ exp.IsExpanded = true;
+ }
+ }
+ }
}
}
public static Dictionary<String, Instantiator> Instantiators = new Dictionary<string, Instantiator>();
public bool DesignMode = false;
public int TopWindows = 0;//window always on top count
+ public List<CrowThread> CrowThreads = new List<CrowThread>();//used to monitor thread finished
#endregion
#region Private Fields
/// <summary>Widget is focused and button is down or another perif action is occuring
/// , it can not lose focus while Active</summary>
- public GraphicObject activeWidget
+ public GraphicObject ActiveWidget
{
get { return _activeWidget; }
set
_focusedWidget.onKeyDown (this, lastKeyDownEvt);
}
}
+ CrowThread[] tmpThreads;
+ lock (CrowThreads) {
+ tmpThreads = new CrowThread[CrowThreads.Count];
+ Array.Copy (CrowThreads.ToArray (), tmpThreads, CrowThreads.Count);
+ }
+ for (int i = 0; i < tmpThreads.Length; i++)
+ tmpThreads [i].CheckState ();
if (!Monitor.TryEnter (UpdateMutex))
return;
#region GraphicTree handling
/// <summary>Add widget to the Graphic tree of this interface and register it for layouting</summary>
- public void AddWidget(GraphicObject g)
+ public void AddWidget(GraphicObject g, bool topMost = false)
{
g.Parent = this;
int ptr = TopWindows;
if (g is Window) {
if ((g as Window).AlwaysOnTop)
ptr = 0;
- }
+ } else if (topMost)
+ ptr = 0;
GraphicTree.Insert (ptr, g);
g.RegisteredLayoutings = LayoutingType.None;
g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
GraphicTree.Remove (g);
}
/// <summary> Put widget on top of other root widgets</summary>
- public void PutOnTop(GraphicObject g)
+ public void PutOnTop(GraphicObject g, bool topMost = false)
{
- if (GraphicTree.IndexOf(g) > TopWindows)
+ int ptr = TopWindows;
+ if (g is Window) {
+ if ((g as Window).AlwaysOnTop)
+ ptr = 0;
+ } else if (topMost)
+ ptr = 0;
+ if (GraphicTree.IndexOf(g) > ptr)
{
GraphicTree.Remove(g);
- GraphicTree.Insert(TopWindows, g);
+ GraphicTree.Insert(ptr, g);
EnqueueForRepaint (g);
}
}
MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
e.Mouse = Mouse;
- if (activeWidget != null) {
+ if (ActiveWidget != null) {
//TODO, ensure object is still in the graphic tree
//send move evt even if mouse move outside bounds
- activeWidget.onMouseMove (this, e);
+ ActiveWidget.onMouseMove (this, e);
return true;
}
}
_activeWidget.onMouseUp (_activeWidget, e);
- activeWidget = null;
+ ActiveWidget = null;
return true;
}
public bool ProcessMouseButtonDown(int button)