|
Only thing is, MS says you're not supposed to use them in your own applications.
I'm making my own XP icon look-alikes.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
The thing is, in MS's windows style guide, they say you must use certain icons in order to maintain a visual appearance. How then can you do this if you can use the same icons? In this guide, it says MS will be releasing them, but I cannot find anything on this release.
|
|
|
|
|
Ahh, just do it anyway. Everyone does, including non-Microsoft employees for sample code posted on Microsoft sites like MSDN. Just be mindful that certain things - like icons for Cut, Copy, and Paste, are not icons at all but bitmaps in the Bitmap resource section (just in case you were looking for them).
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
I have a simple little componnent below.
Why is the ouput 1 then 0 ? I don't understand why the instance variable is reset after the transaction is completed ?
using System;
using System.Runtime.CompilerServices;
using System.EnterpriseServices;
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: ApplicationName("TestApp")]
[assembly: ApplicationAccessControl(false)]
[assembly: AssemblyKeyFileAttribute("TestApp.snk")]
[Transaction(TransactionOption.Required)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class Test : ServicedComponent
{
protected int i;
public int I
{
get
{
return i;
}
}
[AutoComplete]
public void test()
{
i++;
Console.WriteLine( i );
}
}
public class client
{
public static int Main()
{
Test t = new Test();
t.test();
Console.WriteLine( t.I );
return 0;
}
}
|
|
|
|
|
I read an image file,then I want to write a a string on it and save it again. I write an string with whith graphic object in the Paint event,but I cant save it to a file. I think I don't really write on a image,I just write on the screen,so how to write a text on image an save it?
Mazy
No sig. available now.
|
|
|
|
|
The following will open an image, create a Graphics object to use for drawing to it, draw a string, and save it to another file.
Image image = Image.FromFile("source.jpg");
Graphics g = Graphics.FromImage(image);
g.DrawString("Hello World!", new Font("Tahoma", 24), Brushes.Magenta, 10.0f, 10.0f);
g.Dispose();
image.Save("target.jpg");
Note that this will only work for non-indexed image formats. For an indexed format you could just create a new non-indexed Image into which you first draw the loaded Image before writing other stuff on top. Of course when you save the file it won't be in the same format as the original.
Image image = Image.FromFile("source.gif");
Bitmap bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(image, 0.0f, 0.0f);
g.DrawString("Hello World!", new Font("Tahoma", 24), Brushes.Magenta, 10.0f, 10.0f);
g.Dispose();
bmp.Save("target.jpg");
|
|
|
|
|
Thank you. I'll test it very soon.
Mazy
No sig. available now.
|
|
|
|
|
It works,but I can't use it for tiff file,unhandled error happend for the Save method. Any idea?
Mazy
No sig. available now.
|
|
|
|
|
What was the Exception that you got?
If you want to save to TIFF format you need to specify an encoder like so:
ImageCodecInfo FindEncoder(ImageFormat format) {
ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
for (int i = 0; i < encoders.Length; i++)
if (encoders[i].FormatID == format.Guid)
return encoders[i];
return null;
}
...
image.Save("target.tiff", FindEncoder(ImageFormat.Tiff), null);
... Actually the example I gave before for saving an index-formatted image probably should have explicity specified the JPEG encoder even though I believe it uses Image.RawFormat which defaults to the JPEG format (at least on my system).
|
|
|
|
|
This is my code for multipage Tiff file:
Image image = Image.FromFile("1.tiff");
image.SelectActiveFrame(FrameDimension.Page,0);
Graphics g = Graphics.FromImage(image);
g.DrawString("Hello World!", new Font("Tahoma", 24), Brushes.Magenta, 10.0f, 10.0f);
g.Dispose();
image.Save("1.tiff",FindEncoder(ImageFormat.Tiff),null);
This is an error:
A Generic Error Ocurde In GDI+
The file is multipage and I want to save it into same file.
Mazy
No sig. available now.
|
|
|
|
|
hmmm....thanks.
Mazy
No sig. available now.
|
|
|
|
|
Has anyone heard of this class? I came across it in a custom config section handler I built on v1.0 (derived from System.Configuration.DictionarySectionHandler). The Create method loops thru an XMLNode to retrieve config file section settings. In v1.0, only ConfigXmlElement objects were in the enumerator (or so it seems). In v1.1, I'm also getting ConfigXmlWhitespace objects.
My previous code:
IEnumerator enumer = section.ChildNodes.GetEnumerator();
The workaround:
IEnumerator enumer = ((XmlElement)section).GetElementsByTagName("myTag").GetEnumerator();
The workaround ensured that only XmlElements named "myTag" would be included in the enumerator.
|
|
|
|
|
Hi:
I want to save my pictures in an .tiff file as an multipage,it means there are more that one picture in one file.How can I do it? (Hope that I'm clear about the problem)
Mazy
No sig. available now.
|
|
|
|
|
The following example creates three Bitmap objects: one from a BMP file, one from a JPEG file, and one from a PNG file. The code saves all three images in a single, multiple-frame TIFF file.
using System;
using System.Drawing;
using System.Drawing.Imaging;
class Example_MultiFrame
{
public static void Main()
{
Bitmap multi;
Bitmap page2;
Bitmap page3;
ImageCodecInfo myImageCodecInfo;
Encoder myEncoder;
EncoderParameter myEncoderParameter;
EncoderParameters myEncoderParameters;
// Create three Bitmap objects.
multi = new Bitmap("Shapes.bmp");
page2 = new Bitmap("Iron.jpg");
page3 = new Bitmap("House.png");
// Get an ImageCodecInfo object that represents the TIFF codec.
myImageCodecInfo = GetEncoderInfo("image/tiff");
// Create an Encoder object based on the GUID
// for the SaveFlag parameter category.
myEncoder = Encoder.SaveFlag;
// Create an EncoderParameters object.
// An EncoderParameters object has an array of EncoderParameter
// objects. In this case, there is only one
// EncoderParameter object in the array.
myEncoderParameters = new EncoderParameters(1);
// Save the first page (frame).
myEncoderParameter = new EncoderParameter(
myEncoder,
(long)EncoderValue.MultiFrame);
myEncoderParameters.Param[0] = myEncoderParameter;
multi.Save("Multiframe.tiff", myImageCodecInfo, myEncoderParameters);
// Save the second page (frame).
myEncoderParameter = new EncoderParameter(
myEncoder,
(long)EncoderValue.FrameDimensionPage);
myEncoderParameters.Param[0] = myEncoderParameter;
multi.SaveAdd(page2, myEncoderParameters);
// Save the third page (frame).
myEncoderParameter = new EncoderParameter(
myEncoder,
(long)EncoderValue.FrameDimensionPage);
myEncoderParameters.Param[0] = myEncoderParameter;
multi.SaveAdd(page3, myEncoderParameters);
// Close the multiple-frame file.
myEncoderParameter = new EncoderParameter(
myEncoder,
(long)EncoderValue.Flush);
myEncoderParameters.Param[0] = myEncoderParameter;
multi.SaveAdd(myEncoderParameters);
}
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
}
|
|
|
|
|
Oh,Thank you man. It works.
Mazy
No sig. available now.
|
|
|
|
|
Hi !
I've got a strange problem with printing documents with C#.
When I preview the document, it is always OK.
But on the paper, there may be some wrong characters : '#' instead of 'R', '&' instead of 'A'.....
It seems to depend of the used font (common fonts) and printer (recent printers).
For example, if I choose the 'Arial' font, it will be ok with one printer but won't be correct with other one which will prefer the 'Ms sans serif' font.
Do you have any idea to get a correct printed document with any font and any priter and without any eronated character ?
jpeg
|
|
|
|
|
does someone know how to save a data form datagrid as txt?
Thanx
|
|
|
|
|
This is really a rudimentary task done by first-year computer science students. This type of question usually indicates that the person asking doesn't really want to do the work to find the answer. Here's a hint for you--the answer is readily available. Just search the MSDN library for System.IO and related classes for writing to text files. Just iterate through your collection of objects found in the data grid and write them out to a text file separating each field with a comma or tab. It's very simple.
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
thank u very much for helping me to find myself!!!
i really believe i find the answere in MSDN but first i got to have it!
Thanx
|
|
|
|
|
hi,
i want to know how can i make a fixed digits conversion like below C printf() function in c#?
CString a;
a.format("%02d, %02d, %02d", 1, 12, 123);
thanks,
jim
|
|
|
|
|
|
Hi everyone, does anyone know how to rotate a UserControl? Or, if there is no method to do this, is there any other way to rotate whatever is inside the UserControl (perhaps by rotating the region or something).
thanks in advance,
Lisa
|
|
|
|
|
You can't rotate the control itself, but you can rotate its contents using Graphics.Transform.Rotate() .
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi, jdunlap,
I want to find some example of rotating image as well.
I have an image drawn by Graphics.drawImage(), and now want to rotate it at 90, 180 , 270.
I use graphic.DrawImage(img, p) where p is the position of image.
how can I rotate it to 90 ?
Or, do you have any example of this?
Thank you
|
|
|
|
|
Point[] destinationPoints = {
new Point(200, 20), // destination for upper-left point of
// original
new Point(110, 100), // destination for upper-right point of
// original
new Point(250, 30)}; // destination for lower-left point of
// original
Image image = new Bitmap(YOUR_IMAGE_NAME);
// Draw the image unaltered with its upper-left corner at (0, 0).
e.Graphics.DrawImage(image, 0, 0);
// Draw the image mapped to the parallelogram.
e.Graphics.DrawImage(image, destinationPoints);
You'll have to make calculations of destination poins for different angles.
|
|
|
|
|