Text printing is giving me trouble

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Text printing is giving me trouble

 
0
  #1
Sep 17th, 2005
ok, so i have been working on a program that i call "Sharppad" any ways it is a text editor. it has all teh basic functions. but it can also speak teh text you type. and convert text to .wav files. so you can listen to what you type. it also has a syntax editor. any ways i came too the part where i want it to print... and i get figure it out. i hvae tried code on the internet and it all just prints blank paper. any ideas?
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: Text printing is giving me trouble

 
0
  #2
Sep 18th, 2005
dude, did you finish the mp3 copier?
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Text printing is giving me trouble

 
0
  #3
Sep 18th, 2005
lol, yea pretty much, i still cant get it to read all the tags. but it copies the mp3 from the ipod to the harddrive. it provides a skin for itunes,(looks like an ipod functions like one) provides an interface for making contacts to put on teh ipod(vcards). and is also an id3 editor. so yea thats done. still trying to get it to read all the tags


EDIT: Hey r0ck if i put the code on here do you think you could help me get it to read all the tags in the directory in display them in the listbox
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Text printing is giving me trouble

 
0
  #4
Sep 18th, 2005
o and r0ck one more question how could i let the user choose between mp4 and pm3 cuz i try to declarte the textbox as teh file type. but it wont work? maybe a whole new fileType(filetype2) or an if else statement?????
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: Text printing is giving me trouble

 
0
  #5
Sep 18th, 2005
what about some radiobuttons which display the choice ? yes, you can post the code , so we can try to work it out
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Text printing is giving me trouble

 
0
  #6
Sep 18th, 2005
yea i was think bout radio buttons. but here is the weird thing. on my bro's ipod it read ALMOST all of them where as on mine and my dads it reads almost none....


i will post the code tommrow. its late now i gotta catch some z's


p.s

Thank you for all of your help. You have really taught me alot.
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Text printing is giving me trouble

 
0
  #7
Sep 19th, 2005
Originally Posted by tayspen
yea i was think bout radio buttons. but here is the weird thing. on my bro's ipod it read ALMOST all of them where as on mine and my dads it reads almost none....


i will post the code tommrow. its late now i gotta catch some z's


p.s

Thank you for all of your help. You have really taught me alot.


Ok, here is teh code...Keep in mind i am trying to backup the songs off my ipod onto my harddrive. I got this down. but when it copies it comes out with the weird names like QEYX i want it to read the id3 tags as it copies and spits them out with good names. i also need to be able to coopy mp4's out to.( i think i can do that) what i reallly n eed help on is the id3 part. anywho here it is.


the first thing that i will do is press a browse button that will bring up a folerbrowser.....
  1.  
  2. folderBrowserDialog1.ShowDialog(); //the textbox2 text is = to the folderbrowser selected index
  3. textBox2.Text = folderBrowserDialog1.SelectedPath;


then it displays in the textbox, the filename.

From there its as easy as pressing the cop button..... this is the code for when it is pressed.....

  1.  
  2. private void button1_Click(object sender, EventArgs e)
  3. {
  4. try
  5. {
  6. string sourceDir = textBox1.Text + "\\iPod_Control\\Music";//add this to the drive that the user typed in (sets up the source file)
  7. string targetDir = folderBrowserDialog1.SelectedPath; //show them the browser there directory = target
  8.  
  9. foreach (string d in Directory.GetDirectories(sourceDir))
  10. {
  11.  
  12. foreach (string f in Directory.GetFiles(d, fileType))
  13. {
  14.  
  15.  
  16. MessageBox.Show("Please be patient process may take a while", "Please wait");//Notify the user
  17. label2.Visible = true;//label2 now visible upon button click
  18.  
  19.  
  20. File.Copy(f,
  21. targetDir + "\\" + new FileInfo(f).Name, //Attempt copy
  22. false);
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. }
  30. }
  31. }

Here is teh Read(); part. i tried puting Read(); in a few places. (no dice)

  1.  
  2. public void Read()
  3. {
  4.  
  5. // Read the 128 byte ID3 tag into a byte array
  6. FileStream oFileStream;
  7. oFileStream = new FileStream(this.filename, FileMode.Open);
  8. byte[] bBuffer = new byte[128];
  9. oFileStream.Seek(-128, SeekOrigin.End);
  10. oFileStream.Read(bBuffer, 0, 128);
  11. oFileStream.Close();
  12.  
  13. // Convert the Byte Array to a String
  14. Encoding instEncoding = new ASCIIEncoding(); // NB: Encoding is an Abstract class
  15. string id3Tag = instEncoding.GetString(bBuffer);
  16.  
  17. // If there is an attched ID3 v1.x TAG then read it
  18. if (id3Tag.Substring(0, 3) == "TAG")
  19. {
  20. this.Title = id3Tag.Substring(3, 30).Trim();
  21. this.Artist = id3Tag.Substring(33, 30).Trim();
  22. this.Album = id3Tag.Substring(63, 30).Trim();
  23. this.Year = id3Tag.Substring(93, 4).Trim();
  24. this.Comment = id3Tag.Substring(97, 28).Trim();
  25.  
  26. // Get the track number if TAG conforms to ID3 v1.1
  27. if (id3Tag[125] == 0)
  28. this.Track = bBuffer[126];
  29. else
  30. this.Track = 0;
  31. this.GenreID = bBuffer[127];
  32.  
  33. this.hasTag = true;
  34. // ********* IF USED IN ANGER: ENSURE to test for non-numeric year
  35. }
  36. else
  37. {
  38. this.hasTag = false;
  39. }
  40. }

(i might have trimmed some out so if u see somthing missing lemme no)


maybe i should update teh mp3's as there being cbacked up

  1.  
  2. public void updateMP3Tag()
  3. {
  4. // Trim any whitespace
  5. this.Title = this.Title.Trim();
  6. this.Artist = this.Artist.Trim();
  7. this.Album = this.Album.Trim();
  8. this.Year = this.Year.Trim();
  9. this.Comment = this.Comment.Trim();
  10.  
  11. // Ensure all properties are correct size
  12. if (this.Title.Length > 30) this.Title = this.Title.Substring(0, 30);
  13. if (this.Artist.Length > 30) this.Artist = this.Artist.Substring(0, 30);
  14. if (this.Album.Length > 30) this.Album = this.Album.Substring(0, 30);
  15. if (this.Year.Length > 4) this.Year = this.Year.Substring(0, 4);
  16. if (this.Comment.Length > 28) this.Comment = this.Comment.Substring(0, 28);
  17.  
  18. // Build a new ID3 Tag (128 Bytes)
  19. byte[] tagByteArray = new byte[128];
  20. for (int i = 0; i < tagByteArray.Length; i++) tagByteArray[i] = 0; // Initialise array to nulls
  21.  
  22. // Convert the Byte Array to a String
  23. Encoding instEncoding = new ASCIIEncoding(); // NB: Encoding is an Abstract class // ************ To DO: Make a shared instance of ASCIIEncoding so we don't keep creating/destroying it
  24. // Copy "TAG" to Array
  25. byte[] workingByteArray = instEncoding.GetBytes("TAG");
  26. Array.Copy(workingByteArray, 0, tagByteArray, 0, workingByteArray.Length);
  27. // Copy Title to Array
  28. workingByteArray = instEncoding.GetBytes(this.Title);
  29. Array.Copy(workingByteArray, 0, tagByteArray, 3, workingByteArray.Length);
  30. // Copy Artist to Array
  31. workingByteArray = instEncoding.GetBytes(this.Artist);
  32. Array.Copy(workingByteArray, 0, tagByteArray, 33, workingByteArray.Length);
  33. // Copy Album to Array
  34. workingByteArray = instEncoding.GetBytes(this.Album);
  35. Array.Copy(workingByteArray, 0, tagByteArray, 63, workingByteArray.Length);
  36. // Copy Year to Array
  37. workingByteArray = instEncoding.GetBytes(this.Year);
  38. Array.Copy(workingByteArray, 0, tagByteArray, 93, workingByteArray.Length);
  39. // Copy Comment to Array
  40. workingByteArray = instEncoding.GetBytes(this.Comment);
  41. Array.Copy(workingByteArray, 0, tagByteArray, 97, workingByteArray.Length);
  42. // Copy Track and Genre to Array
  43. tagByteArray[126] = System.Convert.ToByte(this.Track);
  44. tagByteArray[127] = System.Convert.ToByte(this.GenreID);
  45.  
  46. // SAVE TO DISK: Replace the final 128 Bytes with our new ID3 tag
  47. FileStream oFileStream = new FileStream(this.filename, FileMode.Open);
  48. if (this.hasTag)
  49. oFileStream.Seek(-128, SeekOrigin.End);
  50. else
  51. oFileStream.Seek(0, SeekOrigin.End);
  52. oFileStream.Write(tagByteArray, 0, 128);
  53. oFileStream.Close();
  54. this.hasTag = true;
  55. }

So that bout some that up. thanks r0ck for any ideas that you might have


p.s

i have tried the previous ideas(i just may have switched some things around or put it back hw it was,, so if it looks like i havnt tried any of your previous ideas...i have)
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: Text printing is giving me trouble

 
0
  #8
Sep 19th, 2005
Hi, i think yo didn't get the point of the Read() function ...Read is in fact a member function of a class called ID3v1.

I gave a you a link to a this complete class in another thread, so what you do is the following, copy-paste the whole code to a file called ID3v1.cs , and then you incorporate that file into your project, then after that you call it like this:

  1. foreach (string f in Directory.GetFiles(d, fileType))
  2. {
  3. MessageBox.Show("Please be patient process may take a while", "Please wait");//Notify the user
  4. label2.Visible = true;//label2 now visible upon button click
  5.  
  6. // Now try to read tags from the file to copy
  7. ID3v1 mp3Tag = new ID3v1(f);
  8. File.Copy(f, targetDir+"\\"+mp3Tag.Artist+"_"+mp3Tag.Title+new FileInfo(f).Extension, false);
  9.  
  10. //........
  11. }

I didn't test this code, so there might be some bugs.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Text printing is giving me trouble

 
0
  #9
Sep 19th, 2005
Originally Posted by r0ckbaer
Hi, i think yo didn't get the point of the Read() function ...Read is in fact a member function of a class called ID3v1.

I gave a you a link to a this complete class in another thread, so what you do is the following, copy-paste the whole code to a file called ID3v1.cs , and then you incorporate that file into your project, then after that you call it like this:

  1. foreach (string f in Directory.GetFiles(d, fileType))
  2. {
  3. MessageBox.Show("Please be patient process may take a while", "Please wait");//Notify the user
  4. label2.Visible = true;//label2 now visible upon button click
  5.  
  6. // Now try to read tags from the file to copy
  7. ID3v1 mp3Tag = new ID3v1(f);
  8. File.Copy(f, targetDir+"\\"+mp3Tag.Artist+"_"+mp3Tag.Title+new FileInfo(f).Extension, false);
  9.  
  10. //........
  11. }

I didn't test this code, so there might be some bugs.
lemme gixe it a go..... be back soon
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Text printing is giving me trouble

 
0
  #10
Sep 19th, 2005
ok so i tried this is is the exact code under the rip button


  1.  
  2.  
  3. private void button1_Click(object sender, EventArgs e)
  4. {
  5.  
  6. try
  7. {
  8.  
  9. string sourceDir = textBox1.Text + "\\iPod_Control\\Music";//add this to the drive that the user typed in (sets up the source file)
  10. string targetDir = folderBrowserDialog1.SelectedPath; //show them the browser there directory = target
  11.  
  12. foreach (string d in Directory.GetDirectories(sourceDir))
  13. {
  14.  
  15.  
  16. foreach (string f in Directory.GetFiles(d, fileType))
  17. {
  18.  
  19. label2.Visible = true;//label2 now visible upon button click
  20.  
  21. // Now try to read tags from the file to copy
  22. ID3v1 mp3Tag = new ID3v1(f);
  23. File.Copy(f, targetDir + "\\" + mp3Tag.Artist + "_" + mp3Tag.Title + new FileInfo(f).Extension, false);
  24.  
  25. //........
  26. }
  27. }
  28. }
  29.  
  30. catch
  31. {
  32. frmerror frm = new frmerror();
  33. frm.ShowDialog(this); // show notes (EDIT: notes canceled now show about)
  34. frm.Dispose();
  35. }
  36.  
  37.  
  38.  
  39.  
  40. }




EDIT: just took off catch statement. the error was that the file - already exists...
now it copies one song with the file name -

and then it shows me my catch form if somthing goes wrong.....

i hadded that ID# form and everything...
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC