picturebox

Z-Index of Drawing Rectangle C#

强颜欢笑 提交于 2019-12-25 02:24:04
问题 I have an application which uses the mouse to free-draw a rectangle on a picbox image. However the rectangle only shows up behind the picbox, rather than on top of it. Is there a property i can set which can fix this? (show rect on top of picbox image rather than behind it). Here is the code: System.Drawing.Graphics picboxGraphics; bool mDown = false; int mouseX; int mouseY; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { mDown = true; mouseX = e.X; mouseY = e.Y; }

Displaying images from a picturebox list

扶醉桌前 提交于 2019-12-24 22:09:09
问题 I am trying to display a line of pictures in my program. But I am having a problem, where it is only showing the first image in the imagelist and only showing one image-box. Private Cards As New List(Of PictureBox) Private Sub SetupCards() For i As Integer = 0 To imglist1.Images.Count - 1 Dim PicCard As PictureBox = New PictureBox() PicCard.Width = 100 PicCard.Height = 200 PicCard.Top = 50 PicCard.Left = 50 Me.Controls.Add(PicCard) PicCard.Image = imglist1.Images(i) Cards.Add(PicCard) Next i

Change two images in one picture box using a button (VB.NET)

橙三吉。 提交于 2019-12-24 22:05:03
问题 I've been trying to change the image in a picture box. It works if I want to change it with one image, but I can't get it to change to the other image. It should alternate between the two images when I click the button. Here is my code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num As Boolean If num = False Then PictureBox3.Image = My.Resources.Beep num = True Else PictureBox3.Image = My.Resources.Skateboard num = False End

How can I drag dynamically created pictureboxes?

故事扮演 提交于 2019-12-24 18:03:05
问题 So, I have a form with a background image (picturebox) and some jigsaw puzzle pieces (pictureboxes created dynamically named pic[i]) on random locations. I have this piece of code inside the for-loop creating the pieces. pic[i].MouseDown += new MouseEventHandler(picMouseDown); pic[i].MouseMove += new MouseEventHandler(picMouseMove); pic[i].MouseUp += new MouseEventHandler(picMouseUp); And below I show the corresponding events. int x = 0; int y = 0; bool drag = false; private void picMouseDown

C# - Detect PictureBox overlap

别来无恙 提交于 2019-12-24 13:34:09
问题 Is it possible to detect if a pictureBox is colliding with/overlapping with another pictureBox? Sorry for the vague question formulation. 回答1: To check if 2 rectangles overlapped you can use IntersectsWith: bool overlapped= pictureBox1.Bounds.IntersectsWith(pictureBox12.Bounds); To find the intersection area you can use Rectangle.Intersect: Rectangle intersectionArea = Rectangle.Intersect(pictureBox1.Bounds, pictureBox2.Bounds); 回答2: You can use Rectangle.Intersect. Just give Bounds of both

Adding multiple pictureboxes to a form programmatically in vb.net ?

夙愿已清 提交于 2019-12-24 13:22:46
问题 i have to add pictueboxes in to a panel as per my requirement . "Adding multiple pictureboxes to a form programmatically in vb.net " In this question PictureBox are drawn in random but i want it in a synchronous way enter code here Dim i As String = ListBox1.Items.Count For j As Integer = 0 To i Dim PicBox As New PictureBox PicBox.Width = 40 PicBox.Top = 25 PicBox.Left = j + 15 PicBox.SizeMode = PictureBoxSizeMode.StretchImage PicBox.BorderStyle = BorderStyle.FixedSingle Me.Panel1.Controls

How can I crop original image in a pictureBox that shows image in Stretch mode?

Deadly 提交于 2019-12-24 12:10:08
问题 How can I crop an image in a pictureBox that shows in Stretch mode? I draw a rectangle in pictureBox : void pictureBox1_MouseUp(object sender, MouseEventArgs e) { //pictureBox1.Image.Clone(); xUp = e.X; yUp = e.Y; Rectangle rec = new Rectangle(xDown, yDown, Math.Abs(xUp - xDown), Math.Abs(yUp - yDown)); using (Pen pen = new Pen(Color.YellowGreen, 3)) { pictureBox1.CreateGraphics().DrawRectangle(pen, rec); } rectCropArea = rec; } void pictureBox1_MouseDown(object sender, MouseEventArgs e) {

Scrolling PictureBox

↘锁芯ラ 提交于 2019-12-24 11:54:06
问题 I am trying to make an application that is drawing Dendrograms like this one. So I added a PictureBox to the winform, and for start, I wanted to wrote all labels like in the picture with this code: foreach (var line1 in lines) { i++; gpx.DrawString(line1, myFont, Brushes.Green, new PointF(2, 10 * i)); } But the problem is that I have a lot of labels so it writes only a few of them on 800x600 px. I wanted to add scrolling bars, but it doesn't work at all. It works only when I am setting an

Rotating image around center C#

假装没事ソ 提交于 2019-12-24 11:22:31
问题 I have a small error when trying to rotate an image within a picture box. It all works. But when rotating, it doesn't rotate perfectly around the center. It's slightly off (not very noticeable) but kinda annoying. Here is my code: private readonly Bitmap _origPowerKnob = Properties.Resources.PowerKnob; //CODE WHERE ROTATE METHOD IS CALLED// using (Bitmap b = new Bitmap(_origPowerKnob)) { Bitmap newBmp = RotateImage(b, _powerAngle); PowerKnob.BackgroundImage = newBmp; } private Bitmap

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