Changeset 2245 for trunk/eraser
- Timestamp:
- 9/24/2010 2:21:27 AM (3 years ago)
- Location:
- trunk/eraser/Eraser
- Files:
-
- 3 edited
-
AboutForm.Designer.cs (modified) (1 diff)
-
AboutForm.cs (modified) (4 diffs)
-
AboutForm.resx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser/AboutForm.Designer.cs
r1675 r2245 68 68 // AboutForm 69 69 // 70 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;71 70 resources.ApplyResources(this, "$this"); 71 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 72 72 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 73 73 this.Name = "AboutForm"; 74 74 this.ShowInTaskbar = false; 75 this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.AboutForm_MouseUp); 76 this.Paint += new System.Windows.Forms.PaintEventHandler(this.AboutForm_Paint); 75 77 this.Click += new System.EventHandler(this.AboutForm_Click); 76 this.Paint += new System.Windows.Forms.PaintEventHandler(this.AboutForm_Paint);77 78 this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.AboutForm_MouseDown); 78 79 this.MouseLeave += new System.EventHandler(this.AboutForm_MouseLeave); 79 80 this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.AboutForm_MouseMove); 80 this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.AboutForm_MouseUp);81 81 this.ResumeLayout(false); 82 82 -
trunk/eraser/Eraser/AboutForm.cs
r2135 r2245 62 62 Left = point.X; 63 63 Top = point.Y; 64 65 //Get the parent dialog's screen buffer. 66 ParentBitmap = new Bitmap(parent.ClientSize.Width, parent.ClientSize.Height); 67 using (Graphics dest = Graphics.FromImage(ParentBitmap)) 68 { 69 parent.Refresh(); 70 Point parentPos = parent.PointToScreen(new Point(0, 0)); 71 dest.CopyFromScreen(parentPos, new Point(0, 0), parent.ClientSize); 72 } 64 73 65 74 //Load the localised About Text … … 100 109 //Create the About bitmap localised for the current version (sans scrolling 101 110 //text) so it can be drawn quickly later. 102 AboutBitmap = Properties.Resources.AboutDialog; 103 AboutBitmap = AboutBitmap.Clone(new Rectangle(0, 0, AboutBitmap.Width, 104 AboutBitmap.Height), PixelFormat.DontCare); 111 //First, duplicate the bitmap and scale it according to the resolution of the 112 //monitor. 113 float dpiScale = 0f; 114 using (Graphics controlDC = CreateGraphics()) 115 { 116 Debug.Assert(controlDC.DpiX == controlDC.DpiY); 117 dpiScale = controlDC.DpiX / 96.0f; 118 } 119 120 Bitmap sourceBitmap = Properties.Resources.AboutDialog; 121 AboutBitmap = new Bitmap((int)(sourceBitmap.Width * dpiScale), 122 (int)(sourceBitmap.Height * dpiScale)); 105 123 using (Graphics g = Graphics.FromImage(AboutBitmap)) 106 124 { 125 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; 126 g.ScaleTransform(dpiScale, dpiScale); 127 g.DrawImage(sourceBitmap, Point.Empty); 128 129 //Scale the font down since we will be using a scale transform later. 130 Font = new Font(Font.FontFamily, Font.SizeInPoints / dpiScale); 131 107 132 //Version number 108 133 Font boldFont = new Font(Font, FontStyle.Bold); … … 152 177 AboutBitmapPos = new Point((ClientSize.Width - AboutBitmap.Width) / 2, 153 178 (ClientSize.Height - AboutBitmap.Height) / 2); 154 WebsiteRect.X += AboutBitmapPos.X; 155 WebsiteRect.Y += AboutBitmapPos.Y; 156 DonateRect.X += AboutBitmapPos.X; 157 DonateRect.Y += AboutBitmapPos.Y; 179 WebsiteRect.X = (int)(WebsiteRect.X * dpiScale + AboutBitmapPos.X); 180 WebsiteRect.Y = (int)(WebsiteRect.Y * dpiScale + AboutBitmapPos.Y); 181 WebsiteRect.Width = (int)(WebsiteRect.Width * dpiScale); 182 WebsiteRect.Height = (int)(WebsiteRect.Height * dpiScale); 183 DonateRect.X = (int)(DonateRect.X * dpiScale + AboutBitmapPos.X); 184 DonateRect.Y = (int)(DonateRect.Y * dpiScale + AboutBitmapPos.Y); 185 DonateRect.Width = (int)(DonateRect.Width * dpiScale); 186 DonateRect.Height = (int)(DonateRect.Height * dpiScale); 158 187 159 188 //And calculate the bounds of the About Text. 160 AboutTextRect = new Rectangle(AboutBitmapPos.X + 19 + 149, AboutBitmapPos.Y + 20 + 147, 161 AboutBitmap.Width - 19 - 149 - 20, 130); 189 AboutTextRect = Rectangle.Truncate(new RectangleF( 190 AboutBitmapPos.X + (19 + 149) * dpiScale, 191 AboutBitmapPos.Y + (20 + 147) * dpiScale, 192 AboutBitmap.Width - (19 + 149 + 20) * dpiScale, 193 130 * dpiScale)); 162 194 163 195 //Create the About Text laid out on screen. … … 165 197 using (Bitmap b = new Bitmap(1, 1)) 166 198 using (Graphics g = Graphics.FromImage(b)) 199 { 200 g.ScaleTransform(dpiScale, dpiScale); 167 201 aboutTextSize = g.MeasureString(AboutText, Font, AboutTextRect.Width); 202 } 168 203 AboutTextBitmap = new Bitmap(AboutTextRect.Width, (int)aboutTextSize.Height); 169 204 using (Graphics g = Graphics.FromImage(AboutTextBitmap)) 170 205 { 171 206 g.Clear(Color.FromArgb(0, 0, 0, 0)); 172 g.DrawString(AboutText, Font, new SolidBrush(Color.White), new RectangleF( 173 0.0f, 0.0f, AboutTextRect.Width, aboutTextSize.Height)); 174 } 175 176 //Get the parent dialog's screen buffer. 177 ParentBitmap = new Bitmap(parent.ClientSize.Width, parent.ClientSize.Height); 178 using (Graphics dest = Graphics.FromImage(ParentBitmap)) 179 { 180 parent.Refresh(); 181 Point parentPos = parent.PointToScreen(new Point(0, 0)); 182 dest.CopyFromScreen(parentPos, new Point(0, 0), parent.ClientSize); 207 g.ScaleTransform(dpiScale, dpiScale); 208 g.DrawString(AboutText, Font, new SolidBrush(Color.White), 209 new RectangleF(0.0f, 0.0f, AboutTextBitmap.Width / dpiScale, 210 AboutTextBitmap.Height / dpiScale)); 183 211 } 184 212 -
trunk/eraser/Eraser/AboutForm.resx
r474 r2245 125 125 </metadata> 126 126 <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 127 <data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing"> 128 <value>96, 96</value> 129 </data> 127 130 <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing"> 128 131 <value>568, 326</value>
Note: See TracChangeset
for help on using the changeset viewer.
