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

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

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

revision 326 by william, Thu Jun 7 16:33:41 2012 UTC revision 327 by william, Thu Jun 7 18:29:28 2012 UTC
# Line 26  namespace RomCheater.Docking Line 26  namespace RomCheater.Docking
26          public PIDSelector(int pid) : this() { this.ProcessPID = pid; }          public PIDSelector(int pid) : this() { this.ProcessPID = pid; }
27          [Obsolete("constructor PIDSelector(IConfigPlugin plugin, int pid) is not implemented", false)]          [Obsolete("constructor PIDSelector(IConfigPlugin plugin, int pid) is not implemented", false)]
28          public PIDSelector(IConfigPlugin plugin, int pid) : this(plugin) { this.ProcessPID = pid; }          public PIDSelector(IConfigPlugin plugin, int pid) : this(plugin) { this.ProcessPID = pid; }
29            
30          #region IAcceptsProcessPID          #region IAcceptsProcessPID
31          public int ProcessPID { get; set; }          public int ProcessPID { get; set; }
32          #endregion          #endregion
# Line 36  namespace RomCheater.Docking Line 36  namespace RomCheater.Docking
36          #region IAcceptsChangedProcess members          #region IAcceptsChangedProcess members
37          public event BaseEventHandler<ProcessChangedEventArgs> OnSelectedProcessChanged;          public event BaseEventHandler<ProcessChangedEventArgs> OnSelectedProcessChanged;
38          #endregion          #endregion
39            
40    
41    
42          public new void Show() { this.Show(null); }          public new void Show() { this.Show(null); }
# Line 67  namespace RomCheater.Docking Line 67  namespace RomCheater.Docking
67          private void btnTile_Click(object sender, EventArgs e) { this.lstProcessList.View = View.Tile; }          private void btnTile_Click(object sender, EventArgs e) { this.lstProcessList.View = View.Tile; }
68    
69          private void PerformListViewItemSelect(ListViewItem li)          private void PerformListViewItemSelect(ListViewItem li)
70          {                      {
71              this.ProcessPID = Convert.ToInt32(li.SubItems[1].Text);              this.ProcessPID = Convert.ToInt32(li.SubItems[1].Text);
72              Process SelectedProcess = Process.GetProcessById(this.ProcessPID);              Process SelectedProcess = Process.GetProcessById(this.ProcessPID);
73              logger.Debug.WriteLine("Using Process: ({0} : {1})", SelectedProcess.Id, SelectedProcess.ProcessName);              logger.Debug.WriteLine("Using Process: ({0} : {1})", SelectedProcess.Id, SelectedProcess.ProcessName);
74              //this.Close();              //this.Close();
75              if (OnSelectedProcessChanged != null)              if (OnSelectedProcessChanged != null)
76                  OnSelectedProcessChanged(new ProcessChangedEventArgs(this, this.ProcessPID));                            OnSelectedProcessChanged(new ProcessChangedEventArgs(this, this.ProcessPID));
77          }          }
78          private void btnOK_Click(object sender, EventArgs e)          private void btnOK_Click(object sender, EventArgs e)
79          {          {
80                
81          }          }
82    
83          //private void btnCancel_Click(object sender, EventArgs e)          //private void btnCancel_Click(object sender, EventArgs e)
# Line 98  namespace RomCheater.Docking Line 98  namespace RomCheater.Docking
98              // create a selection of PCSX2 processes              // create a selection of PCSX2 processes
99              List<ProcContainer> proc_list = AcceptedPlugin.ValidProcessesForPlugin;              List<ProcContainer> proc_list = AcceptedPlugin.ValidProcessesForPlugin;
100    
101              if (!(proc_list.Count > 0)) { //MessageBox.Show("Could not find any PCSX2 Processes.  Please start an instance of one.");              if (!(proc_list.Count > 0))
102                  return false; }              { //MessageBox.Show("Could not find any PCSX2 Processes.  Please start an instance of one.");
103                    return false;
104                }
105    
106              List<ListViewItem> items = new List<ListViewItem>();              List<ListViewItem> items = new List<ListViewItem>();
107              ImageList small_image_list = new ImageList();              ImageList small_image_list = new ImageList();
# Line 110  namespace RomCheater.Docking Line 112  namespace RomCheater.Docking
112    
113              small_image_list.ImageSize = new Size(small_width, small_width);              small_image_list.ImageSize = new Size(small_width, small_width);
114              large_image_list.ImageSize = new Size(large_width, large_width);              large_image_list.ImageSize = new Size(large_width, large_width);
115              foreach (ProcContainer p in proc_list)              foreach (ProcContainer p in proc_list)
116              {              {
117                  Bitmap small_image = null;                  Bitmap small_image = null;
118                  Bitmap large_image = null;                  Bitmap large_image = null;
# Line 121  namespace RomCheater.Docking Line 123  namespace RomCheater.Docking
123                      if (small_image != null) { small_image_list.Images.Add(image_key, small_image); }                      if (small_image != null) { small_image_list.Images.Add(image_key, small_image); }
124                      if (large_image != null) { large_image_list.Images.Add(image_key, large_image); }                      if (large_image != null) { large_image_list.Images.Add(image_key, large_image); }
125                      ListViewItem item = new ListViewItem();                      ListViewItem item = new ListViewItem();
126                        item.Name = p.GetHashCode().ToString();
127                      // process name                      // process name
128                      item.Text = p.Name;                      item.Text = p.Name;
129                      // pid                      // pid
# Line 142  namespace RomCheater.Docking Line 145  namespace RomCheater.Docking
145              lstProcessList.LargeImageList = large_image_list;              lstProcessList.LargeImageList = large_image_list;
146              this.lstProcessList.Items.AddRange(items.ToArray());              this.lstProcessList.Items.AddRange(items.ToArray());
147    
148              if (lstProcessList.Items.Count > 0)              if (lstProcessList.Items.Count > 1)
149              {              {
150                  lstProcessList.Items[0].Selected = true;                  lstProcessList.Items[0].Selected = true;
151              }              }
# Line 202  namespace RomCheater.Docking Line 205  namespace RomCheater.Docking
205              PerformListViewItemSelect(Item);              PerformListViewItemSelect(Item);
206          }          }
207    
208            private void btnLaunchAndAttach_Click(object sender, EventArgs e)
209            {
210                DialogResult result = EXESelector.ShowDialog();
211                if (result != DialogResult.OK) return;
212    
213                FileInfo fi = new FileInfo(EXESelector.FileName);
214                if (!fi.Exists) { logger.Warn.WriteLine("Cannot load and attach to non-existing exe file: {0}", fi.FullName); return; }
215    
216                Process p = Process.Start(fi.FullName);            
217                ProcContainer container = null;
218                try
219                {
220                    container = new ProcContainer(p);
221                }
222                catch (FileNotFoundException) { }
223                catch (Exception) { }
224                ListViewItem item = new ListViewItem();
225                ImageList small_image_list = new ImageList();
226                ImageList large_image_list = new ImageList();
227    
228                int small_width = 32;
229                int large_width = 48;
230    
231                small_image_list.ImageSize = new Size(small_width, small_width);
232                large_image_list.ImageSize = new Size(large_width, large_width);
233                //foreach (ProcContainer pc in proc_list)
234                //{
235                Bitmap small_image = null;
236                Bitmap large_image = null;
237                string image_key = string.Empty;
238                this.AddProcessItem(container, small_image_list.ImageSize, large_image_list.ImageSize, out image_key, out small_image, out large_image);
239                if (image_key != string.Empty)
240                {
241                    if (small_image != null) { lstProcessList.SmallImageList.Images.Add(image_key, small_image); }
242                    if (large_image != null) { lstProcessList.LargeImageList.Images.Add(image_key, large_image); }
243                    item.Name = container.GetHashCode().ToString();
244                    // process name
245                    item.Text = container.Name;
246                    // pid
247                    item.SubItems.Add(container.ProcessInfo.Id.ToString());
248                    // FullPath
249                    item.SubItems.Add(container.FileName);
250                    // image key
251                    item.ImageKey = container.FileName;
252                    //if (!items.Contains(item)) items.Add(item);
253                }
254                this.lstProcessList.Items.Add(item);
255                if (lstProcessList.Items.Count == 1)
256                {
257                    lstProcessList.Items[0].Selected = true;
258                }
259                else
260                {
261                    lstProcessList.Items[lstProcessList.SelectedItems[0].Index].Selected = false;
262                    lstProcessList.Items[lstProcessList.Items.IndexOf(item)].Selected = true;
263                }
264            }
265      }      }
266  }  }
267    

Legend:
Removed from v.326  
changed lines
  Added in v.327

  ViewVC Help
Powered by ViewVC 1.1.22