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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 william 88 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 william 100 using libWin32.Win32.Threading;
9 william 88
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 william 100 this.ProcessInfo = process;
19 william 101 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 william 88 this.FileName = fi.FullName;
31     this.Name = fi.Name;
32 william 100 this.CreateProcessIcon(4);
33 william 88 }
34     public ProcContainer(Process process, Icon icon)
35     : this()
36     {
37     this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap();
38 william 101 string fname = ProcessModeleInfoEx.GetMainModulePath(process);
39 william 100 FileInfo fi = new FileInfo(fname);
40 william 88 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 william 101 string fname = ProcessModeleInfoEx.GetMainModulePath(process);
48 william 100 FileInfo fi = new FileInfo(fname);
49 william 88 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 william 100 return this.FileName;
66 william 88 }
67    
68 william 100 public static Bitmap CreateIconFromProcess(ProcContainer proc)
69 william 88 {
70     if (proc == null) return null;
71 william 100 return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
72 william 88 }
73 william 100 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale)
74 william 88 {
75     if (proc == null) return null;
76 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
77 william 88 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
78     return ret;
79     }
80 william 100 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height)
81 william 88 {
82     if (proc == null) return null;
83 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
84 william 88 ret = new Bitmap(ret, Width, Height);
85     return ret;
86     }
87     private void CreateProcessIcon()
88     {
89     if (this.ProcessInfo == null) return;
90 william 100 this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
91 william 88 }
92     private void CreateProcessIcon(int Scale)
93     {
94 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
95 william 88 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 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
102 william 88 ret = new Bitmap(ret, Width, Height);
103     this.ProcessIcon = ret;
104     }
105     }
106     }

  ViewVC Help
Powered by ViewVC 1.1.22