Skip to content

Commit ae5f732

Browse files
author
Arthur
committed
Merge pull request #11 from cyotek/HtmlPanel.BorderStyle
Added HtmlPanel.BorderStyle
2 parents 8590990 + d77a932 commit ae5f732

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

‎Source/HtmlRenderer/HtmlPanel.cs‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class HtmlPanel : ScrollableControl
6161
{
6262
#region Fields and Consts
6363

64+
private BorderStyle _borderStyle;
65+
6466
/// <summary>
6567
///
6668
/// </summary>
@@ -104,6 +106,12 @@ public HtmlPanel()
104106
_htmlContainer.ImageLoad += OnImageLoad;
105107
}
106108

109+
/// <summary>
110+
/// Occurs when the BorderStyle property value changes
111+
/// </summary>
112+
[Category("Property Changed")]
113+
public event EventHandler BorderStyleChanged;
114+
107115
/// <summary>
108116
/// Raised when the user clicks on a link in the html.<br/>
109117
/// Allows canceling the execution of the link.
@@ -156,6 +164,76 @@ public bool AvoidImagesLateLoading
156164
set { _htmlContainer.AvoidImagesLateLoading = value; }
157165
}
158166

167+
/// <summary>
168+
/// Gets the required creation parameters when the control handle is created.
169+
/// </summary>
170+
/// <value>The create params.</value>
171+
/// <returns>
172+
/// A <see cref="T:System.Windows.Forms.CreateParams" /> that contains the required creation parameters when the handle to the control is created.
173+
/// </returns>
174+
protected override CreateParams CreateParams
175+
{
176+
get
177+
{
178+
CreateParams createParams;
179+
180+
createParams = base.CreateParams;
181+
182+
switch (_borderStyle)
183+
{
184+
case BorderStyle.FixedSingle:
185+
createParams.Style |= Win32Utils.WS_BORDER;
186+
break;
187+
188+
case BorderStyle.Fixed3D:
189+
createParams.ExStyle |= Win32Utils.WS_EX_CLIENTEDGE;
190+
break;
191+
}
192+
193+
return createParams;
194+
}
195+
}
196+
197+
/// <summary>
198+
/// Gets or sets the border style.
199+
/// </summary>
200+
/// <value>The border style.</value>
201+
[Category("Appearance")]
202+
[DefaultValue(typeof(BorderStyle), "None")]
203+
public virtual BorderStyle BorderStyle
204+
{
205+
get { return _borderStyle; }
206+
set
207+
{
208+
if (this.BorderStyle != value)
209+
{
210+
_borderStyle = value;
211+
212+
this.OnBorderStyleChanged(EventArgs.Empty);
213+
}
214+
}
215+
}
216+
217+
/// <summary>
218+
/// Raises the <see cref="BorderStyleChanged" /> event.
219+
/// </summary>
220+
/// <param name="e">
221+
/// The <see cref="EventArgs" /> instance containing the event data.
222+
/// </param>
223+
protected virtual void OnBorderStyleChanged(EventArgs e)
224+
{
225+
EventHandler handler;
226+
227+
base.UpdateStyles();
228+
229+
handler = this.BorderStyleChanged;
230+
231+
if (handler != null)
232+
{
233+
handler(this, e);
234+
}
235+
}
236+
159237
/// <summary>
160238
/// Is content selection is enabled for the rendered html (default - true).<br/>
161239
/// If set to 'false' the rendered html will be static only with ability to click on links.

‎Source/HtmlRenderer/Utils/Win32Utils.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ namespace HtmlRenderer.Utils
2121
/// </summary>
2222
internal static class Win32Utils
2323
{
24+
public const int WS_BORDER = 0x00800000;
25+
26+
public const int WS_EX_CLIENTEDGE = 0x200;
27+
2428
/// <summary>
2529
/// Const for BitBlt copy raster-operation code.
2630
/// </summary>

0 commit comments

Comments
 (0)