1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using RomCheater.PluginFramework.Interfaces; |
6 |
using RomCheater.PluginFramework.Events; |
7 |
using System.Diagnostics; |
8 |
|
9 |
namespace RomCheater.PluginFramework.Core |
10 |
{ |
11 |
/// <summary> |
12 |
/// The base class for all plugins |
13 |
/// </summary> |
14 |
public abstract class PluginBase : IPluginBase |
15 |
{ |
16 |
public PluginBase() { } |
17 |
|
18 |
public virtual bool IsNullPlugin { get { return false; } } |
19 |
public virtual bool IsGenericPlugin { get { return false; } } |
20 |
|
21 |
#region IPluginBase Members |
22 |
public abstract Guid ID { get; } |
23 |
public abstract string Name { get; } |
24 |
public abstract string Description { get; } |
25 |
public virtual void Reload() { Reload(false); } |
26 |
public abstract void Reload(bool silent); |
27 |
#endregion |
28 |
public override string ToString() |
29 |
{ |
30 |
return string.Format("{0} [{1}]", Name, ID.ToString()); |
31 |
} |
32 |
|
33 |
private IPEDData _peData; |
34 |
protected IPEDData peData { get { return _peData; } } |
35 |
public void SetPEViewerData(IPEDData peData) |
36 |
{ |
37 |
_peData = peData; |
38 |
if (OnPEDataUpdated != null) |
39 |
{ |
40 |
OnPEDataUpdated.Invoke(new PEViewerDataUpdatedEventArgs(this, peData)); |
41 |
} |
42 |
} |
43 |
|
44 |
private Process _AcceptedProcess; |
45 |
protected Process AcceptedProcess { get { return _AcceptedProcess; } } |
46 |
public void SetAcceptedProcess(Process proc) |
47 |
{ |
48 |
_AcceptedProcess = proc; |
49 |
if (OnSelectedProcessChanged != null) |
50 |
{ |
51 |
OnSelectedProcessChanged.Invoke(new ProcessChangedEventArgs(this, proc.Id)); |
52 |
} |
53 |
} |
54 |
|
55 |
private IConfigPlugin _AcceptedConfig; |
56 |
protected IConfigPlugin AcceptedConfig { get { return _AcceptedConfig; } } |
57 |
public void SetAcceptedConfig(IConfigPlugin config) |
58 |
{ |
59 |
_AcceptedConfig = config; |
60 |
if (OnSelectedConfigChanged != null) |
61 |
{ |
62 |
OnSelectedConfigChanged.Invoke(new ConfigChangedEventArgs(this, config)); |
63 |
} |
64 |
} |
65 |
|
66 |
|
67 |
public void SetAcceptedProcessAndConfig(IAcceptsProcessAndConfig iapc) |
68 |
{ |
69 |
SetAcceptedConfig(iapc.AcceptedPlugin); |
70 |
SetAcceptedProcess(iapc.AcceptedProcess); |
71 |
} |
72 |
|
73 |
public event BaseEventHandler<PEViewerDataUpdatedEventArgs> OnPEDataUpdated; |
74 |
public event BaseEventHandler<ProcessChangedEventArgs> OnSelectedProcessChanged; |
75 |
public event BaseEventHandler<ConfigChangedEventArgs> OnSelectedConfigChanged; |
76 |
} |
77 |
} |