static void TestDriveEnums() { BorderSide topSide = BorderSide.Top; bool isTop = (topSide == BorderSide.Top); WriteLine($"isTop: {isTop}"); }
internal double this[int height, BorderSide side] { get { height = TransformIndex(height); switch (side) { case BorderSide.Left: return(leftBorders[height]); case BorderSide.Right: return(rightBorders[height]); default: throw new ArgumentException(); } } set { height = TransformIndex(height); switch (side) { case BorderSide.Left: leftBorders[height] = value; break; case BorderSide.Right: rightBorders[height] = value; break; default: throw new ArgumentException(); } } }
protected override SceneID GetNextMap(IMovesBetweenScenes actor, BorderSide exitSide) { var position = actor.Position.Center; switch (exitSide) { case BorderSide.Right: position.X = (float)(Scene.Position.Right + actor.Position.Width * 4); break; case BorderSide.Left: position.X = (float)(Scene.Position.Left - actor.Position.Width * 4); break; case BorderSide.Top: position.Y = (float)(Scene.Position.Top - actor.Position.Height * 4); break; case BorderSide.Bottom: position.Y = (float)(Scene.Position.Bottom + actor.Position.Height * 4); break; } position = MasterTemplate.PositionInMapToPointInTemplate(CurrentMap, position); var nextMapIndex = MasterTemplate.MapRegions.FindIndex(p => p.Contains(position)); if (nextMapIndex == -1) { throw new ArgumentException("Unable to find adjacent map"); } return(new SceneID(CurrentMap.Name, nextMapIndex)); }
public static Vector2 GetAdjacent(this Vector2 vector, BorderSide side) { switch (side) { case BorderSide.Top: return(vector.Translate(0, -1)); case BorderSide.Left: return(vector.Translate(-1, 0)); case BorderSide.Right: return(vector.Translate(1, 0)); case BorderSide.Bottom: return(vector.Translate(0, 1)); case BorderSide.TopLeftCorner: return(vector.Translate(-1, -1)); case BorderSide.TopRightCorner: return(vector.Translate(1, -1)); case BorderSide.BottomLeftCorner: return(vector.Translate(-1, 1)); case BorderSide.BottomRightCorner: return(vector.Translate(1, 1)); case BorderSide.None: return(vector.Translate(0, 0)); default: throw new NotImplementedException(); } }
public StyleBorder(BorderSide side, System.Drawing.Color color, LineStyle style, BorderWeight border) { this.Side = side; this.Color = color; this.Style = style; this.Border = border; }
/// <summary> /// Starts the new side rule. /// </summary> /// <param name="borderSide">Border side to be applied.</param> /// <returns>Next rule reference.</returns> public IFluentBorderWithAll WithSide(BorderSide borderSide) { currentBorderDefinition.Side = borderSide; Dirty(); return(this); }
public IEnumerable <Tile> GetAdjacentWhile(BorderSide side, Predicate <Tile> condition) { var tile = this; yield return(this); while (side != BorderSide.None) { var adjacent = tile.GetAdjacent(side); if (!adjacent.Position.CollidesWith(tile.TileMap.Position, false)) { break; } if (condition(adjacent)) { yield return(adjacent); } else { break; } tile = adjacent; } }
public void Foo() { BorderSide a = BorderSide.Right; Console.WriteLine(a.ToString()); // Right //gdy nie ma określonego flags to można sprawdzić czy jest okreslone .IsDefined() }
public UnderlineInputBorder copyWith(BorderSide borderSide = null, BorderRadius borderRadius = null) { return(new UnderlineInputBorder( borderSide: borderSide ?? this.borderSide, borderRadius: borderRadius ?? this.borderRadius )); }
/** * Get the type of border to use for the selected border * * @param side - - where to apply the color defInition * @return borderstyle - the type of border to use. default value is NONE if border style is not Set. * @see BorderStyle */ public BorderStyle GetBorderStyle(BorderSide side) { CT_BorderPr ctborder = GetBorder(side); ST_BorderStyle?border = ctborder == null ? ST_BorderStyle.none : ctborder.style; return((BorderStyle)border); }
public override InputBorder copyWith(BorderSide borderSide) { return new OutlineInputBorder( borderSide: borderSide ?? this.borderSide, borderRadius: this.borderRadius, gapPadding: this.gapPadding ); }
public static TableBorder lerp(TableBorder a, TableBorder b, float t) { if (a == null && b == null) { return(null); } if (a == null) { return(b.scale(t)); } if (b == null) { return(a.scale(1.0f - t)); } return(new TableBorder( top: BorderSide.lerp(a.top, b.top, t), right: BorderSide.lerp(a.right, b.right, t), bottom: BorderSide.lerp(a.bottom, b.bottom, t), left: BorderSide.lerp(a.left, b.left, t), horizontalInside: BorderSide.lerp(a.horizontalInside, b.horizontalInside, t), verticalInside: BorderSide.lerp(a.verticalInside, b.verticalInside, t) )); }
/// <summary> /// Return a random position on the broder of the screen /// </summary> /// <param name="offset"></param> /// <returns></returns> public static Vector3 RandomScreenBorderPosition(float offset) { BorderSide randomBorderSide = Variables.RandomSide(); float randomScreenX = Random.Range(-screenConstraint.halfWidth, screenConstraint.halfWidth); float randomScreenY = Random.Range(-screenConstraint.halfHeight, screenConstraint.halfHeight); switch (randomBorderSide) { case BorderSide.TOP: return(new Vector3(randomScreenX, screenConstraint.halfHeight + offset, 0)); case BorderSide.BOTTOM: return(new Vector3(randomScreenX, -screenConstraint.halfHeight - offset, 0)); case BorderSide.LEFT: return(new Vector3(-screenConstraint.halfWidth - offset, randomScreenY, 0)); case BorderSide.RIGHT: return(new Vector3(screenConstraint.halfWidth + offset, randomScreenY, 0)); default: return(new Vector3(0, screenConstraint.halfHeight + offset, 0)); } }
public GridHelper SetBorder(BorderSide border) { this.headerHelper.SetBorder(border); this.columnHelper.SetBorder(border); return(this); }
public List <ClickableComponent> GetBorder(BorderSide side) { List <ClickableComponent> inventory_slots = new List <ClickableComponent>(); int row_size = capacity / rows; switch (side) { case BorderSide.Bottom: { for (int l = 0; l < inventory.Count; l++) { if (l >= actualInventory.Count - row_size) { inventory_slots.Add(inventory[l]); } } break; } case BorderSide.Top: { for (int k = 0; k < inventory.Count; k++) { if (k < row_size) { inventory_slots.Add(inventory[k]); } } break; } case BorderSide.Left: { for (int j = 0; j < inventory.Count; j++) { if (j % row_size == 0) { inventory_slots.Add(inventory[j]); } } break; } case BorderSide.Right: { for (int i = 0; i < inventory.Count; i++) { if (i % row_size == row_size - 1) { inventory_slots.Add(inventory[i]); } } break; } } return(inventory_slots); }
public void should_be_able_to_parse_enum_by_value() { var parsedBottomEnumValue = (BorderSide)Enum.Parse(typeof(BorderSide), "3"); // change the variable value to fix the test. const BorderSide expectedEnumValue = BorderSide.Left; Assert.Equal(expectedEnumValue, parsedBottomEnumValue); }
public UnderlineInputBorder( BorderSide borderSide = null, BorderRadius borderRadius = null ) : base(borderSide: borderSide ?? new BorderSide()) { this.borderRadius = borderRadius ?? BorderRadius.only( topLeft: Radius.circular(4.0f), topRight: Radius.circular(4.0f) ); }
public OutlineInputBorder( BorderSide borderSide = null, BorderRadius borderRadius = null, float gapPadding = 4.0f ) : base(borderSide: borderSide ?? new BorderSide()) { D.assert(gapPadding >= 0.0f); this.gapPadding = gapPadding; this.borderRadius = borderRadius ?? BorderRadius.all(Radius.circular(4.0f)); }
static void Main(string[] args) { BorderSide TopSide = BorderSide.Top; bool IsTop = (TopSide == BorderSide.Top); Days day = Days.Friday; Console.WriteLine(day); }
public UnderlineTabIndicator( BorderSide borderSide = null, EdgeInsetsGeometry insets = null) { borderSide = borderSide ?? new BorderSide(width: 2.0f, color: Colors.white); insets = insets ?? EdgeInsets.zero; this.borderSide = borderSide; this.insets = insets; }
private CT_BorderPr GetBorder(BorderSide side, bool ensure) { CT_BorderPr ctBorderPr; switch (side) { case BorderSide.TOP: ctBorderPr = this.border.top; if (ensure && ctBorderPr == null) { ctBorderPr = this.border.AddNewTop(); break; } break; case BorderSide.RIGHT: ctBorderPr = this.border.right; if (ensure && ctBorderPr == null) { ctBorderPr = this.border.AddNewRight(); break; } break; case BorderSide.BOTTOM: ctBorderPr = this.border.bottom; if (ensure && ctBorderPr == null) { ctBorderPr = this.border.AddNewBottom(); break; } break; case BorderSide.LEFT: ctBorderPr = this.border.left; if (ensure && ctBorderPr == null) { ctBorderPr = this.border.AddNewLeft(); break; } break; case BorderSide.DIAGONAL: ctBorderPr = this.border.diagonal; if (ensure && ctBorderPr == null) { ctBorderPr = this.border.AddNewDiagonal(); break; } break; default: throw new ArgumentException("No suitable side specified for the border"); } return(ctBorderPr); }
public _OutlineBorder( ShapeBorder shape, BorderSide side ) { D.assert(shape != null); D.assert(side != null); this.shape = shape; this.side = side; }
public GridHeaderHelper SetBorder(BorderSide border) { var cell = this.ContainerControl.GetLastCell(); if (cell != null) { cell.SetBorder(border); } return(this); }
public override ShapeBorder lerpTo(ShapeBorder b, float t) { if (b is UnderlineInputBorder) { return new UnderlineInputBorder( borderSide: BorderSide.lerp(this.borderSide, (b as UnderlineInputBorder).borderSide, t), borderRadius: BorderRadius.lerp(this.borderRadius, (b as UnderlineInputBorder).borderRadius, t) ); } return base.lerpTo(b, t); }
public override ShapeBorder lerpFrom(ShapeBorder a, float t) { if (a is UnderlineInputBorder) { return new UnderlineInputBorder( borderSide: BorderSide.lerp((a as UnderlineInputBorder).borderSide, this.borderSide, t), borderRadius: BorderRadius.lerp((a as UnderlineInputBorder).borderRadius, this.borderRadius, t) ); } return base.lerpFrom(a, t); }
public void should_be_able_to_parse_enum_by_name() { // pass without cast to BorderSide var parsedBottomEnumValue = (BorderSide)Enum.Parse(typeof(BorderSide), "Bottom"); // change the variable value to fix the test. const BorderSide expectedEnumValue = BorderSide.Bottom; Assert.Equal(expectedEnumValue, parsedBottomEnumValue); }
/// <summary>See <c>WpfExtensions</c> for details.</summary> public static void DrawRectangle(DrawingContext dc, Rect rect, Paint paint, CornerRadius corners, CornerStyle cornerStyle, BorderSide borderSide, bool snapToPixel) { // get brush and stroke resources if (paint == null) return; var fill = paint.Fill; var strokes = paint.GetStrokePens().ToArray(); var hasFill = (fill != null); var hasStroke = (strokes.Length > 0 && borderSide != BorderSide.None); if (!hasFill && !hasStroke) return; // compute the drawing rectangle with offset for pixel snapping // (assumptions: the box itself is pixel snapped, all strokes have same thickness, and the thickness is a whole number) var halfThickness = Math.Round(hasStroke ? strokes[0].Thickness : 0.0) / 2; if (snapToPixel && hasStroke) { rect = new Rect(rect.X + halfThickness, rect.Y + halfThickness, (rect.Width - 2 * halfThickness).Max(0), (rect.Height - 2 * halfThickness).Max(0)); } // select drawing function based on the corners complexity DrawingFunction fillFunc = null; if (corners.IsZero()) { fillFunc = _drawSimpleRectangle; } else if (corners.IsUniform()) { fillFunc = _drawRoundedRectangle; } else { fillFunc = _drawComplexRectangle; } // draw the border if (hasStroke) { if (paint.IsA<QuadPaint>()) { rect = _drawSide(dc, rect, null, strokes[0], corners, cornerStyle, BorderSide.Left); rect = _drawSide(dc, rect, null, strokes[1], corners, cornerStyle, BorderSide.Top); rect = _drawSide(dc, rect, null, strokes[2], corners, cornerStyle, BorderSide.Right); rect = _drawSide(dc, rect, null, strokes[3], corners, cornerStyle, BorderSide.Bottom); corners = _inflateCorners(corners, strokes[3]); } else { var strokeFunc = (borderSide == BorderSide.All ? fillFunc : _drawSide); foreach (var stroke in strokes) { rect = strokeFunc(dc, rect, null, stroke, corners, cornerStyle, borderSide); corners = _inflateCorners(corners, stroke); } } } // draw the background if (hasFill) { if (snapToPixel) { rect = _deflateRect(rect, -halfThickness); } if (paint.FillMode == BrushMappingMode.Absolute) { fill = _mapAbsoluteFill(fill, rect); } fillFunc(dc, rect, fill, null, corners, cornerStyle, borderSide); } }
static void Main(string[] args) { UnitConverter feetToInches = new UnitConverter(12); UnitConverter milesToFeet = new UnitConverter(5280); Console.WriteLine(feetToInches.Convert(30)); // 360 Console.WriteLine(feetToInches.Convert(100)); // 1200 Console.WriteLine(feetToInches.Convert(milesToFeet.Convert(1))); // 63360 Panda p1 = new Panda("Pan Dee"); Panda p2 = new Panda("Pan Dah"); Console.WriteLine(p1.Name); Console.WriteLine(p2.Name); Console.WriteLine(Panda.Population); BorderSide topSide = BorderSide.Top; bool isTrue = (topSide == BorderSide.Top); // true foreach (char s in "house") { Console.Write(s + " "); } Stock msft = new Stock(); msft.CurrentPrice = 30; msft.CurrentPrice -= 3; Console.WriteLine(msft.CurrentPrice); string msc = MyStaticClass.MyMethod(); Console.WriteLine(msc); MyNonStaticClass mnsc = new MyNonStaticClass(); Console.WriteLine(mnsc.MyMethod()); Shares share = new Shares { Name = "MyShares", SharesOwned = 1000 }; Console.WriteLine(share.Name); Console.WriteLine(share.SharesOwned); House mansion = new House { Name = "Mansion", Mortage = 250000 }; Console.WriteLine(mansion.Name); Console.WriteLine(mansion.Mortage); Console.ReadLine(); }
public OutlineInputBorder copyWith( BorderSide borderSide, BorderRadius borderRadius, float? gapPadding ) { return new OutlineInputBorder( borderSide: borderSide ?? this.borderSide, borderRadius: borderRadius ?? this.borderRadius, gapPadding: gapPadding ?? this.gapPadding ); }
private void AlterSideStyle(BorderSide bSide) { if ((_sides & bSide) == bSide) { this._sides &= (~bSide); } else { this._sides |= bSide; } }
public NotificationDot( string content, BorderSide borderSide = null, EdgeInsets margin = null, Key key = null ) : base(key: key) { this.content = content; this.borderSide = borderSide; this.margin = margin; }
public Border(int iWidth, Color color, BorderSide border) { Width = iWidth; Colour = color; Side = border; }
/** * Set the type of border to use for the selected border * * @param side - - where to apply the color defInition * @param style - border style * @see BorderStyle */ public void SetBorderStyle(BorderSide side, BorderStyle style) { GetBorder(side, true).style = (ST_BorderStyle)Enum.GetValues(typeof(ST_BorderStyle)).GetValue((int)style + 1); }
private static Rect _drawSimpleRectangle(DrawingContext dc, Rect rect, Brush fill, Pen stroke, CornerRadius corners, CornerStyle cornerStyle, BorderSide borderSide) { dc.DrawRectangle(fill, stroke, rect); return _deflateRect(rect, stroke); }
internal static void DoDrawBorder(Graphics gr, ScrollBarBorderStyle style, Color c, Rectangle rect, BorderSide sides, Color parentColor) { if (((style != ScrollBarBorderStyle.None) && (rect.Width > 0)) && ((rect.Height > 0) && (sides != BorderSide.None))) { Pen pen = GetPen(c); if ((rect.Width == 1) && (rect.Height == 1)) { DrawPixel(gr, c, rect.Left, rect.Top); } else if (rect.Width == 1) { if ((sides & (BorderSide.Right | BorderSide.Left)) != BorderSide.None) { gr.DrawLine(pen, rect.Left, rect.Top, rect.Left, rect.Bottom - 1); } } else if (rect.Height == 1) { if ((sides & (BorderSide.Down | BorderSide.Up)) != BorderSide.None) { gr.DrawLine(pen, rect.Left, rect.Top, rect.Right - 1, rect.Top); } } else { int left = rect.Left; int top = rect.Top; int num3 = rect.Right - 1; int num4 = rect.Bottom - 1; if ((style == ScrollBarBorderStyle.Solid) || ((style == ScrollBarBorderStyle.Rounded) && ((rect.Width == 2) || (rect.Height == 2)))) { if ((sides & BorderSide.Left) == BorderSide.Left) { gr.DrawLine(pen, left, top, left, num4); } if ((sides & BorderSide.Up) == BorderSide.Up) { gr.DrawLine(pen, left, top, num3, top); } if ((sides & BorderSide.Right) == BorderSide.Right) { gr.DrawLine(pen, num3, top, num3, num4); } if ((sides & BorderSide.Down) == BorderSide.Down) { gr.DrawLine(pen, left, num4, num3, num4); } } else { if (rect.Width == 3) { if ((sides & BorderSide.Up) == BorderSide.Up) { if ((sides & BorderSide.Left) == BorderSide.None) { gr.DrawLine(pen, left, top, left + 1, top); } else if ((sides & BorderSide.Right) == BorderSide.None) { gr.DrawLine(pen, left + 1, top, num3, top); } else { DrawPixel(gr, c, left + 1, top); } } if ((sides & BorderSide.Down) == BorderSide.Down) { if ((sides & BorderSide.Left) == BorderSide.None) { gr.DrawLine(pen, left, num4, left + 1, num4); } else if ((sides & BorderSide.Right) == BorderSide.None) { gr.DrawLine(pen, left + 1, num4, num3, num4); } else { DrawPixel(gr, c, left + 1, num4); } } } else { if ((sides & BorderSide.Up) == BorderSide.Up) { gr.DrawLine(pen, left + (((sides & BorderSide.Left) == BorderSide.Left) ? 1 : 0), top, num3 - (((sides & BorderSide.Right) == BorderSide.Right) ? 1 : 0), top); } if ((sides & BorderSide.Down) == BorderSide.Down) { gr.DrawLine(pen, left + (((sides & BorderSide.Left) == BorderSide.Left) ? 1 : 0), num4, num3 - (((sides & BorderSide.Right) == BorderSide.Right) ? 1 : 0), num4); } } if (rect.Height == 3) { if ((sides & BorderSide.Left) == BorderSide.Left) { if ((sides & BorderSide.Up) == BorderSide.None) { gr.DrawLine(pen, left, top, left, top + 1); } else if ((sides & BorderSide.Down) == BorderSide.None) { gr.DrawLine(pen, left, top + 1, left, num4); } else { DrawPixel(gr, c, left, top + 1); } } if ((sides & BorderSide.Right) == BorderSide.Right) { if ((sides & BorderSide.Up) == BorderSide.None) { gr.DrawLine(pen, num3, top, num3, top + 1); } else if ((sides & BorderSide.Down) == BorderSide.None) { gr.DrawLine(pen, num3, top + 1, num3, num4); } else { DrawPixel(gr, c, num3, top + 1); } } } else { if ((sides & BorderSide.Left) == BorderSide.Left) { gr.DrawLine(pen, left, top + (((sides & BorderSide.Up) == BorderSide.Up) ? 1 : 0), left, num4 - (((sides & BorderSide.Down) == BorderSide.Down) ? 1 : 0)); } if ((sides & BorderSide.Right) == BorderSide.Right) { gr.DrawLine(pen, num3, top + (((sides & BorderSide.Up) == BorderSide.Up) ? 1 : 0), num3, num4 - (((sides & BorderSide.Down) == BorderSide.Down) ? 1 : 0)); } } if (parentColor != Color.Transparent) { if ((sides & (BorderSide.Up | BorderSide.Left)) == (BorderSide.Up | BorderSide.Left)) { DrawPixel(gr, parentColor, left, top); } if ((sides & (BorderSide.Right | BorderSide.Up)) == (BorderSide.Right | BorderSide.Up)) { DrawPixel(gr, parentColor, num3, top); } if ((sides & (BorderSide.Down | BorderSide.Left)) == (BorderSide.Down | BorderSide.Left)) { DrawPixel(gr, parentColor, left, num4); } if ((sides & (BorderSide.Down | BorderSide.Right)) == (BorderSide.Down | BorderSide.Right)) { DrawPixel(gr, parentColor, num3, num4); } } } } } }
private static Rect _drawComplexRectangle(DrawingContext dc, Rect rect, Brush fill, Pen stroke, CornerRadius corners, CornerStyle cornerStyle, BorderSide borderSide) { var geometry = new StreamGeometry(); using (var ctx = geometry.Open()) { AddRectangleFigure(ctx, rect, (fill != null), (stroke != null), corners, cornerStyle); } geometry.Freeze(); dc.DrawGeometry(fill, stroke, geometry); return _deflateRect(rect, stroke); }
private static Rect _drawRoundedRectangle(DrawingContext dc, Rect rect, Brush fill, Pen stroke, CornerRadius corners, CornerStyle cornerStyle, BorderSide borderSide) { var r = corners.TopLeft; dc.DrawRoundedRectangle(fill, stroke, rect, r, r); return _deflateRect(rect, stroke); }
/** * Gets border color * * @param side the border side * @return the used color */ public XSSFColor GetBorderColor(BorderSide side) { switch (side) { case BorderSide.BOTTOM: return GetBottomBorderXSSFColor(); case BorderSide.RIGHT: return GetRightBorderXSSFColor(); case BorderSide.TOP: return GetTopBorderXSSFColor(); case BorderSide.LEFT: return GetLeftBorderXSSFColor(); default: throw new ArgumentException("Unknown border: " + side); } }
private static Rect _drawSide(DrawingContext dc, Rect rect, Brush fill, Pen stroke, CornerRadius corners, CornerStyle cornerStyle, BorderSide borderSide) { var full = stroke.Thickness; var half = full / 2.0; var x0 = rect.Left; var x1 = rect.Right; var y0 = rect.Top; var y1 = rect.Bottom; var TL = corners.TopLeft; var TR = corners.TopRight; var BR = corners.BottomRight; var BL = corners.BottomLeft; var SQ = 0.0; switch (cornerStyle) { case CornerStyle.Diagonal: SQ = 1.0 / 2.0; break; case CornerStyle.Round: SQ = 1.0 - 1.0 / Math.Sqrt(2); break; case CornerStyle.Concave: SQ = 1.0 / Math.Sqrt(2); break; } var hasCorners = false; var R = new double[4]; var P = new Point[4]; switch (borderSide) { case BorderSide.Left: if (TL > 0) { R[0] = TL; P[0].X = x0 + SQ * (TL - full); P[0].Y = y0 + SQ * TL; hasCorners = true; } P[1].X = x0; P[1].Y = y0 + (TL - half); P[2].X = x0; P[2].Y = y1 - (BL - half); if (BL > 0) { R[3] = BL; P[3].X = x0 + SQ * BL; P[3].Y = y1 - SQ * BL; hasCorners = true; } rect.X += full; rect.Width = (rect.Width - full).Max(0); break; case BorderSide.Top: if (TR > 0) { R[0] = TR; P[0].X = x1 - SQ * TR; P[0].Y = y0 + SQ * (TR - full); hasCorners = true; } P[1].X = x1 - (TR - half); P[1].Y = y0; P[2].X = x0 + (TL - half); P[2].Y = y0; if (TL > 0) { R[3] = TL; P[3].X = x0 + SQ * (TL - full); P[3].Y = y0 + SQ * TL; hasCorners = true; } rect.Y += full; rect.Height = (rect.Height - full).Max(0); break; case BorderSide.Right: if (BR > 0) { R[0] = BR; P[0].X = x1 - SQ * (BR + full); P[0].Y = y1 - SQ * BR; hasCorners = true; } P[1].X = x1; P[1].Y = y1 - (BR - half); P[2].X = x1; P[2].Y = y0 + (TR - half); if (TR > 0) { R[3] = TR; P[3].X = x1 - SQ * TR; P[3].Y = y0 + SQ * (TR - full); hasCorners = true; } rect.Width = (rect.Width - full).Max(0); break; case BorderSide.Bottom: if (BL > 0) { R[0] = BL; P[0].X = x0 + SQ * (BL - full); P[0].Y = y1 - SQ * (BL - full); hasCorners = true; } P[1].X = x0 + (BL - half); P[1].Y = y1; P[2].X = x1 - (BR - half); P[2].Y = y1; if (BR > 0) { R[3] = BR; P[3].X = x1 - SQ * (BR - full); P[3].Y = y1 - SQ * (BR - full); hasCorners = true; } rect.Height = (rect.Height - full).Max(0); break; default: return rect; } if (!hasCorners) { dc.DrawLine(stroke, P[1], P[2]); } else { var sg = new StreamGeometry(); var gc = sg.Open(); switch (cornerStyle) { case CornerStyle.Concave: case CornerStyle.Round: var sweep = (cornerStyle == CornerStyle.Round ? SweepDirection.Counterclockwise : SweepDirection.Clockwise); if (R[0] == 0) { gc.BeginFigure(P[1], false, false); } else { gc.BeginFigure(P[0], false, false); gc.ArcTo(P[1], new Size(R[0], R[0]), 0, false, sweep, true, false); } gc.LineTo(P[2], true, false); if (R[3] != 0) { gc.ArcTo(P[3], new Size(R[3], R[3]), 0, false, sweep, true, false); } break; case CornerStyle.Diagonal: if (R[0] == 0) { gc.BeginFigure(P[1], false, false); } else { gc.BeginFigure(P[0], false, false); gc.LineTo(P[1], true, false); } gc.LineTo(P[2], true, false); if (R[3] != 0) { gc.LineTo(P[3], true, false); } break; } gc.Close(); sg.Freeze(); dc.DrawGeometry(null, stroke, sg); } return rect; }
/** * Get the color to use for the selected border * * @param side - where to apply the color defInition * @return color - color to use as XSSFColor. null if color is not set */ public XSSFColor GetBorderColor(BorderSide side) { CT_BorderPr borderPr = GetBorder(side); if (borderPr != null && borderPr.IsSetColor()) { XSSFColor clr = new XSSFColor(borderPr.color); if (_theme != null) { _theme.InheritFromThemeAsRequired(clr); } return clr; } else { // No border set return null; } }
/** * Set the color to use for the selected border * * @param side - where to apply the color defInition * @param color - the color to use */ public void SetBorderColor(BorderSide side, XSSFColor color) { CT_BorderPr borderPr = GetBorder(side, true); if (color == null) borderPr.UnsetColor(); else borderPr.color = color.GetCTColor(); }
private CT_BorderPr GetBorder(BorderSide side) { return GetBorder(side, false); }
private CT_BorderPr GetBorder(BorderSide side, bool ensure) { CT_BorderPr borderPr; switch (side) { case BorderSide.TOP: borderPr = border.top; if (ensure && borderPr == null) borderPr = border.AddNewTop(); break; case BorderSide.RIGHT: borderPr = border.right; if (ensure && borderPr == null) borderPr = border.AddNewRight(); break; case BorderSide.BOTTOM: borderPr = border.bottom; if (ensure && borderPr == null) borderPr = border.AddNewBottom(); break; case BorderSide.LEFT: borderPr = border.left; if (ensure && borderPr == null) borderPr = border.AddNewLeft(); break; case BorderSide.DIAGONAL: borderPr = border.diagonal; if (ensure && borderPr == null) borderPr = border.AddNewDiagonal(); break; default: throw new ArgumentException("No suitable side specified for the border"); } return borderPr; }
/** * Get the type of border to use for the selected border * * @param side - - where to apply the color defInition * @return borderstyle - the type of border to use. default value is NONE if border style is not Set. * @see BorderStyle */ public BorderStyle GetBorderStyle(BorderSide side) { CT_BorderPr ctborder = GetBorder(side); ST_BorderStyle? border = ctborder == null ? ST_BorderStyle.none : ctborder.style; return (BorderStyle)border; }
/** * Set the color to use for the selected border * * @param side - where to apply the color defInition * @param color - the color to use */ public void SetBorderColor(BorderSide side, XSSFColor color) { switch (side) { case BorderSide.BOTTOM: SetBottomBorderColor(color); break; case BorderSide.RIGHT: SetRightBorderColor(color); break; case BorderSide.TOP: SetTopBorderColor(color); break; case BorderSide.LEFT: SetLeftBorderColor(color); break; } }
/// <summary>Gets the total stroke thickness, computed from the sum of the thicknesses of all the individual stroke pens along the specified border side(s).</summary> public Thickness GetTotalStrokeThickness(BorderSide borders) { if (borders == BorderSide.None) return new Thickness(); var t = new Thickness(GetTotalStrokeThickness()); switch (borders) { case BorderSide.All: return t; case BorderSide.Left: t.Right = t.Top = t.Bottom = 0; break; case BorderSide.Right: t.Left = t.Top = t.Bottom = 0; break; case BorderSide.Top: t.Bottom = t.Left = t.Right = 0; break; case BorderSide.Bottom: t.Top = t.Left = t.Right = 0; break; } return t; }