About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



EventArgs Example

In one my past posts, I talked about that CryptoCollaboration using the EventArgs base class because it keeps things nice and generalized, allowing for expanasion for the handling of future event integration. A person emailed me and asked for a practical example of when would use such a thing in a SharePoint WebPart. Eh, ok.

I am going to use an example of a progress class, that, well, as you can guess will display the progress of some sort of execution that happens with a SharePoint WebPart.

The first class is the Process Arguments class (ProcessArgs), that inherits from the EventArgs base class.

C#:
  1. public class ProgressArgs : EventArgs
  2. {
  3. private int m_nPercentageComplete = 0;
  4. private DataRow m_oDataRow;
  5.  
  6. public ProgressArgs(DataRow dataRow, int percentageComplete)
  7. {
  8. this.m_oDataRow = dataRow;
  9. this.m_nPercentageComplete = percentageComplete;
  10. }
  11.  
  12. public DataRow CurrentDataRow
  13. {
  14. get
  15. {
  16. return this.m_oDataRow;
  17. }
  18. }
  19.  
  20. public int PercentageComplete
  21. {
  22. get
  23. {
  24. return this.m_nPercentageComplete;
  25. }
  26. }
  27. }

In the next class, there will be the establishment of the event handler that will be called from a sister class by use of a delegate.

C#:
  1. public delegate void ProgressEventHandler(object sender, ProgressArgs e);

Now that the delegate is established, you can call it in some general class file.

C#:
  1. public event ProgressEventHandler ProgressEvent;
  2.  
  3. protected virtual void OnProgress(ProgressArgs e)
  4. {
  5. if (this.ProgressEvent != null)
  6. {
  7. this.ProgressEvent(this, e);
  8. }
  9. }

Then calculate out the progress.

C#:
  1. ProgressArgs e = new ProgressArgs(row, (int) ((((double) num) / ((double) this.DBDataTable.Rows.Count)) * 100));
  2. this.OnProgress(e);

I am not saying that this is the only way to do it, but with applications that you plan on extending later it is the route that I have choosen to go in the past. I may at some point explore the deficiencies in a such an approach, however at this current time I just want to finish the damn thing.

  • Share/Bookmark

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment