How can I draw a rectangle on a drawingarea in Mono, GTK#?? I dont want to draw it using the mouse. Thus, I want to do the following but I do not know the right syntax:
int X = 10;
int Y = 10;
int SizeW = 10;
int SizeH = 10;
Drawingarea.DrawRectangle(x,y, SizeW, SizeH);
I'm only posting, because I am super annoyed that there are no answers in StackOverflow for such specific questions. The answer above doesn't answer the initial question in any way :D
gc.RgbFgColor = new Gdk.Color(204,204,204);
You need to change the Gdk.GC Object you're using.
I figured it out.
Step 1. Create an eventbox and change the size of the eventbox. Step 2. Add an imagewidget (without an image) inside the eventbox. Step 3. Decide on a color or add a Colorbutton to determinecolor. Step 4. Create a function as the following:
Private void DrawRectangle()
{
Gdk.Color RectangleColor = colorbutton_RectangleColor.Color;
eventbox_rectangle.ModifyBg(StateType.Normal, RectangleColor);
//To modify the size of the rectangle use the following.
eventbox_rectangle.HeightRequest = 10;
eventbox_rectangle.WidthRequest = 10;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.