当前位置: 首页>>代码示例>>C#>>正文


C# UIElement类代码示例

本文整理汇总了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);
        }
开发者ID:Slesa,项目名称:Poseidon,代码行数:31,代码来源:WatermarkAdorner.cs

示例2: FindStoryboard

 public BeginStoryboard FindStoryboard(UIElement element)
 {
   INameScope ns = FindNameScope();
   if (ns != null)
     return ns.FindName(BeginStoryboardName) as BeginStoryboard;
   return null;
 }
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:7,代码来源:StoryboardContinuationTrigger.cs

示例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);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:27,代码来源:ToolBarButton.cs

示例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;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:29,代码来源:ZoomableInlineAdornment.cs

示例5: button_OnButtonClick

 void button_OnButtonClick(UIElement button)
 {
     if (data != null)
     {
         owner.SelectedItem = data;
     }
 }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:7,代码来源:UIGridViewerRender.cs

示例6: GetCanBeDragged

        public static bool GetCanBeDragged(UIElement uiElement)
        {
            if (uiElement == null)
                return false;

            return (bool)uiElement.GetValue(CanBeDraggedProperty);
        }
开发者ID:alexguirre,项目名称:Emergency-Strobes,代码行数:7,代码来源:DragCanvas.cs

示例7: ElementsClipboardData

 // The constructor which takes a FrameworkElement array.
 internal ElementsClipboardData(UIElement[] elements)
 {
     if ( elements != null ) 
     {
         ElementList = new List<UIElement>(elements); 
     } 
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:8,代码来源:ElementsClipboardData.cs

示例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;
        }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:27,代码来源:ZoomableInlineAdornment.cs

示例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();
            }
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:29,代码来源:Canvas.cs

示例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);
 }
开发者ID:vesteksoftware,项目名称:Common_VT5061,代码行数:7,代码来源:PageDebugViewState.xaml.cs

示例11: ToDirections

 public static Tuple<IObservable<Direction>, IObservable<Direction>> ToDirections(UIElement element)
 {
     return Tuple.Create(
         ToDirections(element, "KeyDown"),
         ToDirections(element, "KeyUp")
         );
 }
开发者ID:markrendle,项目名称:Aggro,代码行数:7,代码来源:KeyToDirectionConverter.cs

示例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);
            }
        }
开发者ID:Slowhobo,项目名称:path-of-exile-skilltree-planer,代码行数:25,代码来源:ZoomBorder.cs

示例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;
            }
        }
开发者ID:kav-it,项目名称:SharpLib,代码行数:30,代码来源:BusyIndicator.Control.xaml.cs

示例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);
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:28,代码来源:InfoTextEnterArea.cs

示例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);
 }
开发者ID:willy2358,项目名称:iBooks,代码行数:7,代码来源:ShelfFrameView.xaml.cs


注:本文中的UIElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。