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

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

  ViewVC Help
Powered by ViewVC 1.1.22