public FormatCellDialog(C1FlexSheet flex, IEnumerable <CellRange> cellRange) : this() { _flex = flex; _cellRange = cellRange; //Number _numberViewModel = new NumberViewModel(flex, cellRange); numberGrid.DataContext = _numberViewModel; //Align _alignViewModel = new AlignmentViewModel(flex, cellRange); alignmentGrid.DataContext = _alignViewModel; //Font _fontViewModel = new FontViewModel(flex, cellRange); fontGrid.DataContext = _fontViewModel; lstBoxFonts.SelectedItem = _fontViewModel.SelectedFont; cmbUnderlines.SelectedItem = _fontViewModel.SelectedUnderLine; lstFontSize.SelectedItem = _fontViewModel.SelectedFontSize; lstFontStyle.SelectedItem = _fontViewModel.SelectedFontStyle; //Fill HandleFill(flex, cellRange); colorSelector.SelectionChanged += colorSelector_SelectionChanged; btnTransparent.Checked += btnTransparent_Checked; //Border _borderViewModel = new BorderViewModel(flex, cellRange); previewPanel.DataContext = _borderViewModel; }
public SelectedRangeWindow(C1FlexSheet owner) : this() { _owner = owner; _owner.SelectionChanged += _owner_SelectionChanged; _tbTextRange.Text = owner.GetAddress(owner.Selection, true); _textRange = owner.Selection; }
public NumberViewModel(C1FlexSheet flex, IEnumerable <CellRange> cellRange) { _flex = flex; _cellRange = cellRange; var cell = cellRange.FirstOrDefault(); if (cell.IsValid) { _cellValue = _flex[cell.Row, cell.Column]; } _numberFormats = new ObservableCollection <FormatBase>(); if (NoDecimalPlacesList == null) { NoDecimalPlacesList = new List <FormatBase>(); } InitialNumberFormats(); }
private void HandleFill(C1FlexSheet flex, IEnumerable <CellRange> cellRange) { var cell = cellRange.FirstOrDefault(); var row = flex.Rows[cell.TopRow] as ExcelRow; if (row != null && cell.IsValid) { var col = flex.Columns[cell.Column]; var cs = row.GetCellStyle(col); if (cs == null || cs.Background == null) { _origionFill = Brushes.Transparent; } else { _origionFill = cs.Background; } } }
public BorderViewModel(C1FlexSheet flex, IEnumerable <CellRange> cellRange) { _flex = flex; _cellRange = cellRange; var cell = cellRange.FirstOrDefault(); var row = _flex.Rows[cell.TopRow] as ExcelRow; if (row != null && cell.IsValid) { var col = _flex.Columns[cell.Column]; var cs = row.GetCellStyle(col) as ExcelCellStyle; if (cs != null) { if (cs.CellBorderThickness != new Thickness(0)) { CellBorderThickness = cs.CellBorderThickness; } if (cs.CellBorderBrushTop != null) { ShowBorderTop = true; var brush = cs.CellBorderBrushTop as SolidColorBrush; if (brush != null) { CellBorderColor = brush.Color; } } if (cs.CellBorderBrushLeft != null) { ShowBorderLeft = true; } if (cs.CellBorderBrushRight != null) { ShowBorderRight = true; } if (cs.CellBorderBrushBottom != null) { ShowBorderBottom = true; } } } BorderStyle = BorderStyles.Solid; }
public AlignmentViewModel(C1FlexSheet flex, IEnumerable <CellRange> cellRange) { _flex = flex; UpdateContent(cellRange); Horizontal = new ObservableCollection <HorizontalAlignment>() { HorizontalAlignment.Stretch, HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right }; Vertical = new ObservableCollection <VerticalAlignment>() { VerticalAlignment.Stretch, VerticalAlignment.Top, VerticalAlignment.Center, VerticalAlignment.Bottom, }; }
public FontViewModel(C1FlexSheet flex, IEnumerable <CellRange> cellRange) { _flex = flex; _cellRange = cellRange; foreach (var font in Fonts.SystemFontFamilies) { if (FontsCollection == null) { FontsCollection = new ObservableCollection <FontFamily>(); } FontsCollection.Add(font); } if (FontsStyles == null) { FontsStyles = new ObservableCollection <FontStyleFormat>() { FontStyleFormat.Normal, FontStyleFormat.Italic, FontStyleFormat.Bold } } ; if (FontSize == null) { FontSize = new ObservableCollection <double>(); } int from = 8; int to = 72; for (; from <= to;) { FontSize.Add(from); if (from < 12) { from++; } else { from = from + 2; } } if (Underlines == null) { Underlines = new ObservableCollection <UnderLines>() { UnderLines.None, UnderLines.Underline } } ; var cell = cellRange.FirstOrDefault(); var row = _flex.Rows[cell.TopRow] as ExcelRow; if (row != null && cell.IsValid) { var col = _flex.Columns[cell.Column]; var cs = row.GetCellStyle(col); cs = cs ?? new CellStyle(); _origionFont = SelectedFont = cs.FontFamily ?? new FontFamily("Arial"); _origionFontSize = SelectedFontSize = cs.FontSize ?? 11; SelectedFontStyle = FontStyleConvertFrom(cs.FontStyle, cs.FontWeight); _origionFontStyle = SelectedFontStyle; if (cs.TextDecorations == null || cs.TextDecorations.Count == 0) { SelectedUnderLine = UnderLines.None; } else { SelectedUnderLine = UnderLinesConvertFrom(cs.TextDecorations); } _origionUnderline = SelectedUnderLine; var brush = (SolidColorBrush)cs.Foreground; _origionColor = SelectedColor = brush == null ? Colors.Transparent : brush.Color; } }
/// <summary> /// Initializes a new instance of a <see cref="FindReplaceWindow"/>. /// </summary> public FindReplaceWindow(C1FlexSheet owner) : this() { _owner = owner; }