/// <summary> /// Initializes a new instance of an <see cref="ExcelCellFactory"/>. /// </summary> /// <param name="flex"><see cref="C1FlexGrid"/> that owns this cell factory.</param> public ExcelCellFactory(C1FlexGrid flex) { _flex = flex; if (_styleRight == null) { _styleRight = new CellStyle(); _styleRight.HorizontalAlignment = HorizontalAlignment.Right; } }
// ** object model /// <summary> /// Applies a style to a cell in this row. /// </summary> public void SetCellStyle(Column col, CellStyle style) { if (!object.ReferenceEquals(style, GetCellStyle(col))) { if (_cellStyles == null) { _cellStyles = new Dictionary<Column, CellStyle>(); } _cellStyles[col] = style; if (Grid != null) { Grid.Invalidate(new CellRange(this.Index, col.Index)); } } }
public FormCellFactory() { _editStyle = new CellStyle(); _editStyle.Background = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xe0)); _calculatedStyle = new CellStyle(); _calculatedStyle.FontWeight = FontWeights.Bold; _calculatedStyle.Background = new SolidColorBrush(Color.FromArgb(0xff, 0xe0, 0xe0, 0xff)); _calculatedStyle.HorizontalAlignment = HorizontalAlignment.Right; _numberStyle = new CellStyle(); _numberStyle.HorizontalAlignment = HorizontalAlignment.Right; _groupRowStyle = new CellStyle(); _groupRowStyle.FontWeight = FontWeights.Bold; }
static CellFactory() { _padding = new Thickness(4, 0, 4, 0); _bdrError = new Thickness(4); _bdrFixed = new Thickness(0, 0, 1, 1); _bdrV = new Thickness(0, 0, 1, 0); _bdrH = new Thickness(0, 0, 0, 1); _bdrA = new Thickness(0, 0, 1, 1); _bdrN = Util.Util.ThicknessEmpty; // _brBlack = Brushes.Black; _brWhite = Brushes.White; _brError = new SolidColorBrush(Color.FromArgb(255, 220, 0, 12)); _brError.Freeze(); _brBlue = new SolidColorBrush(Color.FromArgb(255, 100, 150, 200)); _brBlue.Freeze(); // _brOpaque = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); // _brOpaque.Freeze(); _brTransparent = Brushes.Transparent; _imgError = null; _csSelected = new CellStyle(); }
private CellStyle GetStyle(bool header) { if (header) { return HeaderCellStyle ?? (HeaderCellStyle = new CellStyle()); } return CellStyle ?? (CellStyle = new CellStyle()); }
/// <summary> /// Initializes a new instance of a <see cref="T:C1.WPF.FlexGrid.C1FlexGrid" />. /// </summary> public C1FlexGrid() { DefaultStyleKey = typeof (C1FlexGrid); _mouseHandler = new MouseHandler(this); SelectionHandler = new SelectionHandler(this); _editHandler = new EditHandler(this); _mergeManager = new MergeManager(); _addNewHandler = new AddNewHandler(this); _kbdHandler = new KeyboardHandler(this); Cells = new GridPanel(this, CellType.Cell, ROWHEIGHT, COLWIDTH); ColumnHeaders = new GridPanel(this, CellType.ColumnHeader, ROWHEIGHT, COLWIDTH); ColumnHeaders.Columns = Cells.Columns; RowHeaders = new GridPanel(this, CellType.RowHeader, ROWHEIGHT, COLWIDTH); RowHeaders.Rows = Cells.Rows; TopLeftCells = new GridPanel(this, CellType.TopLeft, ROWHEIGHT, COLWIDTH); TopLeftCells.Rows = ColumnHeaders.Rows; TopLeftCells.Columns = RowHeaders.Columns; ColumnFooters = new GridPanel(this, CellType.ColumnFooter, ROWHEIGHT, COLWIDTH); ColumnFooters.Columns = Cells.Columns; BottomLeftCells = new GridPanel(this, CellType.BottomLeft, ROWHEIGHT, COLWIDTH); BottomLeftCells.Rows = ColumnFooters.Rows; BottomLeftCells.Columns = RowHeaders.Columns; _gridPanelArray = new[] {ColumnHeaders, RowHeaders, Cells, TopLeftCells, ColumnFooters, BottomLeftCells}; ICellFactory cellFactory = GetCellFactory(); _botRight = cellFactory.CreateCell(this, CellType.BottomRight, CellRange.Empty); ColumnHeaders.Rows.Add(new Row()); RowHeaders.Columns.Add(new Column()); _canvas = new Canvas(); _canvas.Clip = new RectangleGeometry(); Marquee = new Rectangle(); Marquee.IsHitTestVisible = false; Marquee.StrokeThickness = 2; Marquee.Stroke = Brushes.Black; Marquee.Visibility = Visibility.Collapsed; _canvas.Children.Add(Marquee); _lnFX = new Line(); _lnFX.Visibility = Visibility.Collapsed; _lnFX.StrokeThickness = FROZEN_LINE_WIDTH; _canvas.Children.Add(_lnFX); _lnFY = new Line(); _lnFY.Visibility = Visibility.Collapsed; _lnFY.StrokeThickness = FROZEN_LINE_WIDTH; _canvas.Children.Add(_lnFY); ErrorStyle = new CellStyle(); ErrorStyle.BorderBrush = _errorBorderBrush; ErrorStyle.BorderThickness = new Thickness(1); ErrorStyle.CornerRadius = new CornerRadius(2); Rows.CollectionChanged += (s, e) => { if (ItemsSource == null) { UpdateAggregates(null, false); } }; LayoutUpdated += (s, e) => { if (!ReferenceEquals(Foreground, _lastForeground)) { _lastForeground = Foreground; Invalidate(); return; } if (ViewRange.IsValid && Rows.Count > 0 && Columns.Count > 0 && Cells.IsEmpty() && Rows.GetTotalSize() > 0 && Columns.GetTotalSize() > 0) { InvalidateMeasure(); } }; FocusVisualStyle = null; // bool checkLicense = true; // try // { // string fullName = Assembly.GetCallingAssembly().FullName; // if (fullName.ToLower().StartsWith("c1.wpf.olap") && fullName.EndsWith("PublicKeyToken=2aa4ec5576d6c3ce")) // { // checkLicense = false; // _skipLicenseCheck = true; // } // else if (_skipLicenseCheck) // { // checkLicense = false; // } // } // catch // { // } // if (checkLicense) // { // lock (typeof (C1FlexGrid)) // { // ProviderInfoWPF.Validate(typeof (C1FlexGrid), this, true); // } // } }