|
OK some more info from MSDN ms-help://MS.VSCC/MS.MSDNVS/cptutorials/html/image_resources.htm[^], sorry I cant help anymore without actually learning how to use resources.
Image Resources
To create image resources, perform the following three steps:
Create an XML-based .resx file containing the named resources.
Convert the .resx file into a .resources file using Resgen.exe.
Create a DLL, and embed the .resources file using the Assembly Generation Tool (AL).
Note For more information on AL, see Appendix B: Resource Tools.
As with strings, if the image resources are localized into nondefault cultures, the process must be done for each culture — which must also be specified when using AL — as well as for a default, language-neutral culture.
The first step — creating the .resx file — is more complicated with image resources. There are several methods for doing this, but ultimately the resource must be converted into ASCII text using BASE64 encoding and embedded into an XML-formatted .resx file.
ResXGen — A handy tool for converting resources is the ResXGen utility included with this tutorial. This small console application takes three arguments: the name of the image file, the .resx output file, and the name to give the resource. The following command line is from the Build.bat file for the Graphic sample application:
ResXGen /i:un.jpg /o:Images.resx /n:flag
A more complete description of this tool, including a discussion of the source code, can be found in Appendix B: Resource Tools.
ResEditor — Another tool for converting resources is the ResEditor utility included with this tutorial. This Windows Forms application allows to you add and delete resources — including bitmaps, icons, and strings — that are located in .resources files. By using a property browser, ResEditor allows you to explore the properties of graphic resources and directly edit string resources.
To illustrate how to use this tool (which might not be completely obvious), you can now walk through the process of creating a common .resources file that combines the German resources from the WorldCalc and Graphic samples discussed earlier. Start ResEditor, and open MyStrings.de.resources from the \de subdirectory of the WorldCalc sample directory for either Visual Basic or C#. Note that the string name/value pairs are listed in the property grid. In the Add group of controls near the bottom of ResEditor, type flag, and click the Add button (which will no longer be disabled). A new node is added to the tree of controls and properties that is on the left. Select the new flag node, and click the ellipsis button (…) that is just to the right. Navigate to the \flags subdirectory of the WorldDocs sample, and specify the de-DE.jpg image file. Note that the properties for the Flag bitmap are now shown as a thumbnail image — in this case, of the German flag. You should now see something like the following illustration.
Resource Editor (RESEDITOR) (from the Appendix B link)
The Resource Editor (ResEditor) sample application is also a useful tool. It provides a graphical interface that allows you to construct .resources files containing bitmaps, icons, and strings.
It appears RESEDITOR is a sample app included with the SDK samples. You might be required to build it 1st.
ANyways hope this helps
PS: JTJ had an article/post a few months back if I remember correctly, not sure if that would help.
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
leppie wrote:
JTJ had an article/post a few months back if I remember correctly, not sure if that would help.
Not really, my article covers using VS.NET and the commandline; but I don't know anything about SharpDevelop...but I may have to install it just so I can add more to the article
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Jesse,
Not sure if this is exactly what you're looking for, but in addition to what leppie said, you can embed the .resource file (generated by resgen) in your assembly using /res <resource file="" name=""> in your csc command and then read it back again using
Assembly ass = Assembly.GetCallingAssembly();
Stream strm = ass.GetManifestResourceStream("MyResourceFile.resources");
IResourceReader rr = new ResourceReader(strm);
IDictionaryEnumerator de = rr.GetEnumerator();
while (de.MoveNext())
{
} (This requires System.Reflection and System.Resources)
Paul
Pleasently caving in, I come undone - Queens of the Stone Age, No One Knows
|
|
|
|
|
Hi all,
The function below is used to filter out messages in a DataSet depending on wheather they are between the two dates; "DateTime from" and "DateTime to".
The date of the message is the first column of each row.
(logDataSet is a global variable)
I'm having trouble with this line:
tempDS.Tables["Table"].Rows.Add(logDataSet.Tables["Table"].Rows[i]);
in the below code.
I get the following exception:
"System.ArgumentException
This Row already belongs to another table"
Also, I have tried creating an copy of the DataSet logDataSet (DataSet tempDS = logDataSet), but when I delete rows from the copy it seems to also delete these rows from the global DataSet logDataSet.
Does anyone have any ideas where I am going wrong?
Thanks,
Donal
<br />
private DataSet filterDates(DateTime from, DateTime to)<br />
{<br />
DataSet tempDS = logDataSet.Clone();<br />
for(int i=0;i < logDataSet.Tables["Table"].Rows.Count;i++)<br />
{<br />
DateTime fromTime = (DateTime)logDataSet.Tables["Table"].Rows[i][0];<br />
DateTime toTime = (DateTime)logDataSet.Tables["Table"].Rows[i][0];<br />
if( fromTime.Date >= from.Date && toTime.Date <= to.Date)<br />
{<br />
tempDS.Tables["Table"].Rows.Add(logDataSet.Tables["Table"].Rows[i]);<br />
}<br />
}<br />
return tempDS;<br />
}
|
|
|
|
|
I suggest using a DataView as a filter - or -
From MSDN:
DataTable.NewRow Method
See Also
DataTable Class | DataTable Members | System.Data Namespace | AcceptChanges | Add | DataColumnCollection | DataColumn | DataRowCollection
Creates a new DataRow with the same schema as the table.
[Serializable]
public DataRow NewRow();
Return Value
A DataRow with the same schema as the DataTable.
Remarks
You must use the NewRow method to create new DataRow objects with the same schema as the DataTable. After creating a DataRow, you can add it to the DataRowCollection, through the DataTable object's Rows property.
- or -
Copy the value directly from the DataRow's ItemArray property.
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
I tried to integrate a flex program with C# the way I used to integrate with VB6 but nothing is happening.
I want to know the correct way to do it. Is there any DLLs I have to attach?
Anybody know abt this? Pls help me.
Thanks.
kind rgds,
Anjana Aluthwala
|
|
|
|
|
If you give more details perhaps someone can help you, if you repost it, no one will. To be honest I dont even know WTF you are talking about , FLEX (is it some kind of aerobics exercise?) never heard of it. VB6 never touched it. Maybe post some VB6 code in the VB.NET forum. Just dont repost!!!!
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
I have to write a program in c#,recently. However I don't know what to write about.I think it may be about socket programing. But in fact, there are still too much we can write using sockets. Still, I want to write something new. Can you all help me, and give me some sugguestion? Think you all.
|
|
|
|
|
Anything on Remoting or using Managed DirectX A C# CodeDom codeparser will be nice while you are at it
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
I vote for Yacc and Lex.
Вагиф Абилов
MCP (Visual C++)
Oslo, Norway
Hex is for sissies. Real men use binary. And the most hardcore types use only zeros - uppercase zeros and lowercase zeros.
Tomasz Sowinski
|
|
|
|
|
Hi all,
How do I convert the current value of a DateTimePicker control to a DataTime object?
Thanks
Donal
|
|
|
|
|
From MSDN:
DateTimePicker.Value Property
See Also
DateTimePicker Class | DateTimePicker Members | System.Windows.Forms Namespace | DateTime
public DateTime Value {get; set;}
Property Value
The DateTime value assign to the control.
Remarks
If the Value property has not been changed in code or by the user, it is set to the current date and time (DateTime.Now).
Example
The following example demonstrates how use the Value property to retrieve the current date value. First, the example displays the Value property. The example then increments the Value property by one day and displays the property value again.
public MyClass()
{
DateTimePicker dateTimePicker1 = new DateTimePicker();
Controls.AddRange(new Control[] {dateTimePicker1});
MessageBox.Show(dateTimePicker1.Value.ToString());
dateTimePicker1.Value = DateTime.Now.AddDays(1);
MessageBox.Show(dateTimePicker1.Value.ToString());
}
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
|
Hi:
I’m an intermediate level C#.net programmer and I found your email address at www.dotnet247.com … My difficulty is parsing a Log File into a SQL database. The RegEx looks very interesting; however I would like a sample code to learn with. Help….
This is a sample from a typical Log File. The “Headings” (Date & Time, etc) above the Log File entries are NOT in the actual file. I placed them there to represent my SQL database table columns I would like to “Break” the information into...
| Date & Time | Activity | Source IP | Dest IP | Reason |
Wed, 01/15/2003 10:29:03 - TCP connection dropped - Source:211.218.37.114, 3017, WAN - Destination:206.104.18.112, 1433, LAN - 'Suspicious TCP Data'
Wed, 01/15/2003 11:01:25 - UDP packet dropped - Source:200.11.88.226, 64546, WAN - Destination:206.104.18.112, 137, LAN - 'Suspicious UDP Data'
Wed, 01/15/2003 11:08:05 - TCP connection dropped - Source:198.87.196.145, 53, WAN - Destination:206.104.18.112, 1177, LAN - 'Suspicious TCP Data'
Wed, 01/15/2003 11:38:08 - UDP packet dropped - Source:65.167.107.117, 1027, WAN - Destination:206.104.18.112, 137, LAN - 'Suspicious UDP Data'
Wed, 01/15/2003 14:26:02 - TCP connection dropped - Source:208.186.78.104, 80, WAN - Destination:206.104.18.112, 2563, LAN - 'Suspicious TCP Data'
Kevin@upgrade1.com (Please reply to email address)
|
|
|
|
|
The BeginListener function will not receive any information from the socket
past a certain amount (apparently 4096 bytes). Information sent that is
smaller than that is received properly. If data is sent that is larger than
that, it's truncated to 4096 bytes, and then the while loop exits (which it
should never do).
<br />
private void BeginListener()<br />
{<br />
byte[] b = new byte[10000000];<br />
int k;<br />
Socket s;<br />
String strMessage = "";<br />
<br />
TcpListener newList = new TcpListener(10000);<br />
newList.Start();<br />
while (true)<br />
{<br />
strMessage = "";<br />
<br />
s = newList.AcceptSocket();<br />
k = s.Receive(b);<br />
<br />
for (int nCounter = 0; nCounter < k; nCounter++)<br />
{<br />
strMessage += (char)b[nCounter];<br />
}<br />
}<br />
newList.Stop();<br />
}<br />
<br />
<br />
private void SendCommand(String Address,String strTempFile)<br />
{<br />
StreamReader newReader = new StreamReader(strTempFile);<br />
String strSendString = newReader.ReadToEnd();<br />
newReader.Close();<br />
<br />
newClient = new TcpClient();<br />
NetworkStream tcpStream = null;<br />
byte[] ba;<br />
<br />
try<br />
{<br />
newClient.Connect(Address,10000);<br />
tcpStream = newClient.GetStream();<br />
ASCIIEncoding asem = new ASCIIEncoding();<br />
ba = asem.GetBytes(strSendString);<br />
tcpStream.Write(ba,0,ba.Length);<br />
}<br />
catch (System.Net.Sockets.SocketException)<br />
{<br />
}<br />
finally<br />
{<br />
if (tcpStream != null) {tcpStream.Close();}<br />
if (newClient != null) {newClient.Close();}<br />
}<br />
}<br />
Any help would be greatly appreciated.
|
|
|
|
|
You should never read this much information in one read. Many servers don't even send information that fast and your socket times-out while waiting. Buffer your respones into byte[4096] (a good recommended size) and write them out to a stream (using the read byte count) as they're read-in. This is how practically every transport mechanism works.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
First of all, there no such limitation in the .NET Socket implementation : the actual code beinh Receive() is in fact a direct Winsock2 recv() function call, and it passes your buffer directly, not an intermediate buffer.
I can see an error in your code : in your loop, you are Accepting a new socket instance at each iteration. Usually, you accept a socket once, and then loop with Receive.
|
|
|
|
|
I have a Bitmap that has loaded in a map. When I click on the map (bitmap), I want to draw a filled circle at that point. I understand how to do it with a PictureBox or something that I can get a Graphics object for/from it, but I can't for the life of me figure out how to do the same with a bitmap.
Is there a way to do this? I'm sure there is, I just haven't figured it out yet. So, if any of you could help me out by pointing me in the correct direction, code fragments, or whatever, I'd really appreciate it.
Thanks a bunch!
Mike
|
|
|
|
|
Graphics g = Graphics.FromImage(bmp);
g.DrawLine(...);
g.Dispose();
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Heath,
Thanks for responding.
I tried that and got the following error:
An unhandled exception of type 'System.Exception' occurred in system.drawing.dll
Additional information: A Graphics object cannot be created from an image that has an indexed pixel format.
Any ideas?
Thanks again,
Mike
|
|
|
|
|
Well, my first suggestion would be to read the docs (especially about Image and Bitmap ). My second suggestion, having said that, it to save the indexed image to a MemoryStream using a different <codepixelformat< code=""> then read it back in and get the <code>Graphics object from that. There are many other ways you can do this, too.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Hi Heath!
Thanks again for replying. To start off, as if you probably couldn't tell, this is my first foray into doing much of anything with graphics. Lots of middle/backend programming with next to nothing in the UI department for the last 8 years.
That being said, what docs are you talking about? I've read the documentation that Microsoft has written on the Image and Bitmap classes but they're rather thin when you don't know much about using graphics in general. Are there other places that have better documentation? If so, please point me to them!
Also, I will look into the MemoryStream option, but I have one question: you say to save the indexed image (BTW what is that? I just thought I was loading a BMP file! There's different types of BMPs?) using a different ...?? I get the last part (at least in theory) but what different thing am I to use?
Thanks again for the advice. It really does help.
|
|
|
|
|
Yeah, the Microsoft .NET documentation. This documentation is what I've used and don't know much about graphics either, but these is *very* basic drawing routines - not much documentation is needed.
The Bitmap</code class does not equate to a .bmp file. It adds a few methods and properties to the <code>Image class for bitmap images. All image formats (i.e., JPEG, GID, PNG, BMP, RGB, etc.) that I'm aware of are technically bitmaps - a map of bits essentially. Most formats basically have an (A)RGB value for each bit (the whole of which makes up the bitmap). Index images basically have a palette of colors that are indexed and the image contains a mapping of pixels <-> palette index. That's a very basic description of both of those things, but that covers the gist of it.
BTW, there are different kinds of .bmp files (remember, this is not exclusive to the Bitmap class). The difference is the way the bitmaps are encoded in the file. There's Windows and OS/2 encodings that I know of. This is a similar concept to video files, just like an AVI can have different encodings (MPEG4, DivX, etc.).
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Thanks Heath. You've added to my knowledge base and that's great.
I did get things to work, but not in the place that I want it. Now that I know it works like you said, it's just a matter of figuring out how to do it in the OnMouseXxx functions.
Thanks for you help and input!
Mike
|
|
|
|
|
If a method doesn't give you a Graphics object, you can always get one for a particular control by using Control.CreateGraphics() . In this case, though, you must call Graphics.Dispose() when you're done with it. In event handlers like OnPaint() that give you one, it will clean it up for you so *never* call Graphics.Dipose() at that time.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|