Jump to content
Xtreme .Net Talk

sticksbs

Members
  • Posts

    5
  • Joined

  • Last visited

sticksbs's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Well seems you posted as i was creating my post :)... Thanks for the the reply Joe, your's is a much cleaner solution -- especially since it's actually implemented in full. I got mine working in a slightly different fashion, but after reading your's i'm more confident in my thought process. Thanks again.
  2. Hi again, Well after some more trial and error I figured it out... For anyone that it may help here's the jist of it. This is again in relation to divil's plugin based app code available on this site. Note however that i'm doing a c# project and started my plugin app from scratch and has a slightly different architecture and as such what i'm posting may not work -- I'm posting what I *think* the changes would be if you were using divil's code, this is totally untested. //--------------------------------------------------------------------------- // in file IPlugin following would be added public class CounterEventArgs : System.EventArgs { private int newCount; //Constructor. public CounterEventArgs(newCount) { this.newCount = newCount; } public int NewCount { get {return newCount;} } } public delegate void CounterEventHandler(object sender, CounterEventArgs e); public interface IPlugin { event CounterEventHandler EventOccured; ... } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // then in the implementation file -- Plugin1 lets say public class Class1 : PluginSample.Interfaces.IPlugin { private PluginSample.Interfaces.IHost objHost; public event CounterEventHandler EventOccured; ... public double Calculate(int int1, int int2) { RaiseCounterEvent(); // lets raise this as an event return int1 + int2 } private void RaiseCounterEvent() { // Invokes the delegate with a random number passed Random rand = new Random(); int rand1 = rand.Next(); CounterEventArgs counterEventArgs = new CounterEventArgs(rand1); EventOccured(this, counterEventArgs); } } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Then in the application that uses the above plugin // after the plugin is created and there is an object for it // you can setup it's event handler as usual ie. objPlugin.EventOccured += new CounterEventHandler(this.EventOccured); // then create a function to deal with the event when it's captured private void EventOccured(object sender, CounterEventArgs e) { MessageBox.Show(e.NewCount.ToString()); } HOpe that helps somebody... Here are the references you may want to read. divil's plugin based apps code: http://www.xtremedotnettalk.com/showthread.php?t=49597 msdn ref on events: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconeventsmini-sample.asp
  3. Hi all, To begin I'm working with divil's plugin tutorial, and understand that quite well. I'm now at the point where one of the plugin's i'm writing needs to have and raise events. So for simplicity lets say IPlugin has an event CounterEvent and in the implementation of this plugin there is a function CountAndFireEvents() which every 10 seconds will raise the CounterEvent event. Then my host application needs to be such CounterEvent events and when they are raised from the implemented plugin. So my question is how would I implement this CounterEvent event in the IPlugin interface, and after that how would I implement the actual raise of events in the Plugin that create that implements the IPlugin interface. I assume there is some delegate / event based programming that needs to be done, but can't quite understand how it would all tie in together. I hope I've made myself clear, thanks for any help.
  4. Hi all, Unfortunately searches here didn't quite result in anything that helped to answer my question. So here it is. I would like to have a control that displays an image and can accept focus. Using the button control (actually I'm subclassing it to do what I need) I can get it to load an image, however I can't resize the image that is loaded (as the button1.ImageList.Image.Size property is read-only) -- wasn't able to find anything to describe how to resize it. Decided to then use the PictureBox control (again subclassed to do some of the stuff I need), and although I have full control over it's ability to work with images, I can't find a way to make it accept focus when tab is pressed, the CanFocus is set to false by default, and I'm not sure how to enable it. Also according to MSDN the replacement to VB6's GotFocus and LostFocus are Enter and Leave, neither of which events I can seem to make use of (also the intellisense displays GotFocus and LostFocus events), but I can't get the control to accept focus. If anyone could please help me that would be greatly appreciated, thanks.
  5. Hi all, Well i'm relatively new to C#, and for that matter working with DLL's. For one of the pieces of software I'm working on at the moment, I'd like to allow others to create their own "plugins" for certain functions. Essentially I'd like to have a class that anyone can remake provided I give the interface and specs on what each function should do. I reckon that this would simply mean others can compile a dll assembly, and my program could load that dll at runtime (based on a string variable indicating the name of the dll specified in a config file or something). I assume I'd need to use reflection for such matters. The main problem I'm having right now, is where can I find out about loading the dll's at runtime, and how to load them based on a string variable, obviously it's not as simple as adding a reference to the project as that isn't done at runtime. I hope that clairfies things, and if I'm way off track in how to do this "plugin" type off stuff, please do let me know. Thank you in advance...
×
×
  • Create New...