From 55a5b43eb84110d6b07e11ab117daccd352132cf Mon Sep 17 00:00:00 2001 From: Graham Lyon Date: Mon, 22 Aug 2011 07:47:07 +0100 Subject: [PATCH] Remove FiguresReversed property --- MonoDevelop.ClassDesigner/ClassDiagram.cs | 2 +- MonoHotDraw/IDrawing.cs | 1 - MonoHotDraw/MonoHotDraw.Figures/CompositeFigure.cs | 10 +--------- .../MonoHotDraw.Handles/ChangeConnectionHandle.cs | 9 +++------ MonoHotDraw/MonoHotDraw.Tools/SelectAreaTool.cs | 2 +- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/MonoDevelop.ClassDesigner/ClassDiagram.cs b/MonoDevelop.ClassDesigner/ClassDiagram.cs index 15ec017..cc5fffc 100644 --- a/MonoDevelop.ClassDesigner/ClassDiagram.cs +++ b/MonoDevelop.ClassDesigner/ClassDiagram.cs @@ -401,7 +401,7 @@ protected void OnGroupSettingChanged (DiagramEventArgs e) protected void OnCreatedHandler (object o, FigureEventArgs e) { Add (e.Figure); - IFigure last = FiguresReversed.LastOrDefault (); + IFigure last = Figures.FirstOrDefault (); if (last == null) return; diff --git a/MonoHotDraw/IDrawing.cs b/MonoHotDraw/IDrawing.cs index 7fe4266..11c6804 100644 --- a/MonoHotDraw/IDrawing.cs +++ b/MonoHotDraw/IDrawing.cs @@ -51,7 +51,6 @@ public interface IDrawing : IDisposable void SendToBack (IFigure figure); RectangleD DisplayBox { get; } - IEnumerable FiguresReversed { get; } IEnumerable Figures { get; } //IList FigureCollection { get; } } diff --git a/MonoHotDraw/MonoHotDraw.Figures/CompositeFigure.cs b/MonoHotDraw/MonoHotDraw.Figures/CompositeFigure.cs index 9baf2df..832a878 100644 --- a/MonoHotDraw/MonoHotDraw.Figures/CompositeFigure.cs +++ b/MonoHotDraw/MonoHotDraw.Figures/CompositeFigure.cs @@ -52,10 +52,6 @@ protected CompositeFigure () get { return FigureCollection; } } - public IEnumerable FiguresReversed { - get { return FigureCollection.Reverse (); } - } - public override IEnumerable Handles { get { foreach (IFigure fig in FigureCollection) @@ -126,11 +122,7 @@ public override ITool CreateFigureTool (IDrawingEditor editor, ITool dt) public IFigure FindFigure (double x, double y) { - foreach (IFigure figure in FiguresReversed) - if (figure.ContainsPoint (x, y)) - return figure; - - return null; + return Figures.LastOrDefault (f => f.ContainsPoint (x, y)); } public override bool Includes (IFigure figure) diff --git a/MonoHotDraw/MonoHotDraw.Handles/ChangeConnectionHandle.cs b/MonoHotDraw/MonoHotDraw.Handles/ChangeConnectionHandle.cs index f9dd08d..da54a20 100644 --- a/MonoHotDraw/MonoHotDraw.Handles/ChangeConnectionHandle.cs +++ b/MonoHotDraw/MonoHotDraw.Handles/ChangeConnectionHandle.cs @@ -25,6 +25,8 @@ using Cairo; using System; +using System.Linq; + using MonoHotDraw.Connectors; using MonoHotDraw.Commands; using MonoHotDraw.Figures; @@ -160,12 +162,7 @@ protected override void UpdateUndoActivity () #region Private Members private IFigure FindConnectableFigure (double x, double y, IDrawing drawing) { - foreach (IFigure figure in drawing.FiguresReversed) { - if (figure.ContainsPoint (x, y) && IsConnectionPossible (figure)) { - return figure; - } - } - return null; + return drawing.Figures.LastOrDefault (f => f.ContainsPoint (x, y) && IsConnectionPossible (f)); } private IConnector FindConnectionTarget (double x, double y, IDrawing drawing) diff --git a/MonoHotDraw/MonoHotDraw.Tools/SelectAreaTool.cs b/MonoHotDraw/MonoHotDraw.Tools/SelectAreaTool.cs index cc49a2b..9551479 100644 --- a/MonoHotDraw/MonoHotDraw.Tools/SelectAreaTool.cs +++ b/MonoHotDraw/MonoHotDraw.Tools/SelectAreaTool.cs @@ -98,7 +98,7 @@ private void DrawSelectionRect (Gtk.Widget widget, Gdk.Window window) private void SelectFiguresOnRect (IDrawingView view, bool shift_pressed) { - foreach (IFigure figure in view.Drawing.FiguresReversed) { + foreach (IFigure figure in view.Drawing.Figures) { RectangleD rect = figure.DisplayBox; if (selectionRectangle.Contains (rect.X, rect.Y) &&