/// <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> /// <param name="style">Style of border</param> public RGRemoveRangeBorderAction(ReoGridRange range, ReoGridBorderPos pos) : base(range) { this.BorderPos = pos; }
private void SetSelectionBorder(ReoGridBorderPos borderPos, BorderLineStyle style) { grid.DoAction(new RGSetRangeBorderAction(grid.SelectionRange, borderPos, new ReoGridBorderStyle { Color = borderColorPickToolStripItem.SolidColor, Style = style })); }
private void ProcessBorderStyles(ReoGridBorderPos tpos, Action<ReoGridBorderPos> handler) { for (int i = 0; i < allPos.Length; i++) { ReoGridBorderPos pos = allPos[i]; if (allPos[i] != ReoGridBorderPos.None && (tpos & pos) == pos) { handler(pos); } } }
/// <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="style">Style of border</param> public RGSetRangeBorderAction(ReoGridRange range, ReoGridBorderPos pos, ReoGridBorderStyle style) : this(range, new ReoGridBorderPosStyle[] { new ReoGridBorderPosStyle(pos, style) }) { }
public void RemoveBorderStyle(ReoGridBorderPos pos) { ProcessBorderStyles(pos, p => { borders.Remove(p); mixBorders &= ~p; borderRemoved |= pos; borderAdded &= ~p; }); Invalidate(); }
private void AddBorderPosStyle(List<ReoGridBorderPosStyle> posStyles, ReoGridBorderPos scope) { // filter border without any changes var q = borders.Where(b => (scope & b.Key) == b.Key).GroupBy(b => b.Value); ReoGridBorderPos allPos = ReoGridBorderPos.None; // find same styles for creating actions as few as possible foreach (var bs in q) { ReoGridBorderPos pos = ReoGridBorderPos.None; // find same styles foreach (var p in borders.Where(b => (scope & b.Key) == b.Key && b.Value == bs.Key)) { // union position pos |= p.Key; } allPos |= pos; if (pos != ReoGridBorderPos.None) { posStyles.Add(new ReoGridBorderPosStyle(pos, bs.Key)); } } }
public void InvertBorderStats(ReoGridBorderPos 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(); }
/// <summary> /// Load border info from grid /// </summary> /// <param name="grid"></param> public void ReadFromGrid(ReoGridControl grid) { if (grid.SelectionRange.IsEmpty) { this.Enabled = false; } else { ReoGridRangeBorderInfo info = grid.GetRangeBorder(grid.SelectionRange, false); if (!info.Left.IsEmpty) borders[ReoGridBorderPos.Left] = info.Left; if (!info.Right.IsEmpty) borders[ReoGridBorderPos.Right] = info.Right; if (!info.Top.IsEmpty) borders[ReoGridBorderPos.Top] = info.Top; if (!info.Bottom.IsEmpty) borders[ReoGridBorderPos.Bottom] = info.Bottom; if (!info.InsideHorizontal.IsEmpty) borders[ReoGridBorderPos.InsideHorizontal] = info.InsideHorizontal; if (!info.InsideVertical.IsEmpty) borders[ReoGridBorderPos.InsideVertical] = info.InsideVertical; rows = grid.SelectionRange.Rows > 2 ? 2 : grid.SelectionRange.Rows; cols = grid.SelectionRange.Cols > 2 ? 2 : grid.SelectionRange.Cols; mixBorders |= info.NonUniformPos; } }
public void CheckBorderStyle(ReoGridBorderPos pos) { ProcessBorderStyles(pos, p => { borders[p] = new ReoGridBorderStyle { Style = currentBorderStlye, Color = currentColor, }; mixBorders &= ~p; }); borderAdded |= pos; borderRemoved &= ~pos; Invalidate(); }
/// <summary> /// Create instance for BorderRemovedEventArgs with specified range and /// position of border. /// </summary> /// <param name="range"></param> /// <param name="pos"></param> public RGBorderRemovedEventArgs(ReoGridRange range, ReoGridBorderPos 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 RGBorderAddedEventArgs(ReoGridRange range, ReoGridBorderPos pos, ReoGridBorderStyle style) : base(range) { this.Pos = pos; this.Style = style; }
internal static string EncodeBorderPos(ReoGridBorderPos pos) { return pos.ToString().ToLower(); }
private string GetBorderInfo(int r, int c, ReoGridBorderPos borderPos) { StringBuilder sb = new StringBuilder(); if ((borderPos & ReoGridBorderPos.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.Cols)); sb.AppendLine(string.Format("Pos [{0,7}]", top.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", top.Border == null ? "" : " YES ")); } else sb.AppendLine("Empty"); } if ((borderPos & ReoGridBorderPos.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.Cols)); sb.AppendLine(string.Format("Pos [{0,7}]", bottom.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", bottom.Border == null ? "" : " YES ")); } else sb.AppendLine("Empty"); } if ((borderPos & ReoGridBorderPos.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.Rows)); sb.AppendLine(string.Format("Pos [{0,7}]", left.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", left.Border == null ? "" : " YES ")); } else sb.AppendLine("Empty"); } if ((borderPos & ReoGridBorderPos.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.Rows)); sb.AppendLine(string.Format("Pos [{0,7}]", right.Pos)); sb.AppendLine(string.Format("Style [{0,7}]", right.Border == null ? "" : " YES ")); } else sb.AppendLine("Empty"); } return sb.ToString(); }