private void fillLinearItem_Click(object sender, EventArgs e) { Brush brush; //bỏ chọn tất cả button Fill uncheckedAllFill(); if (currentFillItem == fillType.LinearGradient)// đang là Linear=> nofill { currentFillItem = fillType.NoFill; //set brush brush = new SolidBrush(Color.White); } else //đổi { fillLinearItem.Checked = true; currentFillItem = fillType.LinearGradient; //set brush Color primaryColor, subColor; //set màu dựa trên chuột trái phải if (leftMouseButton == true) { primaryColor = currentColor2; subColor = currentColor; } else //chuột phải=> ngược lại { primaryColor = currentColor; subColor = currentColor2; } brush = new LinearGradientBrush(new Point(x, y), new Point(x1, y1), currentColor, currentColor2); } // //vẽ if (_x == 0 && _x1 == 0 && _y == 0 && _y1 == 0) { return;//bỏ vẽ } brushShape(brush, _x, _y, _x1, _y1); pictureBox.Image = drawing; drawingList.AddBaseCapacity(drawing); //tạo drawing mới để vẽ drawing = new Bitmap(drawingList.Last()); g = Graphics.FromImage(drawing); }
//FILL TOOLS private void fillSolidItem_Click(object sender, EventArgs e) { Brush brush; //=new SolidBrush(Color.White); //bỏ chọn tất cả button Fill uncheckedAllFill(); if (currentFillItem == fillType.Solid)// đang là Solid { currentFillItem = fillType.NoFill; brush = new SolidBrush(Color.White); } else //không là solid { //đổi fillSolidItem.Checked = true; currentFillItem = fillType.Solid; Color primaryColor, subColor; if (leftMouseButton == true) { primaryColor = currentColor2; subColor = currentColor; } else //chuột phải=> ngược lại { primaryColor = currentColor; subColor = currentColor2; } brush = new SolidBrush(primaryColor); } //tô màu if (_x == 0 && _x1 == 0 && _y == 0 && _y1 == 0) { return;//bỏ vẽ } brushShape(brush, _x, _y, _x1, _y1); pictureBox.Image = drawing; drawingList.AddBaseCapacity(drawing); //tạo drawing mới để vẽ drawing = new Bitmap(drawingList.Last()); g = Graphics.FromImage(drawing); }
private void fillPathItem_Click(object sender, EventArgs e) { Brush brush; //bỏ chọn tất cả button Fill uncheckedAllFill(); if (currentFillItem == fillType.PathGradient)// đang là Path { currentFillItem = fillType.NoFill; brush = new SolidBrush(Color.White); } else //đổi { fillPathItem.Checked = true; currentFillItem = fillType.PathGradient; //đổi brush Color primaryColor, subColor; //set màu dựa trên chuột trái phải if (leftMouseButton == true) { primaryColor = currentColor2; subColor = currentColor; } else //chuột phải=> ngược lại { primaryColor = currentColor; subColor = currentColor2; } Point[] pList = new Point[5]; pList[0] = new Point(x, y); pList[1] = new Point(x, y1); pList[2] = new Point(x1, y1); pList[3] = new Point(x1, y); //pList[4] = new Point(x, y); //pList[4] = new Point(x + 1, y); //pList[4] = new Point((x * 2 + x1 * 2) / 5, (y * 2 + y1 * 2) / 5); PathGradientBrush pthGrBrush = new PathGradientBrush(pList); //RectangleF rec = new RectangleF(x, y, x1 - x, y1 - y); pthGrBrush.CenterPoint = new PointF((x + x1) / 2, (y + y1) / 2); pthGrBrush.CenterColor = subColor; Color[] colors = { primaryColor }; pthGrBrush.SurroundColors = colors; brush = pthGrBrush; } //vẽ if (_x == 0 && _x1 == 0 && _y == 0 && _y1 == 0) { return;//bỏ vẽ } brushShape(brush, _x, _y, _x1, _y1); pictureBox.Image = drawing; drawingList.AddBaseCapacity(drawing); //tạo drawing mới để vẽ drawing = new Bitmap(drawingList.Last()); g = Graphics.FromImage(drawing); }