/[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

revision 149 by william, Sun May 27 23:34:33 2012 UTC revision 152 by william, Mon May 28 02:01:34 2012 UTC
# Line 16  namespace RomCheater.Docking Line 16  namespace RomCheater.Docking
16  {  {
17      public partial class PIDSelector : DockContent      public partial class PIDSelector : DockContent
18      {      {
19          private IConfigPlugin plugin = null;          //private IConfigPlugin plugin = null;
20          //bool isInError = false;          //bool isInError = false;
21          public PIDSelector() { InitializeComponent(); this.SelectedPid = -1; }          public PIDSelector() { InitializeComponent(); this.SelectedPid = -1; OnSelectedProcessChanged = null; }
22          public PIDSelector(IConfigPlugin plugin) : this() { this.plugin = plugin; }          public PIDSelector(IConfigPlugin plugin) : this() { this.ConfigPlugin = plugin; }
23          // unsued construtor (it's not implmented, may not be)          // unsued construtor (it's not implmented, may not be)
24          [Obsolete("constructor PIDSelector(int pid) is not implemented", false)]          [Obsolete("constructor PIDSelector(int pid) is not implemented", false)]
25          public PIDSelector(int pid) : this() { this.SelectedPid = pid; }          public PIDSelector(int pid) : this() { this.SelectedPid = pid; }
# Line 29  namespace RomCheater.Docking Line 29  namespace RomCheater.Docking
29          private int _SelectedPid;          private int _SelectedPid;
30          public int SelectedPid { get { return _SelectedPid; } set { _SelectedPid = value; } }          public int SelectedPid { get { return _SelectedPid; } set { _SelectedPid = value; } }
31    
32            public IConfigPlugin ConfigPlugin { get; set; }
33    
34            public EventHandler<ProcessChangedEventArgs> OnSelectedProcessChanged { get; set; }
35            
36    
37    
38          public new void Show() { this.Show(null); }          public new void Show() { this.Show(null); }
39          public new void Show(IWin32Window owner) { this.PreInitShow(owner); }          //public new void Show(IWin32Window owner) { this.PreInitShow(owner); }
40          public new DialogResult ShowDialog() { return this.ShowDialog(null); }          public new void Show(DockPanel panel) { this.PreInitShow(panel); }
41          public new DialogResult ShowDialog(IWin32Window owner) { return this.PreInitDialog(owner); }          //public new DialogResult ShowDialog() { return this.ShowDialog(null); }
42          private void PreInitShow(IWin32Window owner)          //public new DialogResult ShowDialog(IWin32Window owner) { return this.PreInitDialog(owner); }
43          {          //private void PreInitShow(IWin32Window owner)
44              if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.",plugin.ToString())); }          //{
45              else { if (owner == null) { base.Show(); } else { base.Show(owner); } }          //    if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.",plugin.ToString())); }
46          }          //    else { if (owner == null) { base.Show(); } else { base.Show(owner); } }
47          private DialogResult PreInitDialog(IWin32Window owner)          //}
48          {          private void PreInitShow(DockPanel panel)
49              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; }          {
50              else { if (owner == null) { return base.ShowDialog(); } else { return base.ShowDialog(owner); } }              //if (panel == null) return;
51          }              if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.", ConfigPlugin.ToString())); }
52                else { if (panel == null) { base.Show(); } else { base.Show(panel); } }
53            }
54            //private DialogResult PreInitDialog(IWin32Window owner)
55            //{
56            //    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; }
57            //    else { if (owner == null) { return base.ShowDialog(); } else { return base.ShowDialog(owner); } }
58            //}
59          private void btnLargeIcon_Click(object sender, EventArgs e) { this.lstProcessList.View = View.LargeIcon; }          private void btnLargeIcon_Click(object sender, EventArgs e) { this.lstProcessList.View = View.LargeIcon; }
60          private void btnDetails_Click(object sender, EventArgs e) { this.lstProcessList.View = View.Details; }          private void btnDetails_Click(object sender, EventArgs e) { this.lstProcessList.View = View.Details; }
61          private void btnSmallIcon_Click(object sender, EventArgs e) { this.lstProcessList.View = View.SmallIcon; }          private void btnSmallIcon_Click(object sender, EventArgs e) { this.lstProcessList.View = View.SmallIcon; }
# Line 54  namespace RomCheater.Docking Line 66  namespace RomCheater.Docking
66          {          {
67              if (!(lstProcessList.SelectedItems.Count > 0)) return;              if (!(lstProcessList.SelectedItems.Count > 0)) return;
68              this.SelectedPid = Convert.ToInt32(lstProcessList.SelectedItems[0].SubItems[1].Text);              this.SelectedPid = Convert.ToInt32(lstProcessList.SelectedItems[0].SubItems[1].Text);
69              this.Close();              //this.Close();
70                if (this.OnSelectedProcessChanged != null)
71                {
72                    this.OnSelectedProcessChanged(this, new ProcessChangedEventArgs(this.SelectedPid));
73                }
74          }          }
75    
76          private void btnCancel_Click(object sender, EventArgs e)          //private void btnCancel_Click(object sender, EventArgs e)
77          {          //{
78              this.SelectedPid = -1;          //    this.SelectedPid = -1;
79              this.Close();          //    //this.Close();
80          }          //}
81    
82          private void btnRefresh_Click(object sender, EventArgs e)          private void btnRefresh_Click(object sender, EventArgs e)
83          {          {
# Line 71  namespace RomCheater.Docking Line 87  namespace RomCheater.Docking
87          private bool RefreshList()          private bool RefreshList()
88          {          {
89              lstProcessList.Items.Clear();              lstProcessList.Items.Clear();
90              this.plugin.Reload();              this.ConfigPlugin.Reload();
91              // create a selection of PCSX2 processes              // create a selection of PCSX2 processes
92              List<ProcContainer> proc_list = plugin.ValidProcessesForPlugin;              List<ProcContainer> proc_list = ConfigPlugin.ValidProcessesForPlugin;
93    
94              if (!(proc_list.Count > 0)) { //MessageBox.Show("Could not find any PCSX2 Processes.  Please start an instance of one.");              if (!(proc_list.Count > 0)) { //MessageBox.Show("Could not find any PCSX2 Processes.  Please start an instance of one.");
95                  return false; }                  return false; }
# Line 153  namespace RomCheater.Docking Line 169  namespace RomCheater.Docking
169              }              }
170    
171          }          }
172    
173            private void PIDSelector_Load(object sender, EventArgs e)
174            {
175                if (ConfigPlugin == null || this.DesignMode) return;
176                btnRefresh.PerformClick();
177            }
178        }
179    
180        #region eventargs
181        public class ProcessChangedEventArgs : EventArgs
182        {
183            public ProcessChangedEventArgs() : this(-1) { }
184            public ProcessChangedEventArgs(int pid) { this.ProcessID = pid; }
185            public int ProcessID { get; private set; }
186      }      }
187        #endregion
188  }  }
189    

Legend:
Removed from v.149  
changed lines
  Added in v.152

  ViewVC Help
Powered by ViewVC 1.1.22