using System.Collections; using System.Collections.Generic; using System.Drawing; namespace Cyotek.Windows.Forms.Demo { // Cyotek ImageBox // Copyright (c) 2010-2015 Cyotek Ltd. // http://cyotek.com // http://cyotek.com/blog/tag/imagebox // Licensed under the MIT License. See license.txt for the full text. // If you use this control in your applications, attribution, donations or contributions are welcome. internal sealed class DragHandleCollection : IEnumerable { #region Instance Fields private readonly IDictionary _items; #endregion #region Public Constructors public DragHandleCollection() { _items = new Dictionary(); _items.Add(DragHandleAnchor.TopLeft, new DragHandle(DragHandleAnchor.TopLeft)); _items.Add(DragHandleAnchor.TopCenter, new DragHandle(DragHandleAnchor.TopCenter)); _items.Add(DragHandleAnchor.TopRight, new DragHandle(DragHandleAnchor.TopRight)); _items.Add(DragHandleAnchor.MiddleLeft, new DragHandle(DragHandleAnchor.MiddleLeft)); _items.Add(DragHandleAnchor.MiddleRight, new DragHandle(DragHandleAnchor.MiddleRight)); _items.Add(DragHandleAnchor.BottomLeft, new DragHandle(DragHandleAnchor.BottomLeft)); _items.Add(DragHandleAnchor.BottomCenter, new DragHandle(DragHandleAnchor.BottomCenter)); _items.Add(DragHandleAnchor.BottomRight, new DragHandle(DragHandleAnchor.BottomRight)); } #endregion #region Public Properties public int Count { get { return _items.Count; } } public DragHandle this[DragHandleAnchor index] { get { return _items[index]; } } #endregion #region Public Members /// /// Returns an enumerator that iterates through the collection. /// /// /// A that can be used to iterate through the collection. /// public IEnumerator GetEnumerator() { return _items.Values.GetEnumerator(); } public DragHandleAnchor HitTest(Point point) { DragHandleAnchor result; result = DragHandleAnchor.None; foreach (DragHandle handle in this) { if (handle.Visible && handle.Bounds.Contains(point)) { result = handle.Anchor; break; } } return result; } #endregion #region IEnumerable Members /// /// Returns an enumerator that iterates through a collection. /// /// /// An object that can be used to iterate through the collection. /// IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } #endregion } }