|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Introduction
The project introduces some nice features of the Streams present in the .NET Base Classes. Stuff that would be lots more code in C++ can be cut down considerably. It also provides for tying events & delegates between the tiers (UI, Controller, Processing). BackgroundI originally created the worker classes in order to split up large MPEG files so they could fit onto 600 MB CD's. Routinely, however, I find a need to split files when transfering files over the internet using FTP, email, etc. While utilities such as WinRar do this for you, in the end you have to pay for the software for a simple task. They do add zip capabilities to the mix, but MPEG files, and existing Zip files are already zipped. So, I just needed a splitter/joiner tool and here it is. Using the codeFileSplitter / File Joiner ClassesThese classes expose a set of simple methods and an event called
In the end, ControllerWithin the UI project, there's a controller class that is responsible for accepting the requests from the UI and spawning, using the The constructor for public Controller( Form owner, Delegate senderDelegate)
{
m_sender = owner;
m_senderDelegate = senderDelegate;
}
It then registers for the fs.ProgressNotify += new ProgressNotifyHandler(NotifyHandler);
NotifyDelegate then in turn, uses the following method to asynchronously update the UI with the progress of the task. private void NotifyHandler( int i ) { m_sender.BeginInvoke(
m_senderDelegate, new object[] { i } ); }
MainFormThe main form is simple. Double clicking on the File Name text field just brings up a file selection dialog. Choosing a file, then either Megabytes or Kilobytes, then click "Split File". When joining files, if the file chosen doesn't end in a '0' (indicating it's the 1st in the series) you'll get an exception. Also, it's only smart enough to join files in sequence numerically. If there's file missing on the join, it will continue without fail - although this is probably not the correct behavior a simple change to The other interesting thing is having a progress bar appear on the status bar within a panel. That is accomplished using the following - 1st add the progress bar to the controls collection progressBar1 = new ProgressBar();
this.Controls.Add(progressBar1); //not really sure if I need this!!!
this.statusBar.Controls.Add( this.progressBar1 );
Then, there's adding a method for the statusbar's OwnerDraw event and wiring it up. The wireup: this.statusBar.DrawItem +=
new System.Windows.Forms.StatusBarDrawItemEventHandler(
this.statusBar_DrawItem);
The method to draw: private void statusBar_DrawItem(object sender,
System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
{
if ( sbdevent.Panel == this.statusBarPanel1 )
{
this.progressBar1.Bounds = sbdevent.Bounds;
}
}
History
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||