|
This is your homework. What have you done to solve it ? Are you allowed to use the DateTime class ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
hey sah496
this will give u days in month according to month no u have passed to
<pre>
public int DaysInMonth(int nMonth)
{
int nDays = 0;
switch (nMonth) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
nDays = 31;
break;
case 4:
case 6:
case 9:
case 11:
nDays = 30;
break;
case 2:
int nDay=1;
int nYear=GetYear();
DateTime oDate;
oDate=Convert.ToDateTime(nDay.ToString()+ "-" +
nMonth.ToString() + "-" +
nYear.ToString() ,"dd-mm-yyyy");
if (DateTime.IsLeapYear(nYear)) {
nDays = 29;
}
else {
nDays = 28;
}
break;
}
return nDays;
}
public int GetYear()
{
// read year and return
}
akhilonly007@gmail.com
modified on Monday, April 6, 2009 5:07 AM
|
|
|
|
|
Hi,
How to sort an arraylist in decending order?
Thankyou
YPKI
|
|
|
|
|
Why would you use an ArrayList ? That's only there for legacy code. Does it not have a Sort method ( I can't remember ).
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: Does it not have a Sort method
Yes it does (how well it works I don't know, never use arraylists)
|
|
|
|
|
Hi,
First u can sort the arraylist using the Sort() method... Then reverse the arraylist using the Reverse() method... Not sure whether this is the best solution, but it is one way of doing it...
Thanks,
ramz_g
|
|
|
|
|
I cna't seem to figure this out and I though I once did this.
I have something like this:
newImage = new Bitmap(path.ToString());
Matrix matrix = new Matrix();
matrix.Rotate(angle);
Graphics g = Graphics.FromImage(newImage);
g.Transform = matrix;
g.Save();
Bitmap newImage2 = new Bitmap(newImage.Width, newImage.Height, g);
Save();
An image is created, but it's just completely black. I am wanting to rotate an image at a specified angle, and not use the RotateFlip, which has static values.
Any ideas? Can this Graphics be converted back to a Bitmap?
|
|
|
|
|
No, a graphics cannot be 'converted' to a bitmap. newImage is already the image your graphics is drawn on. You don't save the graphics, you save the bitmap.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
That what I was doing originally, but I kept getting expetion "A generic error occurred in GDI+". I'm overwriting the the original image....so maybe I'm doing something wrong and not dispoing of the picture. At any rate, if I save to a different ABS path, then it save the image, but the transform did not appear to have taken effect. I even tried drawing a line, but nothing changes with the picture - it's the same as the orignal.
So, i'm doing something like:
newImage.Save(path);
Should I be doing something different? Is there something I'm not calling on the Graphic object to make it apply to the Bitmap?
|
|
|
|
|
Yes, that means .NET already has a lock on the file, you'd need to save to another filename
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
try this
Bitmap newImage2 = new Bitmap(newImage);
Save();
or
newImage.Save();
Assume Graphics as pencil and Bitmap as paper...Now how you gonna do conversion...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You can't convert a Graphics object to a Bitmap , as it doesn't contain the image. The Graphics object is just used to draw on a canvas, in this case the canvas is a Bitmap object.
You are creating a Graphics object to draw on the original image, but what you want to do is to create it to draw on the new image, then you draw the original image onto the new image.
The transform controls how the drawing is done using the Graphics object, so when you draw the original image using that Graphics object it will be rotated.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Oh god, stupid me.....
Thanks for the responses everyone. I was going in circles (and sometimes th wrong way) because I thought the graphics was not writing to the original image. In fact it was. The test line i drew wasn't appearing because the coords I gave it were not long enough and my image is so huge that when I went to look at it I never see the line and the picture never rotated. Until I finally seen a red speck.... ;-0
|
|
|
|
|
Hi,
there are some quirks you have to be aware of:
1. all errors in GDI+ will report "an internal error..."
2. Image.FromFile() locks the file until the image is disposed
BTW: Image.FromStream() does not
Bitmap bm1 = Bitmap.FromFile(filename);
Bitmap bm2 = new Bitmap(width2, height2);
Graphics g = Graphics.FromImage(bm2);
g.Transform = matrix...;
g.DrawImage(bm1);
bm1.Dispose();
bm2.Save(filename, imageFormat);
g.Dispose();
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
|
|
|
|
|
Oh I swear, thank you SOOOO much. I couldn't figure out which object I wasn't dispoing of properly. I knew there was something wrong because if I could create a new bitmap as a new file name it would work, as it wasn't trying to write to the same STILL open file!!
Now on to figuring out to get it to rotate properly given the angle...ehhh.
Thanks for the help everyone!!
|
|
|
|
|
you're welcome.
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
|
|
|
|
|
I'm writing an app to add information to a custom database(which does not exist yet). After that, I will develop an app to work with/view the data.
As a newbie, I'm unaware of exactly what I should be studying to create a database in C#. I've figure out how to create data tables(and datasets) but I'm not sure what to even search for when I'm trying to find code samples or tutorials on how to permanently store the info and every search I do yields stuff with MySQL. Can someone please point me in the right direction?
|
|
|
|
|
You need to learn about SQL. That's basically it. That's what DBs are written in
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
well there are plenty articles here at CP. Take alook[^]
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Dear developers,
I like the type of chm-file for documentation.
I fiddled a while with the ms-help and I understand some principles.
My question is:
How can I automate the creation of "pretty-looking" chm-files?
Best regards
|
|
|
|
|
|
We've had a very good experience with HelpScribble:
http://www.helpscribble.com
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
Hi, I built an application using a TCP/IP connection. Therefore I need an I.P. checker to make sure the given IP is correct. I noticed that when an invalid IP is provided the complier can tell it right away. SO my quesion is if there is a command to check if an IP address is valid. By valid I mean it is less than 255.255.255.255. Or if you happen to have a code that does it i would be greatful.
Thank you in advance
|
|
|
|
|
Hi,
I haven't tried it myself but I would go for IPAddress.TryParse()
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
|
|
|
|
|
You could either ping it (requires internet access), use a regular expression, invoke the IPAddress.TryParse method or split it, and use Byte.TryParse on each of the components
|
|
|
|