drawrectangle

Draw rectangle around Textbox inside a Groupbox

假如想象 提交于 2019-12-12 02:47:36
问题 I want to add a custom border around a TextBox control which is in a GroupBox . Since I'm new to this Graphic stuff I'm having a hard time figuring out the problem. This is the code i'm using: Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint Dim _g As Graphics = Me.GroupBox1.CreateGraphics Dim pen As New Pen(Color.Red, 2.0) _g.DrawRectangle(pen, New Rectangle(TextBox1.Location, TextBox1.Size)) pen.Dispose() End Sub This form is a secondary form that shows when I

I made a rectangle how do I check if the mouse clicked on it?

别来无恙 提交于 2019-12-12 02:12:42
问题 How do I check if a mouse clicked a rectangle? Graphics gfx; Rectangle hitbox; hitbox = new hitbox(50,50,10,10); //TIMER AT THE BOTTOM gfx.Draw(System.Drawing.Pens.Black,hitbox); 回答1: Just a sample quick and dirty, if your "gfx" is a "e.Graphics..." from a Form: public partial class Form1 : Form { private readonly Rectangle hitbox = new Rectangle(50, 50, 10, 10); private readonly Pen pen = new Pen(Brushes.Black); public Form1() { InitializeComponent(); } private void Form1_Paint(object sender

Draw rectangle and update it on every mouse click

為{幸葍}努か 提交于 2019-12-11 20:24:02
问题 Now I want to draw a rectangle on canvas on mouse click Event. Here is my code: protected void imageIR_MouseClick(object sender, System.Windows.Input.MouseEventArgs e) { ... System.Windows.Point startPoint = e.GetPosition(canvas1); rect = new System.Windows.Shapes.Rectangle { Stroke = System.Windows.Media.Brushes.LightBlue, StrokeThickness = 10 }; Canvas.SetLeft(rect, startPoint.X); Canvas.SetTop(rect, startPoint.Y); canvas1.Children.Add(rect); } private void Canvas_MouseMove(object sender,

JavaFX: How to resize a rectangle with set aspect ratio

北慕城南 提交于 2019-12-11 17:44:44
问题 I have an app where user can draw a rectangle, and resize it or move it. I'm interested if is possible to some how bind rectangles width and height in some aspect ratio. E.g. if aspect ratio is 1:2 that user can draw only that kinds of rectangles, or if is 1:1 that user can only draw square. EDIT My eventHandler for MOUSE_DRAGGED event looks something like this EventHandler<MouseEvent> onMouseDraggedEventHandler = event -> { if (event.isSecondaryButtonDown()) return; double offsetX = event

How to create a Rectangle object in Java using g.fillRect method

北战南征 提交于 2019-12-10 02:45:11
问题 I need to create a rectangle object and then paint it to the applet using paint(). I tried Rectangle r = new Rectangle(arg,arg1,arg2,arg3); Then tried to paint it to the applet using g.draw(r); It didn't work. Is there a way to do this in java? I have scoured google to within an inch of its life for an answer, but I haven't been able to find an answer. Please help! 回答1: Try this: public void paint (Graphics g) { Rectangle r = new Rectangle(xPos,yPos,width,height); g.fillRect(r.getX(), r.getY(

drawing a rectangle with mouse click and drag - javascript

两盒软妹~` 提交于 2019-12-07 10:43:30
问题 I was trying to draw a rectangle (actually a selection box) in Javascript, to select the SVG elements that come in the selection. I tried to fix the code for the click and drag rectangle: http://jsfiddle.net/7uNfW/26/ but there is some problem that I can't figure out in function handleMouseDown(e) and function handleMouseUp(e) Plus I need to get some ideas as to how will I go about selecting the SVG elements in the box. Any help would be appreciated. 回答1: As for the creating of a Clink 'N

drawing a rectangle with mouse click and drag - javascript

回眸只為那壹抹淺笑 提交于 2019-12-05 14:08:08
I was trying to draw a rectangle (actually a selection box) in Javascript, to select the SVG elements that come in the selection. I tried to fix the code for the click and drag rectangle: http://jsfiddle.net/7uNfW/26/ but there is some problem that I can't figure out in function handleMouseDown(e) and function handleMouseUp(e) Plus I need to get some ideas as to how will I go about selecting the SVG elements in the box. Any help would be appreciated. As for the creating of a Clink 'N Drag rectangle, I rewrote the code to become this . It looks like it's working just fine. Now, for the SVG part

Bug when drawing rectangles in my Paint Program

。_饼干妹妹 提交于 2019-12-02 19:57:35
问题 public partial class Form1 : Form { Point downPoint , upPoint; List<Shapes> shapes = new List<Shapes>(); public ShapesEnum shapeType; public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); foreach (var s in shapes) s.Draw(e.Graphics); } protected override void OnMouseDown(MouseEventArgs e) { downPoint = e.Location; } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); upPoint = e.Location; CreateShape(); this

Bug when drawing rectangles in my Paint Program

我的梦境 提交于 2019-12-02 09:46:38
public partial class Form1 : Form { Point downPoint , upPoint; List<Shapes> shapes = new List<Shapes>(); public ShapesEnum shapeType; public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); foreach (var s in shapes) s.Draw(e.Graphics); } protected override void OnMouseDown(MouseEventArgs e) { downPoint = e.Location; } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); upPoint = e.Location; CreateShape(); this.Invalidate(); } private void CreateShape() { if (shapeType == ShapesEnum.Circle) { Rectangle rect = new

How to add text into a pygame rectangle

 ̄綄美尐妖づ 提交于 2019-12-01 06:08:06
I have come as far as drawing a rectangle in pygame however I need to be able to get text like "Hello" into that rectangle. How can I do this? (If you can explain it as well that would be much appreciated. Thank-you) Here is my code: import pygame import sys from pygame.locals import * white = (255,255,255) black = (0,0,0) class Pane(object): def __init__(self): pygame.init() pygame.display.set_caption('Box Test') self.screen = pygame.display.set_mode((600,400), 0, 32) self.screen.fill((white)) pygame.display.update() def addRect(self): self.rect = pygame.draw.rect(self.screen, (black), (175,

工具导航Map