本文整理汇总了C#中UIElement类的典型用法代码示例。如果您正苦于以下问题:C# UIElement类的具体用法?C# UIElement怎么用?C# UIElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIElement类属于命名空间,在下文中一共展示了UIElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WatermarkAdorner
/// <summary>
/// Initializes a new instance of the <see cref="WatermarkAdorner"/> class
/// </summary>
/// <param name="adornedElement"><see cref="UIElement"/> to be adorned</param>
/// <param name="watermark">The watermark</param>
public WatermarkAdorner(UIElement adornedElement, object watermark)
: base(adornedElement)
{
IsHitTestVisible = false;
contentPresenter = new ContentPresenter
{
Content = watermark,
Opacity = 0.5,
Margin = new Thickness(Control.Margin.Left + Control.Padding.Left, Control.Margin.Top + Control.Padding.Top, 0, 0)
};
if (Control is ItemsControl && !(Control is ComboBox))
{
contentPresenter.VerticalAlignment = VerticalAlignment.Center;
contentPresenter.HorizontalAlignment = HorizontalAlignment.Center;
}
// Hide the control adorner when the adorned element is hidden
var binding = new Binding("IsVisible")
{
Source = adornedElement,
Converter = new BooleanToVisibilityConverter()
};
SetBinding(VisibilityProperty, binding);
}
示例2: FindStoryboard
public BeginStoryboard FindStoryboard(UIElement element)
{
INameScope ns = FindNameScope();
if (ns != null)
return ns.FindName(BeginStoryboardName) as BeginStoryboard;
return null;
}
示例3: ToolBarButton
public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, IReadOnlyCollection<ICondition> conditions)
{
ToolTipService.SetShowOnDisabled(this, true);
this.codon = codon;
this.caller = caller;
if (createCommand)
this.Command = CommandWrapper.CreateCommand(codon, conditions);
else
this.Command = CommandWrapper.CreateLazyCommand(codon, conditions);
this.CommandParameter = caller;
this.Content = ToolBarService.CreateToolBarItemContent(codon);
this.conditions = conditions;
if (codon.Properties.Contains("name")) {
this.Name = codon.Properties["name"];
}
if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) {
KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]);
MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName());
this.inputGestureText = MenuService.GetDisplayStringForShortcut(kg);
}
UpdateText();
SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ButtonStyleKey);
}
示例4: ZoomableInlineAdornment
public ZoomableInlineAdornment(UIElement content, ITextView parent, Size desiredSize) {
_parent = parent;
Debug.Assert(parent is IInputElement);
_originalSize = _desiredSize = new Size(
Math.Max(double.IsNaN(desiredSize.Width) ? 100 : desiredSize.Width, 10),
Math.Max(double.IsNaN(desiredSize.Height) ? 100 : desiredSize.Height, 10)
);
// First time through, we want to reduce the image to fit within the
// viewport.
if (_desiredSize.Width > parent.ViewportWidth) {
_desiredSize.Width = parent.ViewportWidth;
_desiredSize.Height = _originalSize.Height / _originalSize.Width * _desiredSize.Width;
}
if (_desiredSize.Height > parent.ViewportHeight) {
_desiredSize.Height = parent.ViewportHeight;
_desiredSize.Width = _originalSize.Width / _originalSize.Height * _desiredSize.Height;
}
ContextMenu = MakeContextMenu();
Focusable = true;
MinWidth = MinHeight = 50;
Children.Add(content);
GotFocus += OnGotFocus;
LostFocus += OnLostFocus;
}
示例5: button_OnButtonClick
void button_OnButtonClick(UIElement button)
{
if (data != null)
{
owner.SelectedItem = data;
}
}
示例6: GetCanBeDragged
public static bool GetCanBeDragged(UIElement uiElement)
{
if (uiElement == null)
return false;
return (bool)uiElement.GetValue(CanBeDraggedProperty);
}
示例7: ElementsClipboardData
// The constructor which takes a FrameworkElement array.
internal ElementsClipboardData(UIElement[] elements)
{
if ( elements != null )
{
ElementList = new List<UIElement>(elements);
}
}
示例8: ZoomableInlineAdornment
public ZoomableInlineAdornment(UIElement content, ITextView parent) {
_parent = parent;
Debug.Assert(parent is IInputElement);
Content = new Border { BorderThickness = new Thickness(1), Child = content, Focusable = true };
_zoom = 1.0; // config.GetConfig().Repl.InlineMedia.MaximizedZoom
_zoomStep = 0.25; // config.GetConfig().Repl.InlineMedia.ZoomStep
_minimizedZoom = 0.25; // config.GetConfig().Repl.InlineMedia.MinimizedZoom
_widthRatio = 0.67; // config.GetConfig().Repl.InlineMedia.WidthRatio
_heightRatio = 0.5; // config.GetConfig().Repl.InlineMedia.HeightRatio
_isResizing = false;
UpdateSize();
GotFocus += OnGotFocus;
LostFocus += OnLostFocus;
ContextMenu = MakeContextMenu();
var trigger = new Trigger { Property = Border.IsFocusedProperty, Value = true };
var setter = new Setter { Property = Border.BorderBrushProperty, Value = SystemColors.ActiveBorderBrush };
trigger.Setters.Add(setter);
var style = new Style();
style.Triggers.Add(trigger);
MyContent.Style = style;
}
示例9: SetAnchorValue
private static void SetAnchorValue(UIElement e, int edge, int val)
{
e.VerifyAccess();
UIElement.Pair anchorInfo = e._anchorInfo;
if (anchorInfo == null)
{
anchorInfo = new UIElement.Pair();
e._anchorInfo = anchorInfo;
}
if ((edge & Edge_LeftRight) != 0)
{
anchorInfo._first = val;
anchorInfo._status &= ~Edge_LeftRight;
}
else
{
anchorInfo._second = val;
anchorInfo._status &= ~Edge_TopBottom;
}
anchorInfo._status |= edge;
if (e.Parent != null)
{
e.Parent.InvalidateArrange();
}
}
示例10: AddChildrenToGrid
private void AddChildrenToGrid(Grid grid, UIElement obj)
{
ColumnDefinition col = new ColumnDefinition();
grid.ColumnDefinitions.Add(col);
grid.Children.Add(obj);
Grid.SetColumn(obj, grid.Children.Count - 1);
}
示例11: ToDirections
public static Tuple<IObservable<Direction>, IObservable<Direction>> ToDirections(UIElement element)
{
return Tuple.Create(
ToDirections(element, "KeyDown"),
ToDirections(element, "KeyUp")
);
}
示例12: Initialize
public void Initialize(UIElement element)
{
this.child = element;
if (child != null)
{
TransformGroup group = new TransformGroup();
ScaleTransform st = new ScaleTransform();
group.Children.Add(st);
TranslateTransform tt = new TranslateTransform();
group.Children.Add(tt);
child.RenderTransform = group;
child.RenderTransformOrigin = new Point(0.0, 0.0);
child.MouseWheel += child_MouseWheel;
child.MouseLeftButtonDown += child_MouseLeftButtonDown;
child.MouseLeftButtonUp += child_MouseLeftButtonUp;
child.MouseMove += child_MouseMove;
child.PreviewMouseRightButtonDown += new MouseButtonEventHandler(child_PreviewMouseRightButtonDown);
}
}
示例13: SetVisible
public void SetVisible(bool visible)
{
if (_isVisible != visible)
{
if (visible)
{
// Сохранение контента
_parentContent = (UIElement)_parent.Content;
// Создание таблицы для инъекции в визуальное дерево
_grid = new Grid();
_parent.Content = _grid;
// Конфигурирование свойств
_parentContent.Opacity = 0.5;
_parentContent.IsEnabled = false;
// Инъекция таблицы
_grid.Children.Add(_parentContent);
_grid.Children.Add(this);
}
else
{
_parentContent.Opacity = 1;
_parentContent.IsEnabled = true;
_grid.Children.Clear();
_parent.Content = _parentContent;
}
_isVisible = visible;
}
}
示例14: Start
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer, string text)
{
Debug.Assert(services != null);
Debug.Assert(activeContainer != null);
DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel;
OptionService optionService = services.GetService<OptionService>();
if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
grayOut = new InfoTextEnterArea();
grayOut.designSurfaceRectangle = new RectangleGeometry(
new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height));
grayOut.designPanel = designPanel;
grayOut.adornerPanel = new AdornerPanel();
grayOut.adornerPanel.Order = AdornerOrder.Background;
grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
var tb = new TextBlock(){Text = text};
tb.FontSize = 10;
tb.ClipToBounds = true;
tb.Width = ((FrameworkElement) activeContainer).ActualWidth;
tb.Height = ((FrameworkElement) activeContainer).ActualHeight;
tb.VerticalAlignment = VerticalAlignment.Top;
tb.HorizontalAlignment = HorizontalAlignment.Left;
tb.RenderTransform = (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement);
grayOut.adornerPanel.Children.Add(tb);
designPanel.Adorners.Add(grayOut.adornerPanel);
}
}
示例15: ExpandViewPart
private void ExpandViewPart(UIElement viewPart, Grid hostGrid)
{
hostGrid.Children.Remove(viewPart);
this.Shelf.Children.Add(viewPart);
Grid.SetColumn(viewPart, 0);
Grid.SetColumnSpan(viewPart, 3);
}