Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
UIElementExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using SiliconStudio.Core.Mathematics;
4 using SiliconStudio.Paradox.UI.Panels;
5 
6 namespace SiliconStudio.Paradox.UI
7 {
8  /// <summary>
9  /// Extensions methods for <see cref="UIElement"/>
10  /// </summary>
11  public static class UIElementExtensions
12  {
13  /// <summary>
14  /// Sets the Panel Z-index value for this element.
15  /// The Panel Z-index value is used to determine which child of a same panel should be drawn on top.
16  /// </summary>
17  /// <remarks>Equivalent to set the <see cref="Panel.ZIndexPropertyKey"/> of the element</remarks>
18  /// <param name="element">The element</param>
19  /// <param name="index">The Panel Z-index value</param>
20  public static void SetPanelZIndex(this UIElement element, int index)
21  {
22  element.DependencyProperties.Set(Panel.ZIndexPropertyKey, index);
23  }
24 
25  /// <summary>
26  /// Sets the Panel Z-index value for this element.
27  /// The Panel Z-index value is used to determine which child of a same panel should be drawn on top.
28  /// </summary>
29  /// <remarks>Equivalent to get the <see cref="Panel.ZIndexPropertyKey"/> of the element</remarks>
30  /// <param name="element">The element</param>
31  /// <returns>The Panel Z-index value of the element</returns>
32  public static int GetPanelZIndex(this UIElement element)
33  {
34  return element.DependencyProperties.Get(Panel.ZIndexPropertyKey);
35  }
36 
37  /// <summary>
38  /// Sets the relative size of the element with respect to its parent canvas.
39  /// Set the value of any component to <value>float.NaN</value> to let the element measure itself in this axis.
40  /// </summary>
41  /// <remarks>Equivalent to set the <see cref="Canvas.RelativeSizePropertyKey"/> of the element</remarks>
42  /// <param name="element">The element</param>
43  /// <param name="size">The relative size of the element</param>
44  public static void SetCanvasRelativeSize(this UIElement element, Vector3 size)
45  {
46  element.DependencyProperties.Set(Canvas.RelativeSizePropertyKey, size);
47  }
48 
49  /// <summary>
50  /// Gets the relative size of the element with respect to its parent canvas. <value>float.NaN</value> when not specified.
51  /// </summary>
52  /// <remarks>Equivalent to get the <see cref="Canvas.RelativeSizePropertyKey"/> of the element</remarks>
53  /// <param name="element">The element</param>
54  /// <returns>The relative size of the element to its parent canvas</returns>
55  public static Vector3 GetCanvasRelativeSize(this UIElement element)
56  {
57  return element.DependencyProperties.Get(Canvas.RelativeSizePropertyKey);
58  }
59 
60  /// <summary>
61  /// Sets the relative position of the element into its parent canvas.
62  /// </summary>
63  /// <remarks>Equivalent to set the <see cref="Canvas.RelativePositionPropertyKey"/> of the element</remarks>
64  /// <param name="element">The element</param>
65  /// <param name="size">The relative position normalized between [0,1]</param>
66  public static void SetCanvasRelativePosition(this UIElement element, Vector3 size)
67  {
68  element.DependencyProperties.Set(Canvas.RelativePositionPropertyKey, size);
69  }
70 
71  /// <summary>
72  /// Gets the relative position of the element into its parent canvas. Position is normalized between [0,1].
73  /// </summary>
74  /// <remarks>Equivalent to get the <see cref="Canvas.RelativePositionPropertyKey"/> of the element</remarks>
75  /// <param name="element">The element</param>
76  /// <returns>The relative position of the element into its parent canvas</returns>
77  public static Vector3 GetCanvasRelativePosition(this UIElement element)
78  {
79  return element.DependencyProperties.Get(Canvas.RelativePositionPropertyKey);
80  }
81 
82  /// <summary>
83  /// Sets the absolute position of the element into its parent canvas.
84  /// </summary>
85  /// <remarks>Equivalent to set the <see cref="Canvas.AbsolutePositionPropertyKey"/> of the element</remarks>
86  /// <param name="element">The element</param>
87  /// <param name="size">The absolute position in virtual pixels</param>
88  public static void SetCanvasAbsolutePosition(this UIElement element, Vector3 size)
89  {
90  element.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, size);
91  }
92 
93  /// <summary>
94  /// Gets the absolute position of the element into its parent canvas. The position is in virtual pixels.
95  /// </summary>
96  /// <remarks>Equivalent to get the <see cref="Canvas.AbsolutePositionPropertyKey"/> of the element</remarks>
97  /// <param name="element">The element</param>
98  /// <returns>The absolute position of the element into its parent canvas</returns>
99  public static Vector3 GetCanvasAbsolutePosition(this UIElement element)
100  {
101  return element.DependencyProperties.Get(Canvas.AbsolutePositionPropertyKey);
102  }
103 
104  /// <summary>
105  /// Sets the origin of the element used when pinning it into its parent canvas.
106  /// This value is normalized between [0,1]. (0,0,0) represents the left/top/back corner, (1,1,1) represents the left/top/back corner, etc...
107  /// </summary>
108  /// <remarks>Equivalent to set the <see cref="Canvas.PinOriginPropertyKey"/> of the element</remarks>
109  /// <param name="element">The element</param>
110  /// <param name="size">The pin origin value</param>
111  public static void SetCanvasPinOrigin(this UIElement element, Vector3 size)
112  {
113  element.DependencyProperties.Set(Canvas.PinOriginPropertyKey, size);
114  }
115 
116  /// <summary>
117  /// Gets the origin of the element used when pinning it into its parent canvas.
118  /// This value is normalized between [0,1]. (0,0,0) represents the left/top/back corner, (1,1,1) represents the left/top/back corner, etc...
119  /// </summary>
120  /// <remarks>Equivalent to get the <see cref="Canvas.PinOriginPropertyKey"/> of the element</remarks>
121  /// <param name="element">The element</param>
122  /// <returns>The pin origin of the element</returns>
123  public static Vector3 GetCanvasPinOrigin(this UIElement element)
124  {
125  return element.DependencyProperties.Get(Canvas.PinOriginPropertyKey);
126  }
127 
128  /// <summary>
129  /// Sets the column index of the grid in which resides the element.
130  /// </summary>
131  /// <remarks>Equivalent to set the <see cref="GridBase.ColumnPropertyKey"/> of the element</remarks>
132  /// <param name="element">The element</param>
133  /// <param name="index">The 0-based column index</param>
134  public static void SetGridColumn(this UIElement element, int index)
135  {
136  element.DependencyProperties.Set(GridBase.ColumnPropertyKey, index);
137  }
138 
139  /// <summary>
140  /// Gets the column index of the grid in which resides the element.
141  /// </summary>
142  /// <remarks>Equivalent to get the <see cref="GridBase.ColumnPropertyKey"/> of the element</remarks>
143  /// <param name="element">The element</param>
144  /// <returns>The 0-based column index of the element</returns>
145  public static int GetGridColumn(this UIElement element)
146  {
147  return element.DependencyProperties.Get(GridBase.ColumnPropertyKey);
148  }
149 
150  /// <summary>
151  /// Sets the row index of the grid in which resides the element.
152  /// </summary>
153  /// <remarks>Equivalent to set the <see cref="GridBase.RowPropertyKey"/> of the element</remarks>
154  /// <param name="element">The element</param>
155  /// <param name="index">The 0-based row index</param>
156  public static void SetGridRow(this UIElement element, int index)
157  {
158  element.DependencyProperties.Set(GridBase.RowPropertyKey, index);
159  }
160 
161  /// <summary>
162  /// Gets the row index of the grid in which resides the element.
163  /// </summary>
164  /// <remarks>Equivalent to get the <see cref="GridBase.RowPropertyKey"/> of the element</remarks>
165  /// <param name="element">The element</param>
166  /// <returns>The 0-based row index of the element</returns>
167  public static int GetGridRow(this UIElement element)
168  {
169  return element.DependencyProperties.Get(GridBase.RowPropertyKey);
170  }
171 
172  /// <summary>
173  /// Sets the layer index of the grid in which resides the element.
174  /// </summary>
175  /// <remarks>Equivalent to set the <see cref="GridBase.LayerPropertyKey"/> of the element</remarks>
176  /// <param name="element">The element</param>
177  /// <param name="index">The 0-based layer index</param>
178  public static void SetGridLayer(this UIElement element, int index)
179  {
180  element.DependencyProperties.Set(GridBase.LayerPropertyKey, index);
181  }
182 
183  /// <summary>
184  /// Gets the layer index of the grid in which resides the element.
185  /// </summary>
186  /// <remarks>Equivalent to get the <see cref="GridBase.LayerPropertyKey"/> of the element</remarks>
187  /// <param name="element">The element</param>
188  /// <returns>The 0-based layer index of the element</returns>
189  public static int GetGridLayer(this UIElement element)
190  {
191  return element.DependencyProperties.Get(GridBase.LayerPropertyKey);
192  }
193 
194  /// <summary>
195  /// Sets the number of column spans that the element occupies in the grid.
196  /// </summary>
197  /// <remarks>Equivalent to set the <see cref="GridBase.ColumnSpanPropertyKey"/> of the element</remarks>
198  /// <param name="element">The element</param>
199  /// <param name="index">The number of column spans occupied</param>
200  public static void SetGridColumnSpan(this UIElement element, int index)
201  {
202  element.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, index);
203  }
204 
205  /// <summary>
206  /// Gets the number of column spans that the element occupies in the grid.
207  /// </summary>
208  /// <remarks>Equivalent to get the <see cref="GridBase.ColumnSpanPropertyKey"/> of the element</remarks>
209  /// <param name="element">The element</param>
210  /// <returns>The number column of spans occupied by the element</returns>
211  public static int GetGridColumnSpan(this UIElement element)
212  {
213  return element.DependencyProperties.Get(GridBase.ColumnSpanPropertyKey);
214  }
215 
216  /// <summary>
217  /// Sets the number of row spans that the element occupies in the grid.
218  /// </summary>
219  /// <remarks>Equivalent to set the <see cref="GridBase.RowSpanPropertyKey"/> of the element</remarks>
220  /// <param name="element">The element</param>
221  /// <param name="index">The number of row spans occupied</param>
222  public static void SetGridRowSpan(this UIElement element, int index)
223  {
224  element.DependencyProperties.Set(GridBase.RowSpanPropertyKey, index);
225  }
226 
227  /// <summary>
228  /// Gets the number of row spans that the element occupies in the grid.
229  /// </summary>
230  /// <remarks>Equivalent to get the <see cref="GridBase.RowSpanPropertyKey"/> of the element</remarks>
231  /// <param name="element">The element</param>
232  /// <returns>The number of row spans occupied by the element</returns>
233  public static int GetGridRowSpan(this UIElement element)
234  {
235  return element.DependencyProperties.Get(GridBase.RowSpanPropertyKey);
236  }
237 
238  /// <summary>
239  /// Sets the number of layer spans that the element occupies in the grid.
240  /// </summary>
241  /// <remarks>Equivalent to set the <see cref="GridBase.LayerSpanPropertyKey"/> of the element</remarks>
242  /// <param name="element">The element</param>
243  /// <param name="index">The number of layer spans occupied</param>
244  public static void SetGridLayerSpan(this UIElement element, int index)
245  {
246  element.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, index);
247  }
248 
249  /// <summary>
250  /// Gets the number of layer spans that the element occupies in the grid.
251  /// </summary>
252  /// <remarks>Equivalent to get the <see cref="GridBase.LayerSpanPropertyKey"/> of the element</remarks>
253  /// <param name="element">The element</param>
254  /// <returns>The number of layer spans occupied by the element</returns>
255  public static int GetGridLayerSpan(this UIElement element)
256  {
257  return element.DependencyProperties.Get(GridBase.LayerSpanPropertyKey);
258  }
259  }
260 }
static void SetCanvasPinOrigin(this UIElement element, Vector3 size)
Sets the origin of the element used when pinning it into its parent canvas. This value is normalized ...
static void SetGridRow(this UIElement element, int index)
Sets the row index of the grid in which resides the element.
Provides a base class for all the User Interface elements in Paradox applications.
Definition: UIElement.cs:21
static void SetPanelZIndex(this UIElement element, int index)
Sets the Panel Z-index value for this element. The Panel Z-index value is used to determine which chi...
static Vector3 GetCanvasRelativePosition(this UIElement element)
Gets the relative position of the element into its parent canvas. Position is normalized between [0...
static int GetPanelZIndex(this UIElement element)
Sets the Panel Z-index value for this element. The Panel Z-index value is used to determine which chi...
static void SetGridColumn(this UIElement element, int index)
Sets the column index of the grid in which resides the element.
static Vector3 GetCanvasAbsolutePosition(this UIElement element)
Gets the absolute position of the element into its parent canvas. The position is in virtual pixels...
static void SetGridLayer(this UIElement element, int index)
Sets the layer index of the grid in which resides the element.
static void SetGridRowSpan(this UIElement element, int index)
Sets the number of row spans that the element occupies in the grid.
Represents a three dimensional mathematical vector.
Definition: Vector3.cs:42
static int GetGridLayerSpan(this UIElement element)
Gets the number of layer spans that the element occupies in the grid.
static void SetCanvasRelativePosition(this UIElement element, Vector3 size)
Sets the relative position of the element into its parent canvas.
static void SetCanvasAbsolutePosition(this UIElement element, Vector3 size)
Sets the absolute position of the element into its parent canvas.
static void SetGridColumnSpan(this UIElement element, int index)
Sets the number of column spans that the element occupies in the grid.
static int GetGridColumnSpan(this UIElement element)
Gets the number of column spans that the element occupies in the grid.
static int GetGridRowSpan(this UIElement element)
Gets the number of row spans that the element occupies in the grid.
static void SetGridLayerSpan(this UIElement element, int index)
Sets the number of layer spans that the element occupies in the grid.
static int GetGridColumn(this UIElement element)
Gets the column index of the grid in which resides the element.
static Vector3 GetCanvasPinOrigin(this UIElement element)
Gets the origin of the element used when pinning it into its parent canvas. This value is normalized ...
_In_ size_t _In_ size_t size
Definition: DirectXTexP.h:175
static int GetGridRow(this UIElement element)
Gets the row index of the grid in which resides the element.
static void SetCanvasRelativeSize(this UIElement element, Vector3 size)
Sets the relative size of the element with respect to its parent canvas. Set the value of any compone...
static int GetGridLayer(this UIElement element)
Gets the layer index of the grid in which resides the element.
static Vector3 GetCanvasRelativeSize(this UIElement element)
Gets the relative size of the element with respect to its parent canvas. float.NaNwhen not specified...