|
Hi,
If i have a 100*100 array of values (say 0 is black and 255 white), how do I display it as in image on a picture box ?
thanks,
Assi.
|
|
|
|
|
Create a Bitmap object and use the SetPixel method to set the color of each pixel.
If you need extra speed, you can use the LockBits and UnlockBits methods to access the pixel data more directly.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Append a bitmap header to a memory stream and then copy your array to the stream. Then create a new bitmap using the stream constructor. That will be the fastest way. See wikipedia for the format definition.
http://en.wikipedia.org/wiki/Windows_bitmap
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I am currently using the HTTPWebRequest class. I need to add the following to the request line:
POST /Search HTTP/1.1
It is simple to get 'POST HTTP/1.1' but i am having difficulty adding the additional string.
I cannot seem to get the '/Search' inserted in the request line. I understand HTTP 1.1 and the VERBS allowed as part of a request.
The 'method' property is used to set the VERB. Adding anything other than a single string throws a null reference exception. I have seen extra information appended to the method many times in the past so not too sure why this is so problematic.
I initially thought of overriding the HTTPWebRequest but as it is created from calling Create() on the WebRequest, this doesn't appear possible.
Thanks in advance.
Carl
|
|
|
|
|
As far as I know, you only have access to the Headers collection on the HttpWebRequest. You will probably need to write your own class for this functionality.
Luckily, you can use this post as a basis for getting that done. http://www.thescripts.com/forum/thread343158.html[^]
Good luck.
|
|
|
|
|
Hi Mike,
thanks for the post. I did something very similar already as a back up to the problem, using the TCPClient and NetworkStream. Created an additional HttpProtocol class and added all the members that might be needed. provided an override of ToString with booleans against each of the properties as to whether to include them in the ToString. Feels so cludgy though. plus it's a real pain interrogating the response headers and content. as it just comes back as a byte array.
still think there must be a better way.
thanks.
Carl
|
|
|
|
|
I want to handel an event like combobox_textchange or selected index change in a gridview column(combobox column) and text_textchange in anther grid column(text column).
merwa
|
|
|
|
|
Hi!
I have 2 buttons in my form and array objects of picturebox.
when button1 is clicked. One Picture box is created. Then i move it (picturebox1)to a desire place.
I clicked button1 again and the second picturebox (picturebox2) is also created and i move it to a place that i want.
The problem is when i click the picturebox1 after the picturebox2 is created and moved. The picturebox2 moves automatically and disappears quickly. I don't know why and how to fix it.
Best regard!
|
|
|
|
|
We know why - there's bugs in your code. Can't really offer much more help than that, without seeing the code.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Here is my code:
public partial class Form1 : Form
{
private Point old;
private bool isDragging = false;
private PictureBox[] myPic;
private int count = 0;
public Form1()
{
InitializeComponent();
begin();
}
public void begin()
{
myPic = new PictureBox[5];
}
private void button1_Click(object sender, EventArgs e)
{
myPic[count] = new PictureBox();
myPic[count].Image =System.Drawing.Image.FromFile("house.gif");
this.Controls.Add(myPic[count]);
myPic[count].MouseDown += new MouseEventHandler(Form1_MouseDown);
myPic[count].MouseMove += new MouseEventHandler(Form1_MouseMove);
myPic[count].MouseUp += new MouseEventHandler(Form1_MouseUp);
count++;
}
void Form1_MouseUp(object sender, MouseEventArgs e)
{
isDragging = false;
}
void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (isDragging)
{
myPic[count-1].Left = myPic[count-1].Left + (e.X - old.X);
myPic[count-1].Top = myPic[count-1].Top + (e.Y - old.Y);
}
}
void Form1_MouseDown(object sender, MouseEventArgs e)
{
old.X = e.X;
old.Y = e.Y;
isDragging = true;
}
}
|
|
|
|
|
You should use a list, this will break after 5 items.
If you debug, is count 0 or 1 the second time ? It looks like it should be 1, but it seems likely it's not.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I can't debug because when i just move mouse on the picturebox, click event is not excuted but the mouse move event is excuted firstly. So the mouse move event is always happened while i can't reach the mouse click event.
By the way, count is always increased after clicking button1.
Please tell me how to correct the problem.
Thanks for replying.
-- modified at 5:45 Thursday 8th November, 2007
|
|
|
|
|
Okay, first off, don't use myPic[count-1] to access the control you want tp drag, you have the object 'sender' which is the control that was actually clicked, so if you use:
PictureBox temp = sender as PictureBox;
temp.Location.X = ...
temp.Location.Y =
...
Then you will always drag the picture box that you actually clicked.
Infact, if you add another picturebox like, currentPicBox or something and use that to find out which picbox was clicked. So, in the MouseDown event:
currentPicBox = sender as PictureBox;
and in the mouse move event:
currentPicBox.Location.X
...
-- modified at 6:09 Thursday 8th November, 2007
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
It works.
But when i clicked currentPicBox and move, there is more than 1 currentPicBox moving. That seems it appears and disappears, appears and disappears... until MouseUp event happens. So how to resolve?
Thanks for replying.
-- modified at 6:43 Thursday 8th November, 2007
|
|
|
|
|
I have the following scenario:
An application is using async. keys to verify itself to other apps. I've put the key in the key container with the following code:
CspParameters csp = new CspParameters();<br />
csp.KeyContainerName = "MyApplication"; <br />
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);
The problem is that the (untrusted) user can make another application and easily get the key.
Is there any way to make a key accessible to my application only? The application could e.g. be identified by Strong Naming it...
PS: I am aware that one could run the app as a special user, and let that user have rights, but this application will launch other apps, and those other apps should preferably be run as the logged in user)
Jens Petter Abrahamsen
|
|
|
|
|
The only way this would be truely possible is if a web service (or another type of service) encrypts the key before saving to disk. The user would have no access to the web service, and therefore could not get the password used to encrypt the file. You would then need to use the same service to decrypt the file before using.
This service could be a simply Windows Service running on the same box as your application. You could then set the service to run as a user with priviliges (for example, to a directory) that your real user doesn't have.
Basically, if your application (running as the user) can encrypt/decrypt the file then the user would be able to do it without your application. Some developers embed a password in their application binaries and use that for encryption and decryption. A technical user could extract the password from your binary (regardless of whether it's in .Net).
You can use impersonation[^] to launch applications as different users.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thank you very much for your reply!
I have one follow-up question:
If I create a Windows Service, running as a privileged user, I agree that the key (on disk) is safe. But when my application asks the service for the key, how can the Windows Service know that it gives the (unencrypted) key to the correct program? Is there a secure way for a WinForm program to communicate with a service?
Jens Petter Abrahamsen
|
|
|
|
|
The idea is that you pass the encrypted data to the windows service and it would decrypt it for you (and encrypt). It would not provide the password to your application.
As far as whether it's talking to the correct program. The user would have to have enough restrictions that they cannot run another application that can talk to your service.
The best way to think of it is, anything your application can do, another application could do. So you need to restrict the users right enough that they can't use "another application".
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
TJoe wrote: The user would have no easy access to the web service, and therefore could not get the password used to encrypt the file without jumping through hoops .
Edited for correctness. If someone really wanted to swipe your password they could either sniff packets, or run your application in a disassembler/debugger environment to lift the password out of memory after it's been retrieved.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Well, the idea was that service would do the encrypting and decrypting. So the application would pass the encrypted data to the service, which would decrypt it and send it back.
But you are right, the user could still get at the decrypted data in memory or through a packet sniffer. The user could get the decrypted data from memory even if it was never encrypted and/or sent to the service.
See my other reply, but this process only works if the user is restricted enough that they can't run a program that would sniff the packets, view memory contents, or duplicate his application.
It's definitely a complex problem.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi all,
I need to extract game statistics in my application for games like CS 1.6, Half life2, halo 1 and halo 2,battlefield etc....Is there any library that I can use to extract the game info??
Shoaib
|
|
|
|
|
Hello guys,
I want to connect to and edit ms access database. The oledb functionality is
not present for .NET CF. When I try to build the solution, it gives me an
error "are you missing an assembly reference?" PS. I am coding in C#
I would like to know if there is a way to connect ms access database, and if
there is a way then what is it?
If not, then how should I go about dealing with this problem?
A little info on my project - I am doing a vending machine project for my
senior design where I have to take out all the logic circuit and replace it
with some thing new. I am using EBOX 2300 as the main control board, which
will have signals coming in and out to control other modules of the project.
The database is for keeping pricing information, authorized user information
such as user name and password (we are implementing student id and rfid card
purchases), and other things.
-- modified at 3:04 Thursday 8th November, 2007
Arsu
|
|
|
|
|
|
How can a winform table layout panel be constructed with mutiple columns on the top row and only one single column on the bottom row?
|
|
|
|
|
TableLayout panel must be simetric. You can solve this creating a panel and add inside the tablelayout panel and a panel. Set Dock of panel to bottom, and tlp Dock property to Fill.
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|