|
Dear Friend,
Actually I am receiving the bytes as
serverSocket.EndReceive(ar, ref epSender);
Data streamRead = new Data(byteData);// byteData is to hold the read conents and Data is the class assigned as the object state for asyn reading.
Then I am taking bytes by bytes.
Actually now I am not having the complete code as I am not in office.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
hi,
i am desigining a game in which i want that the image(that is a bitmap of simply looking like a pacman) to show the that it is eating the pills on the key press and i want to show the movement of its mouth when it eat pills.
|
|
|
|
|
And what is the question?
Maybe show some code (where it goes wrong).
|
|
|
|
|
the problem is i am not getting how to simulate or develop the motion in its mouth seems that it is eating the pills on the key press .
|
|
|
|
|
Well, this is not really something I've tried doing in C#. But I've done it in flash several times.
But to make it there, you should try and research about silverlight, it's about pictures and images and movement, it's like flash inside Visual Studio.
You could also use common sense. You want a picture to change several times per second, so it would look like motion. And this motion should only take place if you pressed the key.
First hook an event on your key press and then do something like this:
String[] imageList = { @"C:/Image1", @"C:/Image2", @"C:/Image3", @"C:/Image4", @"C:/Image5" };
public void keyPressed(Object sender, KeyEventArgs e)
{
for(int i = 0; i < imageList.Length; i++)
{
pictureBox.Image = new Image(imageList[i]);
Thread.Sleep(150);
}
}
What will this function do?
You first define a list of pictures (you can do this by adding them to the resources list, or just pointing to several files on your hard disk.
Then you loop through all the images and you add the images (from 1 to as many as you have in your imageList) and you let the application 'sleep' for 150 miliseconds.
This is a way to accomplish a motion.
In order to do this, you will have to do this inside a thread, because if you don't, your application won't be able to do anything while showing the motion.
|
|
|
|
|
thanxs alot for the suggestion i will try it and tell all about the results i have.
|
|
|
|
|
Hi all i have a problem that i have been struggling for a week and a half now
this is the function i use to try and update a image in my database
void t(MemoryStream msI)
{
string query;
query ="insert into testimage (id_image,pic) values(" +'"'+"t"+'"' + "," +"@pic)";
BinaryReader oReader = new BinaryReader(msI);
System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(query,OdbcCon );
cmd.Parameters.Add("pic",oReader.ReadBytes((int)msI.Length));
cmd.Prepare();
cmd.ExecuteNonQuery();
MessageBox.Show("Image Added");
}
But the problem that i get that it doesn't insert any data into the blob field
msI is a Memory Stream that is the image that i want to insert
Any help would be greatly appreciated
|
|
|
|
|
hendrik wrote: +'"'+"t"+
Looks like a quote mismatch. I think this might be what you want,
query = "insert into testimage (id_image,pic) values('t', @pic)";
hendrik wrote: cmd.Parameters.Add("pic",oReader.ReadBytes((int)msI.Length));
Second paramter should be a valid OdbcType. You can use the OdbcType enum for it. Also, the parameter name should be @pic
Finally, assign the value of parameter and execute.
e.g.,
System.Data.Odbc.OdbcCommand command = new System.Data.Odbc.OdbcCommand(commandText, connection);<br />
command.Parameters.Add("@ID", SqlDbType.Int);<br />
command.Parameters["@ID"].Value = myvalue;
Edit - Forgot to mention the wrong parameter name
|
|
|
|
|
Thanks for the fead back i have implemented like you show still
no image gets saved to the blob field
void t(MemoryStream msI)
{
string query;
query ="insert into testimage (id_image,pic) values('t', @pic)";
BinaryReader oReader = new BinaryReader(msI);
System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(query,OdbcCon );
cmd.Parameters.Add("@pic", System.Data.DbType.Byte);
cmd.Parameters["@pic"].Value = oReader.ReadBytes((int)msI.Length);
cmd.Prepare();
cmd.ExecuteNonQuery();
MessageBox.Show("Image Added");
}
Note That msI does have a image in it
Thanks any other ideas will help a lot
|
|
|
|
|
hendrik wrote: cmd.Parameters.Add("@pic", System.Data.DbType.Byte);
That says your trying to store a byte but your data is a byte array
Maybe you can use the ObdbType.Image datatype.
cmd.Parameters.Add("@pic", OdbcType.Image);
Also, MemoryStream can be directly converted to byte array.
byte[] blob = msI.ToArray()
|
|
|
|
|
Thanks have done that as well
no change to outcome
string query;
query ="insert into testimage (id_image,pic) values('t', @pic)";
msI.Position=0;
System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(query,OdbcCon );
cmd.Parameters.Add("@pic",System.Data.Odbc.OdbcType.Image);
cmd.Parameters["@pic"].Value = msI.ToArray();
cmd.Prepare();
cmd.ExecuteNonQuery();
MessageBox.Show("Image Added");
thanks again for your help so far
Just for clarification i'm using Mysql as the DB
and sharpdeveloper for my IDE
And using MySQL ODBC 3.51 Driver for the odbc conention
modified on Saturday, February 14, 2009 12:43 PM
|
|
|
|
|
Hi,
maybe msI is a stream you just filled with some data and forgot to reposition to the beginning of the data?
try adding msI.Position=0;
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:05 AM
|
|
|
|
|
Hi,
why is your subject line starting with "MySQL" while your code uses ODBC?
the solution to your problem is in this page[^], read all of it!
PS: don't disable statements by commenting them out, it makes your source unreadable.
the purpose of comments is to clarify things, not obfuscate them.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:06 AM
|
|
|
|
|
Thanks working great after replacing named parameter with a ?
and sorry for not putting every thing needed in the subject
line this was my first time posting on the forum
but i would like to as you one more question if you had 2 parameters
that you would wand to put in the same query how would go about doing that
and the commenting of code was done to show the implementation of the previous replays
|
|
|
|
|
hendrik wrote: Thanks
you're welcome.
hendrik wrote: if you had 2 parameters ...
then I would recommend you read this page[^] twice.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:06 AM
|
|
|
|
|
Luc Pattyn wrote: then I would recommend you read this page[^] twice. Big Grin
thanks i don't know how i mist that the first time
|
|
|
|
|
Hello, I have a problem on the table layout panel control. I wanted to create a program that on run time I could set the table layout panel's number of rows and columns. My Problem is that the spaces of each boxes on the table are not evenly distributed. How do I make it evenly distributed?
|
|
|
|
|
This code worked fine for columns, it can also be slightly modifed to fit for rows:
tableLayoutPanel1.ColumnStyles.Clear();
int numOfColumns = 4;
tableLayoutPanel1.ColumnCount = numOfColumns;
for (int i = 0; i < numOfColumns ; i++ )
{
ColumnStyle cStyle = new ColumnStyle();
cStyle.SizeType = SizeType.Percent;
cStyle.Width = 100 / numOfColumns;
tableLayoutPanel1.ColumnStyles.Add(cStyle);
}
|
|
|
|
|
Is possible to define mp3 format in SDP protocol ?
In examples i found only definition for various voice comunication or asf/wma format.
|
|
|
|
|
Hello, I have a DataGridView on a Windows Form , it has 3 columns, one of them is a CheckboxColumn, the other two columns are set to be automatically sortable.
The problem is that when I sort one of the sortable columns, the selected checkboxes in the CheckBox column are lost..
How can I keep the checked checkboxes checked after performing a sort on another column.
modified on Saturday, February 14, 2009 7:20 AM
|
|
|
|
|
If I populate a listview with somethinglike:
foreach (DebtorDataSet.DebtorListRow row in debtorDataSet.DebtorList.Rows)
{
ListViewItem item = listView.Items.Add(row.Code);
item.SubItems.Add(name);
item.SubItems.Add(row.IsPostcodeNull() ? "" : row.Postcode);
item.SubItems.Add(row.IsTelephoneNull() ? "" : row.Telephone);
}
How can I set the backcolor of a row to red if row.Telephone is null please?
|
|
|
|
|
Well, The method ListViewItem.SubItems.Add() can take a simple string to create a subitem, but it also can take a ListViewItem.ListViewSubItem object to do the same thing.
So, you can create ListViewItem.ListViewSubItem subitem, set its BackColor property to whatever you want, and then add it to the SubItems collection of your ListViewItem
ListViewItem.ListViewSubItem it1 = new ListViewItem.ListViewSubItem();
it1.BackColor = Color.Red;
item.SubItems.Add(it1);
|
|
|
|
|
hello...
my form has a static image like a photo of 100 computers. then my application pings the systems and if the destination is reachable then the corresponding computer must have a green light else a red one.
the problem is that the image has to be the same and only a part of it has to be changed,
i am thinking of doing this with the help of graphics in c# and would be pleased if any other methods work.... thank you .
|
|
|
|
|
|