</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<OutputPath>bin\Debug</OutputPath>\r
- <DefineConstants>TRACE;DEBUG;__linux__;DEBUG_LOAD_TIME</DefineConstants>\r
+ <DefineConstants>TRACE;DEBUG;__linux__;DEBUG_LOAD_TIME=1</DefineConstants>\r
</PropertyGroup>\r
<!-- <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">\r
<DefineConstants>__linux__</DefineConstants>\r
<File pattern="*.goml" />
</MimeType>
</Extension>
+<!-- <Extension path = "/MonoDevelop/DesignerSupport/PropertyProviders" extension-nodes="Class">
+ <Class class = "MonoDevelop.GOLib.GOLibItemPropertyProvider"/>
+ </Extension>-->
</ExtensionModel>
\ No newline at end of file
<OutputPath>build</OutputPath>
<CustomCommands>
<CustomCommands>
- <Command type="Execute"
- command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe --no-redirect"
- workingdir="/usr/local/lib/monodevelop/bin"
- >
+ <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe --no-redirect" workingdir="/usr/local/lib/monodevelop/bin">
<EnvironmentVariables>
<Variable name="MONODEVELOP_DEV_ADDINS" value="${TargetDir}" />
<Variable name="MONODEVELOP_CONSOLE_LOG_LEVEL" value="UpToDebug" />
<Variable name="MONODEVELOP_LOGGING_PAD_LEVEL" value="UpToDebug" />
- <Variable name="MONODEVELOP_CONSOLE_LOG_USE_COLOUR" value="True"/>
+ <Variable name="MONODEVELOP_CONSOLE_LOG_USE_COLOUR" value="True" />
</EnvironmentVariables>
</Command>
</CustomCommands>
<HintPath>\usr\local\lib\monodevelop\bin\MonoDevelop.Ide.dll</HintPath>
<Private>False</Private>
</Reference>
+ <Reference Include="MonoDevelop.Core">
+ <HintPath>\usr\local\lib\monodevelop\bin\MonoDevelop.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="MonoDevelop.DesignerSupport">
+ <HintPath>\usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
<Reference Include="Mono.Cairo" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>gtk-sharp-2.0</Package>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
- <Reference Include="MonoDevelop.DesignerSupport">
- <HintPath>\usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
- <Private>False</Private>
- </Reference>
<Reference Include="OpenTK">
<HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
</Reference>
- <Reference Include="MonoDevelop.Core">
- <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\bin\MonoDevelop.Core.dll</HintPath>
+ <Reference Include="MonoDevelop.SourceEditor2">
+ <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor2.dll</HintPath>
+ </Reference>
+ <Reference Include="Mono.TextEditor">
+ <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\bin\Mono.TextEditor.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
}
}
public bool CanUseAsDefault
- { get { return false; }}
+ { get { return true; }}
public IViewContent CreateContent (FilePath fileName, string mimeType, Project ownerProject)
{
using System.Diagnostics;
using OpenTK.Input;
using MonoDevelop.DesignerSupport;
+using System.IO;
+using MonoDevelop.Components.Commands;
namespace MonoDevelop.GOLib
{
- public class GOLibGtkHost : Gtk.DrawingArea, ILayoutable, IGOLibHost, IPropertyPadProvider
+ public class GOLibGtkHost : Gtk.DrawingArea, ILayoutable, IGOLibHost, IPropertyPadProvider,ICommandDelegator
{
+ #region ICommandDelegator implementation
+
+ public object GetDelegatedCommandTarget ()
+ {
+ return hoverWidget;
+ }
+
+ #endregion
+
#region IPropertyPadProvider implementation
public object GetActiveComponent ()
{
- return hoverWidget;
+ return activeWidget;
}
public object GetProvider ()
{
- return hoverWidget;
+ return activeWidget;
}
public void OnEndEditing (object obj)
{
}
public void OnChanged (object obj)
{
-
+ (obj as GraphicObject).registerForGraphicUpdate ();
+ QueueDraw ();
}
#endregion
Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
_redrawClip.AddRectangle (this.ClientRectangle);
- LoggingService.LogInfo ("expose event");
+ //LoggingService.LogInfo ("expose event");
update (cr);
((int)args.Event.X, (int)args.Event.Y,
gtkButtonIdToOpenTkButton(args.Event.Button), true);
Mouse_ButtonDown (o, e);
- DesignerSupport.DesignerSupport.Service.SetPadContent (this);
+
+ DesignerSupport.DesignerSupport.Service.SetPadContent (this, this);
}
void GOLibGtkHost_ButtonReleaseEvent (object o, Gtk.ButtonReleaseEventArgs args)
{
public void Load(string path)
{
- goWidget = Interface.Load (path);
+ load(Interface.Load (path));
+ }
+
+ public void Load(Stream stream)
+ {
+ GraphicObject tmp = null;
+ try {
+ tmp = Interface.Load (stream, Interface.GetTopContainerOfGOMLStream (stream));
+ } catch (Exception ex) {
+ return;
+ }
+ load (tmp);
+ QueueDraw ();
+ }
+
+ void load(GraphicObject go)
+ {
+ if (goWidget != null)
+ DeleteWidget (goWidget);
+ goWidget = go;
this.AddWidget (goWidget);
}
+ public void AddWidget(GraphicObject g)
+ {
+ g.Parent = this;
+ GraphicObjects.Insert (0, g);
+ g.RegisterForLayouting ((int)LayoutingType.Sizing);
+ }
+ public void DeleteWidget(GraphicObject g)
+ {
+ g.Visible = false;//trick to ensure clip is added to refresh zone
+ g.ClearBinding();
+ GraphicObjects.Remove (g);
+ }
public List<GraphicObject> GraphicObjects = new List<GraphicObject>();
public Color Background = Color.Transparent;
#endregion
- public void AddWidget(GraphicObject g)
- {
- g.Parent = this;
- GraphicObjects.Insert (0, g);
-
- g.RegisterForLayouting ((int)LayoutingType.Sizing);
- }
- public void DeleteWidget(GraphicObject g)
- {
- g.Visible = false;//trick to ensure clip is added to refresh zone
- g.ClearBinding();
- GraphicObjects.Remove (g);
- }
-
// public void LoadInterface<T>(string path, out T result)
// {
// GraphicObject.Load<T> (path, out result, this);
#region Mouse Handling
void Mouse_Move(object sender, MouseMoveEventArgs e)
{
- if (_activeWidget != null) {
- //send move evt even if mouse move outside bounds
- _activeWidget.onMouseMove (_activeWidget, e);
- return;
- }
+// if (_activeWidget != null) {
+// //send move evt even if mouse move outside bounds
+// _activeWidget.onMouseMove (_activeWidget, e);
+// return;
+// }
if (_hoverWidget != null) {
//check topmost graphicobject first
}
void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
{
- if (_activeWidget == null)
- return;
+// if (_activeWidget == null)
+// return;
- _activeWidget.onMouseButtonUp (this, e);
- _activeWidget = null;
+ //_activeWidget.onMouseButtonUp (this, e);
+ //_activeWidget = null;
MouseButtonUp.Raise (this, e);
}
void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
MouseButtonDown.Raise (this, e);
return;
}
-
- GraphicObject g = _hoverWidget;
- while (!g.Focusable) {
- g = g.Parent as GraphicObject;
- if (g == null) {
- return;
- }
- }
-
- _activeWidget = g;
- _activeWidget.onMouseButtonDown (this, e);
+
+ _activeWidget = _hoverWidget;
+ //_activeWidget.onMouseButtonDown (this, e);
}
void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
using System.Linq;
+using MonoDevelop.DesignerSupport;
namespace MonoDevelop.GOLib
{
}
}
- class GOLibCommandHandler: NodeCommandHandler
+ class GOLibCommandHandler: NodeCommandHandler //, IPropertyPadProvider
{
[CommandHandler (Commands.ShowGOLibViewer)]
protected void OnShowGOLibViewer ()
IdeApp.Workbench.OpenDocument (view, true);
//IdeApp.Workbench.Documents.Where (d => d.FileName == file.FilePath);
-
}
- public override void ActivateItem ()
- {
+
+// public override void ActivateItem ()
+// {
// ProjectFile o = this.CurrentNode.DataItem as ProjectFile;
+//
// Ide.Gui.Document[] doc = IdeApp.Workbench.Documents.Where (d => d.FileName == o.FilePath).ToArray();
-// if (doc [0].ActiveView != null)
-// return;
- //doc [0].ActiveView.Select();
- OnShowGOLibViewer ();
- }
+// var tmp = MonoDevelop.Ide.Gui.DisplayBindingService.GetFileViewers (o.FilePath, o.Project).ToList();
+//
+// OnShowGOLibViewer ();
+// }
+// #region IPropertyPadProvider implementation
+// public object GetActiveComponent ()
+// {
+// if (CurrentNodes.Length == 1)
+// return CurrentNode.DataItem;
+// else
+// return null;
+// }
+// public object GetProvider ()
+// {
+// return null;
+// }
+// public void OnEndEditing (object obj)
+// {
+// throw new NotImplementedException ();
+// }
+// public void OnChanged (object obj)
+// {
+//
+// }
+// #endregion
}
+// class GOLibItemPropertyProvider : IPropertyProvider
+// {
+// #region IPropertyProvider implementation
+// public object CreateProvider (object obj)
+// {
+// var projectFile = obj as ProjectFile;
+// return projectFile;
+// }
+//
+// public bool SupportsObject (object obj)
+// {
+// return obj is ProjectFile;
+// }
+// #endregion
+// }
}
using MonoDevelop.Ide;
using go;
using MonoDevelop.DesignerSupport;
+using MonoDevelop.SourceEditor;
namespace MonoDevelop.GOLib
{
- class GOLibView : AbstractViewContent
+ class CustomVPaned : Gtk.VPaned, IPropertyPadProvider
+ {
+ #region IPropertyPadProvider implementation
+ public object GetActiveComponent ()
+ {
+ return this.Child1 == null ? this as object: (this.Child1 as GOLibGtkHost).activeWidget as object;
+ }
+ public object GetProvider ()
+ {
+ return null;
+ //throw new NotImplementedException ();
+ }
+ public void OnEndEditing (object obj)
+ {
+ //throw new NotImplementedException ();
+ }
+ public void OnChanged (object obj)
+ {
+ //throw new NotImplementedException ();
+ }
+ #endregion
+
+ }
+ class GOLibView : SourceEditorView
{
GOLibGtkHost gtkGoWidgetHost;
+ CustomVPaned gtkGOMLWidget;
double zoom = 1.0;
public override Gtk.Widget Control {
get {
- return gtkGoWidgetHost;
+ return gtkGOMLWidget;
}
}
- public GOLibView ()
+ public GOLibView () : base()
{
gtkGoWidgetHost = new GOLibGtkHost ();
+ gtkGOMLWidget = new CustomVPaned ();
+ gtkGOMLWidget.CanFocus = true;
+ gtkGOMLWidget.Name = "vpaned1";
+ gtkGOMLWidget.Add (gtkGoWidgetHost);
+ gtkGOMLWidget.Add (base.Control);
+ gtkGOMLWidget.SizeAllocated += GtkGOMLWidget_SizeAllocated;
+ this.Document.DocumentUpdated += Document_DocumentUpdated;
+ //this.DirtyChanged += GOLibView_DirtyChanged;
}
- public override void Load (string fileName)
- {
- gtkGoWidgetHost.Load (fileName);
- ContentName = fileName;
- this.IsDirty = false;
+ void Document_DocumentUpdated (object sender, EventArgs e)
+ {
+ reloadGOML ();
+ }
+
+ void GOLibView_DirtyChanged (object sender, EventArgs e)
+ {
- gtkGoWidgetHost.Show ();
}
- public override bool CanReuseView (string fileName)
+
+ void reloadGOML()
{
- return base.CanReuseView (fileName);
+ using (MemoryStream stream = new MemoryStream ()) {
+ using (StreamWriter writer = new StreamWriter (stream)) {
+ writer.Write (this.Document.Text);
+ writer.Flush ();
+
+ stream.Position = 0;
+ gtkGoWidgetHost.Load (stream);
+ }
+ }
}
- public override void RedrawContent ()
+
+ void GtkGOMLWidget_SizeAllocated (object o, Gtk.SizeAllocatedArgs args)
{
- base.RedrawContent ();
+ gtkGoWidgetHost.SetSizeRequest (-1, args.Allocation.Height / 2);
+ }
+
+ public override void Load (string fileName)
+ {
+ gtkGoWidgetHost.Load (fileName);
+ //ContentName = fileName;
+ //this.IsDirty = false;
+ gtkGOMLWidget.ShowAll ();
+ gtkGOMLWidget.Show ();
+
+ base.Load (fileName);
}
+// public override bool CanReuseView (string fileName)
+// {
+// return base.CanReuseView (fileName);
+// }
+// public override void RedrawContent ()
+// {
+// base.RedrawContent ();
+// }
}
}
new ClsItem("string 1"),\r
new ClsItem("string 2")\r
});\r
+ int i = 0;\r
+ Color[] colorsArray;\r
+ volatile List<GraphicObject> loadedCols = new List<GraphicObject>();\r
+ volatile bool allColsLoaded = false;\r
+ private static readonly object mutex = new object();\r
\r
protected override void OnLoad (EventArgs e)\r
{\r
// };\r
\r
\r
- int i = 0;\r
- foreach (Color col in Color.ColorDic) {\r
- HorizontalStack s = colors.addChild (new HorizontalStack () { Fit = true});\r
+ colorsArray = Color.ColorDic.ToArray ();\r
+\r
+ Thread t = new Thread (loadingThread);\r
+ t.Start ();\r
+\r
+// ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));\r
+ }\r
+\r
+ void loadingThread()\r
+ { \r
+ foreach (Color col in colorsArray) {\r
+ HorizontalStack s = new HorizontalStack () { Fit = true};\r
s.HorizontalAlignment = HorizontalAlignment.Left;\r
Border b = new Border () {\r
Bounds = new Size (32, 20),\r
}\r
);\r
i++;\r
- if (i > 150)\r
- break;\r
- }\r
-// ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));\r
+\r
+ while(true){\r
+ lock (mutex) {\r
+ loadedCols.Add (s);\r
+ break;\r
+ }\r
+ }\r
+\r
+ Thread.Sleep (10);\r
+ \r
+ } \r
+ allColsLoaded = true;\r
}\r
void pFps_mousemove(object sender, MouseMoveEventArgs e)\r
{\r
c.Top += e.YDelta;\r
c.registerForGraphicUpdate ();\r
}\r
-\r
+ void onButClick(object send, MouseButtonEventArgs e)\r
+ {\r
+ Color col = Color.ColorDic.ToArray () [i];\r
+ HorizontalStack s = colors.addChild (new HorizontalStack () { Fit = true});\r
+ s.HorizontalAlignment = HorizontalAlignment.Left;\r
+ Border b = new Border () {\r
+ Bounds = new Size (32, 20),\r
+ CornerRadius = 5,\r
+ Background = col,\r
+ BorderWidth = 2,\r
+ BorderColor = Color.Transparent,\r
+ Focusable = true\r
+ };\r
+ b.MouseEnter += delegate(object sender, MouseMoveEventArgs ee) {\r
+ (sender as Border).BorderColor = Color.White;\r
+ };\r
+ b.MouseLeave += delegate(object sender, MouseMoveEventArgs ee) {\r
+ (sender as Border).BorderColor = Color.Transparent;\r
+ };\r
+ s.addChild (b);\r
+\r
+ s.addChild (\r
+ new Label (col.ToString ()){\r
+ Bounds=new Rectangle(0,0,-1,-1),\r
+ }\r
+ );\r
+ i++;\r
+ }\r
private int frameCpt = 0;\r
protected override void OnUpdateFrame (FrameEventArgs e)\r
{\r
\r
fps = (int)RenderFrequency;\r
\r
+ lock (mutex) {\r
+ if (loadedCols.Count > 50 || allColsLoaded) {\r
+ while (loadedCols.Count > 0) {\r
+ colors.addChild (loadedCols[0]);\r
+ loadedCols.RemoveAt (0);\r
+ }\r
+ }\r
+ }\r
\r
if (frameCpt > 200) {\r
resetFps ();\r
<?xml version="1.0"?>\r
-<Container Name="MainGrp" Background="0,5;0,5;0,5;0,5"\r
- Margin="10" Width="-1" Height="-1" Focusable="True" >\r
- <VerticalStack Name="vsFps" BorderWidth="1" Margin="5" Spacing="4" Fit="true">\r
- <HorizontalStack Height="-1">\r
- <Label Text="Update:" FontColor="White" />\r
- <Label Name="labUpdate" Text="{update}" FontSize="12" Background="DarkGreen"/>\r
- </HorizontalStack>\r
- <HorizontalStack Height="-1" Name="hsFps" Background="Mantis" >\r
- <Label Name="captionFps" Text="Fps:" />\r
- <Label Name="valueFps" Text="{fps}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- <HorizontalStack Height="-1" Background="UniversityOfCaliforniaGold">\r
- <Label Text="Min:" Width = "30" />\r
- <Label Text="{fpsMin}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- <HorizontalStack Height="-1" Background="Sienna" >\r
- <Label Text="Max:" Width = "30"/>\r
- <Label Text="{fpsMax}" Font="droid bold, 12" TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- </VerticalStack> \r
-</Container>
\ No newline at end of file
+<Border Fit="true" CornerRadius="5" BorderWidth="1">\r
+ <Container Name="MainGrp" Background="0,5;0,5;0,5;0,4" Width="120" Fit="true"\r
+ Margin="10" Focusable="True" >\r
+ <VerticalStack Fit="true" Name="vsFps" Spacing="10" >\r
+ <HorizontalStack Fit="true">\r
+ <Label Text="Update:" Width="50" TextAlignment="RightCenter"/>\r
+ <Label Name="labUpdate" Text="{update}" Font="droid,12" Background="AoEnglish" Width="50" TextAlignment="Center"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack Fit="true">\r
+ <Label Name="captionFps" Text="Fps:" Width="50" TextAlignment="RightCenter"/>\r
+ <Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack Fit="true">\r
+ <Label Text="Min:" Width="50" TextAlignment="RightCenter"/>\r
+ <Label Text="{fpsMin}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack Fit="true">\r
+ <Label Text="Max:" Width="50" TextAlignment="RightCenter"/>\r
+ <Label Text="{fpsMax}" Font="droid , 12" Background="AoEnglish" Width="50" TextAlignment="Center"/>\r
+ </HorizontalStack>\r
+ </VerticalStack> \r
+ </Container>\r
+</Border>
\ No newline at end of file
<VerticalStack Fit="true"> \r
<Checkbox Name="chk1"/>\r
<Checkbox Name="chk2" IsChecked="true"/>\r
- <Checkbox Name="chk4" >\r
- <Template>\r
- <HorizontalStack Fit="True" Margin="0" Spacing="1">\r
- <Image Name="Image" Width="20" Height="20" Path="#go.Images.Icons.checkbox.svg"/>\r
- <Label Name="Caption" Height="-1" Width="-1" Foreground="Black" Background="Yellow"/>\r
- </HorizontalStack>\r
- </Template>\r
- </Checkbox>\r
+\r
</VerticalStack>\r
<VerticalStack Fit="true">\r
<RadioButton IsChecked="true"/>\r
<RadioButton/>\r
- <RadioButton> \r
- <Template>\r
- <HorizontalStack Fit="true" Background="Green" Margin="0" Spacing="1" Focusable="false">\r
- <Image Name="Image" Width="20" Height="20" Path="#go.Images.Icons.radiobutton.svg"/>\r
- <Label Name="Caption"/>\r
- </HorizontalStack>\r
- </Template>\r
- </RadioButton>\r
+ <Button MouseClick="onButClick"/>\r
</VerticalStack>\r
</HorizontalStack>\r
<TextBoxWidget Name="textbox1" TextAlignment="LeftCenter" Font="droid,14" \r
<Scroller Name="scroller1" Background="DimGray" Width="-1" \r
Margin="5" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">\r
<VerticalStack Name="colors" VerticalAlignment="Top" Margin="1" Fit="true">\r
- <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
+<!-- <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>\r
<ProgressBar Width="100" Height="20" Value="{fps}" BorderWidth="2"\r
- BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/> \r
+ BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/> -->\r
</VerticalStack>\r
</Scroller>\r
<Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}"\r
- Orientation="Vertical" Width="16" />\r
+ Orientation="Vertical" Width="10" Height="0"/>\r
</HorizontalStack>\r
</HorizontalStack>\r
<!-- <HorizontalStack Name="hs0"\r
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTests</StartupObject>
+ <StartupObject>test.GOLIBTest_4</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
<HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath>
</Reference>
<Reference Include="Mono.Cairo" />
- <Reference Include="golib">
- <HintPath>..\bin\Release\golib.dll</HintPath>
- </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="GOLIBTest_5.cs" />
<ItemGroup>
<EmbeddedResource Include="image\tetra.png" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\GOLib.csproj">
+ <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
+ <Name>GOLib</Name>
+ </ProjectReference>
+ </ItemGroup>
</Project>
FieldInfo fiRefs = typeof(Interface).GetField("References");
il.Emit(OpCodes.Ldsfld, fiRefs);
il.Emit(OpCodes.Ldc_I4, dstIdx);
-
MethodInfo miGetRef = Interface.References.GetType().GetMethod("get_Item");
il.Emit(OpCodes.Callvirt, miGetRef);
il.Emit(OpCodes.Isinst, dstType);
using System.Xml;\r
using System.IO;\r
using System.Collections;\r
+using System.Threading;\r
\r
namespace go\r
{\r
_list.registerForGraphicUpdate ();\r
if (data == null)\r
return;\r
+ if (SelectedIndex < 0)\r
+ return;\r
\r
- #if DEBUG_LOAD_TIME\r
- Stopwatch loadingTime = new Stopwatch ();\r
- loadingTime.Start ();\r
- #endif\r
+ //force raise of changes\r
+ SelectedIndex = SelectedIndex;\r
\r
- MemoryStream ms = new MemoryStream ();\r
- using (Stream stream = Interface.GetStreamFromPath (ItemTemplate)) \r
- stream.CopyTo (ms);\r
+ pendingChildrenAddition = new Queue<GraphicObject> ();\r
+ threadedLoadingFinished = false;\r
\r
- Type t = Interface.GetTopContainerOfGOMLStream (ms);\r
+ Thread t = new Thread (loadingThread);\r
+ t.Start ();\r
\r
- foreach (var item in data) {\r
- ms.Seek(0,SeekOrigin.Begin);\r
- GraphicObject g = Interface.Load (ms, t, item);\r
- g.MouseClick += itemClick;\r
- _list.addChild(g);\r
- }\r
+ }\r
+ }\r
+ public override void UpdateLayout (LayoutingType layoutType)\r
+ {\r
+ CheckPendingChildrenAddition ();\r
+ base.UpdateLayout (layoutType);\r
+ }\r
+ internal void CheckPendingChildrenAddition()\r
+ {\r
+ if (pendingChildrenAddition == null)\r
+ return;\r
+ lock (pendingChildrenAddition) {\r
+ if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50)\r
+ return;\r
+ while (pendingChildrenAddition.Count > 0)\r
+ _list.addChild (pendingChildrenAddition.Dequeue ());\r
+ }\r
+ }\r
\r
- ms.Dispose ();\r
+ volatile Queue<GraphicObject> pendingChildrenAddition;\r
+ volatile bool threadedLoadingFinished = false;\r
\r
- if (SelectedIndex < 0)\r
- return;\r
+ void loadingThread()\r
+ {\r
+ #if DEBUG_LOAD_TIME\r
+ Stopwatch loadingTime = new Stopwatch ();\r
+ loadingTime.Start ();\r
+ #endif\r
+\r
+ MemoryStream ms = new MemoryStream ();\r
+ lock (ItemTemplate) {\r
+ using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))\r
+ stream.CopyTo (ms);\r
+ }\r
\r
- //force raise of changes\r
- SelectedIndex = SelectedIndex;\r
+ Type t = Interface.GetTopContainerOfGOMLStream (ms);\r
+\r
+ foreach (var item in data) {\r
+ ms.Seek(0,SeekOrigin.Begin);\r
+ GraphicObject g = Interface.Load (ms, t, item);\r
+ g.MouseClick += itemClick;\r
\r
- #if DEBUG_LOAD_TIME\r
- loadingTime.Stop ();\r
- Debug.WriteLine("Listbox Loading: {0} ticks \t, {1} ms",\r
- loadingTime.ElapsedTicks,\r
- loadingTime.ElapsedMilliseconds);\r
- #endif\r
+ lock (pendingChildrenAddition) {\r
+ pendingChildrenAddition.Enqueue (g);\r
+ }\r
}\r
+\r
+ ms.Dispose (); \r
+\r
+ threadedLoadingFinished = true;\r
+\r
+ #if DEBUG_LOAD_TIME\r
+ loadingTime.Stop ();\r
+ Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",\r
+ loadingTime.ElapsedTicks,\r
+ loadingTime.ElapsedMilliseconds, this.ToString());\r
+ #endif\r
}\r
public GraphicObject Overlay {\r
get { return _overlay; }\r
\r
public override void RegisterForLayouting (int layoutType)\r
{ \r
+ if (Parent == null)\r
+ return;\r
base.RegisterForLayouting (layoutType);\r
\r
if ((layoutType & (int)LayoutingType.PositionChildren) > 0)\r
{\r
if (Parent == null)\r
return;\r
- \r
- Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
+ lock (Interface.LayoutingQueue) {\r
+ Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
\r
- if ((layoutType & (int)LayoutingType.Width) > 0) {\r
+ if ((layoutType & (int)LayoutingType.Width) > 0) {\r
\r
- //force sizing to fit if parent is sizing on children and \r
- //this object has stretched size\r
- if (Parent.getBounds ().Width < 0 && Width == 0)\r
- Width = -1;\r
+ //force sizing to fit if parent is sizing on children and \r
+ //this object has stretched size\r
+ if (Parent.getBounds ().Width < 0 && Width == 0)\r
+ Width = -1;\r
\r
- if (Bounds.Width == 0) //stretch in parent\r
+ if (Bounds.Width == 0) //stretch in parent\r
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
- else if (Bounds.Width < 0) //fit \r
- Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this); \r
- else\r
- Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
- }\r
+ else if (Bounds.Width < 0) //fit \r
+ Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);\r
+ else\r
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
+ }\r
\r
- if ((layoutType & (int)LayoutingType.Height) > 0) {\r
+ if ((layoutType & (int)LayoutingType.Height) > 0) {\r
\r
- //force sizing to fit if parent is sizing on children\r
- if (Parent.getBounds ().Height < 0 && Height == 0)\r
- Height = -1;\r
+ //force sizing to fit if parent is sizing on children\r
+ if (Parent.getBounds ().Height < 0 && Height == 0)\r
+ Height = -1;\r
\r
- if (Bounds.Height == 0) //stretch in parent\r
+ if (Bounds.Height == 0) //stretch in parent\r
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
- else if (Bounds.Height < 0) //fit \r
+ else if (Bounds.Height < 0) //fit \r
Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);\r
- else\r
- Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
- }\r
+ else\r
+ Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
+ }\r
\r
- if ((layoutType & (int)LayoutingType.X) > 0)\r
+ if ((layoutType & (int)LayoutingType.X) > 0)\r
//for x positionning, sizing of parent and this have to be done\r
Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
\r
- if ((layoutType & (int)LayoutingType.Y) > 0)\r
+ if ((layoutType & (int)LayoutingType.Y) > 0)\r
//for x positionning, sizing of parent and this have to be done\r
Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
- \r
+ }\r
}\r
\r
/// <summary> trigger dependant sizing component update </summary>\r
LastSlots.Height = Slot.Height;\r
break;\r
}\r
-\r
- //if no layouting remains in queue for item, registre for redraw\r
- if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp == null)\r
- this.RegisterForRedraw ();\r
+ lock (Interface.LayoutingQueue) {\r
+ //if no layouting remains in queue for item, registre for redraw\r
+ if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp == null)\r
+ this.RegisterForRedraw ();\r
+ }\r
}\r
\r
/// <summary> This is the common overridable drawing routine to create new widget </summary>\r
using System.IO;
using System.Diagnostics;
using System.Xml;
+using System.Collections.Generic;
+using System.Threading;
namespace go
{
if (data == null)
return;
- #if DEBUG_LOAD_TIME
- Stopwatch loadingTime = new Stopwatch ();
- loadingTime.Start ();
- #endif
+ pendingChildrenAddition = new Queue<GraphicObject> ();
+ threadedLoadingFinished = false;
- MemoryStream ms = new MemoryStream ();
- using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
+ Thread t = new Thread (loadingThread);
+ t.Start ();
+
+ }
+ }
+
+ internal void CheckPendingChildrenAddition()
+ {
+ if (pendingChildrenAddition == null)
+ return;
+ lock (pendingChildrenAddition) {
+ if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50)
+ return;
+ while (pendingChildrenAddition.Count > 0)
+ _list.addChild (pendingChildrenAddition.Dequeue ());
+ }
+ }
+
+ volatile Queue<GraphicObject> pendingChildrenAddition;
+ volatile bool threadedLoadingFinished = false;
+
+ void loadingThread()
+ {
+ #if DEBUG_LOAD_TIME
+ Stopwatch loadingTime = new Stopwatch ();
+ loadingTime.Start ();
+ #endif
+
+ MemoryStream ms = new MemoryStream ();
+ lock (ItemTemplate) {
+ using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
stream.CopyTo (ms);
-
- Type t = Interface.GetTopContainerOfGOMLStream (ms);
-
- foreach (var item in data) {
- ms.Seek(0,SeekOrigin.Begin);
- GraphicObject g = Interface.Load (ms, t, item);
- g.MouseClick += itemClick;
- _list.addChild(g);
- }
+ }
+
+ Type t = Interface.GetTopContainerOfGOMLStream (ms);
- ms.Dispose ();
+ foreach (var item in data) {
+ ms.Seek(0,SeekOrigin.Begin);
+ GraphicObject g = Interface.Load (ms, t, item);
+ g.MouseClick += itemClick;
- #if DEBUG_LOAD_TIME
- loadingTime.Stop ();
- Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
- loadingTime.ElapsedTicks,
- loadingTime.ElapsedMilliseconds, this.ToString());
- #endif
+ lock (pendingChildrenAddition) {
+ pendingChildrenAddition.Enqueue (g);
+ }
}
+
+ ms.Dispose ();
+
+ threadedLoadingFinished = true;
+
+ #if DEBUG_LOAD_TIME
+ loadingTime.Stop ();
+ Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
+ loadingTime.ElapsedTicks,
+ loadingTime.ElapsedMilliseconds, this.ToString());
+ #endif
}
void itemClick(object sender, OpenTK.Input.MouseButtonEventArgs e){
CurrentGOMLPath = "";
}
+
+
public static GraphicObject Load (Stream stream, Type type, object hostClass = null, bool resolve = true)
{
#if DEBUG_LOAD_TIME
Height = 0x08,
Sizing = 0x0C,
PositionChildren = 0x10,
+ ChildAddition = 0x20,
All = 0xFF
}
invGOList = invGOList.Reverse ().ToArray ();\r
\r
//Debug.WriteLine ("======= Layouting queue start =======");\r
- while (Interface.LayoutingQueue.Count > 0) {\r
- LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();\r
- lqi.ProcessLayouting ();\r
+ lock (Interface.LayoutingQueue) { \r
+ while (Interface.LayoutingQueue.Count > 0) {\r
+// Stopwatch lqiProcTime = new Stopwatch ();\r
+// lqiProcTime.Start ();\r
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();\r
+ lqi.ProcessLayouting ();\r
+// lqiProcTime.Stop ();\r
+// if (lqiProcTime.ElapsedMilliseconds > 10) {\r
+// Debug.WriteLine("lqi {2}: {0} ticks \t, {1} ms",\r
+// updateTime.ElapsedTicks,\r
+// updateTime.ElapsedMilliseconds, lqi.ToString());\r
+// }\r
+ }\r
}\r
\r
//Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");\r