Exemplo n.º 1
0
        private void DrawArea(SelectShapeEnum fill)
        {
            DrawParams dp = new DrawParams();

            dp.Graphics = this.CreateGraphics();
            dp.Graphics.Clear(Color.White);
            dp.Trans = new Trans { XScale = 20, YScale = 20, Origin = new Point(240, 350) };
            dp.Pen = new Pen(Color.Blue);
            dp.FillBrush = new SolidBrush(Color.GreenYellow);

            Sketcher.Draw(shapeMaker, dp, fill, userLines);

            List<Shape> flatList = shapeMaker.GetFlatListOfShapes();
            int nShapes = flatList.Count;
            label5.Text = nShapes.ToString();

            if (nShapes > 0)
            {
                label10.Text = shapeMaker.CalculateSmallestArea(flatList).ToString();
                label11.Text = shapeMaker.CalculateLargestArea(flatList).ToString();
                label12.Text = shapeMaker.CalculateLargestAdjacentArea(flatList).ToString();
            }
        }
Exemplo n.º 2
0
        public static void Draw(ShapeMaker a, DrawParams dParams, SelectShapeEnum fillMode, List<ILine> lines)
        {
            if (a.Shapes.Count == 0)
            {
                foreach (ILine line in lines)
                {
                    Draw(line, dParams);
                }
            }
            else
            {
                List<Shape> flatList = a.GetFlatListOfShapes();

                int [] fill = {-1, -1};

                switch (fillMode)
                {
                    case SelectShapeEnum.Largest:
                        fill[0] = a.FindLargestShape(flatList);
                        break;
                    case SelectShapeEnum.Smallest:
                        fill[0] = a.FindSmallestShape(flatList);
                        break;
                    case SelectShapeEnum.LargestAdjacentPair:
                        fill = a.FindLargestAdjacentPair(flatList);
                        break;
                }

                int nShape = flatList.Count;

                for (int i = 0; i < nShape; i++)
                {
                    Draw(flatList[i], dParams, fill[0] == i || fill[1] == i);
                }
            }
        }