--- trunk/RomCheater/Docking/PIDSelector.cs 2012/05/28 10:37:53 195 +++ trunk/RomCheater/Docking/PIDSelector.cs 2012/05/31 05:52:41 196 @@ -11,27 +11,31 @@ using RomCheater.PluginFramework.Core; using System.IO; using RomCheater.Logging; using WeifenLuo.WinFormsUI.Docking; +using RomCheater.PluginFramework.Events; namespace RomCheater.Docking { - public partial class PIDSelector : DockContent, IAcceptsPlugin<IConfigPlugin> + public partial class PIDSelector : DockContent, IAcceptsPlugin<IConfigPlugin>, IAcceptsChangedProcess, IAcceptsProcessPID { //private IConfigPlugin plugin = null; //bool isInError = false; - public PIDSelector() { InitializeComponent(); this.SelectedPid = -1; OnSelectedProcessChanged = null; this.AcceptedPlugin = null; } + public PIDSelector() { InitializeComponent(); this.ProcessPID = -1; OnSelectedProcessChanged = null; this.AcceptedPlugin = null; } public PIDSelector(IConfigPlugin plugin) : this() { this.AcceptedPlugin = plugin; } // unsued construtor (it's not implmented, may not be) [Obsolete("constructor PIDSelector(int pid) is not implemented", false)] - public PIDSelector(int pid) : this() { this.SelectedPid = pid; } + public PIDSelector(int pid) : this() { this.ProcessPID = pid; } [Obsolete("constructor PIDSelector(IConfigPlugin plugin, int pid) is not implemented", false)] - public PIDSelector(IConfigPlugin plugin, int pid) : this(plugin) { this.SelectedPid = pid; } - - private int _SelectedPid; - public int SelectedPid { get { return _SelectedPid; } set { _SelectedPid = value; } } + public PIDSelector(IConfigPlugin plugin, int pid) : this(plugin) { this.ProcessPID = pid; } + #region IAcceptsProcessPID + public int ProcessPID { get; set; } + #endregion + #region IAcceptsPlugin<IConfigPlugin> members public IConfigPlugin AcceptedPlugin { get; set; } - - public EventHandler<ProcessChangedEventArgs> OnSelectedProcessChanged { get; set; } + #endregion + #region IAcceptsChangedProcess members + public BaseEventHandler<ProcessChangedEventArgs> OnSelectedProcessChanged { get; set; } + #endregion @@ -64,13 +68,13 @@ namespace RomCheater.Docking private void PerformListViewItemSelect(ListViewItem li) { - this.SelectedPid = Convert.ToInt32(li.SubItems[1].Text); + this.ProcessPID = Convert.ToInt32(li.SubItems[1].Text); //this.Close(); if (this.OnSelectedProcessChanged != null) { - this.OnSelectedProcessChanged(this, new ProcessChangedEventArgs(this.SelectedPid)); + this.OnSelectedProcessChanged(new ProcessChangedEventArgs(this.ProcessPID)); } - Process SelectedProcess = Process.GetProcessById(this.SelectedPid); + Process SelectedProcess = Process.GetProcessById(this.ProcessPID); logger.Debug.WriteLine("Using Process: ({0} : {1})", SelectedProcess.Id, SelectedProcess.ProcessName); } private void btnOK_Click(object sender, EventArgs e) @@ -202,14 +206,5 @@ namespace RomCheater.Docking } - - #region eventargs - public class ProcessChangedEventArgs : EventArgs - { - public ProcessChangedEventArgs() : this(-1) { } - public ProcessChangedEventArgs(int pid) { this.ProcessID = pid; } - public int ProcessID { get; private set; } - } - #endregion } |