• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UIElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UIElement的典型用法代码示例。如果您正苦于以下问题:C# UIElement类的具体用法?C# UIElement怎么用?C# UIElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UIElement类属于命名空间,在下文中一共展示了UIElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: SetMouseHandlersForElement

 /// <summary>
 /// Sets the mouse handlers for element. Mouse hover handler is added to change the helpful text, and click handler is
 /// added to open the color picker.
 /// When the color is saved, it updates the theme, and applies it.
 /// </summary>
 /// <param name="themeKey">The theme key (as per the json theme).</param>
 /// <param name="hoverText">The hover text.</param>
 /// <param name="element">The element on which we add hover and click handlers.</param>
 private void SetMouseHandlersForElement(string themeKey, string hoverText, UIElement element)
 {
     if (element == null) {
         return;
     }
     // change the instruction text to hoverText
     element.IsMouseDirectlyOverChanged += (sender, e) =>
     {
         if (ViewModel.Editable && (bool) e.NewValue) {
             // mouse is now directly over this element, show the helpful text to the user so they know what they are hovering
             HoveredElementInfo.Text = hoverText;
             return;
         }
         // mouse is no longer directly over this element
         HoveredElementInfo.Text = "";
     };
     // handle onclick
     element.PreviewMouseDown += (sender, e) =>
     {
         // the rhs of the OR is a hack because TextBox elements have child element of TextBoxView (internal), its ugly, needs improvement
         var isCorrectElement = e.OriginalSource.Equals(element) ||
                                (element.GetType() == typeof (TextBox) &&
                                 e.OriginalSource.GetType().Name == "TextBoxView");
         if (ViewModel.Editable && isCorrectElement) {
             // mouse is now directly over this element, show the helpful text to the user so they know what they are hovering
             ViewModel.ShowColorPicker(Window.GetWindow(this), hoverText, themeKey);
             e.Handled = true;
         }
     };
 }
开发者ID:jameshy,项目名称:else,代码行数:38,代码来源:ThemeEditor.xaml.cs


示例17: DropPreviewAdorner

 /// <summary>
 /// Initializes a new instance of the <see cref="DropPreviewAdorner"/> class.
 /// </summary>
 /// <param name="feedbackUI">The UI element used as feedback element.</param>
 /// <param name="adornedElement">The element to bind the adorner to.</param>
 public DropPreviewAdorner(UIElement feedbackUI, UIElement adornedElement)
     : base(adornedElement)
 {
     m_Presenter = new ContentPresenter();
     m_Presenter.Content = feedbackUI;
     m_Presenter.IsHitTestVisible = false;
 }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:12,代码来源:DropPreviewAdorner.cs


示例18: DisconnectedUIElementCollection

 private DisconnectedUIElementCollection(UIElement owner, SurrogateVisualParent surrogateVisualParent)
     : base(surrogateVisualParent, null)
 {
     _ownerPanel = owner as Panel;
     surrogateVisualParent.InitializeOwner(this);
     _elements = new Collection<UIElement>();
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:7,代码来源:DisconnectedUIElementCollection.cs


示例19: Start

        public static void Start(UIElement element)
        {
            if (Element != null)
                throw new Exception("Another element is being dragged.  Only one element at a time may be dragged.");

            Element = element;
            Element.CaptureMouse();
            Element.MouseMove += new MouseEventHandler(UIElement_MouseMove);

            TransformGroup tg = Element.RenderTransform as TransformGroup;
            if (tg == null)
            {
                tg = CreateTransformGroup();
                Element.RenderTransform = tg;

            }//end if

            TranslateTransform tt = tg.Children.Where(t => t is TranslateTransform).SingleOrDefault() as TranslateTransform;
            if (tt == null)
                tt = new TranslateTransform();

            tt.X = 0;
            tt.Y = 0;

            OnDragStarted(Element);
        }
开发者ID:jsmithorg,项目名称:Dragging,代码行数:26,代码来源:Drag.cs


示例20: SetLabelMaxMovingDistance

 internal static void SetLabelMaxMovingDistance(XYChartArea chartArea, UIElement element)
 {
     double maximumMovingDistance = 0.0;
     if (chartArea.Orientation == Orientation.Horizontal)
         maximumMovingDistance = 40.0;
     AnchorPanel.SetMaximumMovingDistance(element, maximumMovingDistance);
 }
开发者ID:sulerzh,项目名称:chart,代码行数:7,代码来源:ColumnSeriesLabelPresenter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UIElementInfo类代码示例发布时间:2022-05-24
下一篇:
C# UIEdgeInsets类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap