public ArrayList UnifyStrokes()
        {
            ArrayList unifiedStrokes = new ArrayList();

            foreach (SegmentOffset offset in this.segments.Keys)
            {
                StrokeCollection col = (StrokeCollection)this.segments[offset];

                foreach (Stroke stroke in col.strokes)
                {
                    //stroke.xc += col.strokeOffset.X;
                    //stroke.yc += col.strokeOffset.Y;
                    unifiedStrokes.Add(stroke);
                }
            }

            return(unifiedStrokes);
        }
        public SegmentedStrokes(int segWidth, int segHeight, int width, int height, ArrayList strokes)
        {
            this.Width     = width;
            this.Height    = height;
            this.segWidth  = segWidth;
            this.segHeight = segHeight;

            int xCount = 0, yCount = 0;
            int endOfSegmentY = 0, endOfSegmentX = 0;
            int strokeCount = strokes.Count;

            for (int y = 0; y < (height - segHeight); y += segHeight)
            {
                endOfSegmentY = y + (segHeight - 1);

                for (int x = 0; x < (width - segWidth); x += segWidth)
                {
                    endOfSegmentX = x + (segWidth - 1);

                    StrokeCollection col = new StrokeCollection();
                    col.strokes = new ArrayList();

                    for (int i = 0; i < strokes.Count; i++)
                    {
                        Stroke stroke = (Stroke)strokes[i];

                        if ((stroke.xc >= x) && (stroke.xc <= endOfSegmentX) &&
                            (stroke.yc >= y) && (stroke.yc <= endOfSegmentY))
                        {
                            //Console.WriteLine("Segmenting stroke, remaining: " + --strokeCount);
                            col.strokes.Add(stroke);
                        }
                    }


                    AddSegment(col, new SegmentOffset(xCount++, yCount));
                }

                xCount = 0;
                yCount++;
            }
        }
        public SegmentedStrokes(int segWidth, int segHeight, int width, int height)
        {
            this.Width     = width;
            this.Height    = height;
            this.segWidth  = segWidth;
            this.segHeight = segHeight;

            int xCount = 0, yCount = 0;

            for (int y = 0; y < (height - segHeight); y += segHeight)
            {
                for (int x = 0; x < (width - segWidth); x += segWidth)
                {
                    StrokeCollection col = new StrokeCollection();
                    col.strokes = new ArrayList();

                    AddSegment(col, new SegmentOffset(xCount++, yCount));
                }

                xCount = 0;
                yCount++;
            }
        }
        public bool FitsInto(SegmentedStrokes destRegion, SegmentOffset destOffset)
        {
            // For every segment within this "source" region, check to see if
            // each can be placed in its relative location in the destRegion.
            foreach (SegmentOffset offset in this.segments.Keys)
            {
                SegmentOffset adjusted = new SegmentOffset(destOffset.xOffset + offset.xOffset, destOffset.yOffset + offset.yOffset);
                if (destRegion.segments.ContainsKey(adjusted))
                {
                    StrokeCollection segment = (StrokeCollection)destRegion.segments[adjusted];
                    if (segment.filled)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
 public void AddSegment(StrokeCollection strokes, SegmentOffset offset)
 {
     this.segments[offset] = strokes;
     this.MaxXOffset       = System.Math.Max(this.MaxXOffset, offset.xOffset);
     this.MaxYOffset       = System.Math.Max(this.MaxYOffset, offset.yOffset);
 }