本文整理汇总了C#中UIElement.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.ToString方法的具体用法?C# UIElement.ToString怎么用?C# UIElement.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateThumb_DragStarted
private void RotateThumb_DragStarted(object sender, DragStartedEventArgs e)
{
FrameworkElement adornedElement = this.AdornedElement as FrameworkElement;
this.designerItem = adornedElement as UIElement;
if (designerItem.ToString().Contains("RadioButton"))
{
if (this.designerItem != null)
{
this.canvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;
if (this.canvas != null)
{
this.centerPoint = this.designerItem.TranslatePoint(
new Point((this.designerItem as RadioButton).Width * this.designerItem.RenderTransformOrigin.X,
(this.designerItem as RadioButton).Height * this.designerItem.RenderTransformOrigin.Y),
this.canvas);
Point startPoint = Mouse.GetPosition(this.canvas);
this.startVector = Point.Subtract(startPoint, this.centerPoint);
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform == null)
{
this.designerItem.RenderTransform = new RotateTransform(0);
this.initialAngle = 0;
}
else
{
this.initialAngle = this.rotateTransform.Angle;
}
}
}
}
else if (designerItem.ToString().Contains("Button"))
{
if (this.designerItem != null)
{
this.canvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;
if (this.canvas != null)
{
this.centerPoint = this.designerItem.TranslatePoint(
new Point((this.designerItem as Button).Width * this.designerItem.RenderTransformOrigin.X,
(this.designerItem as Button).Height * this.designerItem.RenderTransformOrigin.Y),
this.canvas);
Point startPoint = Mouse.GetPosition(this.canvas);
this.startVector = Point.Subtract(startPoint, this.centerPoint);
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform == null)
{
this.designerItem.RenderTransform = new RotateTransform(0);
this.initialAngle = 0;
}
else
{
this.initialAngle = this.rotateTransform.Angle;
}
}
}
}
else if (designerItem.ToString().Contains("TextBox"))
{
if (this.designerItem != null)
{
this.canvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;
if (this.canvas != null)
{
this.centerPoint = this.designerItem.TranslatePoint(
new Point((this.designerItem as TextBox).Width * this.designerItem.RenderTransformOrigin.X,
(this.designerItem as TextBox).Height * this.designerItem.RenderTransformOrigin.Y),
this.canvas);
Point startPoint = Mouse.GetPosition(this.canvas);
this.startVector = Point.Subtract(startPoint, this.centerPoint);
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform == null)
{
this.designerItem.RenderTransform = new RotateTransform(0);
this.initialAngle = 0;
}
else
{
this.initialAngle = this.rotateTransform.Angle;
}
}
}
}
else if (designerItem.ToString().Contains("Image"))
{
if (this.designerItem != null)
{
this.canvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;
if (this.canvas != null)
{
this.centerPoint = this.designerItem.TranslatePoint(
new Point((this.designerItem as Image).Width * this.designerItem.RenderTransformOrigin.X,
(this.designerItem as Image).Height * this.designerItem.RenderTransformOrigin.Y),
this.canvas);
Point startPoint = Mouse.GetPosition(this.canvas);
this.startVector = Point.Subtract(startPoint, this.centerPoint);
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (this.rotateTransform == null)
{
this.designerItem.RenderTransform = new RotateTransform(0);
//.........这里部分代码省略.........
示例2: AddElement
/// <summary>
/// Inspects a specific element and adds it to the list
/// </summary>
/// <param name="element">The element.</param>
/// <param name="collection">The collection.</param>
/// <param name="rootView">The root view.</param>
private static void AddElement(UIElement element, ObservableCollection<UIElementViewModel> collection, UIElement rootView)
{
var parts1 = element.ToString().Split(' ');
var parts2 = parts1[0].Split('.');
var elementName = parts2[parts2.Length - 1].Replace(":", "");
var content = string.Empty;
if (parts1.Length > 1) content = parts1[1];
var cc = element as ContentControl;
if (cc != null && cc.Content != null)
content = cc.Content.ToString();
var newElement = new UIElementViewModel(rootView)
{
Name = elementName,
Content = content,
Type = element.GetType().ToString(),
UIElement = element
};
var contentControl = element as ContentControl;
if (contentControl != null)
{
if (contentControl.Content is UIElement)
AddElement(contentControl.Content as UIElement, newElement.Elements, rootView);
}
else
{
var childControl = element as Panel;
if (childControl != null)
foreach (var child in childControl.Children)
{
if (child is UIElement)
AddElement(child as UIElement, newElement.Elements, rootView);
}
else
{
var itemsControl = element as ItemsControl;
if (itemsControl != null)
foreach (var item in itemsControl.Items)
if (item is UIElement)
AddElement(item as UIElement, newElement.Elements, rootView);
}
}
collection.Add(newElement);
}