Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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));
                }
            }
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            BorderPositions pos = GetBorderPos(e.Location);

            if (pos != BorderPositions.None)
            {
                InvertBorderStats(pos);
                Invalidate();
            }
        }
Ejemplo n.º 5
0
 public void RemoveBorderStyle(BorderPositions pos)
 {
     ProcessBorderStyles(pos, p =>
     {
         borders.Remove(p);
         mixBorders    &= ~p;
         borderRemoved |= pos;
         borderAdded   &= ~p;
     });
     Invalidate();
 }
Ejemplo n.º 6
0
 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);
         }
     }
 }
Ejemplo n.º 7
0
        public void CheckBorderStyle(BorderPositions pos)
        {
            ProcessBorderStyles(pos, p =>
            {
                borders[p] = new RangeBorderStyle
                {
                    Style = currentBorderStlye,
                    Color = currentColor,
                };
                mixBorders &= ~p;
            });

            borderAdded   |= pos;
            borderRemoved &= ~pos;
            Invalidate();
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 /// <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);
 }
Ejemplo n.º 10
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);
 }
Ejemplo n.º 11
0
 internal static string EncodeBorderPos(BorderPositions pos)
 {
     return(pos.ToString().ToLower());
 }
Ejemplo n.º 12
0
 /// <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) })
 {
 }
Ejemplo n.º 13
0
        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());
        }
Ejemplo n.º 14
0
 /// <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;
 }
Ejemplo n.º 15
0
 /// <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;
 }
Ejemplo n.º 16
0
 /// <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;
 }