[mapguide-commits] r6182 - in trunk/Tools/Maestro:
Maestro.Editors/LayerDefinition/Vector/Scales
OSGeo.MapGuide.MaestroAPI/ObjectModels
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Oct 25 21:49:07 EDT 2011
Author: jng
Date: 2011-10-25 18:49:07 -0700 (Tue, 25 Oct 2011)
New Revision: 6182
Modified:
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs
Log:
#1838: Fix rule re-ordering breakage due to our new interfaces not returning lists
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs 2011-10-21 08:34:10 UTC (rev 6181)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs 2011-10-26 01:49:07 UTC (rev 6182)
@@ -317,23 +317,28 @@
{
this.Controls.SetChildIndex(selectedControl, pos + (down ? -1 : 1));
- System.Collections.IList ic = null;
- if (m_point != null)
- ic = (System.Collections.IList)m_point.Rules;
- else if (m_line != null)
- ic = (System.Collections.IList)m_line.Rules;
- else if (m_area != null)
- ic = (System.Collections.IList)m_area.Rules;
- else if (m_comp != null)
- ic = (System.Collections.IList)m_comp.CompositeRule;
-
- pos = ic.IndexOf(selectedRule);
- if ((!down && pos > 0) || (down && pos < ic.Count - 1 && pos > 0))
+ if (down)
{
- ic.RemoveAt(pos);
- ic.Insert(pos + (down ? 1 : -1), selectedRule);
+ if (m_point != null)
+ m_point.MoveDown((IPointRule)selectedRule);
+ else if (m_line != null)
+ m_line.MoveDown((ILineRule)selectedRule);
+ else if (m_area != null)
+ m_area.MoveDown((IAreaRule)selectedRule);
+ else if (m_comp != null)
+ m_comp.MoveDown((ICompositeRule)selectedRule);
}
-
+ else
+ {
+ if (m_point != null)
+ m_point.MoveUp((IPointRule)selectedRule);
+ else if (m_line != null)
+ m_line.MoveUp((ILineRule)selectedRule);
+ else if (m_area != null)
+ m_area.MoveUp((IAreaRule)selectedRule);
+ else if (m_comp != null)
+ m_comp.MoveUp((ICompositeRule)selectedRule);
+ }
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs 2011-10-21 08:34:10 UTC (rev 6181)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs 2011-10-26 01:49:07 UTC (rev 6182)
@@ -697,7 +697,7 @@
/// <summary>
/// Style specification for a area geometry layer
/// </summary>
- public interface IAreaVectorStyle : IVectorStyle
+ public interface IAreaVectorStyle : IVectorStyle, IRuleCollection<IAreaRule>
{
/// <summary>
/// Enumerates the rules in this specification
@@ -725,7 +725,7 @@
/// <summary>
/// Style specification for a line geometry layer
/// </summary>
- public interface ILineVectorStyle : IVectorStyle
+ public interface ILineVectorStyle : IVectorStyle, IRuleCollection<ILineRule>
{
/// <summary>
/// Enumerates the rules in this specification
@@ -758,9 +758,41 @@
}
/// <summary>
+ /// Defines a collection of style rules
+ /// </summary>
+ /// <typeparam name="TRule">The type of the rule.</typeparam>
+ public interface IRuleCollection<TRule>
+ {
+ /// <summary>
+ /// Gets the index of the specified rule
+ /// </summary>
+ /// <param name="rule"></param>
+ /// <returns></returns>
+ int IndexOfRule(TRule rule);
+ /// <summary>
+ /// Gets the rule at the specified index
+ /// </summary>
+ /// <param name="index">The index.</param>
+ /// <returns></returns>
+ TRule GetRuleAt(int index);
+ /// <summary>
+ /// Moves the specified rule up the list
+ /// </summary>
+ /// <param name="rule">The rule.</param>
+ /// <returns></returns>
+ bool MoveUp(TRule rule);
+ /// <summary>
+ /// Moves the specified rule down the list
+ /// </summary>
+ /// <param name="rule">The rule.</param>
+ /// <returns></returns>
+ bool MoveDown(TRule rule);
+ }
+
+ /// <summary>
/// Style specification for a point geometry layer
/// </summary>
- public interface IPointVectorStyle : IVectorStyle
+ public interface IPointVectorStyle : IVectorStyle, IRuleCollection<IPointRule>
{
/// <summary>
/// Gets or sets whether to create a text layer
@@ -1620,7 +1652,7 @@
/// <summary>
/// Represents a composite style definition
/// </summary>
- public interface ICompositeTypeStyle : IVectorStyle
+ public interface ICompositeTypeStyle : IVectorStyle, IRuleCollection<ICompositeRule>
{
/// <summary>
/// Gets the composite rules.
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs 2011-10-21 08:34:10 UTC (rev 6181)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs 2011-10-26 01:49:07 UTC (rev 6182)
@@ -476,8 +476,80 @@
{
get { return StyleType.Area; }
}
+
+ #region IRuleCollection<IAreaRule> Members
+
+ public int IndexOfRule(IAreaRule rule)
+ {
+ var r = rule as AreaRuleType;
+ if (r != null)
+ return this.AreaRule.IndexOf(r);
+ return -1;
+ }
+
+ public IAreaRule GetRuleAt(int index)
+ {
+ return this.AreaRule[index];
+ }
+
+ public bool MoveUp(IAreaRule rule)
+ {
+ var r = rule as AreaRuleType;
+ if (r != null)
+ {
+ return CollectionUtil.MoveUp(this.AreaRule, r);
+ }
+ return false;
+ }
+
+ public bool MoveDown(IAreaRule rule)
+ {
+ var r = rule as AreaRuleType;
+ if (r != null)
+ {
+ return CollectionUtil.MoveDown(this.AreaRule, r);
+ }
+ return false;
+ }
+
+ #endregion
}
+ internal static class CollectionUtil
+ {
+ public static bool MoveUp<T>(IList<T> list, T obj)
+ {
+ var idx = list.IndexOf(obj);
+ if (idx == 0) //Already at top
+ return false;
+
+ var newIdx = idx - 1;
+ //Get object at index
+ var obj2 = list[newIdx];
+ //Swap them
+ list[idx] = obj2;
+ list[newIdx] = obj;
+
+ return true;
+ }
+
+ public static bool MoveDown<T>(IList<T> list, T obj)
+ {
+ var idx = list.IndexOf(obj);
+ if (idx == list.Count - 1) //Already at bottom
+ return false;
+
+ var newIdx = idx + 1;
+ //Get object at index
+ var obj2 = list[newIdx];
+ //Swap them
+ list[idx] = obj2;
+ list[newIdx] = obj;
+
+ return true;
+ }
+ }
+
partial class AreaRuleType : IAreaRule
{
[XmlIgnore]
@@ -559,6 +631,39 @@
{
get { return StyleType.Point; }
}
+
+ #region IRuleCollection<IPointRule> Members
+
+ public int IndexOfRule(IPointRule rule)
+ {
+ var pr = rule as PointRuleType;
+ if (pr != null)
+ return this.PointRule.IndexOf(pr);
+ return -1;
+ }
+
+ public IPointRule GetRuleAt(int index)
+ {
+ return this.PointRule[index];
+ }
+
+ public bool MoveUp(IPointRule rule)
+ {
+ var pr = rule as PointRuleType;
+ if (pr != null)
+ return CollectionUtil.MoveUp(this.PointRule, pr);
+ return false;
+ }
+
+ public bool MoveDown(IPointRule rule)
+ {
+ var pr = rule as PointRuleType;
+ if (pr != null)
+ return CollectionUtil.MoveDown(this.PointRule, pr);
+ return false;
+ }
+
+ #endregion
}
@@ -657,6 +762,34 @@
{
get { return StyleType.Line; }
}
+
+ #region IRuleCollection<ILineRule> Members
+
+ public int IndexOfRule(ILineRule rule)
+ {
+ var lr = rule as LineRuleType;
+ if (lr != null)
+ return this.LineRule.IndexOf(lr);
+ return -1;
+ }
+
+ public bool MoveUp(ILineRule rule)
+ {
+ var lr = rule as LineRuleType;
+ if (lr != null)
+ return CollectionUtil.MoveUp(this.LineRule, lr);
+ return false;
+ }
+
+ public bool MoveDown(ILineRule rule)
+ {
+ var lr = rule as LineRuleType;
+ if (lr != null)
+ return CollectionUtil.MoveDown(this.LineRule, lr);
+ return false;
+ }
+
+ #endregion
}
partial class LineRuleType : ILineRule
@@ -1997,6 +2130,39 @@
{
get { return this.CompositeRule.Count; }
}
+
+ #region IRuleCollection<ICompositeRule> Members
+
+ public int IndexOfRule(ICompositeRule rule)
+ {
+ var cr = rule as CompositeRule;
+ if (cr != null)
+ return this.CompositeRule.IndexOf(cr);
+ return -1;
+ }
+
+ public ICompositeRule GetRuleAt(int index)
+ {
+ return this.CompositeRule[index];
+ }
+
+ public bool MoveUp(ICompositeRule rule)
+ {
+ var cr = rule as CompositeRule;
+ if (cr != null)
+ return CollectionUtil.MoveUp(this.CompositeRule, cr);
+ return false;
+ }
+
+ public bool MoveDown(ICompositeRule rule)
+ {
+ var cr = rule as CompositeRule;
+ if (cr != null)
+ return CollectionUtil.MoveDown(this.CompositeRule, cr);
+ return false;
+ }
+
+ #endregion
}
#endif
#endregion
More information about the mapguide-commits
mailing list