ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.PluginFramework/Core/ProcContainer.cs
Revision: 107
Committed: Thu May 10 11:16:03 2012 UTC (10 years, 10 months ago) by william
File size: 5297 byte(s)
Log Message:

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Diagnostics;
6 using System.Drawing;
7 using System.IO;
8 using libWin32.Win32.Threading;
9
10 namespace RomCheater.PluginFramework.Core
11 {
12 public class ProcContainer
13 {
14 public ProcContainer() { this.init(); }
15 public ProcContainer(Process process)
16 : this()
17 {
18 this.ProcessInfo = process;
19 FileInfo fi = null;
20 string fname = "";
21 try
22 {
23 fname = ProcessModeleInfoEx.GetMainModulePath(process);
24 fi = new FileInfo(fname);
25 }
26 catch (Exception)
27 {
28 throw;
29 }
30 this.FileName = fi.FullName;
31 this.Name = fi.Name;
32 this.CreateProcessIcon(4);
33 }
34 public ProcContainer(Process process, Icon icon)
35 : this()
36 {
37 this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap();
38 string fname = ProcessModeleInfoEx.GetMainModulePath(process);
39 FileInfo fi = new FileInfo(fname);
40 this.FileName = fi.FullName;
41 this.Name = fi.Name;
42 }
43 public ProcContainer(Process process, Bitmap icon)
44 : this()
45 {
46 this.ProcessInfo = process; this.ProcessIcon = icon;
47 string fname = ProcessModeleInfoEx.GetMainModulePath(process);
48 FileInfo fi = new FileInfo(fname);
49 this.FileName = fi.FullName;
50 this.Name = fi.Name;
51 }
52 private void init() { this.ProcessInfo = null; this.ProcessIcon = null; }
53
54
55 public string Name { get; set; }
56 public string FileName { get; set; }
57
58 private Process _ProcessInfo;
59 public Process ProcessInfo { get { return _ProcessInfo; } set { _ProcessInfo = value; } }
60 private Bitmap _ProcessIcon;
61 public Bitmap ProcessIcon { get { return _ProcessIcon; } set { _ProcessIcon = value; } }
62
63 public override string ToString()
64 {
65 return this.FileName;
66 }
67
68 public static Bitmap CreateIconFromProcess(ProcContainer proc)
69 {
70 if (proc == null) return null;
71 Icon large = ProcessIconEx.ExtractIConFromFile(proc.FileName, true);
72 if (large == null) large = ProcessIconEx.ExtractIConFromFile(proc.FileName, false);
73 Bitmap ret = large.ToBitmap();
74 if (ret == null)
75 {
76 int i = 0;
77 }
78 return ret;
79 }
80 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale)
81 {
82 if (proc == null) return null;
83 Icon large = ProcessIconEx.ExtractIConFromFile(proc.FileName, true);
84 if (large == null) large = ProcessIconEx.ExtractIConFromFile(proc.FileName, false);
85 Bitmap ret = large.ToBitmap();
86 if (ret == null)
87 {
88 int i = 0;
89 }
90 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
91 return ret;
92 }
93 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height)
94 {
95 if (proc == null) return null;
96 Icon large = ProcessIconEx.ExtractIConFromFile(proc.FileName, true);
97 if (large == null) large = ProcessIconEx.ExtractIConFromFile(proc.FileName, false);
98 Bitmap ret = large.ToBitmap();
99 if (ret == null)
100 {
101 int i = 0;
102 }
103 ret = new Bitmap(ret, Width, Height);
104 return ret;
105 }
106 private void CreateProcessIcon()
107 {
108 if (this.ProcessInfo == null) return;
109 Icon large = ProcessIconEx.ExtractIConFromFile(this.FileName, true);
110 if (large == null) large = ProcessIconEx.ExtractIConFromFile(this.FileName, false);
111 Bitmap ret = large.ToBitmap();
112 if (ret == null)
113 {
114 int i = 0;
115 }
116 this.ProcessIcon = ret;
117 }
118 private void CreateProcessIcon(int Scale)
119 {
120 Icon large = ProcessIconEx.ExtractIConFromFile(this.FileName, true);
121 if (large == null) large = ProcessIconEx.ExtractIConFromFile(this.FileName, false);
122 Bitmap ret = large.ToBitmap();
123 if (ret == null)
124 {
125 int i = 0;
126 }
127 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
128 this.ProcessIcon = ret;
129 }
130 private void CreateProcessIcon(int Width, int Height)
131 {
132 if (this.ProcessInfo == null) return;
133 Icon large = ProcessIconEx.ExtractIConFromFile(this.FileName, true);
134 if (large == null) large = ProcessIconEx.ExtractIConFromFile(this.FileName, false);
135 Bitmap ret = large.ToBitmap();
136 if (ret == null)
137 {
138 int i = 0;
139 }
140 ret = new Bitmap(ret, Width, Height);
141 this.ProcessIcon = ret;
142 }
143 }
144 }