/[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 88 - (hide annotations) (download)
Wed May 9 20:52:20 2012 UTC (9 years, 6 months ago) by william
File size: 3639 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    
9     namespace RomCheater.PluginFramework.Core
10     {
11     public class ProcContainer
12     {
13     public ProcContainer() { this.init(); }
14     public ProcContainer(Process process)
15     : this()
16     {
17     this.ProcessInfo = process; this.CreateProcessIcon(4);
18     FileInfo fi = new FileInfo(process.MainModule.FileName);
19     this.FileName = fi.FullName;
20     this.Name = fi.Name;
21     }
22     public ProcContainer(Process process, Icon icon)
23     : this()
24     {
25     this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap();
26     FileInfo fi = new FileInfo(process.MainModule.FileName);
27     this.FileName = fi.FullName;
28     this.Name = fi.Name;
29     }
30     public ProcContainer(Process process, Bitmap icon)
31     : this()
32     {
33     this.ProcessInfo = process; this.ProcessIcon = icon;
34     FileInfo fi = new FileInfo(process.MainModule.FileName);
35     this.FileName = fi.FullName;
36     this.Name = fi.Name;
37     }
38     private void init() { this.ProcessInfo = null; this.ProcessIcon = null; }
39    
40    
41     public string Name { get; set; }
42     public string FileName { get; set; }
43    
44     private Process _ProcessInfo;
45     public Process ProcessInfo { get { return _ProcessInfo; } set { _ProcessInfo = value; } }
46     private Bitmap _ProcessIcon;
47     public Bitmap ProcessIcon { get { return _ProcessIcon; } set { _ProcessIcon = value; } }
48    
49     public override string ToString()
50     {
51     return this.FileName == "" ?
52     (ProcessInfo != null) ? ProcessInfo.MainModule.FileName : "" :
53     this.FileName;
54     }
55    
56     public static Bitmap CreateIconFromProcess(Process proc)
57     {
58     if (proc == null) return null;
59     return Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap();
60     }
61     public static Bitmap CreateIconFromProcess(Process proc, int Scale)
62     {
63     if (proc == null) return null;
64     Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap();
65     ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
66     return ret;
67     }
68     public static Bitmap CreateIconFromProcess(Process proc, int Width, int Height)
69     {
70     if (proc == null) return null;
71     Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap();
72     ret = new Bitmap(ret, Width, Height);
73     return ret;
74     }
75     private void CreateProcessIcon()
76     {
77     if (this.ProcessInfo == null) return;
78     this.ProcessIcon = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap();
79     }
80     private void CreateProcessIcon(int Scale)
81     {
82     Bitmap ret = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap();
83     ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
84     this.ProcessIcon = ret;
85     }
86     private void CreateProcessIcon(int Width, int Height)
87     {
88     if (this.ProcessInfo == null) return;
89     Bitmap ret = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap();
90     ret = new Bitmap(ret, Width, Height);
91     this.ProcessIcon = ret;
92     }
93     }
94     }

  ViewVC Help
Powered by ViewVC 1.1.22