Ejemplo n.º 1
0
        private void btnFlood_Click(object sender, EventArgs e)
        {
            if (choosingShape >= 0 && shapes[choosingShape].fillColor != userColor)
            {
                if (shapes[choosingShape].type != Shape.shapeType.CIRCLE && shapes[choosingShape].type != Shape.shapeType.ELLIPSE && shapes[choosingShape].controlPoints.Count < 3)
                {
                    return;
                }

                Thread thread = new Thread
                                (
                    () => FloodFiller.Fill(shapes[choosingShape], userColor, ref isShapesChanged)
                                );
                thread.IsBackground = true;
                thread.Start();
            }
        }
Ejemplo n.º 2
0
        private void drawBoard_MouseUp(object sender, MouseEventArgs e)
        {
            //Sự kiện "nhả chuột", kết thúc quá trình vẽ
            if (userType != Shape.shapeType.POLYGON)
            {
                isDrawing = false;
            }
            if (isTransforming == true)
            {
                //Nếu hình có tô màu => tô màu lại
                if (shapes[choosingShape].fillColor != Color.Black && shapes[choosingShape].fillPoints.Count == 0)
                {
                    shapes[choosingShape].fillPoints.Clear();
                    if (shapes[choosingShape].controlPoints.Count < 3)
                    {
                        Thread thread = new Thread
                                        (
                            () => FloodFiller.Fill(shapes[choosingShape], shapes[choosingShape].fillColor, ref isShapesChanged)
                                        );
                        thread.IsBackground = true;
                        thread.Start();
                    }
                    else
                    {
                        Thread thread = new Thread
                                        (
                            () => ScanlineFiller.Fill(shapes[choosingShape], shapes[choosingShape].fillColor, ref isShapesChanged)
                                        );
                        thread.IsBackground = true;
                        thread.Start();
                    }
                }

                backupShape    = shapes[choosingShape].Clone();
                isTransforming = false;
            }
        }