|
3 | 3 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
4 | 4 |
|
5 | 5 | using System.Collections; |
6 | | -using System.ComponentModel; |
7 | 6 | using System.Drawing; |
8 | | -using System.Reflection; |
9 | | -using System.Resources; |
10 | 7 | using System.Windows.Forms.Design; |
11 | 8 |
|
12 | 9 | namespace CefSharp.WinForms |
13 | 10 | { |
14 | | - public class ChromiumWebBrowserDesigner : ControlDesigner |
15 | | - { |
16 | | - protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe) |
17 | | - { |
18 | | - //NOTE: Removed until a better image can be found, add image as Embedded Resource and update name below |
19 | | - //var assembly = Assembly.GetAssembly(typeof(ChromiumWebBrowserDesigner)); |
20 | | - |
21 | | - //using (var logo = assembly.GetManifestResourceStream("CefSharp.WinForms.CefSharpLogo.png")) |
22 | | - //using (var img = Image.FromStream(logo)) |
23 | | - //{ |
24 | | - // pe.Graphics.DrawImage(img, 0, 0); |
25 | | - //} |
26 | | - |
27 | | - using(var font = new Font("Arial", 16)) |
28 | | - using (var stringFormat = new StringFormat |
29 | | - { |
30 | | - // Create a StringFormat object with the each line of text, and the block |
31 | | - // of text centered on the page. |
32 | | - Alignment = StringAlignment.Center, |
33 | | - LineAlignment = StringAlignment.Center |
34 | | - }) |
35 | | - { |
36 | | - pe.Graphics.DrawString("ChromiumWebBrowser", font, Brushes.Black, pe.ClipRectangle, stringFormat); |
37 | | - } |
38 | | - |
39 | | - base.OnPaintAdornments(pe); |
40 | | - } |
41 | | - |
42 | | - protected override void PreFilterProperties(IDictionary properties) |
43 | | - { |
44 | | - //Remove some of the default properties from the designer |
45 | | - //they don't have much meaning for the browser |
46 | | - //Probably more that can be removed/tweaked |
47 | | - properties.Remove("BackgroundImage"); |
48 | | - properties.Remove("BackgroundImageLayout"); |
49 | | - properties.Remove("Text"); |
50 | | - |
51 | | - properties.Remove("Font"); |
52 | | - properties.Remove("ForeColor"); |
53 | | - properties.Remove("BackColor"); |
54 | | - properties.Remove("RightToLeft"); |
55 | | - |
56 | | - base.PreFilterProperties(properties); |
57 | | - } |
58 | | - } |
| 11 | + /// <summary> |
| 12 | + /// ChromiumWebBrowser Control Designer |
| 13 | + /// </summary> |
| 14 | + public class ChromiumWebBrowserDesigner : ControlDesigner |
| 15 | + { |
| 16 | + /// <summary> |
| 17 | + /// Receives a call when the control that the designer is managing has painted its surface so the designer can paint any additional adornments on top of the control. |
| 18 | + /// </summary> |
| 19 | + /// <param name="pe">args</param> |
| 20 | + protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe) |
| 21 | + { |
| 22 | + //NOTE: Removed until a better image can be found, add image as Embedded Resource and update name below |
| 23 | + //var assembly = Assembly.GetAssembly(typeof(ChromiumWebBrowserDesigner)); |
| 24 | + |
| 25 | + //using (var logo = assembly.GetManifestResourceStream("CefSharp.WinForms.CefSharpLogo.png")) |
| 26 | + //using (var img = Image.FromStream(logo)) |
| 27 | + //{ |
| 28 | + // pe.Graphics.DrawImage(img, 0, 0); |
| 29 | + //} |
| 30 | + |
| 31 | + using(var font = new Font("Arial", 16)) |
| 32 | + using (var stringFormat = new StringFormat |
| 33 | + { |
| 34 | + // Create a StringFormat object with the each line of text, and the block |
| 35 | + // of text centered on the page. |
| 36 | + Alignment = StringAlignment.Center, |
| 37 | + LineAlignment = StringAlignment.Center |
| 38 | + }) |
| 39 | + { |
| 40 | + pe.Graphics.DrawString("ChromiumWebBrowser", font, Brushes.Black, pe.ClipRectangle, stringFormat); |
| 41 | + } |
| 42 | + |
| 43 | + base.OnPaintAdornments(pe); |
| 44 | + } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// Adjusts the set of properties the component exposes through a TypeDescriptor. |
| 48 | + /// </summary> |
| 49 | + /// <param name="properties">properties</param> |
| 50 | + protected override void PreFilterProperties(IDictionary properties) |
| 51 | + { |
| 52 | + //Remove some of the default properties from the designer |
| 53 | + //they don't have much meaning for the browser |
| 54 | + //Probably more that can be removed/tweaked |
| 55 | + properties.Remove("BackgroundImage"); |
| 56 | + properties.Remove("BackgroundImageLayout"); |
| 57 | + properties.Remove("Text"); |
| 58 | + |
| 59 | + properties.Remove("Font"); |
| 60 | + properties.Remove("ForeColor"); |
| 61 | + properties.Remove("BackColor"); |
| 62 | + properties.Remove("RightToLeft"); |
| 63 | + |
| 64 | + base.PreFilterProperties(properties); |
| 65 | + } |
| 66 | + } |
59 | 67 | } |
0 commit comments