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


C# Border.GetValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.Border.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Border.GetValue方法的具体用法?C# Border.GetValue怎么用?C# Border.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.Border的用法示例。


在下文中一共展示了Border.GetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnApplyTemplate


//.........这里部分代码省略.........
                    this.noteTextBlockPart.Visibility = Visibility.Visible;
                    ToolTipService.SetToolTip(this.noteTextBlockPart, nodeProxy.GetNodeMetadata(noteKey).MetadataValue);
                }
                else
                {
                    this.noteTextBlockPart.Visibility = Visibility.Collapsed;
                }
            }

            BitmapImage nodeImg = new BitmapImage();
            //for optimal memory usage and speed only create as many ImageBrush objects as there are images.
            if (ImageUrl != null)
            {
                if (!nodeImageCache.ContainsKey(ImageUrl))
                {
                    nodeImg.UriSource = new Uri(ImageUrl);

                    ImageBrush imageBrush = new ImageBrush();
                    imageBrush.ImageSource = nodeImg;

                    NodeImage = imageBrush;
                    nodeImageCache.Add(ImageUrl, imageBrush);
                }
                else
                {
                    NodeImage = nodeImageCache[ImageUrl];
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(NodeImageName))
                {
                    
                    switch (NodeImageName)
                    {
                        case "Map":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/network.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Pro":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/plus.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Con":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/minus.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Decision":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/generic.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Idea":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/exclamation.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Question":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/question.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        default:
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/generic.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                    }
                }
            }

            this.okButtonPart = GetTemplateChild(NodeControl.OkButtonPartName) as Button;
            this.cancelButtonPart = GetTemplateChild(NodeControl.CancelButtonPartName) as Button;

            if (this.textBlockBorderPart != null 
                && this.okButtonPart != null && this.cancelButtonPart != null)
            {
                double left = (double)textBlockBorderPart.GetValue(Canvas.LeftProperty);
                double top = (double)textBlockBorderPart.GetValue(Canvas.TopProperty);

                this.okButtonPart.SetValue(Canvas.LeftProperty, left + this.textBoxPart.Width - 100);
                this.okButtonPart.SetValue(Canvas.TopProperty, top + this.textBoxPart.Height);
                this.okButtonPart.Click += new RoutedEventHandler(OnNodeTextBoxOkClick);

                this.cancelButtonPart.SetValue(Canvas.LeftProperty, left + this.textBoxPart.Width - 50);
                this.cancelButtonPart.SetValue(Canvas.TopProperty, top + this.textBoxPart.Height);
                this.cancelButtonPart.Click += new RoutedEventHandler(OnNodeTextBoxCancelClick);
            }

            if (InEditState)
            {
                GoToState(NodeControl.EdittingStateName, false);
                if (this.textBoxPart != null)
                {
                    this.textBoxPart.Focus();
                }
            }
            else
            {
                this.GoToState(NodeControl.NormalStateName, false);
            }

            this.isTemplateApplied = true;
        }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:101,代码来源:NodeControl.cs

示例2: NCellMouseMove

        private void NCellMouseMove(object sender, NCellMouseEventArgs args)
        {
            if (args.MouseEventArgs.LeftButton == MouseButtonState.Pressed && _mouseDownNCell != null)
            {
                var currentNCell = GetNCellFromMousePosition(args.MouseEventArgs.GetPosition(this));
                if (currentNCell != null && !currentNCell.Equals(_mouseDownNCell) && !currentNCell.Equals(_lastMouseOverNCell))
                {
                    var mouseDownNCellRow = (int)_mouseDownNCell.GetValue(Grid.RowProperty);
                    var mouseDownNCellColumn = (int)_mouseDownNCell.GetValue(Grid.ColumnProperty);
                    var currentNCellRow = (int)currentNCell.GetValue(Grid.RowProperty);
                    var currentNCellColumn = (int)currentNCell.GetValue(Grid.ColumnProperty);

                    //计算绘制选中效果的矩形区域的起始点
                    Point startPoint, endPoint;
                    if (currentNCellRow >= mouseDownNCellRow)
                    {
                        if (currentNCellColumn >= mouseDownNCellColumn)
                        {
                            startPoint = _mouseDownNCell.TranslatePoint(new Point(), NCellContainer);
                            endPoint = currentNCell.TranslatePoint(new Point(currentNCell.ActualWidth, currentNCell.ActualHeight),
                                NCellContainer);
                        }
                        else
                        {
                            startPoint = _mouseDownNCell.TranslatePoint(new Point(_mouseDownNCell.ActualWidth, 0),
                                NCellContainer);
                            endPoint = currentNCell.TranslatePoint(new Point(0, currentNCell.ActualHeight), NCellContainer);
                        }
                    }
                    else
                    {
                        if (currentNCellColumn >= mouseDownNCellColumn)
                        {
                            startPoint = _mouseDownNCell.TranslatePoint(new Point(0, _mouseDownNCell.ActualHeight), NCellContainer);
                            endPoint = currentNCell.TranslatePoint(new Point(currentNCell.ActualWidth, 0), NCellContainer);
                        }
                        else
                        {
                            startPoint = _mouseDownNCell.TranslatePoint(new Point(_mouseDownNCell.ActualWidth, _mouseDownNCell.ActualHeight),
                                NCellContainer);
                            endPoint = currentNCell.TranslatePoint(new Point(0, 0), NCellContainer);
                        }
                    }

                    //设置选中效果
                    var leftMargin = Math.Min(startPoint.X, endPoint.X);
                    var topMargin = Math.Min(startPoint.Y, endPoint.Y);
                    _effectBorder = new Border() { BorderThickness = new Thickness(2), BorderBrush = Brushes.Blue };
                    _effectBorder.SetValue(Canvas.LeftProperty, leftMargin);
                    _effectBorder.SetValue(Canvas.TopProperty, topMargin);
                    _effectBorder.Width = Math.Abs(startPoint.X - endPoint.X);
                    _effectBorder.Height = Math.Abs(startPoint.Y - endPoint.Y);
                    _effectBorder.Background = Brushes.SkyBlue;
                    _effectBorder.Opacity = 0.3;

                    //当合并项处于选中边界时
                    var selectedRect = NTableUtils.BuildRect(startPoint, endPoint);
                    //标识经过合并项的处理,选中区域是否已改变,若已改变则重新扫描,是否有合并项处于边界
                    bool isSelectionRectChanged;
                    do
                    {
                        isSelectionRectChanged = false;
                        foreach (var mergeItem in _nTableData.MergeCollection)
                        {
                            var mergeItemRect = NTableUtils.TranslateBounds(mergeItem.RootNCell, NCellContainer);
                            if (NTableUtils.IsRectIntersect(selectedRect, mergeItemRect))
                            {
                                if (mergeItemRect.Y < selectedRect.Y)
                                {
                                    _effectBorder.SetValue(Canvas.TopProperty, mergeItemRect.Y);
                                    _effectBorder.Height += selectedRect.Y - mergeItemRect.Y;
                                }
                                if (mergeItemRect.X < selectedRect.X)
                                {
                                    _effectBorder.SetValue(Canvas.LeftProperty, mergeItemRect.X);
                                    _effectBorder.Width += selectedRect.X - mergeItemRect.X;
                                }

                                if (mergeItemRect.Right > selectedRect.Right)
                                {
                                    _effectBorder.Width += mergeItemRect.Right - selectedRect.Right;
                                }
                                if (mergeItemRect.Bottom > selectedRect.Bottom)
                                {
                                    _effectBorder.Height += mergeItemRect.Bottom - selectedRect.Bottom;
                                }
                                var newSelectionRect = new Rect((double)_effectBorder.GetValue(Canvas.LeftProperty), (double)_effectBorder.GetValue(Canvas.TopProperty), _effectBorder.Width, _effectBorder.Height);
                                if (newSelectionRect != selectedRect)
                                {
                                    selectedRect = newSelectionRect;
                                    isSelectionRectChanged = true;
                                }
                            }
                        }
                    } while (isSelectionRectChanged);

                    //实时更新选中的单元格集合
                    _selectedNCells.Clear();
                    var rows = _nTableData.Rows.Count;
                    var columns = _nTableData.Columns.Count;
//.........这里部分代码省略.........
开发者ID:erdao,项目名称:NTable,代码行数:101,代码来源:MainWindow.xaml.cs


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