5 |
using System.Diagnostics; |
using System.Diagnostics; |
6 |
using System.Drawing; |
using System.Drawing; |
7 |
using System.IO; |
using System.IO; |
8 |
|
using libWin32.Win32.Threading; |
9 |
|
|
10 |
namespace RomCheater.PluginFramework.Core |
namespace RomCheater.PluginFramework.Core |
11 |
{ |
{ |
15 |
public ProcContainer(Process process) |
public ProcContainer(Process process) |
16 |
: this() |
: this() |
17 |
{ |
{ |
18 |
this.ProcessInfo = process; this.CreateProcessIcon(4); |
this.ProcessInfo = process; |
19 |
FileInfo fi = new FileInfo(process.MainModule.FileName); |
string fname = ThreadControl.GetProcessFilename(process); |
20 |
|
FileInfo fi = new FileInfo(fname); |
21 |
this.FileName = fi.FullName; |
this.FileName = fi.FullName; |
22 |
this.Name = fi.Name; |
this.Name = fi.Name; |
23 |
|
this.CreateProcessIcon(4); |
24 |
} |
} |
25 |
public ProcContainer(Process process, Icon icon) |
public ProcContainer(Process process, Icon icon) |
26 |
: this() |
: this() |
27 |
{ |
{ |
28 |
this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap(); |
this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap(); |
29 |
FileInfo fi = new FileInfo(process.MainModule.FileName); |
string fname = ThreadControl.GetProcessFilename(process); |
30 |
|
FileInfo fi = new FileInfo(fname); |
31 |
this.FileName = fi.FullName; |
this.FileName = fi.FullName; |
32 |
this.Name = fi.Name; |
this.Name = fi.Name; |
33 |
} |
} |
35 |
: this() |
: this() |
36 |
{ |
{ |
37 |
this.ProcessInfo = process; this.ProcessIcon = icon; |
this.ProcessInfo = process; this.ProcessIcon = icon; |
38 |
FileInfo fi = new FileInfo(process.MainModule.FileName); |
string fname = ThreadControl.GetProcessFilename(process); |
39 |
|
FileInfo fi = new FileInfo(fname); |
40 |
this.FileName = fi.FullName; |
this.FileName = fi.FullName; |
41 |
this.Name = fi.Name; |
this.Name = fi.Name; |
42 |
} |
} |
53 |
|
|
54 |
public override string ToString() |
public override string ToString() |
55 |
{ |
{ |
56 |
return this.FileName == "" ? |
return this.FileName; |
|
(ProcessInfo != null) ? ProcessInfo.MainModule.FileName : "" : |
|
|
this.FileName; |
|
57 |
} |
} |
58 |
|
|
59 |
public static Bitmap CreateIconFromProcess(Process proc) |
public static Bitmap CreateIconFromProcess(ProcContainer proc) |
60 |
{ |
{ |
61 |
if (proc == null) return null; |
if (proc == null) return null; |
62 |
return Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap(); |
return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap(); |
63 |
} |
} |
64 |
public static Bitmap CreateIconFromProcess(Process proc, int Scale) |
public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale) |
65 |
{ |
{ |
66 |
if (proc == null) return null; |
if (proc == null) return null; |
67 |
Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap(); |
Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap(); |
68 |
ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale); |
ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale); |
69 |
return ret; |
return ret; |
70 |
} |
} |
71 |
public static Bitmap CreateIconFromProcess(Process proc, int Width, int Height) |
public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height) |
72 |
{ |
{ |
73 |
if (proc == null) return null; |
if (proc == null) return null; |
74 |
Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap(); |
Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap(); |
75 |
ret = new Bitmap(ret, Width, Height); |
ret = new Bitmap(ret, Width, Height); |
76 |
return ret; |
return ret; |
77 |
} |
} |
78 |
private void CreateProcessIcon() |
private void CreateProcessIcon() |
79 |
{ |
{ |
80 |
if (this.ProcessInfo == null) return; |
if (this.ProcessInfo == null) return; |
81 |
this.ProcessIcon = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap(); |
this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); |
82 |
} |
} |
83 |
private void CreateProcessIcon(int Scale) |
private void CreateProcessIcon(int Scale) |
84 |
{ |
{ |
85 |
Bitmap ret = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap(); |
Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); |
86 |
ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale); |
ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale); |
87 |
this.ProcessIcon = ret; |
this.ProcessIcon = ret; |
88 |
} |
} |
89 |
private void CreateProcessIcon(int Width, int Height) |
private void CreateProcessIcon(int Width, int Height) |
90 |
{ |
{ |
91 |
if (this.ProcessInfo == null) return; |
if (this.ProcessInfo == null) return; |
92 |
Bitmap ret = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap(); |
Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); |
93 |
ret = new Bitmap(ret, Width, Height); |
ret = new Bitmap(ret, Width, Height); |
94 |
this.ProcessIcon = ret; |
this.ProcessIcon = ret; |
95 |
} |
} |