aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2017-06-15 17:32:04 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2017-06-15 17:32:04 +0200
commit1fdbaaf4ae209e26ef8767ae13ebb9aa9d1f79c7 (patch)
tree5586932c635ca68a67bddcb83918b74ecad79758
parent570f6f9b7c9ed25adf618b02f5cfe0f1b3e9afe7 (diff)
Revert "replace foreach loops with for ones"
This reverts commit 1c3263454961eb207a01b67c51d0acf88376d522.
-rwxr-xr-xTemplates/ToolWindow.template2
-rw-r--r--src/Colors.cs17
-rw-r--r--src/GraphicObjects/GenericStack.cs16
-rw-r--r--src/GraphicObjects/GraphicObject.cs12
-rw-r--r--src/GraphicObjects/Group.cs46
-rw-r--r--src/Interface.cs8
6 files changed, 51 insertions, 50 deletions
diff --git a/Templates/ToolWindow.template b/Templates/ToolWindow.template
index 919c0bad..f021f6ee 100755
--- a/Templates/ToolWindow.template
+++ b/Templates/ToolWindow.template
@@ -19,6 +19,6 @@
<GraphicObject Width="5"/>
</HorizontalStack>
<!-- </Border>-->
- <Container Name="Content" MinimumSize="50,50" />
+ <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/>
</VerticalStack>
</Border>
diff --git a/src/Colors.cs b/src/Colors.cs
index 89f5c932..3f200829 100644
--- a/src/Colors.cs
+++ b/src/Colors.cs
@@ -88,9 +88,10 @@ namespace Crow
if (c.Length == 1)
{
- for (int i = 0; i < ColorDic.Count; i++) {
- if (string.Equals(ColorDic [i].Name,s,StringComparison.Ordinal))
- return ColorDic [i];
+ foreach (Color cr in ColorDic)
+ {
+ if (string.Equals(cr.Name,s,StringComparison.Ordinal))
+ return cr;
}
}
return new Color(
@@ -1126,10 +1127,12 @@ namespace Crow
if (!string.IsNullOrEmpty(Name))
return Name;
- for (int i = 0; i < ColorDic.Count; i++) {
- if (ColorDic[i] == this) {
- Name = ColorDic[i].Name;
- return ColorDic[i].Name;
+ foreach (Color cr in ColorDic)
+ {
+ if (cr == this)
+ {
+ Name = cr.Name;
+ return cr.Name;
}
}
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index a21c903d..cecdaffd 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -97,18 +97,18 @@ namespace Crow
{
int d = 0;
if (Orientation == Orientation.Horizontal) {
- for (int i = 0; i < Children.Count; i++) {
- if (!Children[i].Visible)
+ foreach (GraphicObject c in Children) {
+ if (!c.Visible)
continue;
- Children[i].Slot.X = d;
- d += Children[i].Slot.Width + Spacing;
+ c.Slot.X = d;
+ d += c.Slot.Width + Spacing;
}
} else {
- for (int i = 0; i < Children.Count; i++) {
- if (!Children[i].Visible)
+ foreach (GraphicObject c in Children) {
+ if (!c.Visible)
continue;
- Children[i].Slot.Y = d;
- d += Children[i].Slot.Height + Spacing;
+ c.Slot.Y = d;
+ d += c.Slot.Height + Spacing;
}
}
IsDirty = true;
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 46b4c31b..0db8fb54 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -719,10 +719,10 @@ namespace Crow
//set local GraphicObject to root object passed as 1st argument
il.Emit (OpCodes.Ldarg_0);
il.Emit (OpCodes.Stloc_0);
- EventInfo[] eis = thisType.GetEvents(BindingFlags.Public | BindingFlags.Instance);
- for (int i = 0; i < eis.Length; i++) {
+
+ foreach (EventInfo ei in thisType.GetEvents(BindingFlags.Public | BindingFlags.Instance)) {
string expression;
- if (!getDefaultEvent(eis[i], styling, out expression))
+ if (!getDefaultEvent(ei, styling, out expression))
continue;
//TODO:dynEventHandler could be cached somewhere, maybe a style instanciator class holding the styling delegate and bound to it.
foreach (string exp in CompilerServices.splitOnSemiColumnOutsideAccolades(expression)) {
@@ -733,15 +733,15 @@ namespace Crow
//push eventInfo as 1st arg of compile
il.Emit (OpCodes.Ldloc_0);
il.Emit (OpCodes.Call, CompilerServices.miGetType);
- il.Emit (OpCodes.Ldstr, eis[i].Name);//push event name
+ il.Emit (OpCodes.Ldstr, ei.Name);//push event name
il.Emit (OpCodes.Call, CompilerServices.miGetEvent);
//push expression as 2nd arg of compile
il.Emit (OpCodes.Ldstr, trimed.Substring (1, trimed.Length - 2));
//push null as 3rd arg, currentNode, not known when instanciing
il.Emit (OpCodes.Ldnull);
il.Emit (OpCodes.Callvirt, CompilerServices.miCompileDynEventHandler);
- il.Emit (OpCodes.Castclass, eis[i].EventHandlerType);
- il.Emit (OpCodes.Callvirt, eis[i].AddMethod);
+ il.Emit (OpCodes.Castclass, ei.EventHandlerType);
+ il.Emit (OpCodes.Callvirt, ei.AddMethod);
}else
Debug.WriteLine("error in styling, event not handled : " + trimed);
}
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index ad0d28a0..549ca219 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -135,10 +135,9 @@ namespace Crow
{
base.OnDataSourceChanged (this, e);
lock (children) {
- for (int i = 0; i < children.Count; i++) {
- if (children[i].localDataSourceIsNull & children[i].localLogicalParentIsNull)
- children[i].OnDataSourceChanged (sender, e);
- }
+ foreach (GraphicObject g in children)
+ if (g.localDataSourceIsNull & g.localLogicalParentIsNull)
+ g.OnDataSourceChanged (sender, e);
}
}
public override GraphicObject FindByName (string nameToFind)
@@ -147,8 +146,8 @@ namespace Crow
return this;
GraphicObject tmp = null;
lock (children) {
- for (int i = 0; i < children.Count; i++) {
- tmp = children[i].FindByName (nameToFind);
+ foreach (GraphicObject w in Children) {
+ tmp = w.FindByName (nameToFind);
if (tmp != null)
break;
}
@@ -157,10 +156,10 @@ namespace Crow
}
public override bool Contains (GraphicObject goToFind)
{
- for (int i = 0; i < children.Count; i++) {
- if (children[i] == goToFind)
+ foreach (GraphicObject w in Children) {
+ if (w == goToFind)
return true;
- if (children[i].Contains (goToFind))
+ if (w.Contains (goToFind))
return true;
}
return false;
@@ -196,19 +195,19 @@ namespace Crow
//position smaller objects in group when group size is fit
switch (layoutType) {
case LayoutingType.Width:
- for (int i = 0; i < children.Count; i++) {
- if (children[i].Width.Units == Unit.Percent)
- children[i].RegisterForLayouting (LayoutingType.Width);
+ foreach (GraphicObject c in Children){
+ if (c.Width.Units == Unit.Percent)
+ c.RegisterForLayouting (LayoutingType.Width);
else
- children[i].RegisterForLayouting (LayoutingType.X);
+ c.RegisterForLayouting (LayoutingType.X);
}
break;
case LayoutingType.Height:
- for (int i = 0; i < children.Count; i++) {
- if (children[i].Height.Units == Unit.Percent)
- children[i].RegisterForLayouting (LayoutingType.Height);
+ foreach (GraphicObject c in Children) {
+ if (c.Height.Units == Unit.Percent)
+ c.RegisterForLayouting (LayoutingType.Height);
else
- children[i].RegisterForLayouting (LayoutingType.Y);
+ c.RegisterForLayouting (LayoutingType.Y);
}
break;
}
@@ -226,8 +225,8 @@ namespace Crow
}
lock (children) {
- for (int i = 0; i < children.Count; i++) {
- children[i].Paint (ref gr);
+ foreach (GraphicObject g in Children) {
+ g.Paint (ref gr);
}
}
gr.Restore ();
@@ -248,12 +247,11 @@ namespace Crow
gr.Clip ();
lock (Children) {
- for (int i = 0; i < children.Count; i++) {
- if (!children[i].Visible)
- continue;
- if (Clipping.Contains (children[i].Slot + ClientRectangle.Position) == RegionOverlap.Out)
+ foreach (GraphicObject c in Children) {
+ if (!c.Visible)
continue;
- children[i].Paint (ref gr);
+ if (Clipping.intersect (c.Slot + ClientRectangle.Position))
+ c.Paint (ref gr);
}
}
diff --git a/src/Interface.cs b/src/Interface.cs
index f451dc56..8439c31e 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -630,8 +630,8 @@ namespace Crow
/// <summary>Search a Graphic object in the tree named 'nameToFind'</summary>
public GraphicObject FindByName (string nameToFind)
{
- for (int i = 0; i < GraphicTree.Count; i++) {
- GraphicObject r = GraphicTree[i].FindByName (nameToFind);
+ foreach (GraphicObject w in GraphicTree) {
+ GraphicObject r = w.FindByName (nameToFind);
if (r != null)
return r;
}
@@ -647,8 +647,8 @@ namespace Crow
int bmpSize = Math.Abs (stride) * ClientRectangle.Height;
bmp = new byte[bmpSize];
- for (int i = 0; i < GraphicTree.Count; i++)
- GraphicTree[i].RegisterForLayouting (LayoutingType.All);
+ foreach (GraphicObject g in GraphicTree)
+ g.RegisterForLayouting (LayoutingType.All);
clipping.AddRectangle (clientRectangle);
}