aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/GraphicObject.cs89
-rw-r--r--src/GraphicObjects/Image.cs6
-rw-r--r--src/GraphicObjects/MessageBox.cs26
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs24
4 files changed, 78 insertions, 67 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 5de94f60..559719a9 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -40,6 +40,7 @@ namespace Crow
{
public class GraphicObject : ILayoutable, IValueChange
{
+ internal NamedMutex mutex = new NamedMutex("GRAPHIC OBJECT");
internal static ulong currentUid = 0;
internal ulong uid = 0;
@@ -162,8 +163,9 @@ namespace Crow
if (parent == value)
return;
DataSourceChangeEventArgs e = new DataSourceChangeEventArgs (parent, value);
- lock (this)
- parent = value;
+ CrowMonitor.Enter (mutex, "set parent of object");
+ parent = value;
+ CrowMonitor.Exit (mutex);
onParentChanged (this, e);
}
@@ -887,12 +889,12 @@ namespace Crow
public virtual void RegisterForLayouting(LayoutingType layoutType){
if (Parent == null)
return;
- lock (CurrentInterface.LayoutMutex) {
- //prevent queueing same LayoutingType for this
- layoutType &= (~RegisteredLayoutings);
+ CrowMonitor.Enter (CurrentInterface.LayoutMutex, "register for layouting");
+ //prevent queueing same LayoutingType for this
+ layoutType &= (~RegisteredLayoutings);
- if (layoutType == LayoutingType.None)
- return;
+ if (layoutType != LayoutingType.None) {
+
//dont set position for stretched item
if (Width == Measure.Stretched)
layoutType &= (~LayoutingType.X);
@@ -909,21 +911,21 @@ namespace Crow
// //prevent queueing same LayoutingType for this
// layoutType &= (~RegisteredLayoutings);
- if (layoutType == LayoutingType.None)
- return;
-
- //enqueue LQI LayoutingTypes separately
- if (layoutType.HasFlag (LayoutingType.Width))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
- if (layoutType.HasFlag (LayoutingType.Height))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
- if (layoutType.HasFlag (LayoutingType.X))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
- if (layoutType.HasFlag (LayoutingType.Y))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
- if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
- CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
+ if (layoutType != LayoutingType.None) {
+ //enqueue LQI LayoutingTypes separately
+ if (layoutType.HasFlag (LayoutingType.Width))
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+ if (layoutType.HasFlag (LayoutingType.Height))
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+ if (layoutType.HasFlag (LayoutingType.X))
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+ if (layoutType.HasFlag (LayoutingType.Y))
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+ if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
+ }
}
+ CrowMonitor.Exit (CurrentInterface.LayoutMutex);
}
/// <summary> trigger dependant sizing component update </summary>
@@ -1154,33 +1156,36 @@ namespace Crow
//TODO:this test should not be necessary
if (Slot.Height < 0 || Slot.Width < 0 || parent == null)
return;
- lock (this) {
- if (cacheEnabled) {
- if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
- cacheEnabled = false;
- }
+
+ CrowMonitor.Enter (mutex, "Paint");
- if (cacheEnabled) {
- if (IsDirty)
- RecreateCache ();
+ if (cacheEnabled) {
+ if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
+ cacheEnabled = false;
+ }
- UpdateCache (ctx);
- if (!isEnabled)
- paintDisabled (ctx, Slot + Parent.ClientRectangle.Position);
- } else {
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
- ctx.Save ();
+ if (cacheEnabled) {
+ if (IsDirty)
+ RecreateCache ();
- ctx.Translate (rb.X, rb.Y);
+ UpdateCache (ctx);
+ if (!isEnabled)
+ paintDisabled (ctx, Slot + Parent.ClientRectangle.Position);
+ } else {
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ ctx.Save ();
- onDraw (ctx);
- if (!isEnabled)
- paintDisabled (ctx, Slot);
+ ctx.Translate (rb.X, rb.Y);
- ctx.Restore ();
- }
- LastPaintedSlot = Slot;
+ onDraw (ctx);
+ if (!isEnabled)
+ paintDisabled (ctx, Slot);
+
+ ctx.Restore ();
}
+ LastPaintedSlot = Slot;
+
+ CrowMonitor.Exit (mutex);
}
void paintDisabled(Context gr, Rectangle rb){
gr.Operator = Operator.Xor;
diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs
index 6a4c590d..84385e85 100644
--- a/src/GraphicObjects/Image.cs
+++ b/src/GraphicObjects/Image.cs
@@ -79,9 +79,9 @@ namespace Crow
if (string.IsNullOrEmpty(value))
Picture = null;
else {
- lock(CurrentInterface.LayoutMutex){
- LoadImage (value);
- }
+ CrowMonitor.Enter(CurrentInterface.LayoutMutex, "load image");
+ LoadImage (value);
+ CrowMonitor.Exit(CurrentInterface.LayoutMutex);
}
} catch (Exception ex) {
Debug.WriteLine (ex.Message);
diff --git a/src/GraphicObjects/MessageBox.cs b/src/GraphicObjects/MessageBox.cs
index d8ce1dae..88be521e 100644
--- a/src/GraphicObjects/MessageBox.cs
+++ b/src/GraphicObjects/MessageBox.cs
@@ -132,18 +132,20 @@ namespace Crow
close ();
}
public static MessageBox Show (Type msgBoxType, string message, string okMsg = "", string cancelMsg = ""){
- lock (Interface.CurrentInterface.UpdateMutex) {
- MessageBox mb = new MessageBox ();
- mb.Initialize ();
- mb.CurrentInterface.AddWidget (mb);
- mb.MsgType = msgBoxType;
- mb.Message = message;
- if (!string.IsNullOrEmpty(okMsg))
- mb.OkMessage = okMsg;
- if (!string.IsNullOrEmpty(cancelMsg))
- mb.CancelMessage = cancelMsg;
- return mb;
- }
+ MessageBox mb = null;
+ CrowMonitor.Enter (Interface.CurrentInterface.UpdateMutex, "message box show");
+ mb = new MessageBox ();
+ mb.Initialize ();
+ mb.CurrentInterface.AddWidget (mb);
+ mb.MsgType = msgBoxType;
+ mb.Message = message;
+ if (!string.IsNullOrEmpty(okMsg))
+ mb.OkMessage = okMsg;
+ if (!string.IsNullOrEmpty(cancelMsg))
+ mb.CancelMessage = cancelMsg;
+ CrowMonitor.Exit (Interface.CurrentInterface.UpdateMutex);
+ return mb;
+
}
}
}
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index eea3a184..c2184867 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -160,13 +160,15 @@ namespace Crow
NotifyValueChanged ("Data", data);
- lock (CurrentInterface.LayoutMutex)
- ClearItems ();
+ CrowMonitor.Enter (CurrentInterface.LayoutMutex, "templated group enclosing clearItems");
+ ClearItems ();
+ CrowMonitor.Exit (CurrentInterface.LayoutMutex);
if (data == null)
return;
loadingThread = new CrowThread (this, loading);
+ loadingThread.thread.Name = "list loading thread";
loadingThread.Finished += (object sender, EventArgs e) => (sender as TemplatedGroup).Loaded.Raise (sender, e);
loadingThread.Start ();
@@ -324,8 +326,9 @@ namespace Crow
if (page == items)
return;
- lock (CurrentInterface.LayoutMutex)
- items.AddChild (page);
+ CrowMonitor.Enter (CurrentInterface.LayoutMutex, "templeted group add chile (page)");
+ items.AddChild (page);
+ CrowMonitor.Exit (CurrentInterface.LayoutMutex);
#if DEBUG_LOAD
loadingTime.Stop ();
@@ -377,12 +380,13 @@ namespace Crow
iTemp = ItemTemplates ["default"];
}
- lock (CurrentInterface.LayoutMutex) {
- g = iTemp.CreateInstance(CurrentInterface);
- page.AddChild (g);
- //g.LogicalParent = this;
- registerItemClick (g);
- }
+ CrowMonitor.Enter (CurrentInterface.LayoutMutex, "templeted group add item to page");
+ g = iTemp.CreateInstance(CurrentInterface);
+ page.AddChild (g);
+ //g.LogicalParent = this;
+ registerItemClick (g);
+ CrowMonitor.Exit (CurrentInterface.LayoutMutex);
+
if (iTemp.Expand != null && g is Expandable) {
(g as Expandable).Expand += iTemp.Expand;