/[RomCheater]/trunk/RomCheater.PluginFramework/Core/ProcContainer.cs
ViewVC logotype

Contents of /trunk/RomCheater.PluginFramework/Core/ProcContainer.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 101 - (show annotations) (download)
Thu May 10 09:53:16 2012 UTC (8 years, 4 months ago) by william
File size: 3836 byte(s)

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 ex)
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 return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
72 }
73 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale)
74 {
75 if (proc == null) return null;
76 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
77 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
78 return ret;
79 }
80 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height)
81 {
82 if (proc == null) return null;
83 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
84 ret = new Bitmap(ret, Width, Height);
85 return ret;
86 }
87 private void CreateProcessIcon()
88 {
89 if (this.ProcessInfo == null) return;
90 this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
91 }
92 private void CreateProcessIcon(int Scale)
93 {
94 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
95 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
96 this.ProcessIcon = ret;
97 }
98 private void CreateProcessIcon(int Width, int Height)
99 {
100 if (this.ProcessInfo == null) return;
101 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
102 ret = new Bitmap(ret, Width, Height);
103 this.ProcessIcon = ret;
104 }
105 }
106 }

  ViewVC Help
Powered by ViewVC 1.1.22