/[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 revision 107 by william, Thu May 10 11:16:03 2012 UTC trunk/RomCheater/Docking/PIDSelector.cs revision 150 by william, Sun May 27 23:59:22 2012 UTC
# Line 8  using System.Windows.Forms; Line 8  using System.Windows.Forms;
8  using System.Diagnostics;  using System.Diagnostics;
9  using RomCheater.PluginFramework.Interfaces;  using RomCheater.PluginFramework.Interfaces;
10  using RomCheater.PluginFramework.Core;  using RomCheater.PluginFramework.Core;
11    using System.IO;
12    using RomCheater.Logging;
13    using WeifenLuo.WinFormsUI.Docking;
14    
15  namespace RomCheater  namespace RomCheater.Docking
16  {  {
17      public partial class PIDSelector : Form      public partial class PIDSelector : DockContent
18      {      {
19          private IConfigPlugin plugin = null;          private IConfigPlugin plugin = null;
20          //bool isInError = false;          //bool isInError = false;
# Line 28  namespace RomCheater Line 31  namespace RomCheater
31    
32    
33          public new void Show() { this.Show(null); }          public new void Show() { this.Show(null); }
34          public new void Show(IWin32Window owner) { this.PreInitShow(owner); }          //public new void Show(IWin32Window owner) { this.PreInitShow(owner); }
35          public new DialogResult ShowDialog() { return this.ShowDialog(null); }          public new void Show(DockPanel panel) { this.PreInitShow(panel); }
36          public new DialogResult ShowDialog(IWin32Window owner) { return this.PreInitDialog(owner); }          //public new DialogResult ShowDialog() { return this.ShowDialog(null); }
37          private void PreInitShow(IWin32Window owner)          //public new DialogResult ShowDialog(IWin32Window owner) { return this.PreInitDialog(owner); }
38          {          //private void PreInitShow(IWin32Window owner)
39              if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.",plugin.ToString())); }          //{
40              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())); }
41          }          //    else { if (owner == null) { base.Show(); } else { base.Show(owner); } }
42          private DialogResult PreInitDialog(IWin32Window owner)          //}
43          {          private void PreInitShow(DockPanel panel)
44              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; }          {
45              else { if (owner == null) { return base.ShowDialog(); } else { return base.ShowDialog(owner); } }              //if (panel == null) return;
46          }              if (!this.RefreshList()) { MessageBox.Show(string.Format("Could not find any Processes for plugin {0}.  Please start an instance of one.", plugin.ToString())); }
47                else { if (panel == null) { base.Show(); } else { base.Show(panel); } }
48            }
49            //private DialogResult PreInitDialog(IWin32Window owner)
50            //{
51            //    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; }
52            //    else { if (owner == null) { return base.ShowDialog(); } else { return base.ShowDialog(owner); } }
53            //}
54          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; }
55          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; }
56          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 78  namespace RomCheater Line 88  namespace RomCheater
88              List<ListViewItem> items = new List<ListViewItem>();              List<ListViewItem> items = new List<ListViewItem>();
89              ImageList small_image_list = new ImageList();              ImageList small_image_list = new ImageList();
90              ImageList large_image_list = new ImageList();              ImageList large_image_list = new ImageList();
91              foreach (ProcContainer p in proc_list) { this.AddProcessItem(p, ref items, out small_image_list, out large_image_list); }  
92                int small_width = 32;
93                int large_width = 48;
94    
95                small_image_list.ImageSize = new Size(small_width, small_width);
96                large_image_list.ImageSize = new Size(large_width, large_width);
97                foreach (ProcContainer p in proc_list)
98                {
99                    Bitmap small_image = null;
100                    Bitmap large_image = null;
101                    string image_key = string.Empty;
102                    this.AddProcessItem(p, small_image_list.ImageSize, large_image_list.ImageSize, out image_key, out small_image, out large_image);
103                    if (image_key != string.Empty)
104                    {
105                        if (small_image != null) { small_image_list.Images.Add(image_key, small_image); }
106                        if (large_image != null) { large_image_list.Images.Add(image_key, large_image); }
107                        ListViewItem item = new ListViewItem();
108                        // process name
109                        item.Text = p.Name;
110                        // pid
111                        item.SubItems.Add(p.ProcessInfo.Id.ToString());
112                        // FullPath
113                        item.SubItems.Add(p.FileName);
114                        // image key
115                        item.ImageKey = p.FileName;
116                        if (!items.Contains(item)) items.Add(item);
117                    }
118                    else
119                    {
120                        logger.Error.Write("image_key is an empty string!");
121                        if (small_image != null) { logger.Error.Write(" [however small_image is not null]"); }
122                        if (large_image != null) { logger.Error.Write(" [however large_image is not null]\n"); }
123                    }
124                }
125              lstProcessList.SmallImageList = small_image_list;              lstProcessList.SmallImageList = small_image_list;
126              lstProcessList.LargeImageList = large_image_list;              lstProcessList.LargeImageList = large_image_list;
127              this.lstProcessList.Items.AddRange(items.ToArray());              this.lstProcessList.Items.AddRange(items.ToArray());
128              return true;              return true;
129          }          }
130    
131          private void AddProcessItem(ProcContainer p, ref  List<ListViewItem> items, out ImageList small_image_list, out ImageList large_image_list)          private void AddProcessItem(ProcContainer p, Size small, Size large, out string image_key, out Bitmap small_image, out Bitmap large_image)
132          {          {
133              small_image_list = new ImageList();              image_key = "";
134              large_image_list = new ImageList();              small_image = null;
135              ListViewItem item = new ListViewItem();              large_image = null;
136              // process              ////small_image_list = new ImageList();
137              item.Text = p.Name;              ////large_image_list = new ImageList();
138              if (p.ProcessIcon != null)              //ListViewItem item = new ListViewItem();
139                //// process
140                //item.Text = p.Name;
141                //if (p.ProcessIcon != null)
142                //{  
143                //    //small_image_list.Images.Add(
144                //    //large_image_list.Images.Add(p.FileName, p.ProcessIcon);                
145                //    item.ImageKey = p.FileName;
146                //}
147                //// pid
148                //item.SubItems.Add(p.ProcessInfo.Id.ToString());
149                //// FullPath
150                //item.SubItems.Add(p.FileName);
151                //if (!items.Contains(item)) items.Add(item);
152                if (p != null)
153              {              {
154                  Bitmap small_image = ProcContainer.CreateIconFromProcess(p, 1);                  if (p.ProcessIcon != null)
155                  Bitmap large_image = ProcContainer.CreateIconFromProcess(p, 2);                  {
156                  small_image_list.Images.Add(p.FileName, ProcContainer.CreateIconFromProcess(p, 1));                      image_key = p.FileName;
157                  small_image_list.ImageSize = new Size(small_image.Width, small_image.Height);                      small_image = new Bitmap(p.ProcessIcon, small);
158                  large_image_list.Images.Add(p.FileName, ProcContainer.CreateIconFromProcess(p, 2));                      large_image = new Bitmap(p.ProcessIcon, large);
159                  large_image_list.ImageSize = new Size(large_image.Width, large_image.Height);                  }
                 item.ImageKey = p.FileName;  
160              }              }
161              // pid  
             item.SubItems.Add(p.ProcessInfo.Id.ToString());  
             // FullPath  
             item.SubItems.Add(p.FileName);  
             if (!items.Contains(item)) items.Add(item);  
162          }          }
163      }      }
164  }  }

Legend:
Removed from v.107  
changed lines
  Added in v.150

  ViewVC Help
Powered by ViewVC 1.1.22