- Plugged.zip
- Common.Plugin.Platform
- Common.Plugin.Platform.sln
- Common.Plugin.Platform.sln.docstates.suo
- Common.Plugin.Platform.suo
- Common.Plugin.Platform
- Common.Plugin.SampleHost
- KickStartPlugin
- TimeEventPlugin
- binaries.zip
- binaries
- Common.Plugin.Platform.dll
- Common.Plugin.SampleHost.exe
- plugins
- KickStartPlugin.dll
- TimeEventPlugin.dll
- docs.zip
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.ComponentModel.Composition;
using Common.Plugin.Platform.Common;
using Common.Plugin.Platform.Events;
using System.Timers;
namespace TimeEventPlugin
{
[Export(typeof(IApplicationPlugin))]
public class TwoPlugin : IApplicationPlugin
{
private TabText textControl;
ExtensionEvent eventPump = new ExtensionEvent();
Timer timer;
public TwoPlugin()
{
textControl = new TabText(eventPump, Name);
timer = new Timer(10000) { Enabled = true, AutoReset = true };
timer.Elapsed += (o, e) => { eventPump.RaiseStartedEvent("TimeEventPlugin - time elapsed and reset at " + DateTime.Now.ToShortTimeString()); };
timer.Start();
}
IExtensionEvents IApplicationPlugin.ExtensionEvents
{
get { return eventPump; }
}
public string Name
{
get { return "TimeEventPlugin"; }
}
public string DisplayName
{
get
{
return "TimeEvent";
}
}
public string Version
{
get
{
return "0.0.0.1";
}
}
public UserControl UserSettingsControl
{
get
{
// can return a databound settings for host to show all settings in the same place
// plugin can also show its settings by itself
return null;
}
}
public void Initialize(UserContext userContext, string settings)
{
// manage initialization of the plugin with current user context; if required
}
public void RegisterEvents(IApplicationEvents eventPump)
{
eventPump.OnFileSystemEvent += eventPump_OnFileSystemEvent;
eventPump.OnActivateEvent += eventPump_OnActivateEvent;
}
public void UnRegisterEvents(IApplicationEvents eventPump)
{
eventPump.OnFileSystemEvent -= eventPump_OnFileSystemEvent;
eventPump.OnActivateEvent -= eventPump_OnActivateEvent;
}
public bool IsVisible
{
get { return textControl.IsVisible; }
}
private void eventPump_OnFileSystemEvent(object sender, EventArgs e)
{
var arg = e as FileSystemInfoEventArg;
if (arg != null)
{
textControl.Dispatcher.Invoke(new Action(() => textControl.GetApplicationMessage(arg.ItemPath)));
}
}
private void eventPump_OnActivateEvent(object sender, EventArgs e)
{
var arg = e as ActivateInfoEventArg;
if (arg != null)
{
if (!textControl.IsLoaded && arg.VisibleChangedHandler != null)
textControl.IsVisibleChanged += arg.VisibleChangedHandler;
textControl.Dispatcher.Invoke(new Action(() =>
{
if (!double.IsNaN(arg.Left) && !double.IsNaN(arg.Top))
{
textControl.Left = arg.Left;
textControl.Top = arg.Top;
}
textControl.Topmost = arg.TopMost;
textControl.Show();
textControl.Activate();
}));
}
}
#region IStatusQuery Members
public string StatusMessage
{
get { return "Idle"; }
}
private Status status;
public Status Status
{
get
{
if (status == Status.NotResponding || status == Status.Suspended || status == Status.Waiting) return status;
else return textControl.IsActive ? Status.Active : Status.Idle;
}
set
{
status = value;
}
}
#endregion
}
public class ExtensionEvent : IExtensionEvents
{
public event EventHandler OnStarted;
public event EventHandler OnCompleted;
public event EventHandler OnError;
public void RaiseCompletedEvent(string message, string openPath = null)
{
if (OnCompleted != null)
{
OnCompleted(this, new PluginNotifyIconMessageArgs() { Message = message, NotificationType = PluginNotifyMessageType.Message, InvokeOnClickCommand = openPath });
}
}
public void RaiseStartedEvent(string message)
{
if (OnStarted != null)
{
OnStarted(this, new PluginNotifyIconMessageArgs() { Message = message, NotificationType = PluginNotifyMessageType.Message });
}
}
public void RaiseErrorEvent(string message)
{
if (OnError != null)
{
OnError(this, new PluginNotifyIconMessageArgs() { Severity = PluginMessageSeverity.Error, Message = message, NotificationType = PluginNotifyMessageType.Message, ForceMessage = true });
}
}
public AuthenticationDelegate Authenticate { get; set; }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
is a poor software developer and thinker. Presently working on a theory of "complementary perception". It's a work in progress.