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--; } } }
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(); }
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); }
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; } }
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; }
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); }; } }
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); }
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; }
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; }
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; }
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; }
/// <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; }
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( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this._mbsRoot.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); background.SetValue(Grid.ColumnSpanProperty, 3); opaqueOverlay.SetValue(Grid.ColumnSpanProperty, 3); container.SetValue(Grid.ColumnSpanProperty, 3); this.CreateYesButton( null == customLabels ? MessageBoxServiceStrings.Yes : customLabels[0]); this.CreateNoButton( null == customLabels ? MessageBoxServiceStrings.No : customLabels[1], 3); this.CreateCancelButton( null == customLabels ? MessageBoxServiceStrings.Cancel : customLabels[2], 2); break; case MessageBoxServiceButton.YesNo: this._mbsRoot.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this.CreateYesButton( null == customLabels ? MessageBoxServiceStrings.Yes : customLabels[0]); this.CreateNoButton( null == customLabels ? MessageBoxServiceStrings.No : customLabels[1]); break; default: // Not possible to hit this. break; } // Update and start the storyboard to show the message box. foreach (var timeline in this._showStoryboard.Children) { Storyboard.SetTarget(timeline, this._mbsRoot); } // Once the elements are ready, start the storyboard to show them. this._mbsRoot.InvokeOnLayoutUpdated(() => { this._showStoryboard.Begin(); }); } }
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; textBoxs.Add((i + 1) + "," + j, textBox); } } textBox.HorizontalAlignment = HorizontalAlignment.Center; textBox.HorizontalContentAlignment = HorizontalAlignment.Center; border.Child = textBox; border.SetValue(Grid.RowProperty, i + 1); border.SetValue(Grid.ColumnProperty, j); _grid_detail.Children.Add(border); } } _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); textBox.IsReadOnly = true; if (j == 0) { textBox.Text = "合计"; } else { textBox.Text = "0"; textBoxs.Add("列合计" + j, textBox); } textBox.Foreground = Brushes.Black; textBox.HorizontalAlignment = HorizontalAlignment.Center; textBox.HorizontalContentAlignment = HorizontalAlignment.Center; border.Child = textBox; border.SetValue(Grid.RowProperty, _grid_detail.RowDefinitions.Count - 1); border.SetValue(Grid.ColumnProperty, j); _grid_detail.Children.Add(border); } lastTextboxValues.Clear(); for (int i = 0; i < table.Rows.Count; i++) { for (int j = 2; j < table.Columns.Count; j++) { if (textBoxs.ContainsKey((i + 1) + "," + (j - 1))) { textBoxs[(i + 1) + "," + (j - 1)].Text = table.Rows[i][j].ToString().Length == 0 ? "0" : table.Rows[i][j].ToString(); } } } }
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); }; MapGrid.Children.Add(button); button.SetValue(Grid.RowProperty, CurrentMapTable.W); button.SetValue(Grid.ColumnProperty, j); } else { TextBlock tb = new TextBlock() { Text = markValue.ToString() //Now use BossStart as zero mark, farewell 3 }; Border b = new Border { Child = tb }; MapGrid.Children.Add(b); b.SetValue(Grid.RowProperty, CurrentMapTable.W); b.SetValue(Grid.ColumnProperty, j); } } //绘制左侧冻结行标记 MapMarkGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(25) }); for (int i = 0; i < CurrentMapTable.Rows.Count; i++) { MapMarkGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(25) }); TextBlock tb = new TextBlock() { Text = CurrentMapTable.W-i > offsetRemain ? (CurrentMapTable.Y - i - offsetRemain).ToString() : ((CurrentMapTable.Y - i - offsetRemain + CurrentMapTable.W) % CurrentMapTable.W).ToString() }; Border b = new Border {Child = tb}; MapMarkGrid.Children.Add(b); b.SetValue(Grid.RowProperty, i); b.SetValue(Grid.ColumnProperty, 0); } //收起地图工具栏 MapToolbarToggleButton.IsChecked = false; }
void GenerateGroups() { for(int i = 0; i < 8; i++) { Border brd = new Border(); brd.CornerRadius = new CornerRadius(5); brd.Margin = new Thickness(2); brd.SetValue(Grid.ColumnProperty, i % 4); brd.SetValue(Grid.RowProperty, i / 4); LinearGradientBrush lgb = new LinearGradientBrush(); lgb.StartPoint = new Point(0, 0); lgb.EndPoint = new Point(1, 1); lgb.GradientStops = new GradientStopCollection(); lgb.GradientStops.Add(new GradientStop() { Offset = 0.0, Color = Color.FromArgb(255, 0, 0, 0)}); lgb.GradientStops.Add(new GradientStop() { Offset = 0.5, Color = Color.FromArgb(255, 30, 30, 30)}); lgb.GradientStops.Add(new GradientStop() { Offset = 1.0, Color = Color.FromArgb(255, 40, 40, 40)}); brd.Background = lgb; lgbEven.StartPoint = new Point(0, 0); lgbEven.EndPoint = new Point(1, 1); lgbEven.GradientStops = new GradientStopCollection(); lgbEven.GradientStops.Add(new GradientStop() { Offset = 0.0, Color = Color.FromArgb(255, 0, 0, 0) }); lgbEven.GradientStops.Add(new GradientStop() { Offset = 0.5, Color = Color.FromArgb(255, 30, 30, 30) }); lgbEven.GradientStops.Add(new GradientStop() { Offset = 1.0, Color = Color.FromArgb(255, 80, 80, 80) }); Grid grdGroup = new Grid(); grdGroup.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(28) }); grdGroup.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grdGroup.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grdGroup.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(18) }); grdGroup.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(18) }); grdGroup.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(18) }); grdGroup.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(18) }); TextBlock txtGroupID = new TextBlock() { Text = ((char)(i + 65)).ToString(), Foreground = new SolidColorBrush(Colors.White), FontSize = 18, FontWeight = FontWeights.Bold }; txtGroupID.SetValue(Grid.ColumnProperty, 0); txtGroupID.SetValue(Grid.RowProperty, 0); txtGroupID.SetValue(Grid.RowSpanProperty, 4); txtGroupID.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center); txtGroupID.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center); grdGroup.Children.Add(txtGroupID); for (int j = 0; j < 4; j++) { Grid grdTeam = new Grid(); grdTeam.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grdTeam.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grdTeam.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(25) }); grdTeam.SetValue(Grid.ColumnProperty, 1); grdTeam.SetValue(Grid.ColumnSpanProperty, 2); grdTeam.SetValue(Grid.RowProperty, j); grdTeam.HorizontalAlignment = HorizontalAlignment.Stretch; grdTeam.VerticalAlignment = VerticalAlignment.Center; grdTeam.Width = 120; Team team = GameHelper.Instance.TeamsDictionary[GameHelper.Instance.TeamCodes[i * 4 + j]]; Image img = new Image() { Source = new BitmapImage(new Uri(string.Format(@"http://www.fifa.com/imgml/flags/reflected/m/{0}.png", team.TeamID.ToLower()), UriKind.Absolute)), Width = 28.5, Height = 25.0, VerticalAlignment = VerticalAlignment.Center }; img.SetValue(Grid.ColumnProperty, 0); img.SetValue(Grid.RowProperty, j); img.VerticalAlignment = VerticalAlignment.Top; img.HorizontalAlignment = HorizontalAlignment.Stretch; img.Clip = new RectangleGeometry() { Rect = new Rect(new Point(0, 0), new Point(28.5, 14)) }; img.Tag = team.TeamID; TranslateTransform tf = new TranslateTransform() { X = 0, Y = 6 }; img.RenderTransform = tf; TextBlock txt = new TextBlock() { Text = team.TeamName, Foreground = new SolidColorBrush(Colors.White) }; txt.SetValue(Grid.ColumnProperty, 1); txt.SetValue(Grid.RowProperty, j); txt.VerticalAlignment = VerticalAlignment.Center; txt.HorizontalAlignment = HorizontalAlignment.Stretch; txt.Tag = team.TeamID; grdTeam.Tag = team.TeamID; grdTeam.Children.Add(img); grdTeam.Children.Add(txt); grdTeam.MouseEnter += new MouseEventHandler(team_MouseEnter); grdTeam.MouseLeave += new MouseEventHandler(team_MouseLeave); grdTeam.MouseLeftButtonUp += new MouseButtonEventHandler(team_MouseLeftButtonUp); grdGroup.Children.Add(grdTeam); } brd.Child = grdGroup; grdGroupsContainer.Children.Add(brd); } }
private void InitializeStimuliView() { var columns = _stimuli[0].Length; for (int index = 0; index < columns; index++) { StimuliDisplayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); const double epsilon = 0.00001; var color = System.Math.Abs(_stimuli[0][index] - -1) < epsilon ? Colors.Black : Colors.White; var border = new Border() { Background = new SolidColorBrush(color) }; StimuliDisplayGrid.Children.Add(border); border.SetValue(Grid.ColumnProperty, index); } StimuliSlider.Minimum = 0; StimuliSlider.Maximum = _stimuli.Length - 1; }
public ScoreControl() { brdTeam1ScoreAux.MaxHeight = brdTeam2ScoreAux.MaxHeight = 20; this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) }); this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50) }); this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) }); this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0) }); this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) }); this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50) }); this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) }); this.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(16) }); this.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(20) }); TextBlock txtX = new TextBlock() { Text = "x" }; imgBall1.Source = imgBall2.Source = new BitmapImage(new Uri("../Images/Jabulani.png", UriKind.Relative)); imgBall1.SetValue(MarginProperty, new Thickness(0, 2, 0, 0)); imgBall2.SetValue(MarginProperty, new Thickness(0, 2, 0, 0)); RotateTransform rotateTransform1 = new RotateTransform() { Angle = 0, CenterX = 9, CenterY = 9 }; RotateTransform rotateTransform2 = new RotateTransform() { Angle = 0, CenterX = 9, CenterY = 9 }; imgBall1.SetValue(RenderTransformProperty, rotateTransform1); imgBall2.SetValue(RenderTransformProperty, rotateTransform2); Border brdTime = new Border(); txtTime.Text = "12:45"; brdTime.Child = txtTime; brdTime.CornerRadius = new CornerRadius(20, 20, 0, 0); brdTime.Margin = new Thickness(20, 0, 20, 0); Storyboard sbBalls = new Storyboard() { RepeatBehavior = RepeatBehavior.Forever }; DoubleAnimation ballOpacityAnimation1 = new DoubleAnimation() { From = 0.2, To = 1.0, Duration = new Duration(new TimeSpan(0, 0, 0, 1, 0)), RepeatBehavior = RepeatBehavior.Forever, AutoReverse = true }; sbBalls.Children.Add(ballOpacityAnimation1); Storyboard.SetTarget(ballOpacityAnimation1, imgBall1); Storyboard.SetTargetProperty(ballOpacityAnimation1, new PropertyPath("Opacity")); DoubleAnimation ballOpacityAnimation2 = new DoubleAnimation() { From = 0.2, To = 1.0, Duration = new Duration(new TimeSpan(0, 0, 0, 1, 0)), RepeatBehavior = RepeatBehavior.Forever, AutoReverse = true }; sbBalls.Children.Add(ballOpacityAnimation2); Storyboard.SetTarget(ballOpacityAnimation2, imgBall2); Storyboard.SetTargetProperty(ballOpacityAnimation2, new PropertyPath("Opacity")); DoubleAnimation ballAngle1 = new DoubleAnimation() { From = 0.0, To = 360, Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0)), RepeatBehavior = RepeatBehavior.Forever }; sbBalls.Children.Add(ballAngle1); Storyboard.SetTarget(ballAngle1, rotateTransform1); Storyboard.SetTargetProperty(ballAngle1, new PropertyPath("Angle")); DoubleAnimation ballAngle2 = new DoubleAnimation() { From = 0.0, To = 360, Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0)), RepeatBehavior = RepeatBehavior.Forever }; sbBalls.Children.Add(ballAngle2); Storyboard.SetTarget(ballAngle2, rotateTransform2); Storyboard.SetTargetProperty(ballAngle2, new PropertyPath("Angle")); sbBalls.Begin(); brdTime.SetValue(Grid.RowProperty, 0); brdTime.SetValue(Grid.ColumnProperty, 1); brdTime.SetValue(Grid.ColumnSpanProperty, 5); imgBall1.SetValue(Grid.ColumnProperty, 0); imgBall1.SetValue(Grid.RowProperty, 1); txtTeam1ID.SetValue(Grid.ColumnProperty, 1); txtTeam1ID.SetValue(Grid.RowProperty, 1); txtTeam1Score.SetValue(Grid.ColumnProperty, 2); txtTeam1Score.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Right); txtTeam1Score.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center); txtTeam1Score.SetValue(Grid.RowProperty, 1); brdTeam1ScoreAux.SetValue(Grid.ColumnProperty, 2); brdTeam1ScoreAux.SetValue(Grid.RowProperty, 1); txtX.SetValue(Grid.ColumnProperty, 3); txtX.SetValue(Grid.RowProperty, 1); txtTeam2Score.SetValue(Grid.ColumnProperty, 4); txtTeam2Score.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left); txtTeam2Score.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center); txtTeam2Score.SetValue(Grid.RowProperty, 1); brdTeam2ScoreAux.SetValue(Grid.ColumnProperty, 4); brdTeam2ScoreAux.SetValue(Grid.RowProperty, 1); txtTeam2ID.SetValue(Grid.ColumnProperty, 5); txtTeam2ID.SetValue(Grid.RowProperty, 1); imgBall2.SetValue(Grid.ColumnProperty, 6); imgBall2.SetValue(Grid.RowProperty, 1); //txtTeam1Name.Width = 10; //txtTeam2Name.Width = 10; //txtTeam1Score.Width = 10; //txtTeam2Score.Width = 10; txtTeam1ID.Foreground = txtTeam2ID.Foreground = new SolidColorBrush(Colors.Black); txtX.Foreground = txtTeam1Score.Foreground = txtTeam2Score.Foreground = txtTeam1ScoreAux.Foreground = txtTeam2ScoreAux.Foreground = txtTime.Foreground = new SolidColorBrush(Colors.White); LinearGradientBrush lgb = new LinearGradientBrush() { StartPoint = new Point(0, 0), EndPoint = new Point(0, 1) }; lgb.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(255, 160, 140, 0), Offset = 0.0 }); //lgb.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0.3 }); lgb.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0.4 }); lgb.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0.5 }); //lgb.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0.6 }); //lgb.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0.7 }); lgb.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(255, 160, 140, 0), Offset = 1.0 }); LinearGradientBrush lgbNumbers = new LinearGradientBrush() { StartPoint = new Point(0, 0), EndPoint = new Point(0, 1) }; lgbNumbers.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(255, 80, 20, 0), Offset = 0.0 }); lgbNumbers.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(255, 200, 160, 160), Offset = 0.3 }); lgbNumbers.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(255, 120, 30, 0), Offset = 0.5 }); lgbNumbers.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(255, 80, 20, 0), Offset = 1.0 }); brdTeam1ScoreAux.Background = brdTeam2ScoreAux.Background = brdTime.Background = lgbNumbers; txtTeam1ID.FontSize = txtTeam2ID.FontSize = txtX.FontSize = txtTeam1Score.FontSize = txtTeam2Score.FontSize = txtTeam1ScoreAux.FontSize = txtTeam2ScoreAux.FontSize = 16; txtTime.FontSize = 14; txtTeam1ID.FontWeight = txtTeam2ID.FontWeight = txtX.FontWeight = txtTeam1Score.FontWeight = txtTeam2Score.FontWeight = txtTeam1ScoreAux.FontWeight = txtTeam2ScoreAux.FontWeight = txtTime.FontWeight = FontWeights.Bold; txtTeam1ID.FontFamily = txtTeam2ID.FontFamily = txtX.FontFamily = txtTeam1Score.FontFamily = txtTeam2Score.FontFamily = txtTeam1ScoreAux.FontFamily = txtTeam2ScoreAux.FontFamily = txtTime.FontFamily = new FontFamily("Arial Narrow"); txtTeam1ID.HorizontalAlignment = txtTeam2ID.HorizontalAlignment = txtX.HorizontalAlignment = txtTeam1Score.HorizontalAlignment = txtTeam2Score.HorizontalAlignment = txtTeam1ScoreAux.HorizontalAlignment = txtTeam2ScoreAux.HorizontalAlignment = txtTime.HorizontalAlignment = HorizontalAlignment.Center; txtTeam1ScoreAux.Text = "2"; txtTeam2ScoreAux.Text = "3"; translateTransform1 = new TranslateTransform() { X = 0, Y = 0 }; translateTransform2 = new TranslateTransform() { X = 0, Y = 0 }; txtTeam1Score.RenderTransform = translateTransform1; txtTeam2Score.RenderTransform = translateTransform2; this.Width = 560; //StackPanel stackPanel = new StackPanel(); //stackPanel.Orientation = Orientation.Horizontal; //stackPanel.Children.Add(txtTeam1Name); //stackPanel.Children.Add(txtTeam2Name); //stackPanel.Width = 1000; //this.Children.Add(stackPanel); Border brdRound = new Border(); brdRound.CornerRadius = new CornerRadius(0, 0, 20, 20); //brdRound.BorderBrush = new SolidColorBrush(Colors.Black); brdRound.BorderThickness = new Thickness(2); brdRound.SetValue(Grid.ColumnProperty, 1); brdRound.SetValue(Grid.ColumnSpanProperty, 5); brdRound.SetValue(Grid.RowProperty, 1); //Border brdGreen = new Border(); //brdGreen.Background = new SolidColorBrush(Colors.Green); //brdGreen.SetValue(Grid.ColumnSpanProperty, 5); //brdGreen.SetValue(Grid.ColumnProperty, 0); //brdGreen.SetValue(Grid.RowProperty, 1); brdRound.Background = lgb;// new SolidColorBrush(Colors.Black); Image maskImage = new Image(); maskImage.Source = new BitmapImage(new Uri("../Images/ScoreMask.png", UriKind.Relative)); brdTeam1ScoreAux.Child = txtTeam1ScoreAux; brdTeam2ScoreAux.Child = txtTeam2ScoreAux; this.Children.Add(brdRound); this.Children.Add(imgBall1); this.Children.Add(txtTeam1ID); this.Children.Add(txtTeam2ID); this.Children.Add(txtX); this.Children.Add(txtTeam1Score); this.Children.Add(txtTeam2Score); this.Children.Add(brdTeam1ScoreAux); this.Children.Add(brdTeam2ScoreAux); this.Children.Add(imgBall2); this.Children.Add(brdTime); //this.Children.Add(brdGreen); //this.Children.Add(maskImage); this.VerticalAlignment = VerticalAlignment.Bottom; //this.Background = new SolidColorBrush(Colors.Red); sbScore1 = new Storyboard(); sbScore1.Completed += new EventHandler(sbScore1_Completed); DoubleAnimation dAnimation1 = new DoubleAnimation() { Duration = new Duration(new TimeSpan(0, 0, 0, 2)), From = 20, To = 0, }; sbScore2 = new Storyboard(); sbScore2.Completed += new EventHandler(sbScore2_Completed); DoubleAnimation dAnimation2 = new DoubleAnimation() { Duration = new Duration(new TimeSpan(0, 0, 0, 2)), From = 20, To = 0 }; sbScore1.Children.Add(dAnimation1); Storyboard.SetTarget(dAnimation1, translateTransform1); Storyboard.SetTargetProperty(dAnimation1, new PropertyPath("Y")); sbScore2.Children.Add(dAnimation2); Storyboard.SetTarget(dAnimation2, translateTransform2); Storyboard.SetTargetProperty(dAnimation2, new PropertyPath("Y")); }
private void ChildWindow_Loaded(object sender, RoutedEventArgs e) { int lCount = 0; Grid lPage = null; int lPageNumber = 1; int lTotalPage = m_ReportParame.Values.Count / 28 + 1; foreach (List<String> lValues in m_ReportParame.Values) { if (lCount == 0) { Border lPageBorder = new Border(); lPageBorder.Margin = new System.Windows.Thickness(15, 15, 15, 0); lPageBorder.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lPageBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lPageBorder.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); Grid lPagePointer = new Grid(); Grid lPageContion = new Grid(); lPageContion.HorizontalAlignment = HorizontalAlignment.Center; lPageContion.Margin = new System.Windows.Thickness(35, 30, 35, 0); lPageBorder.Child = lPagePointer; //lPageContion.HorizontalAlignment = HorizontalAlignment.Stretch; lPagePointer.Children.Add(lPageContion); RowDefinition lHeader = new RowDefinition(); lPageContion.RowDefinitions.Add(lHeader); RowDefinition lContext = new RowDefinition(); //lContext.MinHeight = 650; lPageContion.RowDefinitions.Add(lContext); RowDefinition lFooder = new RowDefinition(); lPageContion.RowDefinitions.Add(lFooder); Border lHeaderBorder = new Border(); lHeaderBorder.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1); lHeaderBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); StackPanel lStackPanel = new StackPanel(); lStackPanel.Orientation = Orientation.Vertical; TextBlock lHeaderText = new TextBlock(); lHeaderText.Text = m_ReportParame.ReportTitle; lHeaderText.HorizontalAlignment = HorizontalAlignment.Center; lHeaderText.FontSize = 21; //lHeaderText.SetValue(TextBlock.FontWeightProperty, "Bold"); lHeaderText.Margin = new System.Windows.Thickness(0, 10, 0, 15); lHeaderText.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); //lHeaderBorder.Child = lHeaderText; lStackPanel.Children.Add(lHeaderText); TextBlock lHeaderTextName = new TextBlock(); lHeaderTextName.Text = "制表人:" + m_Name + " 日期:" + DateTime.Now.ToShortDateString(); lHeaderTextName.HorizontalAlignment = HorizontalAlignment.Center; //lHeaderTextName.FontSize = 21; lHeaderTextName.Margin = new System.Windows.Thickness(0, 10, 0, 10); lHeaderTextName.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lStackPanel.Children.Add(lHeaderTextName); Border lFooderBorder = new Border(); lFooderBorder.BorderThickness = new System.Windows.Thickness(0, 1, 0, 0); lFooderBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); TextBlock lFooderText = new TextBlock(); lFooderText.Text = "- 第 " + lPageNumber + " 页,共 " + lTotalPage + " 页 -"; lFooderText.Margin = new System.Windows.Thickness(0, 10, 0, 10); lFooderText.HorizontalAlignment = HorizontalAlignment.Center; lFooderText.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); //lFooderBorder.Child = lFooderText; lPageContion.Children.Add(lStackPanel); lHeaderText.SetValue(Grid.RowProperty, 0); lPageContion.Children.Add(lFooderText); lFooderText.SetValue(Grid.RowProperty, 2); Border lPageContextBorder = new Border(); lPageContextBorder.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lPageContextBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lPageContextBorder.VerticalAlignment = VerticalAlignment.Top; //lPageContextBorder.Margin = new System.Windows.Thickness(0, 5, 0, 0); lPage = new Grid(); lPage.Margin = new System.Windows.Thickness(0, 0, 0, 0); lPage.VerticalAlignment = VerticalAlignment.Top; //for (int i = 0; i < m_ReportParame.Title.Count(); i++) foreach (int lWidth in m_ReportParame.TitleWidth) { ColumnDefinition lColumnDefinition = new ColumnDefinition(); lColumnDefinition.MinWidth = lWidth; lPage.ColumnDefinitions.Add(lColumnDefinition); } //{ // ColumnDefinition lColumnDefinition = new ColumnDefinition(); // lPage.ColumnDefinitions.Add(lColumnDefinition); //} lPageContextBorder.Child = lPage; lPageContion.Children.Add(lPageContextBorder); lPageContextBorder.SetValue(Grid.RowProperty, 1); //define header RowDefinition lHeaderRow = new RowDefinition(); lPage.RowDefinitions.Add(lHeaderRow); int lIndex = 0; foreach (String lName in m_ReportParame.Title) { Border lHeaderTextBorder0 = new Border(); if (lIndex < m_ReportParame.Title.Count() - 1) { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 0, 1, 0); } else { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); } //lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lHeaderTextBorder0.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lHeaderTextBorder0.Background = new SolidColorBrush(Color.FromArgb(255, 230, 230, 230)); TextBlock lHeaderText0 = new TextBlock(); lHeaderText0.Text = lName; lHeaderText0.FontSize = 14; lHeaderText0.HorizontalAlignment = HorizontalAlignment.Center; lHeaderText0.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lHeaderText0.Margin = new System.Windows.Thickness(5, 2, 0, 2); lHeaderTextBorder0.Child = lHeaderText0; lPage.Children.Add(lHeaderTextBorder0); lHeaderTextBorder0.SetValue(Grid.RowProperty, 0); lHeaderTextBorder0.SetValue(Grid.ColumnProperty, lIndex); lIndex++; } PintConter.Children.Add(lPageBorder); lPageNumber++; m_PageList.Add(lPagePointer); } lCount++; RowDefinition lValueRow = new RowDefinition(); lPage.RowDefinitions.Add(lValueRow); int lColIndex = 0; foreach (String lName in lValues) { Border lHeaderTextBorder0 = new Border(); if (lColIndex < lValues.Count() - 1) { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 1, 1, 0); } else { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 1, 0, 0); } //lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lHeaderTextBorder0.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); TextBlock lHeaderText0 = new TextBlock(); lHeaderText0.Text = lName; lHeaderText0.Margin = new System.Windows.Thickness(5, 2, 0, 2); lHeaderText0.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lHeaderTextBorder0.Child = lHeaderText0; lPage.Children.Add(lHeaderTextBorder0); lHeaderTextBorder0.SetValue(Grid.RowProperty, lCount); lHeaderTextBorder0.SetValue(Grid.ColumnProperty, lColIndex); lColIndex++; } if (lCount == 28) { lCount = 0; } } }
/// <summary> /// Initialize the cell /// </summary> private void InitCell() { int iPos; Border border; Brush brushDark; Brush brushLite; m_arrBorder = new Border[64]; m_arrPiece = new ChessBoard.PieceE[64]; iPos = 63; brushDark = new SolidColorBrush(DarkCellColor); // m_colorInfo.m_colDarkCase); brushLite = new SolidColorBrush(LiteCellColor); // m_colorInfo.m_colLiteCase); 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(0); border.Background = (((x + y) & 1) == 0) ? brushLite : brushDark; border.BorderBrush = border.Background; border.SetValue(Grid.ColumnProperty, x); border.SetValue(Grid.RowProperty, y); m_arrBorder[iPos] = border; m_arrPiece[iPos] = ChessBoard.PieceE.None; CellContainer.Children.Add(border); iPos--; } } }
private bool PopulateIEntityAttributes(object obj) { EntityViewModel entity = obj as EntityViewModel; if (entity == null) return false; int rc = 0; foreach ( var attr in entity.Entity.Attributes ) { RowDefinition rd = new RowDefinition(); Properties.RowDefinitions.Add(rd); rd.MaxHeight = 20; ++rc; Border borderPname = new Border(); borderPname.BorderBrush = Brushes.Black; borderPname.BorderThickness = new Thickness(0.5); // Add Property Name TextBlock tb = new TextBlock(); tb.Margin = new Thickness(2); tb.Text = attr.Key; tb.TextAlignment = TextAlignment.Left; tb.VerticalAlignment = VerticalAlignment.Center; borderPname.Child = tb; Properties.Children.Add(borderPname); borderPname.SetValue(Grid.RowProperty, rc); borderPname.SetValue(Grid.ColumnProperty, 0); // Add Value TextBox edit = new TextBox(); Binding valueBinding = new Binding(); valueBinding.Path = new PropertyPath("Value"); valueBinding.Source = new ValueWrapper(attr.Key, entity.Entity); edit.SetBinding(TextBox.TextProperty, valueBinding); Properties.Children.Add(edit); edit.SetValue(Grid.RowProperty, rc); edit.SetValue(Grid.ColumnProperty, 2); } GridSplitter gs = new GridSplitter(); gs.ResizeDirection = GridResizeDirection.Columns; gs.ShowsPreview = true; gs.SnapsToDevicePixels = true; Properties.Children.Add(gs); gs.SetValue(Grid.ColumnProperty, 1); return true; }
public void Send(ChannelMessage message) { if (message.Command == ChannelCommand.NoteOn && message.Data1 >= LowNoteID && message.Data1 <= HighNoteID) { if (message.Data2 > 0) { if (!dicNotesOn.ContainsKey(message.Data1)) { var row = 0; var col = 0; var stringId = 0; Rectangle stringRect = null; //We look for the StringInfo matching the //note information var stringInfoQuery = from si in stringInfos where message.Data1 >= si.Min && message.Data1 <= si.Max select si; if (stringInfoQuery.Any()) { var stringInfo = stringInfoQuery.First(); row = stringInfo.Row; col = message.Data1 - stringInfo.Min; stringRect = stringInfo.Rect; stringId = stringInfo.Row; } if (stringRect != null) { stringRect.Stroke = stringRect.Fill = stringOnColor; stringRect.Height = 1; } //This border shows which note //is being played var noteOn = new Border() { Width = 12, Height = 12, Background = innerColor, BorderBrush = outerColor, Tag = stringId, CornerRadius = new CornerRadius(2, 2, 2, 2) }; //This text block displays //the fret number var txt = new TextBlock() { Text = col.ToString(), Foreground = fontBrush, HorizontalAlignment = System.Windows.HorizontalAlignment.Center, VerticalAlignment = System.Windows.VerticalAlignment.Center, FontWeight = FontWeights.Bold, FontSize = 10 }; noteOn.Child = txt; noteOn.SetValue(Grid.RowProperty, row); noteOn.SetValue(Grid.ColumnProperty, col); dicNotesOn.Add(message.Data1, noteOn); grdArm.Children.Add(noteOn); } } else if (message.Data2 == 0) { if (dicNotesOn.ContainsKey(message.Data1)) { var noteOff = dicNotesOn[message.Data1]; dicNotesOn.Remove(message.Data1); grdArm.Children.Remove(noteOff); var stringId = (int)noteOff.Tag; TurnOffString(stringId); } } } else if (message.Command == ChannelCommand.NoteOff) { if (dicNotesOn.ContainsKey(message.Data1)) { var noteOff = dicNotesOn[message.Data1]; dicNotesOn.Remove(message.Data1); grdArm.Children.Remove(noteOff); var stringId = (int)noteOff.Tag; TurnOffString(stringId); } } }
private void createTask() { tableHeaders = new List<string>() { "检测项目", deptname ,"单位"}; //清空控件区域 _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 == tableHeaders.Count - 1) { _grid_detail.ColumnDefinitions[i].Width = new GridLength(60, GridUnitType.Pixel); } else { _grid_detail.ColumnDefinitions[i].Width = new GridLength(150, GridUnitType.Pixel); } } //画出标题 _grid_detail.RowDefinitions.Add(new RowDefinition()); for (int i = 0; i < tableHeaders.Count; i++) { Border border = new Border(); border.BorderBrush = new SolidColorBrush(Color.FromRgb(228, 227, 225)); border.HorizontalAlignment = HorizontalAlignment.Center; if(i == tableHeaders.Count - 1) { border.Width = 60; } else { border.Width = 150; } border.Background = new SolidColorBrush(Color.FromRgb(242, 247, 251)); if (i == tableHeaders.Count - 1) { border.BorderThickness = new Thickness(1, 1, 1, 0); } else { border.BorderThickness = new Thickness(1, 1, 0, 0); } 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); } string sql = "SELECT ItemID,ItemNAME,t.task FROM t_det_item i" + " left join t_task_assign_new t on i.ItemID = t.iid " + "and t.did = '" + deptid + "' " + "WHERE OPENFLAG = '1' "; DataTable table = dbOperation.GetDbHelper().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 = new SolidColorBrush(Color.FromRgb(228, 227, 225)); border.HorizontalAlignment = HorizontalAlignment.Center; if (j == tableHeaders.Count - 1) { if (i == table.Rows.Count - 1) { border.BorderThickness = new Thickness(1, 1, 1, 1); } else { border.BorderThickness = new Thickness(1, 1, 1, 0); } } else { if (i == table.Rows.Count - 1) { border.BorderThickness = new Thickness(1, 1, 0, 1); } else { border.BorderThickness = new Thickness(1, 1, 0, 0); } } TextBox textBox = new TextBox(); textBox.Margin = new Thickness(0); if (j == 0) { border.Width = 150; textBox.IsReadOnly = true; textBox.Text = table.Rows[i][1].ToString(); textBox.Tag = table.Rows[i][0].ToString(); } else if (j == 1) { border.Width = 150; if (table.Rows[i][2].ToString() == null || table.Rows[i][2].ToString() == "") { textBox.Text = "0"; } else { textBox.Text = table.Rows[i][2].ToString(); } //InputMethod.IsInputMethodEnabled="False" DataObject.Pasting="Object_Count_Pasting" textBox.PreviewKeyDown += new KeyEventHandler(Object_Count_PreviewKeyDown); textBox.PreviewTextInput += new TextCompositionEventHandler(Object_Count_PreviewTextInput); textBox.MaxLength = 5; textBox.Tag = (i + 1) + "," + j; textBoxs.Add((i + 1) + "," + j, textBox); } else if (j == 2) { border.Width = 60; textBox.IsReadOnly = true; textBox.Text = "/份次"; textBox.Tag = "/份次"; } textBox.HorizontalAlignment = HorizontalAlignment.Center; textBox.HorizontalContentAlignment = HorizontalAlignment.Center; border.Child = textBox; border.SetValue(Grid.RowProperty, i + 1); border.SetValue(Grid.ColumnProperty, j); _grid_detail.Children.Add(border); } } }
/// <summary> /// 初始化控件 /// </summary> protected virtual void Init_Control() { // 图片 ImageSource = new Image(); ImageSource.Source = IcoImage; ImageSource.Width = ImageWidth; ImageSource.Height = ImageHeight; // 图片的边框 ImageBorder = new Border(); ImageBorder.BorderBrush = new SolidColorBrush(Colors.Black); ImageBorder.BorderThickness = new Thickness(0); ImageBorder.CornerRadius = new CornerRadius(3); ImageBorder.Width = ImageSource.Width; ImageBorder.Height = ImageSource.Height; ImageBorder.Child = ImageSource; // 设备名 TextDeviceName = new TextBlock(); TextDeviceName.FontSize = 14; TextDeviceName.HorizontalAlignment = HorizontalAlignment.Center; TextDeviceName.VerticalAlignment = VerticalAlignment.Center; TextDeviceName.TextAlignment = TextAlignment.Center; // 设备当前状态 ImageStatues = new Ellipse(); ImageStatues.Fill = new SolidColorBrush(Colors.Green); ImageStatues.Height = 12; ImageStatues.Width = 12; // 连接时显示的虚线 LineVirtual = new Line(); LineVirtual.Stroke = new SolidColorBrush(Colors.Black); LineVirtual.StrokeThickness = 2; DoubleCollection dc = new DoubleCollection(); dc.Add(1); dc.Add(1); LineVirtual.StrokeDashArray = dc; // 设置ZIndex ImageBorder.SetValue(Canvas.ZIndexProperty, -64); TextDeviceName.SetValue(Canvas.ZIndexProperty, 64); this.Children.Add(ImageBorder); this.Children.Add(TextDeviceName); this.Children.Add(ImageStatues); this.Children.Add(LineVirtual); }
void _detect_station_SelectionChanged(object sender, SelectionChangedEventArgs e) { lastTextboxValues.Clear(); _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); } string sql = string.Format("SELECT ItemID,ItemNAME FROM t_det_item WHERE (tradeId ='{0}'or ifnull(tradeId,'') = '') and OPENFLAG = '1' order by orderId", (_detect_trade.SelectedItem as Label).Tag); 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; textBoxs.Add((i + 1) + "," + j, textBox); } } textBox.HorizontalAlignment = HorizontalAlignment.Center; textBox.HorizontalContentAlignment = HorizontalAlignment.Center; border.Child = textBox; border.SetValue(Grid.RowProperty, i + 1); border.SetValue(Grid.ColumnProperty, j); _grid_detail.Children.Add(border); } } _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); textBox.IsReadOnly = true; if (j == 0) { textBox.Text = "合计"; } else { textBox.Text = "0"; textBoxs.Add("列合计" + j, textBox); } textBox.Foreground = Brushes.Blue; textBox.HorizontalAlignment = HorizontalAlignment.Center; textBox.HorizontalContentAlignment = HorizontalAlignment.Center; border.Child = textBox; border.SetValue(Grid.RowProperty, _grid_detail.RowDefinitions.Count - 1); border.SetValue(Grid.ColumnProperty, j); _grid_detail.Children.Add(border); } btnSave.Visibility = Visibility.Visible; }
public override DocumentPage GetPage(int pageNumber) { DocumentPage page = null; List<object> itemsSource = new List<object>(); ICollectionView viewSource = CollectionViewSource.GetDefaultView(_documentSource.ItemsSource); if (viewSource != null) { foreach (object item in viewSource) itemsSource.Add(item); } if (itemsSource != null) { int rowIndex = 1; int startPos = pageNumber * _rowsPerPage; int endPos = startPos + _rowsPerPage; //Create a new grid Grid tableGrid = CreateTable(true) as Grid; for (int index = startPos; index < endPos && index < itemsSource.Count; index++) { Console.WriteLine("Adding: " + index); if (rowIndex > 0) { object item = itemsSource[index]; int columnIndex = 0; if (_documentSource.Columns != null) { foreach (DataGridColumn column in _documentSource.Columns) { if (column.Visibility == Visibility.Visible) { AddTableCell(tableGrid, column, item, columnIndex, rowIndex); columnIndex++; } } } if (this.AlternatingRowBorderStyle != null && rowIndex % 2 == 0) { Border alernatingRowBorder = new Border(); alernatingRowBorder.Style = this.AlternatingRowBorderStyle; alernatingRowBorder.SetValue(Grid.RowProperty, rowIndex); alernatingRowBorder.SetValue(Grid.ColumnSpanProperty, columnIndex); alernatingRowBorder.SetValue(Grid.ZIndexProperty, -1); tableGrid.Children.Add(alernatingRowBorder); } } rowIndex++; } page = ConstructPage(tableGrid, pageNumber); } return page; }
/// <summary> /// This function counts the number of rows in the document /// </summary> private object CreateTable(bool createRowDefinitions) { if (_documentSource == null) return null; Grid table = new Grid(); table.Style = this.GridContainerStyle; int columnIndex = 0; if (_documentSource.Columns != null) { double totalColumnWidth = _documentSource.Columns.Sum(column => column.Visibility == Visibility.Visible ? column.Width.Value : 0); foreach (DataGridColumn column in _documentSource.Columns) { if (column.Visibility == Visibility.Visible) { AddTableColumn(table, totalColumnWidth, columnIndex, column); columnIndex++; } } } if (this.TableHeaderBorderStyle != null) { Border headerBackground = new Border(); headerBackground.Style = this.TableHeaderBorderStyle; headerBackground.SetValue(Grid.ColumnSpanProperty, columnIndex); headerBackground.SetValue(Grid.ZIndexProperty, -1); table.Children.Add(headerBackground); } if (createRowDefinitions) { for (int i = 0; i <= _rowsPerPage; i++) table.RowDefinitions.Add(new RowDefinition()); } return table; }
/// <summary> /// This function counts the number of rows in the document /// </summary> private object CreateTable() { if (_viewSource == null) return null; Grid table = new Grid(); table.Style = this.GridContainerStyle; int columnIndex = 0; if (_columns != null) { foreach (var column in _columns) { if (AddTableColumn(table, columnIndex, column)) columnIndex++; } } if (this.TableHeaderBorderStyle != null) { Border headerBackground = new Border(); headerBackground.Style = this.TableHeaderBorderStyle; headerBackground.SetValue(Grid.ColumnSpanProperty, columnIndex); headerBackground.SetValue(Grid.ZIndexProperty, -1); table.Children.Add(headerBackground); } return table; }
public override DocumentPage GetPage(int pageNumber) { //if (pageNumber < PageRange.PageFrom // || pageNumber > PageRange.PageFrom) return null; DocumentPage page = null; List<object> itemsSource = new List<object>(); if (_viewSource != null) { foreach (object item in _viewSource) itemsSource.Add(item); } if (itemsSource != null) { int rowIndex = 1; _start = _startRows[pageNumber]; _end = _startRows.Count > pageNumber + 1 ? _startRows[pageNumber + 1] : itemsSource.Count; //Create a new grid Grid tableGrid = CreateTable() as Grid; AddGridRow(tableGrid, GridLength.Auto); for (int index = _start; index < _end && index < itemsSource.Count; index++) { AddGridRow(tableGrid, GridLength.Auto); if (rowIndex > 0) { object item = itemsSource[index]; int columnIndex = 0; foreach (var column in _columns) { if (AddTableCell(tableGrid, column, item, columnIndex, rowIndex)) columnIndex++; } if (this.AlternatingRowBorderStyle != null && rowIndex % 2 == 0) { Border alernatingRowBorder = new Border(); alernatingRowBorder.Style = this.AlternatingRowBorderStyle; alernatingRowBorder.SetValue(Grid.RowProperty, rowIndex); alernatingRowBorder.SetValue(Grid.ColumnSpanProperty, columnIndex); alernatingRowBorder.SetValue(Grid.ZIndexProperty, -1); tableGrid.Children.Add(alernatingRowBorder); } } rowIndex++; } page = ConstructPage(tableGrid, pageNumber); } return page; }
private void Paint(Size size) { try { var width = size.Width; // _canvas 有margin 所以要减去 _canvas.Children.Clear(); var background1 = new Border(); background1.BorderThickness = new Thickness(1d, 1d, 1d, 0d); background1.BorderBrush = new SolidColorBrush(Color.FromArgb(0xff, 0x74, 0x6A, 0x59)); background1.Background = new SolidColorBrush(Colors.White); background1.SetValue(Canvas.LeftProperty, width * 39d / 657d); background1.SetValue(Canvas.TopProperty, width * 42d / 657d); background1.Width = width * 579d / 657d; background1.Height = width * 343d / 657d; _canvas.Children.Add(background1); var brush1 = new SolidColorBrush(Colors.White); var brush2 = new SolidColorBrush(Color.FromArgb(0xff, 0x84, 0x7B, 0x6C)); PaintBorder1(width, brush1, brush2); PaintBorder2(width, brush1, brush2); PaintBorder3(width, brush1, brush2); PaintBorder4(width, brush1, brush2); PaintBorder5(width, brush1, brush2); PaintBorder6(width, brush1, brush2); PaintBorder7(width, brush1, brush2); var ellipse1 = new Ellipse(); ellipse1.SetValue(Canvas.LeftProperty, width * 3.5d / 657d); ellipse1.SetValue(Canvas.TopProperty, width * 136d / 657d); ellipse1.Width = ellipse1.Height = width * 650d / 657d; ellipse1.Stroke = new SolidColorBrush(Color.FromArgb(0xff, 0xAF, 0xAF, 0x00)); ellipse1.StrokeThickness = 3d; ellipse1.Clip = new RectangleGeometry() { Rect = new Rect(0d, 0d, ellipse1.Width, width * 120d / 657d) }; _canvas.Children.Add(ellipse1); PaintCalibration(size); _canvas.Children.Add(_pointLine); var ellipse2 = new Ellipse(); ellipse2.SetValue(Canvas.LeftProperty, width * 199.5d / 657d); ellipse2.SetValue(Canvas.TopProperty, width * 332d / 657d); ellipse2.Width = ellipse2.Height = width * 258d / 657d; ellipse2.Fill = new SolidColorBrush(Colors.Black); ellipse2.Clip = new RectangleGeometry() { Rect = new Rect(0d, 0d, ellipse2.Width, width * 50d / 657d) }; _canvas.Children.Add(ellipse2); } catch { } }