get {
return data;
}
- set {
- if (loadingInProgress) {
- thread.Join ();
- Interface.LoadingLists.Remove (this);
- pendingChildrenAddition = null;
- loadingInProgress = false;
- }
-
+ set {
+
data = value;
_list.ClearChildren ();
if (data == null)
return;
-
- pendingChildrenAddition = new Queue<GraphicObject> ();
- threadedLoadingFinished = false;
- Interface.LoadingLists.Add (this);
-
- thread = new Thread(loadingThread);
- loadingInProgress = true;
- thread.IsBackground = true;
- thread.Start ();
- thread.Join ();
- }
- }
-// public override void UpdateLayout (LayoutingType layoutType)
-// {
-// CheckPendingChildrenAddition ();
-// base.UpdateLayout (layoutType);
-// }
- internal void CheckPendingChildrenAddition()
- {
- if (!loadingInProgress)
- return;
- lock (pendingChildrenAddition) {
- if (!threadedLoadingFinished && pendingChildrenAddition.Count < 10)
- return;
- while (pendingChildrenAddition.Count > 0) {
- GraphicObject tmp = pendingChildrenAddition.Dequeue ();
- tmp.DataSource = tmp.Tag;
- tmp.Tag = null;
- _list.addChild (tmp);
- }
- if (threadedLoadingFinished) {
- Interface.LoadingLists.Remove (this);
- pendingChildrenAddition = null;
- loadingInProgress = false;
+
+ #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);
}
- }
- }
-
- Queue<GraphicObject> pendingChildrenAddition;
- volatile bool threadedLoadingFinished = false;
- volatile bool loadingInProgress = false;
- Thread thread;
-
- 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);
+ Type t = Interface.GetTopContainerOfGOMLStream (ms);
- foreach (var item in data) {
- ms.Seek(0,SeekOrigin.Begin);
- GraphicObject g = Interface.Load (ms, t);
- g.Tag = item;
- g.MouseClick += itemClick;
- lock (pendingChildrenAddition) {
- pendingChildrenAddition.Enqueue (g);
+ foreach (var item in data) {
+ ms.Seek(0,SeekOrigin.Begin);
+ GraphicObject g = Interface.Load (ms, t);
+ g.DataSource = item;
+ g.MouseClick += itemClick;
+ _list.addChild (g);
}
- }
-
- ms.Dispose ();
- threadedLoadingFinished = true;
+ ms.Dispose ();
- #if DEBUG_LOAD_TIME
- loadingTime.Stop ();
- Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
+ #if DEBUG_LOAD_TIME
+ loadingTime.Stop ();
+ Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
loadingTime.ElapsedTicks,
loadingTime.ElapsedMilliseconds, this.ToString());
- #endif
+ #endif
+
+ }
}
void itemClick(object sender, OpenTK.Input.MouseButtonEventArgs e){
surf = new ImageSurface(bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height,ClientRectangle.Width*4);
ctx = new Context(surf);
- if (Interface.LoadingLists.Count > 0) {
- ListBox[] loadings = new ListBox[Interface.LoadingLists.Count];
- Interface.LoadingLists.CopyTo (loadings, 0);
- for (int i = 0; i < loadings.Length; i++)
- loadings [i].CheckPendingChildrenAddition ();
- }
-
GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
GraphicObjects.CopyTo (invGOList,0);
invGOList = invGOList.Reverse ().ToArray ();