/[RomCheater]/trunk/RomCheater/Docking/PIDSelector.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/PIDSelector.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/PIDSelector.cs	2012/05/10 12:12:26	109
+++ trunk/RomCheater/Docking/PIDSelector.cs	2012/05/28 02:01:34	152
@@ -10,15 +10,16 @@
 using RomCheater.PluginFramework.Core;
 using System.IO;
 using RomCheater.Logging;
+using WeifenLuo.WinFormsUI.Docking;
 
-namespace RomCheater
+namespace RomCheater.Docking
 {
-    public partial class PIDSelector : Form
+    public partial class PIDSelector : DockContent
     {
-        private IConfigPlugin plugin = null;
+        //private IConfigPlugin plugin = null;
         //bool isInError = false;
-        public PIDSelector() { InitializeComponent(); this.SelectedPid = -1; }
-        public PIDSelector(IConfigPlugin plugin) : this() { this.plugin = plugin; }
+        public PIDSelector() { InitializeComponent(); this.SelectedPid = -1; OnSelectedProcessChanged = null; }
+        public PIDSelector(IConfigPlugin plugin) : this() { this.ConfigPlugin = 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; }
@@ -28,21 +29,33 @@
         private int _SelectedPid;
         public int SelectedPid { get { return _SelectedPid; } set { _SelectedPid = value; } }
 
+        public IConfigPlugin ConfigPlugin { get; set; }
+
+        public EventHandler<ProcessChangedEventArgs> OnSelectedProcessChanged { get; set; }
+        
+
 
         public new void Show() { this.Show(null); }
-        public new void Show(IWin32Window owner) { this.PreInitShow(owner); }
-        public new DialogResult ShowDialog() { return this.ShowDialog(null); }
-        public new DialogResult ShowDialog(IWin32Window owner) { return this.PreInitDialog(owner); }
-        private void PreInitShow(IWin32Window owner)
-        {
-            if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.",plugin.ToString())); }
-            else { if (owner == null) { base.Show(); } else { base.Show(owner); } }
-        }
-        private DialogResult PreInitDialog(IWin32Window owner)
-        {
-            if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.", plugin.ToString())); return DialogResult.Cancel; }
-            else { if (owner == null) { return base.ShowDialog(); } else { return base.ShowDialog(owner); } }
-        }
+        //public new void Show(IWin32Window owner) { this.PreInitShow(owner); }
+        public new void Show(DockPanel panel) { this.PreInitShow(panel); }
+        //public new DialogResult ShowDialog() { return this.ShowDialog(null); }
+        //public new DialogResult ShowDialog(IWin32Window owner) { return this.PreInitDialog(owner); }
+        //private void PreInitShow(IWin32Window owner)
+        //{
+        //    if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.",plugin.ToString())); }
+        //    else { if (owner == null) { base.Show(); } else { base.Show(owner); } }
+        //}
+        private void PreInitShow(DockPanel panel)
+        {
+            //if (panel == null) return;
+            if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.", ConfigPlugin.ToString())); }
+            else { if (panel == null) { base.Show(); } else { base.Show(panel); } }
+        }
+        //private DialogResult PreInitDialog(IWin32Window owner)
+        //{
+        //    if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.", plugin.ToString())); return DialogResult.Cancel; }
+        //    else { if (owner == null) { return base.ShowDialog(); } else { return base.ShowDialog(owner); } }
+        //}
         private void btnLargeIcon_Click(object sender, EventArgs e) { this.lstProcessList.View = View.LargeIcon; }
         private void btnDetails_Click(object sender, EventArgs e) { this.lstProcessList.View = View.Details; }
         private void btnSmallIcon_Click(object sender, EventArgs e) { this.lstProcessList.View = View.SmallIcon; }
@@ -53,14 +66,18 @@
         {
             if (!(lstProcessList.SelectedItems.Count > 0)) return;
             this.SelectedPid = Convert.ToInt32(lstProcessList.SelectedItems[0].SubItems[1].Text);
-            this.Close();
+            //this.Close();
+            if (this.OnSelectedProcessChanged != null)
+            {
+                this.OnSelectedProcessChanged(this, new ProcessChangedEventArgs(this.SelectedPid));
+            }
         }
 
-        private void btnCancel_Click(object sender, EventArgs e)
-        {
-            this.SelectedPid = -1;
-            this.Close();
-        }
+        //private void btnCancel_Click(object sender, EventArgs e)
+        //{
+        //    this.SelectedPid = -1;
+        //    //this.Close();
+        //}
 
         private void btnRefresh_Click(object sender, EventArgs e)
         {
@@ -70,9 +87,9 @@
         private bool RefreshList()
         {
             lstProcessList.Items.Clear();
-            this.plugin.Reload();
+            this.ConfigPlugin.Reload();
             // create a selection of PCSX2 processes
-            List<ProcContainer> proc_list = plugin.ValidProcessesForPlugin;
+            List<ProcContainer> proc_list = ConfigPlugin.ValidProcessesForPlugin;
 
             if (!(proc_list.Count > 0)) { //MessageBox.Show("Could not find any PCSX2 Processes.  Please start an instance of one."); 
                 return false; }
@@ -81,8 +98,8 @@
             ImageList small_image_list = new ImageList();
             ImageList large_image_list = new ImageList();
 
-            int small_width = 16;
-            int large_width = 32;
+            int small_width = 32;
+            int large_width = 48;
 
             small_image_list.ImageSize = new Size(small_width, small_width);
             large_image_list.ImageSize = new Size(large_width, large_width);
@@ -152,6 +169,21 @@
             }
 
         }
+
+        private void PIDSelector_Load(object sender, EventArgs e)
+        {
+            if (ConfigPlugin == null || this.DesignMode) return;
+            btnRefresh.PerformClick();
+        }
+    }
+
+    #region eventargs
+    public class ProcessChangedEventArgs : EventArgs
+    {
+        public ProcessChangedEventArgs() : this(-1) { }
+        public ProcessChangedEventArgs(int pid) { this.ProcessID = pid; }
+        public int ProcessID { get; private set; }
     }
+    #endregion
 }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22