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

Diff of /trunk/RomCheater/PIDSelector.cs

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

revision 100 by william, Thu May 10 09:03:13 2012 UTC revision 109 by william, Thu May 10 12:12:26 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    
14  namespace RomCheater  namespace RomCheater
15  {  {
# Line 78  namespace RomCheater Line 80  namespace RomCheater
80              List<ListViewItem> items = new List<ListViewItem>();              List<ListViewItem> items = new List<ListViewItem>();
81              ImageList small_image_list = new ImageList();              ImageList small_image_list = new ImageList();
82              ImageList large_image_list = new ImageList();              ImageList large_image_list = new ImageList();
83              foreach (ProcContainer p in proc_list) { this.AddProcessItem(p, ref items, out small_image_list, out large_image_list); }  
84                int small_width = 16;
85                int large_width = 32;
86    
87                small_image_list.ImageSize = new Size(small_width, small_width);
88                large_image_list.ImageSize = new Size(large_width, large_width);
89                foreach (ProcContainer p in proc_list)
90                {
91                    Bitmap small_image = null;
92                    Bitmap large_image = null;
93                    string image_key = string.Empty;
94                    this.AddProcessItem(p, small_image_list.ImageSize, large_image_list.ImageSize, out image_key, out small_image, out large_image);
95                    if (image_key != string.Empty)
96                    {
97                        if (small_image != null) { small_image_list.Images.Add(image_key, small_image); }
98                        if (large_image != null) { large_image_list.Images.Add(image_key, large_image); }
99                        ListViewItem item = new ListViewItem();
100                        // process name
101                        item.Text = p.Name;
102                        // pid
103                        item.SubItems.Add(p.ProcessInfo.Id.ToString());
104                        // FullPath
105                        item.SubItems.Add(p.FileName);
106                        // image key
107                        item.ImageKey = p.FileName;
108                        if (!items.Contains(item)) items.Add(item);
109                    }
110                    else
111                    {
112                        logger.Error.Write("image_key is an empty string!");
113                        if (small_image != null) { logger.Error.Write(" [however small_image is not null]"); }
114                        if (large_image != null) { logger.Error.Write(" [however large_image is not null]\n"); }
115                    }
116                }
117              lstProcessList.SmallImageList = small_image_list;              lstProcessList.SmallImageList = small_image_list;
118              lstProcessList.LargeImageList = large_image_list;              lstProcessList.LargeImageList = large_image_list;
119              this.lstProcessList.Items.AddRange(items.ToArray());              this.lstProcessList.Items.AddRange(items.ToArray());
120              return true;              return true;
121          }          }
122    
123          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)
124          {          {
125              small_image_list = new ImageList();              image_key = "";
126              large_image_list = new ImageList();              small_image = null;
127              ListViewItem item = new ListViewItem();              large_image = null;
128              // process              ////small_image_list = new ImageList();
129              item.Text = p.FileName;              ////large_image_list = new ImageList();
130              if (p.ProcessIcon != null)              //ListViewItem item = new ListViewItem();
131                //// process
132                //item.Text = p.Name;
133                //if (p.ProcessIcon != null)
134                //{  
135                //    //small_image_list.Images.Add(
136                //    //large_image_list.Images.Add(p.FileName, p.ProcessIcon);                
137                //    item.ImageKey = p.FileName;
138                //}
139                //// pid
140                //item.SubItems.Add(p.ProcessInfo.Id.ToString());
141                //// FullPath
142                //item.SubItems.Add(p.FileName);
143                //if (!items.Contains(item)) items.Add(item);
144                if (p != null)
145              {              {
146                  Bitmap small_image = ProcContainer.CreateIconFromProcess(p, 1);                  if (p.ProcessIcon != null)
147                  Bitmap large_image = ProcContainer.CreateIconFromProcess(p, 2);                  {
148                  small_image_list.Images.Add(p.FileName, ProcContainer.CreateIconFromProcess(p, 1));                      image_key = p.FileName;
149                  small_image_list.ImageSize = new Size(small_image.Width, small_image.Height);                      small_image = new Bitmap(p.ProcessIcon, small);
150                  large_image_list.Images.Add(p.ProcessInfo.MainModule.FileName, ProcContainer.CreateIconFromProcess(p, 2));                      large_image = new Bitmap(p.ProcessIcon, large);
151                  large_image_list.ImageSize = new Size(large_image.Width, large_image.Height);                  }
                 item.ImageKey = p.FileName;  
152              }              }
153              // pid  
             item.SubItems.Add(p.ProcessInfo.Id.ToString());  
             // FullPath  
             item.SubItems.Add(p.FileName);  
             if (!items.Contains(item)) items.Add(item);  
154          }          }
155      }      }
156  }  }

Legend:
Removed from v.100  
changed lines
  Added in v.109

  ViewVC Help
Powered by ViewVC 1.1.22