void RandomSpanTest() { // set for (int i = 0; i < 100; i++) { int r = rand.Next(25); int c = rand.Next(20); BorderPositions borderPos = BorderPositions.None; switch (rand.Next(5)) { case 0: borderPos = BorderPositions.Left; break; case 1: borderPos = BorderPositions.Right; break; case 2: borderPos = BorderPositions.Top; break; case 3: borderPos = BorderPositions.Bottom; break; case 4: borderPos = BorderPositions.Outside; break; } worksheet.SetRangeBorders(new RangePosition(r, c, 1, 1), borderPos, RangeBorderStyle.BlackSolid); //Application.DoEvents(); } // check AssertTrue(Worksheet._Debug_Validate_BorderSpan()); }
private void AddBorderPosStyle(List <RangeBorderInfo> posStyles, BorderPositions scope) { // remove borders that not changed var q = borders.Where(b => (scope & b.Key) == b.Key).GroupBy(b => b.Value); BorderPositions allPos = BorderPositions.None; // create fewer actions for multiple border settings foreach (var bs in q) { BorderPositions pos = BorderPositions.None; // find same styles foreach (var p in borders.Where(b => (scope & b.Key) == b.Key && b.Value == bs.Key)) { // merge positions pos |= p.Key; } allPos |= pos; if (pos != BorderPositions.None) { posStyles.Add(new RangeBorderInfo(pos, bs.Key)); } } }
public void InvertBorderStats(BorderPositions pos) { ProcessBorderStyles(pos, p => { if ((mixBorders & p) == p) { mixBorders &= ~p; borders.Remove(p); borderRemoved |= p; borderAdded &= ~p; } if (borders.ContainsKey(p) && borders[p].Style == currentBorderStlye && borders[p].Color == currentColor) { borders.Remove(p); borderRemoved |= p; borderAdded &= ~p; } else { CheckBorderStyle(p); } }); Invalidate(); }
protected override void OnMouseDown(MouseEventArgs e) { BorderPositions pos = GetBorderPos(e.Location); if (pos != BorderPositions.None) { InvertBorderStats(pos); Invalidate(); } }
public void RemoveBorderStyle(BorderPositions pos) { ProcessBorderStyles(pos, p => { borders.Remove(p); mixBorders &= ~p; borderRemoved |= pos; borderAdded &= ~p; }); Invalidate(); }
private void ProcessBorderStyles(BorderPositions tpos, Action <BorderPositions> handler) { for (int i = 0; i < allPos.Length; i++) { BorderPositions pos = allPos[i]; if (allPos[i] != BorderPositions.None && (tpos & pos) == pos) { handler(pos); } } }
public void CheckBorderStyle(BorderPositions pos) { ProcessBorderStyles(pos, p => { borders[p] = new RangeBorderStyle { Style = currentBorderStlye, Color = currentColor, }; mixBorders &= ~p; }); borderAdded |= pos; borderRemoved &= ~pos; Invalidate(); }
public Border(FormatBase parent, int baseKey) : base(parent, baseKey) { switch (baseKey) { case 1: this.borderPositions_0 = BorderPositions.Left; break; case 2: this.borderPositions_0 = BorderPositions.Top; break; case 3: this.borderPositions_0 = BorderPositions.Bottom; break; case 4: this.borderPositions_0 = BorderPositions.Right; break; case 5: this.borderPositions_0 = BorderPositions.Vertical; break; case 6: this.borderPositions_0 = BorderPositions.Horizontal; break; case 7: this.borderPositions_0 = BorderPositions.DiagonalDown; break; case 8: this.borderPositions_0 = BorderPositions.DiagonalUp; break; } base.method_0(parent); }
/// <summary> /// Check whether the border position contains any one of specified positions /// </summary> /// <param name="pos">border position container to be checked from</param> /// <param name="target">target border position to be checked</param> /// <returns>true if border position flags contains the specified flags</returns> public static bool HasAny(this BorderPositions pos, BorderPositions target) { return((pos & target) > 0); }
/// <summary> /// Check whether specified border position contains another position /// </summary> /// <param name="pos">border position container to be checked from</param> /// <param name="target">target border position to be checked</param> /// <returns>true if border position flags contains the specified flags</returns> public static bool Has(this BorderPositions pos, BorderPositions target) { return((pos & target) == target); }
internal static string EncodeBorderPos(BorderPositions pos) { return(pos.ToString().ToLower()); }
/// <summary> /// Create action that perform setting border to a range /// </summary> /// <param name="range">Range to be appiled this action</param> /// <param name="pos">Position of range to set border</param> /// <param name="styles">Style of border</param> public SetRangeBorderAction(RangePosition range, BorderPositions pos, RangeBorderStyle styles) : this(range, new RangeBorderInfo[] { new RangeBorderInfo(pos, styles) }) { }
private string GetBorderInfo(int r, int c, BorderPositions borderPos) { StringBuilder sb = new StringBuilder(); if ((borderPos & BorderPositions.Top) > 0) { ReoGridHBorder top = grid.RetrieveHBorder(r, c); sb.AppendLine(string.Format("Top [{0,3},{1,3}]", r, c)); if (top != null) { sb.AppendLine(string.Format("Cols [{0,7}]", top.Span)); sb.AppendLine(string.Format("Pos [{0,7}]", top.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", top.Style == null ? "" : " YES ")); } else { sb.AppendLine("Empty"); } } if ((borderPos & BorderPositions.Bottom) > 0) { ReoGridHBorder bottom = grid.RetrieveHBorder(r + 1, c); sb.AppendLine(string.Format("Bottom[{0,3},{1,3}]", r + 1, c)); if (bottom != null) { sb.AppendLine(string.Format("Cols [{0,7}]", bottom.Span)); sb.AppendLine(string.Format("Pos [{0,7}]", bottom.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", bottom.Style == null ? "" : " YES ")); } else { sb.AppendLine("Empty"); } } if ((borderPos & BorderPositions.Left) > 0) { ReoGridVBorder left = grid.RetrieveVBorder(r, c); sb.AppendLine(string.Format("Left [{0,3},{1,3}]", r, c)); if (left != null) { sb.AppendLine(string.Format("Rows [{0,7}]", left.Span)); sb.AppendLine(string.Format("Pos [{0,7}]", left.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", left.Style == null ? "" : " YES ")); } else { sb.AppendLine("Empty"); } } if ((borderPos & BorderPositions.Right) > 0) { ReoGridVBorder right = grid.RetrieveVBorder(r, c + 1); sb.AppendLine(string.Format("Right [{0,3},{1,3}]", r, c + 1)); if (right != null) { sb.AppendLine(string.Format("Rows [{0,7}]", right.Span)); sb.AppendLine(string.Format("Pos [{0,7}]", right.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", right.Style == null ? "" : " YES ")); } else { sb.AppendLine("Empty"); } } return(sb.ToString()); }
/// <summary> /// Create instance for BorderRemovedEventArgs with specified range and /// position of border. /// </summary> /// <param name="range"></param> /// <param name="pos"></param> public BorderRemovedEventArgs(RangePosition range, BorderPositions pos) : base(range) { this.Pos = pos; }
/// <summary> /// Create instance for BorderAddedEventArgs with specified range, /// position of border and style of border. /// </summary> /// <param name="range"></param> /// <param name="pos"></param> /// <param name="style"></param> public BorderAddedEventArgs(RangePosition range, BorderPositions pos, RangeBorderStyle style) : base(range) { this.Pos = pos; this.Style = style; }
/// <summary> /// Create instance for SetRangeBorderAction with specified range and border styles. /// </summary> /// <param name="range">Range to be appiled this action</param> /// <param name="pos">Position of range to set border</param> public RemoveRangeBorderAction(RangePosition range, BorderPositions pos) : base(range) { this.BorderPos = pos; }