|
How do you give a plugin access to all data and methods of the hosting application?
Is it possible to set a plugins/interfaces method to respond to a windows event?
|
|
|
|
|
You don't give a plugin access to the data and methods of the hosting application. Your host communicates with the plugin (which is the opposite way around). Typically, your application will provide some interfaces which your plugin may or may not implement. For instance:
public interface IDataWrapper
{
object State{ get ; set ; }
bool HasProcessed{ get; }
}
public interface IPlugin
{
void Start();
}
public class MyPlugin : IPlugin, IDataWrapper
{
private object _state;
private bool _isSuccessful = false;
public object State
{
get { return _state; }
set { _state = value; }
}
public bool HasProcessed
{
get { return _isSuccessful; }
}
public void Start()
{
}
}
Then, in your application you would load the plugin and do something like:
IPlugin plugin = LoadPlugin(...);
IDataWrapper wrapped = plugin as IDataWrapper;
if (wrapped != null)
{
wrapped.State = ...;
}
plugin.Start();
if (wrapped != null)
{
if (wrapped.HasProcessed)
{
...
}
}
|
|
|
|
|
Take a look at this[^] article, it provides a nice introduction.
|
|
|
|
|
The above article would be great if in c#. Could anyone rewrite?
ty
|
|
|
|
|
There used to be a combo box which allowed you to select the language.
To be honest it's not that difficult to translate from VB.NET to C# since the classes used are all the same.
|
|
|
|
|
Download the code, compile it and run it through the excellent .NET Reflector (from Lutz Roeder). Reflector allows you to change the language target, so you can see what it would be in C#.
|
|
|
|
|
hi all,
how to unload the form from memory through code?
regards,
thanks
|
|
|
|
|
|
I tried this but even after calling form.dispose() the code in form is being executed. I have used a thread and that is a background thread.
thanks
|
|
|
|
|
You may need to abort the thread. Probably the best thing is to have the thread listen for an event that you can raise from your parent thread and use that so it can suspend and or terminate itself cleanly without executing any running code.
Dave
|
|
|
|
|
|
|
Hi
I have some zip files in a directory and want to copy them to another directory with the same of source files. Could any one please tell me.
DirectoryInfo di = new DirectoryInfo(zipsPath);
di.Attributes = FileAttributes.Normal;
FileInfo[] zFiles = di.GetFiles("*.zip");
string tempZip = "/Programme/tempZips";
if (!Directory.Exists(tempZip))
Directory.CreateDirectory(tempZip);
//FileInfo[] tmpFiles = di.GetFiles("*.zip");
foreach (FileInfo file in zFiles)
{
file.CopyTo(tempZip, true);
}
will the above code works.
thanks
|
|
|
|
|
DirectoryInfo di = new DirectoryInfo(zipsPath);
di.Attributes = FileAttributes.Normal;
FileInfo[] zFiles = di.GetFiles("*.zip");
string tempZip = "/Programme/tempZips";
if (!Directory.Exists(tempZip))
Directory.CreateDirectory(tempZip);
for(int a=0;a< FileInfo.Lenght;a++)
{
File.Copy(FileInfo[a].FullName, tempZip, true);
}
run this code, i hope it will work
Becoming Programmer...
|
|
|
|
|
Hi
thank you very much for your reply. I want to remove the files in the source direcory, after copying to new directory. To do this, can I use File.Move() instead of File.Copy() and File.Delete().
thanks
|
|
|
|
|
as you wish, AFAIK Move() may little bit slower than Copy() then Delete()
Becoming Programmer...
|
|
|
|
|
Hi
I have created a splash screen on my own i want my original screen to be appear completely before the splash screen vanishes ....please if any one knows how to calculate the loading time of the form then please do let me know
this is my code for the splash screen
>>> Timer is calling this function .....so its the starting form of mine
private void check(object sender, EventArgs e)
{
if (i < 1 && status == true)
{
this.Opacity = i;
i = i + 0.1;
if (i > 0.9)
{
status = false;
}
}
else if (status == false)
{
this.Opacity = i;
i = i - 0.1;
}
if (i < 0.1)
{
timer1.Stop();
this.Hide();
printsoftwareparent psf = new printsoftwareparent();
psf.Show();
}
}
its me sid
|
|
|
|
|
I suspect you can calculate form loading time only approximately if you can at all so instead I suggest that the main form signals splash screen form when finishes initialization.
|
|
|
|
|
hi thanks for ur reply
I want the application to be started like Acrobat Reader or PhotoShop
If u know how to do this then please do let me know
its me sid
|
|
|
|
|
You can start other applications using Process class but I don't think you will be able to estimate their load time.
|
|
|
|
|
Maybe not a very good way of doing it, but how about getting DateTime.Now when your app starts, and DateTime.Now when it's finished loading, calculate the difference. Should give you a fairly accurate time.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
He is interested in knowing load time before the application has loaded.
|
|
|
|
|
insert a timer in your form and enable it after all code in Form Load event, like:
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
}
then in timer1_Tick event, show your splash screen.
if you want to delay in showing splash screen then just increase the timer1 interval
NOTE: Do not forget to disable timer, you can disable it in timer1_tick event.
private void timer1_tick(object sender, EventArgs e)
{
timer1.Enabled = false;
}
hope it will help.
Becoming Programmer...
|
|
|
|
|
Thanks for the suggestions ...in mean time i have done something its working satisfactory but not as i expected
private void check(object sender, EventArgs e)
{
if (i < 1 && stat== true)
{
this.Opacity = i;
i = i + 0.1;
if (i > 0.9)
{
stat = false;
printsoftwareparent psp = new printsoftwareparent();
psp.Show();
this.BringToFront();
}
}
else if (stat == false)
{
this.Opacity = i;
i = i - 0.1;
}
if (i < 0.1)
{
timer1.Stop();
this.Hide();
}
}
its me sid
|
|
|
|
|
you have said that you want to show splash screen just like Acrobat Reader
that mean the splash screen should show after the Form1.
as i read your code, you are trying to show Splash screen as fading
but you doing little wrong, read my previous post carefully that will help you
Becoming Programmer...
|
|
|
|