| [349] | 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * Copyright 2008 The Eraser Project |
|---|
| 4 | * Original Author: Joel Low <lowjoel@users.sourceforge.net> |
|---|
| [652] | 5 | * Modified By: Kasra Nassiri <cjax@users.sourceforge.net> |
|---|
| [349] | 6 | * |
|---|
| 7 | * This file is part of Eraser. |
|---|
| 8 | * |
|---|
| 9 | * Eraser is free software: you can redistribute it and/or modify it under the |
|---|
| 10 | * terms of the GNU General Public License as published by the Free Software |
|---|
| 11 | * Foundation, either version 3 of the License, or (at your option) any later |
|---|
| 12 | * version. |
|---|
| 13 | * |
|---|
| 14 | * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 15 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
|---|
| 16 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * A copy of the GNU General Public License can be found at |
|---|
| 19 | * <http://www.gnu.org/licenses/>. |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| [119] | 22 | using System; |
|---|
| 23 | using System.Collections.Generic; |
|---|
| 24 | using System.ComponentModel; |
|---|
| 25 | using System.Data; |
|---|
| 26 | using System.Drawing; |
|---|
| [471] | 27 | using System.Drawing.Imaging; |
|---|
| [119] | 28 | using System.Text; |
|---|
| 29 | using System.Windows.Forms; |
|---|
| [470] | 30 | using System.Runtime.InteropServices; |
|---|
| 31 | using System.Reflection; |
|---|
| [471] | 32 | using Eraser.Util; |
|---|
| [474] | 33 | using System.Diagnostics; |
|---|
| [119] | 34 | |
|---|
| 35 | namespace Eraser |
|---|
| 36 | { |
|---|
| 37 | public partial class AboutForm : Form |
|---|
| 38 | { |
|---|
| [471] | 39 | private Bitmap AboutBitmap; |
|---|
| 40 | private Point AboutBitmapPos; |
|---|
| [472] | 41 | private string AboutText; |
|---|
| [471] | 42 | private Bitmap AboutTextBitmap; |
|---|
| 43 | private Rectangle AboutTextRect; |
|---|
| [470] | 44 | |
|---|
| [471] | 45 | private Bitmap ParentBitmap; |
|---|
| 46 | private int ParentOpacity; |
|---|
| 47 | private int AboutTextScrollTop; |
|---|
| 48 | |
|---|
| [474] | 49 | private Rectangle WebsiteRect; |
|---|
| 50 | private Rectangle DonateRect; |
|---|
| 51 | |
|---|
| [471] | 52 | private Bitmap DoubleBufferBitmap; |
|---|
| 53 | |
|---|
| [470] | 54 | public AboutForm(Control parent) |
|---|
| [119] | 55 | { |
|---|
| [471] | 56 | //Create and position the dialog |
|---|
| [119] | 57 | InitializeComponent(); |
|---|
| [470] | 58 | ClientSize = new Size(parent.ClientSize.Width, parent.ClientSize.Height); |
|---|
| 59 | Point point = parent.PointToScreen(new Point(0, 0)); |
|---|
| 60 | Left = point.X; |
|---|
| 61 | Top = point.Y; |
|---|
| 62 | |
|---|
| [472] | 63 | //Load the localised About Text |
|---|
| [500] | 64 | AboutText = S._(@"Eraser is an advanced security tool for Windows, which allows you to completely remove sensitive data from your hard drive by overwriting it several times with carefully selected patterns. Eraser is Free software and its source code is released under GNU General Public License. |
|---|
| [472] | 65 | |
|---|
| [483] | 66 | Erasure Method Credits: |
|---|
| 67 | Gutmann (35 Pass): Copyright Peter Gutmann & Colin Plumb |
|---|
| 68 | Gutmann Lite (10 pass): Copyright Peter Gutmann & Colin Plumb |
|---|
| 69 | US DoD (7 pass): Copyright United States Department of |
|---|
| 70 | Defense |
|---|
| 71 | US DoD (3 pass): Copyright United States Department of |
|---|
| 72 | Defense |
|---|
| [509] | 73 | US Air Force 5020 (3 pass): Copyright United States Department of |
|---|
| [483] | 74 | Defense |
|---|
| 75 | US Army AR380-19 (3 pass): Copyright United States Department of |
|---|
| 76 | Defense |
|---|
| 77 | RCMP TSSIT OPS-II (7 pass): Copyright Government of Canada, |
|---|
| 78 | Royal Canadian Mounted Police |
|---|
| [500] | 79 | Schneier's Method (7 pass): Copyright Bruce Schneier |
|---|
| [483] | 80 | German VSITR (7 pass): Copyright Germany BSI Verschlusssachen |
|---|
| 81 | -IT-Richtlinien |
|---|
| 82 | British HMG IS5 (3 pass): Copyright British Government |
|---|
| 83 | British HMG IS5 (1 pass): Copyright British Government |
|---|
| 84 | Russian GOST P50739-95 (2 pass): Copyright Government of the Soviet |
|---|
| 85 | Union |
|---|
| 86 | Pseudorandom data (1 pass): Public Domain |
|---|
| 87 | First/Last 16Kb: Copyright The Eraser Project |
|---|
| 88 | |
|---|
| 89 | Eraser Copyright " + "\u00A9" + @" The Eraser Project |
|---|
| 90 | |
|---|
| 91 | Eraser Project Members: |
|---|
| [509] | 92 | " + "\u2022" + @" Sami Tolvanen: Mentor/Initiator |
|---|
| [483] | 93 | " + "\u2022" + @" Garrett Trant: Mentor/Researcher |
|---|
| 94 | " + "\u2022" + @" Joel Low: Lead Developer |
|---|
| [655] | 95 | " + "\u2022" + @" Kasra Nassiri: Developer/Security Researcher |
|---|
| 96 | " + "\u2022" + @" Dennis van Lith: Designer"); |
|---|
| [483] | 97 | |
|---|
| [471] | 98 | //Create the About bitmap localised for the current version (sans scrolling |
|---|
| 99 | //text) so it can be drawn quickly later. |
|---|
| 100 | AboutBitmap = Properties.Resources.AboutDialog; |
|---|
| 101 | AboutBitmap = AboutBitmap.Clone(new Rectangle(0, 0, AboutBitmap.Width, |
|---|
| 102 | AboutBitmap.Height), PixelFormat.DontCare); |
|---|
| 103 | using (Graphics g = Graphics.FromImage(AboutBitmap)) |
|---|
| [470] | 104 | { |
|---|
| 105 | //Version number |
|---|
| 106 | Font boldFont = new Font(Font, FontStyle.Bold); |
|---|
| [474] | 107 | Font underlineFont = new Font(Font, FontStyle.Underline); |
|---|
| [470] | 108 | Brush textBrush = new SolidBrush(Color.White); |
|---|
| [471] | 109 | PointF eraserPos = new PointF(168, 80); |
|---|
| [470] | 110 | SizeF eraserSize = g.MeasureString(S._("Eraser"), boldFont); |
|---|
| 111 | g.DrawString(S._("Eraser"), boldFont, textBrush, eraserPos); |
|---|
| 112 | g.DrawString(Assembly.GetExecutingAssembly().GetName().Version.ToString(), |
|---|
| [600] | 113 | Font, textBrush, new PointF(eraserPos.X + eraserSize.Width + 3, eraserPos.Y)); |
|---|
| [470] | 114 | |
|---|
| 115 | //Copyright and Website |
|---|
| 116 | string copyrightText = S._("copyright \u00a9 2008 The Eraser Project"); |
|---|
| 117 | PointF copyrightPos = new PointF(eraserPos.X, eraserPos.Y + eraserSize.Height); |
|---|
| 118 | SizeF copyrightSize = g.MeasureString(copyrightText, Font); |
|---|
| 119 | g.DrawString(copyrightText, Font, textBrush, copyrightPos); |
|---|
| 120 | |
|---|
| 121 | string websiteText = "http://eraser.sourceforge.net/"; |
|---|
| 122 | PointF websitePos = new PointF(copyrightPos.X, copyrightPos.Y + copyrightSize.Height); |
|---|
| 123 | SizeF websiteSize = g.MeasureString(websiteText, Font); |
|---|
| [474] | 124 | g.DrawString(websiteText, underlineFont, textBrush, websitePos); |
|---|
| 125 | WebsiteRect = new Rectangle((int)websitePos.X, (int)websitePos.Y, |
|---|
| 126 | (int)websiteSize.Width, (int)websiteSize.Height); |
|---|
| [470] | 127 | |
|---|
| 128 | //Open source disclaimer. |
|---|
| 129 | string disclaimerText = S._("Eraser is free open-source software!"); |
|---|
| 130 | PointF disclaimerPos = new PointF(websitePos.X, websitePos.Y + websiteSize.Height * 1.5f); |
|---|
| 131 | g.DrawString(disclaimerText, Font, textBrush, disclaimerPos); |
|---|
| 132 | |
|---|
| 133 | //Donation statement |
|---|
| [852] | 134 | string donationText = S._("Please help us to continue developing Eraser - donate some coffee!"); |
|---|
| [470] | 135 | PointF donationPos = new PointF(disclaimerPos.X, disclaimerPos.Y + 170); |
|---|
| 136 | SizeF donationSize = g.MeasureString(donationText, Font); |
|---|
| 137 | g.DrawString(donationText, Font, textBrush, donationPos); |
|---|
| [474] | 138 | DonateRect = new Rectangle((int)donationPos.X, (int)donationPos.Y, |
|---|
| 139 | (int)donationSize.Width, (int)donationSize.Height); |
|---|
| [470] | 140 | } |
|---|
| 141 | |
|---|
| [471] | 142 | //Calculate the position of the About bitmap |
|---|
| 143 | AboutBitmapPos = new Point((ClientSize.Width - AboutBitmap.Width) / 2, |
|---|
| 144 | (ClientSize.Height - AboutBitmap.Height) / 2); |
|---|
| [474] | 145 | WebsiteRect.X += AboutBitmapPos.X; |
|---|
| 146 | WebsiteRect.Y += AboutBitmapPos.Y; |
|---|
| 147 | DonateRect.X += AboutBitmapPos.X; |
|---|
| 148 | DonateRect.Y += AboutBitmapPos.Y; |
|---|
| [471] | 149 | |
|---|
| 150 | //And calculate the bounds of the About Text. |
|---|
| 151 | AboutTextRect = new Rectangle(AboutBitmapPos.X + 19 + 149, AboutBitmapPos.Y + 20 + 147, |
|---|
| 152 | AboutBitmap.Width - 19 - 149 - 20, 130); |
|---|
| 153 | |
|---|
| 154 | //Create the About Text laid out on screen. |
|---|
| 155 | SizeF aboutTextSize = SizeF.Empty; |
|---|
| 156 | using (Bitmap b = new Bitmap(1, 1)) |
|---|
| 157 | using (Graphics g = Graphics.FromImage(b)) |
|---|
| 158 | aboutTextSize = g.MeasureString(AboutText, Font, AboutTextRect.Width); |
|---|
| 159 | AboutTextBitmap = new Bitmap(AboutTextRect.Width, (int)aboutTextSize.Height); |
|---|
| 160 | using (Graphics g = Graphics.FromImage(AboutTextBitmap)) |
|---|
| [470] | 161 | { |
|---|
| [471] | 162 | g.Clear(Color.FromArgb(0, 0, 0, 0)); |
|---|
| 163 | g.DrawString(AboutText, Font, new SolidBrush(Color.White), new RectangleF( |
|---|
| 164 | 0.0f, 0.0f, AboutTextRect.Width, aboutTextSize.Height)); |
|---|
| [470] | 165 | } |
|---|
| 166 | |
|---|
| [471] | 167 | //Get the parent dialog's screen buffer. |
|---|
| 168 | ParentBitmap = new Bitmap(parent.ClientSize.Width, parent.ClientSize.Height); |
|---|
| 169 | using (Graphics dest = Graphics.FromImage(ParentBitmap)) |
|---|
| [470] | 170 | { |
|---|
| [471] | 171 | parent.Refresh(); |
|---|
| 172 | Point parentPos = parent.PointToScreen(new Point(0, 0)); |
|---|
| 173 | dest.CopyFromScreen(parentPos, new Point(0, 0), parent.ClientSize); |
|---|
| 174 | } |
|---|
| [470] | 175 | |
|---|
| [471] | 176 | AboutTextScrollTop = AboutTextRect.Height / 2; |
|---|
| 177 | animationTimer_Tick(null, null); |
|---|
| [470] | 178 | } |
|---|
| 179 | |
|---|
| [119] | 180 | private void AboutForm_Click(object sender, EventArgs e) |
|---|
| 181 | { |
|---|
| [474] | 182 | Point cursorPos = PointToClient(Cursor.Position); |
|---|
| 183 | if (WebsiteRect.IntersectsWith(new Rectangle(cursorPos, new Size(1, 1)))) |
|---|
| [853] | 184 | Process.Start("http://eraser.heidi.ie/"); |
|---|
| [474] | 185 | else if (DonateRect.IntersectsWith(new Rectangle(cursorPos, new Size(1, 1)))) |
|---|
| 186 | Process.Start("https://euro.swreg.org/cgi-bin/s.cgi?r=1&s=80181&db_key=1512312&x=0&lang=&lnk="); |
|---|
| 187 | else |
|---|
| 188 | //Dismiss the dialog. |
|---|
| 189 | Close(); |
|---|
| [119] | 190 | } |
|---|
| [470] | 191 | |
|---|
| [856] | 192 | private void AboutForm_Paint(object sender, PaintEventArgs e) |
|---|
| 193 | { |
|---|
| 194 | DrawComposite(e.Graphics); |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| [474] | 197 | private void AboutForm_MouseMove(object sender, MouseEventArgs e) |
|---|
| 198 | { |
|---|
| 199 | Cursor.Current = Cursors.Default; |
|---|
| 200 | if (WebsiteRect.IntersectsWith(new Rectangle(e.Location, new Size(1, 1))) || |
|---|
| 201 | DonateRect.IntersectsWith(new Rectangle(e.Location, new Size(1, 1)))) |
|---|
| 202 | Cursor.Current = Cursors.Hand; |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | private void AboutForm_MouseLeave(object sender, EventArgs e) |
|---|
| 206 | { |
|---|
| 207 | Cursor.Current = Cursors.Default; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| [471] | 210 | private void animationTimer_Tick(object sender, EventArgs e) |
|---|
| [470] | 211 | { |
|---|
| [471] | 212 | if (ParentOpacity <= 128) |
|---|
| 213 | ParentOpacity += 8; |
|---|
| 214 | if (AboutTextBitmap.Height < -AboutTextScrollTop) |
|---|
| 215 | AboutTextScrollTop = AboutTextRect.Height; |
|---|
| 216 | else |
|---|
| 217 | AboutTextScrollTop -= 1; |
|---|
| [470] | 218 | |
|---|
| [856] | 219 | using (Graphics g = CreateGraphics()) |
|---|
| 220 | DrawComposite(g); |
|---|
| [471] | 221 | } |
|---|
| 222 | |
|---|
| [856] | 223 | private void DrawComposite(Graphics g) |
|---|
| [471] | 224 | { |
|---|
| 225 | if (DoubleBufferBitmap == null) |
|---|
| 226 | DoubleBufferBitmap = new Bitmap(ClientSize.Width, ClientSize.Height); |
|---|
| [856] | 227 | using (Graphics bg = Graphics.FromImage(DoubleBufferBitmap)) |
|---|
| [470] | 228 | { |
|---|
| [471] | 229 | //Draw the parent image with a fading out effect |
|---|
| [856] | 230 | if (ParentOpacity > 128) |
|---|
| 231 | bg.Clip = new Region(AboutTextRect); |
|---|
| 232 | |
|---|
| [471] | 233 | Brush brush = new SolidBrush(Color.FromArgb(ParentOpacity, 0, 0, 0)); |
|---|
| [856] | 234 | bg.DrawImageUnscaled(ParentBitmap, 0, 0); |
|---|
| 235 | bg.FillRectangle(brush, ClientRectangle); |
|---|
| [470] | 236 | |
|---|
| [471] | 237 | //Then draw the About bitmap (which we cached in the constructor) |
|---|
| [856] | 238 | bg.DrawImageUnscaled(AboutBitmap, AboutBitmapPos); |
|---|
| [470] | 239 | |
|---|
| [471] | 240 | //And the scrolling text |
|---|
| [856] | 241 | bg.Clip = new Region(AboutTextRect); |
|---|
| 242 | bg.DrawImageUnscaled(AboutTextBitmap, AboutTextRect.Left, |
|---|
| [471] | 243 | AboutTextRect.Top + AboutTextScrollTop); |
|---|
| [856] | 244 | bg.ResetClip(); |
|---|
| [470] | 245 | } |
|---|
| 246 | |
|---|
| [856] | 247 | if (ParentOpacity > 128) |
|---|
| 248 | if (g.Clip != null) |
|---|
| 249 | g.Clip.Complement(new Region(AboutTextRect)); |
|---|
| 250 | else |
|---|
| 251 | g.Clip = new Region(AboutTextRect); |
|---|
| 252 | g.DrawImageUnscaled(DoubleBufferBitmap, 0, 0); |
|---|
| [470] | 253 | } |
|---|
| [119] | 254 | } |
|---|
| [472] | 255 | } |
|---|