Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/IndividualArrangePanel.cs @ 13792

Last change on this file since 13792 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 3.4 KB
RevLine 
[12503]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6using System.Windows.Media;
7using System.Collections.Specialized;
8using System.Collections;
9using System.ComponentModel;
10using System.Windows.Controls;
11
12namespace Microsoft.Research.DynamicDataDisplay.Common
13{
14  /// <summary>
15  /// Represents a custom Panel, which performs Arrange of its children independently, and does not remeasure or rearrange itself or all children when one child is
16  /// added or removed.
17  /// Is intended to be a base class for special layout panels, in which each childr is arranged independently from each other child,
18  /// e.g. panel with child's position viewport bound to a rectangle in viewport coordinates.
19  /// </summary>
20  public abstract class IndividualArrangePanel : Panel
21  {
22    private bool inBatchAdd = false;
23
24    /// <summary>
25    /// Initializes a new instance of the <see cref="IndependentArrangePanel"/> class.
26    /// </summary>
27    protected IndividualArrangePanel() { }
28
29    private UIChildrenCollection children;
30    /// <summary>
31    /// Creates a new <see cref="T:System.Windows.Controls.UIElementCollection"/>.
32    /// </summary>
33    /// <param name="logicalParent">The logical parent element of the collection to be created.</param>
34    /// <returns>
35    /// An ordered collection of elements that have the specified logical parent.
36    /// </returns>
37    protected sealed override UIElementCollection CreateUIElementCollection(FrameworkElement logicalParent)
38    {
39      children = new UIChildrenCollection(this, logicalParent);
40      children.IsAddingMany = inBatchAdd;
41      return children;
42    }
43
44    public bool InBatchAdd
45    {
46      get { return children.IsAddingMany; }
47    }
48
49    public virtual void BeginBatchAdd()
50    {
51      if (children == null)
52      {
53        inBatchAdd = true;
54        return;
55      }
56
57      children.IsAddingMany = true;
58    }
59
60    public virtual void EndBatchAdd()
61    {
62      children.IsAddingMany = false;
63    }
64
65    /// <summary>
66    /// Called when child is added.
67    /// </summary>
68    /// <param name="child">The added child.</param>
69    protected internal virtual void OnChildAdded(FrameworkElement child) { }
70
71    #region Overrides
72
73    /// <summary>
74    /// Overrides <see cref="M:System.Windows.Media.Visual.GetVisualChild(System.Int32)"/>, and returns a child at the specified index from a collection of child elements.
75    /// </summary>
76    /// <param name="index">The zero-based index of the requested child element in the collection.</param>
77    /// <returns>
78    /// The requested child element. This should not return null; if the provided index is out of range, an exception is thrown.
79    /// </returns>
80    protected sealed override Visual GetVisualChild(int index)
81    {
82      return Children[index];
83    }
84
85    /// <summary>
86    /// Gets the number of visual child elements within this element.
87    /// </summary>
88    /// <value></value>
89    /// <returns>
90    /// The number of visual child elements for this element.
91    /// </returns>
92    protected sealed override int VisualChildrenCount
93    {
94      get { return Children.Count; }
95    }
96
97    /// <summary>
98    /// Gets an enumerator for logical child elements of this element.
99    /// </summary>
100    /// <value></value>
101    /// <returns>
102    /// An enumerator for logical child elements of this element.
103    /// </returns>
104    protected sealed override IEnumerator LogicalChildren
105    {
106      get
107      {
108        return Children.GetEnumerator();
109      }
110    }
111
112    #endregion
113  }
114}
Note: See TracBrowser for help on using the repository browser.