drawrectangle

How to draw a rectangle in C# using a mouse

陌路散爱 提交于 2021-02-10 18:00:42
问题 I want to draw a rectangle on a form in C#. I read and found this article. Are there any samples or tutorials available ? The article was not very helpful. 回答1: The article you linked appears to be C++, which may explain why it didn't help you much. If you create events for MouseDown and MouseUp, you should have the two corner points you need for a rectangle. From there, it's a matter of drawing on the form. System.Drawing.* should probably be your first stop. There are a couple of tutorials

Rotate and Scale rectangle as per user control

痞子三分冷 提交于 2021-02-08 10:45:33
问题 I have UserControl of Size 300*200. and rectangle of size 300*200. graphics.DrawRectangle(Pens.Black, 0, 0, 300, 200); When I rotate rectangle in userControl by 30 degree, I get rotated rectangle but it is outsized. PointF center = new PointF(150,100); graphics.FillRectangle(Brushes.Black, center.X, center.Y, 2, 2); // draw center point. using (Matrix matrix = new Matrix()) { matrix.RotateAt(30, center); graphics.Transform = matrix; graphics.DrawRectangle(Pens.Black, 0, 0, 300, 200); graphics

Rotate and Scale rectangle as per user control

随声附和 提交于 2021-02-08 10:43:06
问题 I have UserControl of Size 300*200. and rectangle of size 300*200. graphics.DrawRectangle(Pens.Black, 0, 0, 300, 200); When I rotate rectangle in userControl by 30 degree, I get rotated rectangle but it is outsized. PointF center = new PointF(150,100); graphics.FillRectangle(Brushes.Black, center.X, center.Y, 2, 2); // draw center point. using (Matrix matrix = new Matrix()) { matrix.RotateAt(30, center); graphics.Transform = matrix; graphics.DrawRectangle(Pens.Black, 0, 0, 300, 200); graphics

Loading PDF in Canvas and Drawing rectangles

落爺英雄遲暮 提交于 2020-04-30 10:07:36
问题 I am trying to build a web page to display a PDF file inside canvas and allow user to draw rectangles. Below is the code I'm trying. The problem is mouse event is going outside canvas also. How to restrict mouse dragging event only inside the canvas. var url = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf'; //Loaded via <script> tag, create shortcut to access PDF.js exports. var pdfjsLib = window['pdfjs-dist/build/pdf']; // The workerSrc property

Loading PDF in Canvas and Drawing rectangles

僤鯓⒐⒋嵵緔 提交于 2020-04-30 10:05:14
问题 I am trying to build a web page to display a PDF file inside canvas and allow user to draw rectangles. Below is the code I'm trying. The problem is mouse event is going outside canvas also. How to restrict mouse dragging event only inside the canvas. var url = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf'; //Loaded via <script> tag, create shortcut to access PDF.js exports. var pdfjsLib = window['pdfjs-dist/build/pdf']; // The workerSrc property

Drawing Rectangle around Custom TextBox control

本秂侑毒 提交于 2020-01-25 12:33:29
问题 I'm trying to create a custom TextBox control that will have two additional properties BorderColor and BorderSize. But the border doesn't shows up, even with BorderStyle set to None. Here is my code: Imports System.Windows.Forms Imports System.Drawing Imports System.ComponentModel Public Class BorderedTextBox Inherits TextBox Dim BColor As Color = Color.Black Dim BSize As Double = 1.0 Public Property BorderColor As Color Get Return BColor End Get Set(value As Color) BColor = value End Set End

Drawing Rectangle around Custom TextBox control

寵の児 提交于 2020-01-25 12:32:20
问题 I'm trying to create a custom TextBox control that will have two additional properties BorderColor and BorderSize. But the border doesn't shows up, even with BorderStyle set to None. Here is my code: Imports System.Windows.Forms Imports System.Drawing Imports System.ComponentModel Public Class BorderedTextBox Inherits TextBox Dim BColor As Color = Color.Black Dim BSize As Double = 1.0 Public Property BorderColor As Color Get Return BColor End Get Set(value As Color) BColor = value End Set End

Picturebox - Get image inside drawn rectangle and show in another Picturebox

大城市里の小女人 提交于 2019-12-24 10:45:28
问题 I made a search and successfully found a solution to draw a rectangle inside my Picturebox while mousemoving using a class named Rectangulo: Public Class Form1 Dim SelectionBoxObj As New Rectangulo() Dim IsMouseDown As Boolean = False Public SelectedObjPoint As Point Private Sub PictureBox1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then IsMouseDown = True SelectedObjPoint = New Point(e.X, e

Draw rectangle with XML shape settings in Android

浪子不回头ぞ 提交于 2019-12-19 10:53:28
问题 I've got a problem which I don't know how to solve. Please, help me if you can. In my app I have to create a custom view extended View. In this view I should draw a lot of rectangles and I create them by canvas.drawRect or canvas.drawRoundRect. It's clear. But I want to create a compound design of these rectangles (with gradients, corners, paddings and etc.) and I want to carry out these settings (gradients, corners, paddings and etc.) in XML. How can I do it? The problem is that I determine

Draw rectangle with XML shape settings in Android

别说谁变了你拦得住时间么 提交于 2019-12-19 10:53:02
问题 I've got a problem which I don't know how to solve. Please, help me if you can. In my app I have to create a custom view extended View. In this view I should draw a lot of rectangles and I create them by canvas.drawRect or canvas.drawRoundRect. It's clear. But I want to create a compound design of these rectangles (with gradients, corners, paddings and etc.) and I want to carry out these settings (gradients, corners, paddings and etc.) in XML. How can I do it? The problem is that I determine