picturebox

Multiple Control Click Events handled by one event

感情迁移 提交于 2019-12-23 02:31:33
问题 I am creating a basic winform application that has many pictureboxes with click events. The click events need to use the name of the picturebox that was clicked in order to execute the rest of the code. I do not want to create unique click events for all of the pictureboxes. I was hoping there would be a simple way to get this information, like using the "sender" parameter or the event arguments. 回答1: You add one click event handler for all of the PictureBoxes: pic1.Click += PictureBoxClick;

Move PictureBox using Arrow Keys - Handle keyboard events in PictureBox

我只是一个虾纸丫 提交于 2019-12-22 10:05:12
问题 I have a PictureBox where I use the code below to move my object. I need to add a few buttons in the form, however when I start the program the arrow keys navigate through the buttons instead of my input keypresses. I've tried many ways like PictureBox.Focus() and PictureBox.Select() on Form.Load() , and disabling the arrow key navigation completely on this answer here, but my object will not move anymore. private void UpdateScreen(object sender, EventArgs e) { if (Input.KeyPressed(Keys.Right

Getting the size of a Windows Form

蓝咒 提交于 2019-12-22 04:47:09
问题 I'm creating a Windows Forms application. How do I capture the size of the windows form? Currently I have something that looks like this in my code: PictureBox display = new PictureBox(); display.Width = 360; display.Height = 290; this.Controls.Add(display); display.Image = bmp; However, the size of my display is hard-coded to a specific value. I know that if I want to draw a square that re-sizes I can use something like this: private Rectangle PlotArea; private int offset = 30; protected

Where does this quality loss on Images come from?

旧街凉风 提交于 2019-12-22 04:34:19
问题 in my Winforms application which is connected to a database via Linq to SQL I am saving images (always *.png) to a table which looks like this: CREATE TABLE [dbo].[Images] ( [Id] INT IDENTITY (1, 1) NOT NULL, [Bild] IMAGE NOT NULL, PRIMARY KEY CLUSTERED ([Id] ASC) ); Before I can store a picture I have to convert it to byte[] and this is how I do it: public static byte[] ImageToByteArray(System.Drawing.Image imageIn) { using (MemoryStream ms = new MemoryStream()) { imageIn.Save(ms, System

Stream from IP cam C#

假装没事ソ 提交于 2019-12-21 20:47:33
问题 I have the following code which isn't working. My camUrl link works if I load into Firefox and streams from my cam, but nothing is displayed in my picturebox at runtime. Any ideas why? public Thread _camThread; private string camUrl = "http://my-domain-ip:2080/videostream.cgi?user=admin&pwd=password"; public HttpWebRequest webReq; public WebResponse webRes; public Stream sr; private void btnStart_Click(object sender, EventArgs e) { if (_camThread == null) _camThread = new Thread(new

Get PixelValue when click on a picturebox

爷,独闯天下 提交于 2019-12-21 18:33:39
问题 I'm working on a .NET C# project and would like to get the pixel value when I click a picturebox, how can I achieve that? The basic idea is that when I click anywhere in the picturebox, I get the pixelvalue of that image point.. Thanks! 回答1: Use this: private void pictureBox2_MouseUp(object sender, MouseEventArgs e) { Bitmap b = new Bitmap(pictureBox1.Image); Color color = b.GetPixel(e.X, e.Y); } 回答2: As @Hans pointed out Bitmap.GetPixel should work unless you have different SizeMode than

How to display a PictureBox from behind code in C#

 ̄綄美尐妖づ 提交于 2019-12-21 17:38:06
问题 I know my question sounds basic, but i searched all over the place and found nothing.. this is my code : public MainWindow() { InitializeComponent(); Map newMap = new Map(); newMap.setMapStrategy(new SmallMapStrategy()); newMap.createMap(); System.Windows.Forms.PictureBox pictureBox1 = new System.Windows.Forms.PictureBox(); pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(newMap.grid[3].afficher); } this is the afficher function : public override void afficher(object sender,

PictureBox not refreshing properly?

匆匆过客 提交于 2019-12-20 07:12:30
问题 I am new to programming pardon me if i am asking a dumb question. I am trying to display real time image that i obtained from a live camera. When i start the program, the picturebox is able to show the object(refer to picture1). When i remove the object, it display this image(refer to picture2). But the problem is that when i put back the object, i should be able to get an image that is similar to picture1 but instead it look like picture2. Is it because the pictureBox is not refreshing

Can I use variables to control which PictureBox I am using?

独自空忆成欢 提交于 2019-12-20 07:06:38
问题 Is there a way that I can use a variable to control which PictureBox I am using in Visual Basic? I.e.: CurrentNumber = 1 PictureBox(CurrentNumber).backcolour = backcolour 回答1: You can use the Me.Controls(String) indexer. It lets you specify the name (as a string) of the control you want to access, thus you can dynamically access a picture box by concatenating the string "PictureBox" with a number. Dim TargetPictureBox As PictureBox = TryCast(Me.Controls("PictureBox" & CurrentNumber),

Moving a picture that is inside a PictureBox to another PictureBox

孤街浪徒 提交于 2019-12-20 04:13:57
问题 How can I move a picture that is inside a picturebox to another picturebox? I want to use it for moving the pieces of chess game. I have a took picturebox for each place, so I have 64 pictureboxes. 回答1: You can just assign the Image displayed in one picture box to another picture box. If you then want to remove the image from the original picture box (so that it is not displayed twice), you can set its Image property to null (or, of course, you can assign any other image of your choice). Like