public override void GenerateXmlAttributes(System.Xml.XmlWriter writer) { base.GenerateXmlAttributes(writer); if (FillColor.IsNotWhiteSpace()) { writer.WriteAttributeString("fillColor", FillColor); } if (FillAlpha.HasValue) { writer.WriteAttributeString("FillAlpha", FillAlpha.ToString()); } if (FillRatio.IsNotWhiteSpace()) { writer.WriteAttributeString("FillRatio", FillRatio); } if (FillAngle.IsNotWhiteSpace()) { writer.WriteAttributeString("FillAngle", FillAngle); } if (FillPattern.HasValue) { writer.WriteAttributeString("FillPattern", FillPattern.ToString()); } if (_border != null) { _border.GenerateXmlAttributes(writer); } }
internal Style(Workbook wb, XfRecord xf) : base(wb) { if(xf.FontIdx > 0 && xf.FontIdx < wb.Fonts.Count) _font = wb.Fonts[xf.FontIdx - 1]; _format = wb.Formats[xf.FormatIdx]; _typeAndProtection = xf.TypeAndProtection; if(_typeAndProtection.IsCell) _parentStyle = wb.Styles[xf.ParentIdx]; _horizontalAlignment = xf.HorizontalAlignment; _wrapped = xf.Wrapped; _verticalAlignment = xf.VerticalAlignment; _rotation = xf.Rotation; _indentLevel = xf.IndentLevel; _shrinkContent = xf.ShrinkContent; _parentStyleAttributes = xf.ParentStyle; _leftLineStyle = xf.LeftLineStyle; _rightLineStyle = xf.RightLineStyle; _topLineStyle = xf.TopLineStyle; _bottomLineStyle = xf.BottomLineStyle; _leftLineColor = wb.Palette.GetColor(xf.LeftLineColor); _rightLineColor = wb.Palette.GetColor(xf.RightLineColor); _diagonalRightTopToLeftBottom = xf.DiagonalRightTopToLeftBottom; _diagonalLeftBottomToTopRight = xf.DiagonalLeftBottomToTopRight; _topLineColor = wb.Palette.GetColor(xf.TopLineColor); _bottomLineColor = wb.Palette.GetColor(xf.BottomLineColor); _diagonalLineColor = wb.Palette.GetColor(xf.DiagonalLineColor); _diagonalLineStyle = xf.DiagonalLineStyle; _fillPattern = xf.FillPattern; _patternColor = wb.Palette.GetColor(xf.PatternColor); _patternBackground = wb.Palette.GetColor(xf.PatternBackground); }
/// <summary> /// Create a complex fillpattern element /// </summary> /// <param name="patternName">The fillpattern name</param> /// <returns>Created fillpattern element</returns> private FillPatternElement GetOrCreateComplexFacePattern(string patternName) { FillPatternTarget target = FillPatternTarget.Model; FillPatternElement fillPatternElement = FillPatternElement.GetFillPatternElementByName(doc, target, patternName); if (fillPatternElement == null) { // Create the fill pattern FillPattern fillPattern = new FillPattern(patternName, target, FillPatternHostOrientation.ToHost); // Add grids List <FillGrid> grids = new List <FillGrid>(); //Horizontal lines. grids.Add(CreateGrid(new UV(0, 0.1), 0.5, 0, 0.55, 1.0, 0.1)); grids.Add(CreateGrid(new UV(0, 0.5), 0.5, 0, 0.55, 1.0, 0.1)); // Vertical lines. grids.Add(CreateGrid(new UV(0, 0.1), 0.55, Math.PI / 2, 0.5, 0.4, 0.6)); grids.Add(CreateGrid(new UV(1.0, 0.1), 0.55, Math.PI / 2, 0.5, 0.4, 0.6)); fillPattern.SetFillGrids(grids); // Create the fill pattern element. Now document is modified; transaction is needed Transaction t = new Transaction(doc, "Create fill pattern"); t.Start(); fillPatternElement = FillPatternElement.Create(doc, fillPattern); t.Commit(); } return(fillPatternElement); }
public static void ImportPattern(this Document doc, string name, List <string> lines) { using (Transaction t = new Transaction(doc, "Create Grids")) { t.Start(); List <FillGrid> grids = new List <FillGrid>(); FillPattern pat = new FillPattern(name, FillPatternTarget.Model, FillPatternHostOrientation.ToHost); foreach (string line in lines) { FillGrid grid = new FillGrid(); grid.Angle = double.Parse(line.Split(',')[0]) * Math.PI / 180; grid.Origin = new UV(double.Parse(line.Split(',')[1]) / 12, double.Parse(line.Split(',')[2]) / 12); grid.Shift = double.Parse(line.Split(',')[3]) / 12; grid.Offset = double.Parse(line.Split(',')[4]) / 12; var segments = new List <double>(); segments.Add(Math.Abs(double.Parse(line.Split(',')[5])) / 12); segments.Add(Math.Abs(double.Parse(line.Split(',')[6])) / 12); grid.SetSegments(segments); grids.Add(grid); } pat.SetFillGrids(grids); FillPatternElement fpe = FillPatternElement.Create(doc, pat); t.Commit(); } }
/// <summary> /// 获取单元格样式 /// </summary> /// <param name="hssfworkbook">Excel操作类</param> /// <param name="font">单元格字体</param> /// <param name="fillForegroundColor">图案的颜色</param> /// <param name="fillPattern">图案样式</param> /// <param name="fillBackgroundColor">单元格背景</param> /// <param name="ha">垂直对齐方式</param> /// <param name="va">垂直对齐方式</param> /// <returns></returns> public static ICellStyle GetCellStyle(HSSFWorkbook hssfworkbook, IFont font, HSSFColor fillForegroundColor, FillPattern fillPattern, HSSFColor fillBackgroundColor, HorizontalAlignment ha, VerticalAlignment va) { ICellStyle cellstyle = hssfworkbook.CreateCellStyle(); cellstyle.FillPattern = fillPattern; cellstyle.Alignment = ha; cellstyle.VerticalAlignment = va; if (fillForegroundColor != null) { cellstyle.FillForegroundColor = fillForegroundColor.Indexed; //.GetIndex(); } if (fillBackgroundColor != null) { cellstyle.FillBackgroundColor = fillBackgroundColor.Indexed; //.GetIndex(); } if (font != null) { cellstyle.SetFont(font); } //有边框 cellstyle.BorderBottom = BorderStyle.Thin; // CellBorderType.THIN; cellstyle.BorderLeft = BorderStyle.Thin; cellstyle.BorderRight = BorderStyle.Thin; cellstyle.BorderTop = BorderStyle.Thin; return(cellstyle); }
//--------------------------------------------------- // IO Implementations public bool Load(string path, ulong offset) { try { SerializeProp ser = new SerializeProp(); Stream objStreamDeSerialize = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); IFormatter objBinaryFormatter = new BinaryFormatter(); ser = (SerializeProp)objBinaryFormatter.Deserialize(objStreamDeSerialize); mShapes = ser.shapes; mGroups = ser.groups; fillPattern = ser.fillPattern; border = ser.border; bitmap = ser.bitmap; mSelectedShapeIndex = ser.selectedShapeIndex; mSelectedGroupIndex = ser.selectedGroupIndex; objStreamDeSerialize.Close(); return(true); } catch (Exception e) { MessageBox.Show(e.Message); return(false); } }
static TextStyles() { DefaultFontText = new FillPattern.Solid() { Color = System.Drawing.Color.Black }; }
internal Style(Workbook wb, XfRecord xf) : base(wb) { if (xf.FontIdx > 0 && xf.FontIdx < wb.Fonts.Count) { _font = wb.Fonts[xf.FontIdx - 1]; } _format = wb.Formats[xf.FormatIdx]; _typeAndProtection = xf.TypeAndProtection; if (_typeAndProtection.IsCell) { _parentStyle = wb.Styles[xf.ParentIdx]; } _horizontalAlignment = xf.HorizontalAlignment; _wrapped = xf.Wrapped; _verticalAlignment = xf.VerticalAlignment; _rotation = xf.Rotation; _indentLevel = xf.IndentLevel; _shrinkContent = xf.ShrinkContent; _parentStyleAttributes = xf.ParentStyle; _leftLineStyle = xf.LeftLineStyle; _rightLineStyle = xf.RightLineStyle; _topLineStyle = xf.TopLineStyle; _bottomLineStyle = xf.BottomLineStyle; _leftLineColor = wb.Palette.GetColor(xf.LeftLineColor); _rightLineColor = wb.Palette.GetColor(xf.RightLineColor); _diagonalRightTopToLeftBottom = xf.DiagonalRightTopToLeftBottom; _diagonalLeftBottomToTopRight = xf.DiagonalLeftBottomToTopRight; _topLineColor = wb.Palette.GetColor(xf.TopLineColor); _bottomLineColor = wb.Palette.GetColor(xf.BottomLineColor); _diagonalLineColor = wb.Palette.GetColor(xf.DiagonalLineColor); _diagonalLineStyle = xf.DiagonalLineStyle; _fillPattern = xf.FillPattern; _patternColor = wb.Palette.GetColor(xf.PatternColor); _patternBackground = wb.Palette.GetColor(xf.PatternBackground); }
/// <summary> /// Add a pattern of points /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtFillPattern_Click(object sender, RoutedEventArgs e) { FillPattern fillPattern = (FillPattern)cbFillPattern.SelectedItem; AddPoints(fillPattern); CreateGraph(); }
static LineStyles() { DefaultLineBorder = new BorderPattern() { Color = System.Drawing.Color.Black, }; DefaultLineFill = new FillPattern.None(); }
public void CreateCell(CellType TypeO, FillPattern FillBackPat, short FillBackColor) { ICellStyle StyleO = ExcelWorkBook.CreateCellStyle(); StyleO.FillForegroundColor = FillBackColor; StyleO.FillPattern = FillBackPat; CurrentCell = CurrentIRow.CreateCell(CurrentCol, TypeO); CurrentCell.CellStyle = StyleO; }
public PatternFill( FillPattern patternType, Color foregroundColor, Color backgroundColor) { PatternType = patternType; ForegroundColor = foregroundColor; BackgroundColor = backgroundColor; }
/// <summary> /// The constructor for the record. /// </summary> /// <param name="biff">The GenericBiff record that should contain the correct type and data for the XF record.</param> /// <exception cref="InvalidRecordIdException"> /// An InvalidRecordIdException is thrown if biff contains an invalid type or invalid data. /// </exception> public XfRecord(GenericBiff biff) { if (biff.Id == (ushort)RecordType.Xf) { BinaryReader reader = new BinaryReader(biff.GetDataStream()); _fontIdx = reader.ReadUInt16(); _formatIdx = reader.ReadUInt16(); ushort data = reader.ReadUInt16(); _typeAndProtection = new TypeAndProtection(data & 0x000F); _parentIdx = (ushort)((data & 0xFFF0) >> 8); byte data2 = reader.ReadByte(); _horizontalAlignment = (HorizontalAlignment)(data2 & 0x07); _wrapped = (data & 0x088) != 0; _verticalAlignment = (VerticalAlignment)((data2 & 0x70) >> 4); data2 = reader.ReadByte(); _rotation = new Rotation(data2); data2 = reader.ReadByte(); _indentLevel = new Nibble((byte)(data2 & 0x0F)); _shrinkContent = (data2 & 0x10) == 1; _parentStyle = (ParentStyleAttributes)(reader.ReadByte()); uint data3 = reader.ReadUInt32(); _leftLineStyle = (LineStyle)(data3 & 0x0000000F); _rightLineStyle = (LineStyle)((data3 & 0x000000F0) >> 1); _topLineStyle = (LineStyle)((data3 & 0x00000F00) >> 2); _bottomLineStyle = (LineStyle)((data3 & 0x0000F000) >> 3); _rightLineColor = (ushort)((data3 & 0x007F0000) >> 4); _leftLineColor = (ushort)((data3 & 0x3F800000) >> 5); _diagonalRightTopToLeftBottom = (data & 0x40000000) == 1; _diagonalLeftBottomToTopRight = (data & 0x80000000) == 1; data3 = reader.ReadUInt32(); _topLineColor = (ushort)(data3 & 0x0000007F); _bottomLineColor = (ushort)((data3 & 0x00003F80) >> 1); _diagonalLineColor = (ushort)((data3 & 0x001FC000) >> 3); _diagonalLineStyle = (LineStyle)((data3 & 0x01E00000) >> 5); _fillPattern = (FillPattern)((data3 & 0xFC000000) >> 6); data = reader.ReadUInt16(); _patternColor = (ushort)(data & 0x007F); _patternBackground = (ushort)((data & 0x3F80) >> 7); Debug.Assert(reader.BaseStream.Position == reader.BaseStream.Length); } else { throw new InvalidRecordIdException(biff.Id, RecordType.Xf); } }
protected override void OnDrawItem(DrawItemEventArgs e) { e.DrawBackground(); Rectangle rect = new Rectangle(e.Bounds.Left, e.Bounds.Top + 2, e.Bounds.Right - e.Bounds.Left, e.Bounds.Bottom - e.Bounds.Y); FillPattern fp = new FillPattern(Color.Black); Brush brush = fp.createBrush(e.Index); e.Graphics.FillRectangle(brush, rect); }
static HandleStyles() { DefaultHandleBorder = new BorderPattern() { Color = System.Drawing.Color.Black, }; DefaultHandleFill = new FillPattern.Solid() { Color = System.Drawing.Color.White }; }
public void UpdateFillPattern() { WaitForRendering(); if (fillPattern != null) { fillPattern.PropertyChanged -= Pattern_PropertyChanged; } fillPattern = style.FillPattern; fillPattern.PropertyChanged += Pattern_PropertyChanged; DrawingBrush = GetNewBrush(style.FillPattern); }
static RectStyles() { DefaultRectBorder = new BorderPattern() { Color = System.Drawing.Color.Black, }; DefaultRectFill = new FillPattern.Solid() { Color = System.Drawing.Color.White }; }
//Graphics graphics; public Controller(int width, int height) { mShapes = new List <Shape>(); mGroups = new List <Group>(); mSelectedShapeIndex = -1; mSelectedGroupIndex = -1; border = new Border(); fillPattern = new FillPattern(); bitmap = new Bitmap(width, height); }
/// <summary> /// 填充背景颜色 /// </summary> /// <param name="Sheetindex"></param> /// <param name="RowIdex"></param> /// <param name="CellIndex"></param> /// <param name="fpt">填充类型</param> /// <param name="Forecolor">前景色:NPOI.HSSF.Util.HSSFColor.BLUE.index</param> /// <param name="backcolor">背景颜色:NPOI.HSSF.Util.HSSFColor.BLUE.index</param> public void FillBackgroundInXls(int Sheetindex, int RowIdex, int CellIndex, FillPattern fpt, short Forecolor, short backcolor) { InitializeWorkbook(); ISheet sheet1 = hssfworkbook.GetSheetAt(Sheetindex); //fill background ICellStyle style1 = hssfworkbook.CreateCellStyle(); style1.FillForegroundColor = Forecolor; style1.FillPattern = fpt; style1.FillBackgroundColor = backcolor; sheet1.GetRow(RowIdex).GetCell(CellIndex).CellStyle = style1; WriteToFile(); }
static string GetFillPatternTemplate(FillPattern pattern) { switch (pattern) { case FillPattern.Solid: return(Strings.area_solid); case FillPattern.Net: return(Strings.area_net); case FillPattern.Line: return(Strings.area_line); case FillPattern.Line_45: return(Strings.area_line_45); case FillPattern.Line_90: return(Strings.area_line_90); case FillPattern.Line_135: return(Strings.area_line_135); case FillPattern.Square: return(Strings.area_square); case FillPattern.Box: return(Strings.area_box); case FillPattern.Cross: return(Strings.area_cross); case FillPattern.Dash: return(Strings.area_dash); case FillPattern.Dolmit: return(Strings.area_dolmit); case FillPattern.Hex: return(Strings.area_hex); case FillPattern.Sacncr: return(Strings.area_sacncr); case FillPattern.Steel: return(Strings.area_steel); default: throw new Exception("Unsupported or unrecognized fill pattern: " + pattern.ToString()); } }
/// <summary> /// Create a fillpattern element /// </summary> /// <param name="patternName">The fillpattern name</param> /// <returns>Created fillpattern element</returns> private FillPatternElement CreateFacePattern(string patternName) { //Create a fillpattern with specified angle and spacing FillPattern fillPattern = new FillPattern(patternName, FillPatternTarget.Model, FillPatternHostOrientation.ToView, 0.5, 0.5, 0.5); Transaction trans = new Transaction(doc); trans.Start("Create a fillpattern element"); FillPatternElement fillPatternElement = FillPatternElement.Create(doc, fillPattern); trans.Commit(); return(fillPatternElement); }
public static bool SaveToModel(Document doc, FillPattern pattern) { using (Transaction t = new Transaction(doc)) { if (t.Start("Save pattern to Model") == TransactionStatus.Started) { FillPatternElement.Create(doc, pattern); t.Commit(); } else { t.RollBack(); } } return(true); }
public CStyleApplier CellColor(RGBColor foregroundColor, RGBColor backgroundColor, FillPattern pattern) { FillForegroundColor = foregroundColor; FillBackgroundColor = backgroundColor; if (foregroundColor.Index == RGBColor.AutomaticIndex && backgroundColor.Index == RGBColor.AutomaticIndex) { FillPattern = FillPattern.NoFill; } else { FillPattern = pattern; } return(this); }
public GDIPlusTools(IStyle style, IMessagePipe mp, RectangleF rect) { this.style = style; this.mp = mp; fillPattern = style.FillPattern; DrawingPen = GetNewPen(style); DrawingBrush = GetNewBrush(fillPattern); fillPattern.PropertyChanged += Pattern_PropertyChanged; style.BorderPattern.PropertyChanged += BorderPattern_PropertyChanged; ExpandRect(ref rect); Bounds = rect; }
public CStyleApplier CellColor(IArgbColor foregroundColor, IArgbColor backgroundColor, FillPattern pattern) { FillForegroundColor = foregroundColor; FillBackgroundColor = backgroundColor; if (ExcelColor.GetIndex(foregroundColor) == ExcelColor.AutomaticIndex && ExcelColor.GetIndex(backgroundColor) == ExcelColor.AutomaticIndex) { FillPattern = FillPattern.NoFill; } else { FillPattern = pattern; } return(this); }
/// <summary> /// 抽象图元基类构造函数 /// </summary> protected AbstractPrimitive() { UUID = Guid.NewGuid().ToString(); border = new BorderPattern(); border.PropertyChanged += PropertyChangedEvent; fillPattern = new FillPattern.None(); fillPattern.PropertyChanged += PropertyChangedEvent; PropertyChanged += PropertyChangedEvent; IsPropertyChanged = true; Layer = null; __messagePipe = new MessagePipe(this); }
private static string GetPatternName(FillPattern pattern) { switch (pattern) { default: case FillPattern.None: return("none"); case FillPattern.Solid: return("solid"); case FillPattern.Gray75: return("darkGray"); case FillPattern.Gray50: return("mediumGray"); case FillPattern.Gray25: return("lightGray"); case FillPattern.Gray125: return("gray125"); case FillPattern.Gray0625: return("gray0625"); case FillPattern.HorzStripe: return("darkHorizontal"); case FillPattern.VertStripe: return("darkVertical"); case FillPattern.ReverseDiagStripe: return("darkDown"); case FillPattern.DiagStripe: return("darkUp"); case FillPattern.DiagCross: return("darkGrid"); case FillPattern.ThickDiagCross: return("darkTrellis"); case FillPattern.ThinHorzStripe: return("lightHorizontal"); case FillPattern.ThinVertStripe: return("lightVertical"); case FillPattern.ThinReverseDiagStripe: return("lightDown"); case FillPattern.ThinDiagStripe: return("lightUp"); case FillPattern.ThinHorzCross: return("lightGrid"); case FillPattern.ThinDiagCross: return("lightTrellis"); } }
private Brush GetNewBrush(FillPattern fillPattern) { switch (fillPattern.FillType) { case FillType.None: return(Brushes.Transparent); case FillType.Solid: return(new SolidBrush(style.FillPattern.Color)); case FillType.LinearGradient: throw new NotImplementedException(); case FillType.Texture: throw new NotImplementedException(); } throw new ArgumentOutOfRangeException("图元的填充类型无效!"); }
public void IterateFillPattern() { if (DoneFillPatterns) { return; } //Get the current node. PositionalNode n = NeedToApply.Current; //If it is a junction, ignore it for now. //FilledRegions covering junctions/tunnels will be // added after fill patterns are applied to rooms. if (NodeStates[n] == NodeState.TunnelJunction) { DoneFillPatterns = !NeedToApply.MoveNext(); return; } //Get the best fill pattern for it and apply it if one exists. FillPattern p = Settings.MostSuitable(NodeAreas[n]); FilledRegion tempF; if (p != null) { FillData.BeingFilled = NodeAreas[n]; tempF = p.Apply(FillData); //If the area has no team spawns, add one at the top. if (tempF.PotentialSpawns[Spawns.Team].Count == 0 && tempF.Covering.Width + 1 >= 4) { tempF.PotentialSpawns[Spawns.Team].Add(new Region(tempF.Covering.Left, tempF.Covering.Top, tempF.Covering.Width, 0)); } FilledRegions.Add(tempF); } else { FilledRegions.Add(new NoRegion(NodeAreas[n])); } //Continue the iteration. DoneFillPatterns = !NeedToApply.MoveNext(); }
static FillPatternTest() { ConstructorArgumentValidationTestScenarios .RemoveAllScenarios() .AddScenario(() => new ConstructorArgumentValidationTestScenario <FillPattern> { Name = "constructor should throw ArgumentOutOfRangeException when parameter 'style' is FillPatternStyle.Unknown", ConstructionFunc = () => { var referenceObject = A.Dummy <FillPattern>(); var result = new FillPattern(FillPatternStyle.Unknown, referenceObject.Color); return(result); }, ExpectedExceptionType = typeof(ArgumentOutOfRangeException), ExpectedExceptionMessageContains = new[] { "style", "Unknown", }, }); }
static CircleStyles() { DefaultCircleBorder = new BorderPattern() { Color = System.Drawing.Color.Black, }; BoundsPatternBorder = new BorderPattern() { Color = System.Drawing.Color.Gray, DashStyle = System.Drawing.Drawing2D.DashStyle.Dash }; DefaultCircleFill = new FillPattern.Solid() { Color = System.Drawing.Color.White }; BoundsPatternFill = new FillPattern.None(); }
public FillPatternViewModel(FillPattern fillPattern) { _fillPattern = fillPattern; }
/// <summary> /// Sets the fill pattern. /// </summary> /// <param name="cell">The cell.</param> /// <param name="fillPattern">The fill pattern.</param> /// <returns>A <seealso cref="FluentCell"/>, for further styling.</returns> public static FluentCell FillPattern(this ICell cell, FillPattern fillPattern) { return new FluentCell(cell).FillPattern(fillPattern); }
/// <summary> /// The constructor for the record. /// </summary> /// <param name="biff">The GenericBiff record that should contain the correct type and data for the XF record.</param> /// <exception cref="InvalidRecordIdException"> /// An InvalidRecordIdException is thrown if biff contains an invalid type or invalid data. /// </exception> public XfRecord(GenericBiff biff) { if(biff.Id == (ushort)RecordType.Xf) { BinaryReader reader = new BinaryReader(biff.GetDataStream()); _fontIdx = reader.ReadUInt16(); _formatIdx = reader.ReadUInt16(); ushort data = reader.ReadUInt16(); _typeAndProtection = new TypeAndProtection(data & 0x000F); _parentIdx = (ushort)((data & 0xFFF0) >> 8); byte data2 = reader.ReadByte(); _horizontalAlignment = (HorizontalAlignment)(data2 & 0x07); _wrapped = (data & 0x088) != 0; _verticalAlignment = (VerticalAlignment)((data2 & 0x70) >> 4); data2 = reader.ReadByte(); _rotation = new Rotation(data2); data2 = reader.ReadByte(); _indentLevel = new Nibble((byte)(data2 & 0x0F)); _shrinkContent = (data2 & 0x10) == 1; _parentStyle = (ParentStyleAttributes)(reader.ReadByte()); uint data3 = reader.ReadUInt32(); _leftLineStyle = (LineStyle)(data3 & 0x0000000F); _rightLineStyle = (LineStyle)((data3 & 0x000000F0) >> 1); _topLineStyle = (LineStyle)((data3 & 0x00000F00) >> 2); _bottomLineStyle = (LineStyle)((data3 & 0x0000F000) >> 3); _rightLineColor = (ushort)((data3 & 0x007F0000) >> 4); _leftLineColor = (ushort)((data3 & 0x3F800000) >> 5); _diagonalRightTopToLeftBottom = (data & 0x40000000) == 1; _diagonalLeftBottomToTopRight = (data & 0x80000000) == 1; data3 = reader.ReadUInt32(); _topLineColor = (ushort)(data3 & 0x0000007F); _bottomLineColor = (ushort)((data3 & 0x00003F80) >> 1); _diagonalLineColor = (ushort)((data3 & 0x001FC000) >> 3); _diagonalLineStyle = (LineStyle)((data3 & 0x01E00000) >> 5); _fillPattern = (FillPattern)((data3 & 0xFC000000) >> 6); data = reader.ReadUInt16(); _patternColor = (ushort)(data & 0x007F); _patternBackground = (ushort)((data & 0x3F80) >> 7); Debug.Assert(reader.BaseStream.Position == reader.BaseStream.Length); } else throw new InvalidRecordIdException(biff.Id, RecordType.Xf); }
/// <summary> /// 获取单元格样式 /// </summary> /// <param name="xssfworkbook">Excel操作类</param> /// <param name="font">单元格字体</param> /// <param name="fillForegroundColor">图案的颜色</param> /// <param name="fillPattern">图案样式</param> /// <param name="fillBackgroundColor">单元格背景</param> /// <param name="ha">垂直对齐方式</param> /// <param name="va">垂直对齐方式</param> /// <returns></returns> public static ICellStyle GetCellStyle(XSSFWorkbook xssfworkbook, IFont font, XSSFColor fillForegroundColor, FillPattern fillPattern, XSSFColor fillBackgroundColor, HorizontalAlignment ha, VerticalAlignment va) { XSSFCellStyle cellstyle = xssfworkbook.CreateCellStyle() as XSSFCellStyle; cellstyle.FillPattern = fillPattern; cellstyle.Alignment = ha; cellstyle.VerticalAlignment = va; if (fillForegroundColor != null) { cellstyle.SetFillForegroundColor(fillForegroundColor); } if (fillBackgroundColor != null) { cellstyle.SetFillBackgroundColor(fillBackgroundColor); } if (font != null) { cellstyle.SetFont(font); } return cellstyle; }
/// <summary> /// Sets the fill pattern. /// </summary> /// <param name="fillPattern">The fill pattern.</param> /// <returns>The cell.</returns> public FluentCell FillPattern(FillPattern fillPattern) { Style.FillPattern = fillPattern; return this; }
public void SetFillPattern( DependencyObject obj, FillPattern value) { obj.SetValue(FillPatternProperty, value); }
private void SetDefaults() { _font = new Font(_doc, this); _format = Formats.Default; _style = new Style(_doc, this); _horizontalAlignment = HorizontalAlignments.Default; _textWrapRight = false; _verticalAlignment = VerticalAlignments.Default; _rotation = 0; _indentLevel = 0; _shrinkToCell = false; _textDirection = TextDirections.Default; _cellLocked = false; //NOTE: Unsure about this default (compare to Commented XF String in BinData) _formulaHidden = false; //NOTE: Unsure about this default (compare to Commented XF String in BinData) _isStyleXF = false; //NOTE: Unsure about this default (compare to Commented XF String in BinData) _useNumber = true; _useFont = true; _useMisc = true; _useBorder = true; _useBackground = true; _useProtection = true; //You should ALWAYS use protection ;-) _leftLineStyle = 0; _rightLineStyle = 0; _topLineStyle = 0; _bottomLineStyle = 0; _leftLineColor = Colors.DefaultLineColor; _rightLineColor = Colors.DefaultLineColor; _diagonalDescending = false; _diagonalAscending = false; _topLineColor = Colors.DefaultLineColor; _bottomLineColor = Colors.DefaultLineColor; _diagonalLineColor = Colors.DefaultLineColor; _diagonalLineStyle = LineStyle.None; _pattern = 0; _patternColor = Colors.DefaultPatternColor; _patternBackgroundColor = Colors.DefaultPatternBackgroundColor; OnChange(); }