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


C# Border.SetValue方法代码示例

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


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

示例1: InitCells

        public void InitCells()
        {
            int iPos;
            Border border;
            Brush brushDark;
            Brush brushLite;

            arrBorder = new Border[64];
            iPos = 63;
            brushDark = new SolidColorBrush(DarkCellColor);
            brushLite = new SolidColorBrush(LiteCellColor);
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    border = new Border();
                    border.Name = "Cell" + (iPos.ToString());
                    border.BorderThickness = new Thickness(20);
                    border.Background = (((x + y) & 1) == 0) ? brushLite : brushDark;
                    border.BorderBrush = border.Background;
                    border.SetValue(Grid.ColumnProperty, x);
                    border.SetValue(Grid.RowProperty, y);
                    arrBorder[iPos] = border;
                    CellContainer.Children.Add(border);
                    iPos--;
                }
            }
        }
开发者ID:Beginner7,项目名称:Command3,代码行数:28,代码来源:BoardControl.xaml.cs

示例2: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            var style = _grid.Resources["Cell"] as Style;

            for (int r = 0; r < Grid.LENGTH; r++)
            {
                for (int c = 0; c < Grid.LENGTH; c++)
                {
                    var block = new TextBlock { Style = style };
                    _blocks[r, c] = block;

                    var border = new Border
                    {
                        BorderThickness = new Thickness(1),
                        BorderBrush = Brushes.Black,
                        Child = block
                    };
                    border.SetValue(System.Windows.Controls.Grid.RowProperty, r + 1);
                    border.SetValue(System.Windows.Controls.Grid.ColumnProperty, c + 1);
                    _grid.Children.Add(border);
                }
            }

            Model.AttachActionTo(nameof(Model.Grid), BindCells);
            _dataGrid = Model.Grid;
            BindCells();
        }
开发者ID:vzabavnov,项目名称:Sudoku,代码行数:28,代码来源:MainWindow.xaml.cs

示例3: showFields

 private void showFields()
 {
     Border border = new Border()
     {
         Opacity = 1,
         BorderBrush = new SolidColorBrush(Colors.LightGray),
         BorderThickness = new Thickness((double)3),
         CornerRadius = new CornerRadius(10),
         Width = 472,
         Height = 336,
         Margin = new Thickness(0,8,170,0),
     };
     border.SetValue(Canvas.LeftProperty,(double)-3);
     border.SetValue(Canvas.TopProperty, (double)-11);
     canvas1.Children.Add(border);
     canvas1.Background = new SolidColorBrush(Colors.Black);
     textBlock1.FontFamily = new FontFamily("Tahoma");
     textBlock1.Foreground = new SolidColorBrush(Colors.White);
     textBlock2.FontFamily = new FontFamily("Tahoma");
     textBlock2.Foreground = new SolidColorBrush(Colors.White);
     textBlock3.FontFamily = new FontFamily("Tahoma");
     textBlock3.Foreground = new SolidColorBrush(Colors.White);
     textBlock4.FontFamily = new FontFamily("Tahoma");
     textBlock4.Foreground = new SolidColorBrush(Color.FromArgb(255, 139, 146, 5));
     textBlock4.Cursor = Cursors.Hand;
     textBlock4.MouseLeftButtonDown += new MouseButtonEventHandler(textBlock4_MouseLeftButtonDown);
     textBlock4.MouseEnter += new MouseEventHandler(textBlock4_MouseEnter);
     textBlock4.MouseLeave += new MouseEventHandler(textBlock4_MouseLeave);
 }
开发者ID:tigerss,项目名称:Grow-Romania,代码行数:29,代码来源:ExtendedDescription.xaml.cs

示例4: InitGrid

        private void InitGrid()
        {
            var first = true;
            _gridPlace.ColumnDefinitions.Clear();
            _gridPlace.RowDefinitions.Clear();
            _gridPlace.Width = _place.GetLength(0)*10;
            _gridPlace.Height = _place.GetLength(1)*10;

            for (var i = 0; i < _place.GetLength(0); i++)
            {
                _gridPlace.ColumnDefinitions.Add(new ColumnDefinition());
                for (var j = 0; j < _place.GetLength(1); j++)
                {
                    if (first) _gridPlace.RowDefinitions.Add(new RowDefinition());
                    var border = new Border();
                    border.SetValue(Grid.RowProperty, i);
                    border.SetValue(Grid.ColumnProperty, j);
                    border.MouseLeftButtonUp += ChangeToSeat;
                    border.MouseRightButtonUp += ChangeToTable;
                    border.Style = _gridPlace.FindResource("Empty") as Style;
                    _gridPlace.Children.Add(border);
                }
                first = false;
            }
        }
开发者ID:Bumper03,项目名称:RestApp,代码行数:25,代码来源:RestaurantViewModel.cs

示例5: Box

            public Box(int row, int col, Grid containingGrid, IList<Box> boxList, TextBlock textBox, WebLayoutChangerAction action)
            {
                _boxList = boxList;
                _grid = containingGrid;
                _textBox = textBox;
                _action = action;

                Row = row;
                Column = col;

                TheBorder = new Border();
                TheBorder.Style = System.Windows.Application.Current.Resources[Key_ToolLayout_BoxBorderStyle] as Style;

                TheRectangle = new System.Windows.Shapes.Rectangle();
                TheRectangle.Style = System.Windows.Application.Current.Resources[Key_ToolLayout_BoxNormalStyle] as Style;

                TheBorder.Child = TheRectangle;
                TheBorder.SetValue(Grid.RowProperty, row);
                TheBorder.SetValue(Grid.ColumnProperty, Column);
            
                _grid.Children.Add(TheBorder);
                
                TheRectangle.MouseEnter += TheRectangle_MouseEnter;
                _grid.MouseLeave += Grid_MouseLeave;

                TheRectangle.MouseLeftButtonUp += TheRectangle_MouseLeftButtonUp;
            }
开发者ID:nhannd,项目名称:Xian,代码行数:27,代码来源:LayoutPopup.xaml.cs

示例6: OnShowBorderChanged

        private static void OnShowBorderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
            var grid = d as Grid;
            if ((bool)e.OldValue) {
                grid.Loaded -= (s, arg) => { };
            }

            if ((bool)e.NewValue) {
                grid.Loaded += (s, arg) => {

                    //确定行数和列数
                    var rows = grid.RowDefinitions.Count;
                    var columns = grid.ColumnDefinitions.Count;

                    var controls = grid.Children;
                    var count = controls.Count;


                    for (int i = 0; i < count; i++) {

                        var item = controls[i] as FrameworkElement;
                        Border border = new Border();
                        border.BorderBrush = BorderBrush;
                        border.BorderThickness = new Thickness(0, 0, BorderThickness, BorderThickness);
                       
                        var row = Grid.GetRow(item);
                        var column = Grid.GetColumn(item);
                        var rowspan = Grid.GetRowSpan(item);
                        var columnspan = Grid.GetColumnSpan(item);

                        Grid.SetRow(border, row);
                        Grid.SetColumn(border, column);
                        Grid.SetRowSpan(border, rowspan);
                        Grid.SetColumnSpan(border, columnspan);

                        grid.Children.Add(border);
                    }


                    //画最外面的边框
                    Border bo = new Border();
                    bo.BorderBrush = BorderBrush;
                
                    bo.BorderThickness = new Thickness(BorderThickness, BorderThickness, 0, 0);
                    bo.SetValue(Grid.ColumnProperty, 0);
                    bo.SetValue(Grid.RowProperty, 0);

                    bo.SetValue(Grid.ColumnSpanProperty, grid.ColumnDefinitions.Count);
                    bo.SetValue(Grid.RowSpanProperty, grid.RowDefinitions.Count);


                    grid.Children.Add(bo);
                };

            }
        }
开发者ID:ychost,项目名称:PowerControlSimulation,代码行数:55,代码来源:GridBorderUtils.cs

示例7: CreateGrid

        protected virtual void CreateGrid(Grid heatmapGrid)
        {
            ColumnDefinition headerColumn = new ColumnDefinition();
            headerColumn.Width = new GridLength(60);
            heatmapGrid.ColumnDefinitions.Add(headerColumn);

            for (int i = 0; i < HeatMapSource.Columns; ++i)
            {
                ColumnDefinition dc = new ColumnDefinition();
                dc.Width = new GridLength(30);
                heatmapGrid.ColumnDefinitions.Add(dc);

                Border columnBorder = new Border();
                columnBorder.BorderThickness = new Thickness(0.5);
                columnBorder.BorderBrush = Brushes.White;
                columnBorder.SetValue(Grid.ColumnProperty, i + 1);
                columnBorder.SetValue(Grid.RowProperty, 1);
                columnBorder.SetValue(Grid.RowSpanProperty, HeatMapSource.Rows);
                columnBorder.SetValue(Panel.ZIndexProperty, 255);
                heatmapGrid.Children.Add(columnBorder);
            }

            ColumnDefinition rightColumn = new ColumnDefinition();
            rightColumn.Width = new GridLength(30);
            heatmapGrid.ColumnDefinitions.Add(rightColumn);

            RowDefinition topRow = new RowDefinition();
            topRow.Height = new GridLength(30);
            heatmapGrid.RowDefinitions.Add(topRow);

            for (int i = 0; i < HeatMapSource.Rows; ++i)
            {
                RowDefinition dr = new RowDefinition();
                dr.Height = new GridLength(30);
                heatmapGrid.RowDefinitions.Add(dr);

                Border rowBorder = new Border();
                rowBorder.BorderThickness = new Thickness(0.5);
                rowBorder.BorderBrush = Brushes.White;
                rowBorder.SetValue(Grid.RowProperty, i+1);
                rowBorder.SetValue(Grid.ColumnProperty, 1);
                rowBorder.SetValue(Grid.ColumnSpanProperty, HeatMapSource.Columns);
                rowBorder.SetValue(Panel.ZIndexProperty, 255);

                heatmapGrid.Children.Add(rowBorder);
            }

            RowDefinition headerRow = new RowDefinition();
            headerRow.Height = new GridLength(60);
            heatmapGrid.RowDefinitions.Add(headerRow);
        }
开发者ID:sac16controllertester,项目名称:ControllerTester,代码行数:51,代码来源:HeatMapControlBase.cs

示例8: setBorder

        public static Border setBorder( int row, int col )
        {
            Border border = new Border();

              if( row != 0 && row % 2 == 0 )
            border.Background = new SolidColorBrush( Color.FromArgb( 255, 164, 194, 220 ) );
              else
            border.Background = new SolidColorBrush( Color.FromArgb( 255, 186, 214, 235 ) );

              border.BorderThickness = new Thickness( 0, 0, col == 2 ? 0 : 1, 0 );
              border.BorderBrush = new SolidColorBrush( Colors.White );
              border.SetValue( Grid.RowProperty, row );
              border.SetValue( Grid.ColumnProperty, col );
              return border;
        }
开发者ID:keyanmca,项目名称:fameLive,代码行数:15,代码来源:ViewHelper.cs

示例9: setBorderTOTextBox

 public static Border setBorderTOTextBox( int row, int col )
 {
     Border border = new Border();
       border.Background = new SolidColorBrush( Colors.White );
       border.Margin = new Thickness( 5, 0, 0, 0 );
       //border.CornerRadius = new CornerRadius( 6 );
       border.HorizontalAlignment = HorizontalAlignment.Left;
       border.VerticalAlignment = VerticalAlignment.Center;
       //border.Height = 20;
       //border.Width = 150;
       border.OpacityMask = new SolidColorBrush( Colors.White );
       border.BorderThickness = new Thickness( 1, 1, 1, 1 );
       border.BorderBrush = new SolidColorBrush( Colors.White );
       border.SetValue( Grid.RowProperty, row );
       border.SetValue( Grid.ColumnProperty, col );
       return border;
 }
开发者ID:keyanmca,项目名称:fameLive,代码行数:17,代码来源:ViewHelper.cs

示例10: RenderLabel

        public static UIElement RenderLabel(Geometries.Point position, LabelStyle labelStyle, IViewport viewport, 
            string labelText)
        {
            var screenPosition = viewport.WorldToScreen(position);
            var windowsPosition = screenPosition.ToXaml();

            // Set some defaults which should be configurable someday
            const double witdhMargin = 3.0;
            const double heightMargin = 0.0;

            var textblock = new TextBlock
            {
                Text = labelText,
                Foreground = new SolidColorBrush(labelStyle.ForeColor.ToXaml()),
                FontFamily = new FontFamily(labelStyle.Font.FontFamily),
                FontSize = labelStyle.Font.Size,
                Margin = new Thickness(witdhMargin, heightMargin, witdhMargin, heightMargin)
            };

            var border = new Border
            {
                Background = labelStyle.BackColor.ToXaml(),
                CornerRadius = new CornerRadius(4),
                Child = textblock
            };

            double textWidth;
            double textHeight;

            DetermineTextWidthAndHeightWpf(out textWidth, out textHeight, labelStyle, labelText);

            border.SetValue(Canvas.LeftProperty, windowsPosition.X + labelStyle.Offset.X
                - (textWidth + 2 * witdhMargin) * (short)labelStyle.HorizontalAlignment * 0.5f);
            border.SetValue(Canvas.TopProperty, windowsPosition.Y + labelStyle.Offset.Y
                - (textHeight + 2 * heightMargin) * (short)labelStyle.VerticalAlignment * 0.5f);

            return border;
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:38,代码来源:SingleLabelRenderer.cs

示例11: InitializeBusyIndicator

        partial void InitializeBusyIndicator()
        {
            if (_busyIndicator != null)
            {
                return;
            }

            _grid = new Grid();
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });

            var backgroundBorder = new Border();
            backgroundBorder.Background = new SolidColorBrush(Colors.Gray);
            backgroundBorder.Opacity = 0.5;
            backgroundBorder.SetValue(Grid.RowSpanProperty, 4);
            _grid.Children.Add(backgroundBorder);

            _statusTextBlock = new TextBlock();
            _statusTextBlock.Style = (Style)Application.Current.Resources["PhoneTextNormalStyle"];
            _statusTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            _statusTextBlock.SetValue(Grid.RowProperty, 1);
            _grid.Children.Add(_statusTextBlock);

            _busyIndicator = ConstructBusyIndicator();
            _busyIndicator.SetValue(Grid.RowProperty, 2);
            _grid.Children.Add(_busyIndicator);

            _containerPopup = new Popup();
            _containerPopup.VerticalAlignment = VerticalAlignment.Center;
            _containerPopup.HorizontalAlignment = HorizontalAlignment.Center;
            _containerPopup.Child = _grid;

            double rootWidth = Application.Current.Host.Content.ActualWidth;
            double rootHeight = Application.Current.Host.Content.ActualHeight;

            _busyIndicator.Width = rootWidth;

            _grid.Width = rootWidth;
            _grid.Height = rootHeight;

            _containerPopup.UpdateLayout();

            return;
        }
开发者ID:justdude,项目名称:DbExport,代码行数:46,代码来源:PleaseWaitService.wpsl.cs

示例12: PdbViewer

        /// <summary>
        /// Initializes a new instance of the <see cref="PdbViewer"/> class and 
        /// sets up its child controls and other visual elements.
        /// </summary>
        internal PdbViewer()
        {
            Grid layoutGrid = new Grid();
            this.Content = layoutGrid;

            RowDefinition rowDefinition = new RowDefinition();
            rowDefinition.Height = GridLength.Auto;
            layoutGrid.RowDefinitions.Add(rowDefinition);

            layoutGrid.RowDefinitions.Add(new RowDefinition());

            this.structureControl = new StructureControl(this);
            this.structureControl.PdbViewer = this;
            this.structureControl.SetValue(Grid.RowSpanProperty, 2);
            layoutGrid.Children.Add(this.structureControl);

            this.residueControl = new ResidueControl();
            this.residueControl.PdbViewer = this;
            this.residueControl.VerticalAlignment = VerticalAlignment.Top;
            layoutGrid.Children.Add(this.residueControl);

            Border strctureCaptureBorder = new Border();
            strctureCaptureBorder.Background = Brushes.Transparent;
            strctureCaptureBorder.SetValue(Grid.RowProperty, 1);
            layoutGrid.Children.Add(strctureCaptureBorder);
            this.structureControl.CaptureElement = strctureCaptureBorder;

            this.actionIndicator = new ActionIndicator();
            this.actionIndicator.HorizontalAlignment = HorizontalAlignment.Left;
            this.actionIndicator.VerticalAlignment = VerticalAlignment.Bottom;
            this.actionIndicator.Margin = new Thickness(10);
            this.actionIndicator.IsHitTestVisible = false;
            this.actionIndicator.SetValue(Grid.RowSpanProperty, 2);
            layoutGrid.Children.Add(this.actionIndicator);

            this.actionPreviewTimer = new DispatcherTimer();
            this.actionPreviewTimer.Interval = TimeSpan.FromMilliseconds(100);
            this.actionPreviewTimer.Tick += this.ActionPreviewTimerTick;
        }
开发者ID:alkampfergit,项目名称:BaktunShell,代码行数:43,代码来源:PdbViewer.cs

示例13: BuildMessageBox

        private void BuildMessageBox(
            string messageBoxText,
            string caption,
            MessageBoxServiceButton button,
            List<string> customLabels)
        {
            var rootVisual = this.FindRootVisual();
            if (null != rootVisual)
            {
                var bgColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                var overlayColor = Color.FromArgb(127, bgColor.R, bgColor.G, bgColor.B);
                var fgColor = (Color)Application.Current.Resources["PhoneForegroundColor"];
                var opacityColor = Color.FromArgb(200, bgColor.R, bgColor.G, bgColor.B);
                this._rootElement = new Grid { Background = new SolidColorBrush(overlayColor) };
                this._rootElement.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                this._rootElement.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
                this._mbsRoot = new Grid
                {
                    Background = new SolidColorBrush(overlayColor),
                    Projection = new PlaneProjection()
                };
                this._mbsRoot.ColumnDefinitions.Add(
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                this._mbsRoot.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                this._mbsRoot.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                this._rootElement.Children.Add(this._mbsRoot);

                // Make sure that our grid spans all rows and columns of it's parent, if the
                // parent is a Grid.
                if (rootVisual is Grid)
                {
                    var parent = (Grid)rootVisual;
                    int columnCount = parent.ColumnDefinitions.Count;
                    if (columnCount > 0)
                    {
                        this._rootElement.SetValue(Grid.ColumnSpanProperty, columnCount);
                    }

                    int rowCount = parent.RowDefinitions.Count;
                    if (rowCount > 0)
                    {
                        this._rootElement.SetValue(Grid.RowSpanProperty, rowCount);
                    }
                }

                Border background = new Border { Background = new SolidColorBrush(fgColor) };
                background.SetValue(Grid.ColumnSpanProperty, 2);
                background.SetValue(Grid.RowSpanProperty, 2);
                this._mbsRoot.Children.Add(background);
                Border opaqueOverlay = new Border { Background = new SolidColorBrush(opacityColor) };
                opaqueOverlay.SetValue(Grid.ColumnSpanProperty, 2);
                opaqueOverlay.SetValue(Grid.RowSpanProperty, 2);
                this._mbsRoot.Children.Add(opaqueOverlay);

                // Add the caption.
                StackPanel container = new StackPanel { Margin = new Thickness(12, 0, 12, 12) };
                container.SetValue(Grid.ColumnSpanProperty, 2);
                TextBlock title = new TextBlock
                {
                    FontFamily = new FontFamily("Segoe WP Semibold"),
                    FontSize = 32,
                    Margin = new Thickness(12),
                    Text = caption,
                    TextWrapping = TextWrapping.Wrap
                };
                title.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated);
                container.Children.Add(title);

                // Add the message text.
                TextBlock message = new TextBlock
                {
                    FontSize = 24,
                    Margin = new Thickness(12, 0, 12, 0),
                    Text = messageBoxText,
                    TextWrapping = TextWrapping.Wrap
                };
                container.Children.Add(message);
                this._mbsRoot.Children.Add(container);
                rootVisual.Children.Add(this._rootElement);

                // Add the required buttons.
                switch (button)
                {
                    case MessageBoxServiceButton.OK:
                        this.CreateOKButton(
                            null == customLabels ? MessageBoxServiceStrings.OK : customLabels[0],
                            2);
                        container.SetValue(Grid.ColumnSpanProperty, 1);
                        break;
                    case MessageBoxServiceButton.OKCancel:
                        this._mbsRoot.ColumnDefinitions.Add(
                            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                        this.CreateOKButton(
                            null == customLabels ? MessageBoxServiceStrings.OK : customLabels[0]);
                        this.CreateCancelButton(
                            null == customLabels ? MessageBoxServiceStrings.Cancel : customLabels[1],
                            1);
                        break;
                    case MessageBoxServiceButton.YesNoCancel:
                        this._mbsRoot.ColumnDefinitions.Add(
//.........这里部分代码省略.........
开发者ID:sbisker,项目名称:MessageBoxService,代码行数:101,代码来源:MessageBoxService.cs

示例14: _tableview_ModifyRowEnvent

        void _tableview_ModifyRowEnvent(string id)
        {
            btnSave.Tag = "修改";
            btnSave.Visibility = Visibility.Visible;
            _detect_trade_name.Visibility = Visibility.Hidden;
            _detect_trade.Visibility = Visibility.Hidden;
            _dept_name.Text = dept_name;
            _detect_station.SelectionChanged -= new SelectionChangedEventHandler(_detect_station_SelectionChanged);
            _tabControl.SelectedIndex = 0;
            _detect_station.IsEnabled = false;
            string sql = string.Format("select iid,ItemNAME,task_jan,task_feb,task_mar,task_apr,task_may,task_jun,task_jul,task_aug,task_sep,task_oct,task_nov,task_dec" +
                                        " from t_task_assign ,t_det_item" +
                                        " where t_task_assign.iid = t_det_item.ItemID" +
                                        " and  did = '{0}' and nian='{1}'", id, DateTime.Now.Year);
            string deptment_name = "";
            for (int i = 0; i < _tableview.Table.Rows.Count; i++)
            {
                if (_tableview.Table.Rows[i][0].ToString() == id)
                {
                    deptment_name = _tableview.Table.Rows[i][1].ToString();
                }
            }

            _detect_station.Items.Clear();
            Label label = new Label();
            label.Content = deptment_name;
            label.Tag = id;
            _detect_station.Items.Add(label);
            _detect_station.SelectedIndex = 0;


            _grid_detail.Children.Clear();
            _grid_detail.RowDefinitions.Clear();
            _grid_detail.ColumnDefinitions.Clear();
            textBoxs.Clear();

            for (int i = 0; i < tableHeaders.Count; i++)
            {

                _grid_detail.ColumnDefinitions.Add(new ColumnDefinition());
                if (i == 0)
                {
                    _grid_detail.ColumnDefinitions[0].Width = new GridLength(2, GridUnitType.Star);
                }
                else
                {
                    _grid_detail.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
                }
            }
            _grid_detail.RowDefinitions.Add(new RowDefinition());
            for (int i = 0; i < tableHeaders.Count; i++)
            {
                Border border = new Border();
                border.BorderBrush = Brushes.Black;
                border.HorizontalAlignment = HorizontalAlignment.Center;
                border.BorderThickness = new Thickness(0.2);
                TextBox textBox = new TextBox();
                textBox.Margin = new Thickness(0);
                textBox.IsReadOnly = true;
                textBox.Text = tableHeaders[i];
                textBox.HorizontalAlignment = HorizontalAlignment.Center;
                textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
                border.Child = textBox;
                border.SetValue(Grid.RowProperty, 0);
                border.SetValue(Grid.ColumnProperty, i);
                _grid_detail.Children.Add(border);
            }

            DataTable table = dbOperation.GetDataSet(sql).Tables[0];
            _grid_detail.Tag = table;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                _grid_detail.RowDefinitions.Add(new RowDefinition());
                for (int j = 0; j < tableHeaders.Count; j++)
                {
                    Border border = new Border();
                    border.BorderBrush = Brushes.Black;
                    border.HorizontalAlignment = HorizontalAlignment.Center;
                    border.BorderThickness = new Thickness(0.2);
                    TextBox textBox = new TextBox();
                    textBox.Margin = new Thickness(0);
                    if (j == 0)
                    {
                        textBox.IsReadOnly = true;
                        textBox.Text = table.Rows[i][1].ToString();
                        textBox.Tag = table.Rows[i][0].ToString();
                    }
                    else
                    {
                        textBox.Text = "0";
                        textBox.MaxLength = 5;
                        if (j == tableHeaders.Count - 1)
                        {
                            textBox.IsReadOnly = true;
                            textBoxs.Add("行合计" + (_grid_detail.RowDefinitions.Count - 1), textBox);
                        }
                        else
                        {
                            textBox.TextChanged += new TextChangedEventHandler(textBox_TextChanged);
                            textBox.Tag = (i + 1) + "," + j;
//.........这里部分代码省略.........
开发者ID:wuqiangqiang,项目名称:easyfood,代码行数:101,代码来源:UcTaskAllocation.xaml.cs

示例15: DrawMap

        private void DrawMap() {
            if (CurrentMapTable == null) {
                MapGrid.Children.Add(new TextBlock()
                {
                    Text = "No map data, import GAME first.",
                    FontWeight = FontWeights.Bold,
                    HorizontalAlignment = HorizontalAlignment.Right
                });
                MapToolbarToggleButton.IsChecked = true;
                return;
            }
            //make offset to 0~CurrentMapTable.W, always positive
            int offsetRemain = (Offset%CurrentMapTable.W + CurrentMapTable.W)%CurrentMapTable.W;
            for (int row = 0; row < CurrentMapTable.Rows.Count; row++) {
                int offsetedRowIndex = (row + offsetRemain) %CurrentMapTable.W;
                MapRow r = CurrentMapTable[offsetedRowIndex];
                MapGrid.RowDefinitions.Add(new RowDefinition() {
                    Height = new GridLength(25)
                });
                for (int col = 0; col < r.Cells.Count; col++) {
                    MapCell c = r[col];
                    if (row == 0) {
                        MapGrid.ColumnDefinitions.Add(new ColumnDefinition() {
                            Width = new GridLength(25)
                        });
                    }
                    TextBlock tb = new TextBlock() {
                        Text = c.Text,
                        Foreground = c.Foreground,
                        FontWeight = c.fontWeight
                    };
                    System.Windows.Shapes.Rectangle rec = new System.Windows.Shapes.Rectangle() {
                        Fill = new LinearGradientBrush() {
                            StartPoint = new Point(0, 1),
                            EndPoint = new Point(1, 0),
                            MappingMode = BrushMappingMode.RelativeToBoundingBox,
                            GradientStops = new GradientStopCollection() {
                                new GradientStop(c.YorishiroColor, 1d/4d),
                                new GradientStop(Colors.Transparent, 1d/4d),
                                new GradientStop(Colors.Transparent, 3d/4d),
                                new GradientStop(c.AttributeColor, 3d/4d)
                            }
                        },
                        StrokeThickness = 2,
                        StrokeDashArray = new DoubleCollection() {2, 1},
                        Stroke = c.EnemyRate > 0 && c.EnemyRate < 100 ? Brushes.DarkGray : Brushes.Transparent
                    };

                    //绘制tooltip
                    StringBuilder sb = new StringBuilder();
                    if (c.EnemyNo > 0) {
                        sb.AppendLine("#:" + c.EnemyNo);
                    }
                    if (c.HasDropInfo) {
                        sb.AppendLine($"evo_pt:{c.add_attribute_exp}|exp:{c.unit_exp}");
                        sb.AppendLine($"atk+{c.unit_attack}|hp+{c.unit_life}");
                        if (c.drop_unit != null) {
                            sb.AppendLine(string.Format("drop:[{0}]{1}", c.drop_unit.g_id, c.drop_unit.name));
                        }
                    }
                    if (c.drop_id != 0) {
                        sb.AppendLine("drop_id:" + c.drop_id);
                        sb.AppendLine("gold:" + c.gold_pt);
                    }
                    if (string.IsNullOrWhiteSpace(sb.ToString().Trim()) == false) {
                        rec.ToolTip = new Run(sb.ToString().Trim());
                    }

                    Border b = new Border() {
                        Background = c.Background,
                        Child = tb
                    };

                    MapGrid.Children.Add(b);
                    b.SetValue(Grid.RowProperty, row);
                    b.SetValue(Grid.ColumnProperty, col);

                    if (c.RawCellData != 0) {   //no rectangle overlay when this cell contains nothing
                        MapGrid.Children.Add(rec);
                        rec.SetValue(Grid.RowProperty, row);
                        rec.SetValue(Grid.ColumnProperty, col);
                        rec.SetValue(Grid.ZIndexProperty, 2);
                    }
                }
            }
            //绘制底部标记
            MapGrid.RowDefinitions.Add(new RowDefinition() {
                Height = new GridLength(25)
            });
            for (int j = 0; j < CurrentMapTable.H; j++) {
                int markValue = CurrentMapTable.ZeroMarkPlace - j;
                if (CurrentMapTable.EventCutins?.Any(cutin => cutin.cutin_w == j) == true) {
                    //走到对应列会触发cutin,把mark换成按钮
                    Button button = new Button() {
                        Content = markValue,
                        HorizontalContentAlignment = HorizontalAlignment.Center
                    };
                    int cutinW = j;
                    button.Click += (s, arg) => {
                        LoadEventCutin(cutinW);
//.........这里部分代码省略.........
开发者ID:WindWT,项目名称:RTDDE.Executer,代码行数:101,代码来源:Map.xaml.cs


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