diff --git a/README.md b/README.md index 379d3ee91..f689bdfac 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **Cross framework** (WinForms/WPF/PDF/Metro/Mono/etc.), **Multipurpose** (UI Controls / Image generation / PDF generation / etc.), **100% managed** (C#), High performance HTML Rendering library. -The library is 100% managed **C#** code without any external dependencies (no WebBrowser control, ActiveX / COM or MSHTML dll), the only requirement is **.NET Framework 4.6.2 or higher**. +The library is 100% managed **C#** code without any external dependencies (no WebBrowser control, ActiveX / COM or MSHTML dll), the only requirement is **.NET Standard 2.0 / .NET 8.0 or higher**. ![Renderer.png](https://raw.githubusercontent.com/ArthurHub/HTML-Renderer/master/Art/demo_winforms.png) @@ -22,7 +22,6 @@ The latest NuGet packages can be found on NuGet.org: * [HtmlRenderer.WinForms](https://www.nuget.org/packages/HtmlRenderer.WinForms) * [HtmlRenderer.WPF](https://www.nuget.org/packages/HtmlRenderer.WPF) -* [HtmlRenderer.Mono](https://www.nuget.org/packages/HtmlRenderer.Mono) * [HtmlRenderer.PdfSharp](https://www.nuget.org/packages/HtmlRenderer.PdfSharp) * [HtmlRenderer.Core](https://www.nuget.org/packages/HtmlRenderer.Core) diff --git a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj index b0e2b7f4c..b2b829640 100644 --- a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj +++ b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj @@ -1,11 +1,11 @@  - net462 + netstandard2.0;net8.0 Library TheArtOfDev.HtmlRenderer.Demo.Common HtmlRendererDemoCommon - false - true + true + true @@ -91,6 +91,9 @@ + + + diff --git a/Source/Demo/Common/Properties/AssemblyInfo.cs b/Source/Demo/Common/Properties/AssemblyInfo.cs deleted file mode 100644 index bb96bf22f..000000000 --- a/Source/Demo/Common/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HtmlRenderer.Demo.Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HtmlRenderer.Demo.Common")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("5d5516c9-aa2c-44cc-883c-467ff9a3d9b9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Source/Demo/WPF/App.xaml.cs b/Source/Demo/WPF/App.xaml.cs index 5a23c097f..93a7c452b 100644 --- a/Source/Demo/WPF/App.xaml.cs +++ b/Source/Demo/WPF/App.xaml.cs @@ -43,7 +43,7 @@ private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) if (stream != null) { byte[] assemblyRawBytes = new byte[stream.Length]; - stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length); + stream.ReadExactly(assemblyRawBytes); return Assembly.Load(assemblyRawBytes); } return null; diff --git a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj index 130a00c08..1cb8cb67f 100644 --- a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj +++ b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj @@ -1,12 +1,12 @@  - net462 + net8.0-windows WinExe TheArtOfDev.HtmlRenderer.Demo.WPF HtmlRendererWpfDemo true - false - true + true + true html.ico @@ -28,11 +28,4 @@ - - - - %(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension) - - - \ No newline at end of file diff --git a/Source/Demo/WPF/Properties/AssemblyInfo.cs b/Source/Demo/WPF/Properties/AssemblyInfo.cs deleted file mode 100644 index d5c8b4eb2..000000000 --- a/Source/Demo/WPF/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HTML Renderer WPF Demo")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HTML Renderer WPF Demo")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) - )] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Source/Demo/WinForms/DemoForm.cs b/Source/Demo/WinForms/DemoForm.cs index 3e7287b70..b408d3176 100644 --- a/Source/Demo/WinForms/DemoForm.cs +++ b/Source/Demo/WinForms/DemoForm.cs @@ -40,7 +40,7 @@ public partial class DemoForm : Form /// public DemoForm() { - SamplesLoader.Init(HtmlRenderingHelper.IsRunningOnMono() ? "Mono" : "WinForms", typeof(HtmlRender).Assembly.GetName().Version.ToString()); + SamplesLoader.Init("WinForms", typeof(HtmlRender).Assembly.GetName().Version.ToString()); InitializeComponent(); @@ -59,8 +59,8 @@ public DemoForm() LoadCustomFonts(); - _showIEViewTSSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); - _generatePdfTSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); + _showIEViewTSSB.Enabled = true; + _generatePdfTSB.Enabled = true; } /// @@ -145,10 +145,12 @@ private void OnGeneratePdf_Click(object sender, EventArgs e) config.SetMargins(20); var doc = PdfGenerator.GeneratePdf(_mainControl.GetHtml(), config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); + var tmpFile = Path.GetTempFileName(); - tmpFile = Path.GetFileNameWithoutExtension(tmpFile) + ".pdf"; - doc.Save(tmpFile); - Process.Start(tmpFile); + var pdfFile = Path.ChangeExtension(tmpFile, ".pdf"); // Preserves the full path + doc.Save(pdfFile); + + Process.Start(new ProcessStartInfo(pdfFile) { UseShellExecute = true }); } /// diff --git a/Source/Demo/WinForms/GenerateImageForm.cs b/Source/Demo/WinForms/GenerateImageForm.cs index 5f966a8f2..f4e8a4577 100644 --- a/Source/Demo/WinForms/GenerateImageForm.cs +++ b/Source/Demo/WinForms/GenerateImageForm.cs @@ -51,8 +51,8 @@ public GenerateImageForm(string html) } _textRenderingHintTSCB.SelectedItem = TextRenderingHint.AntiAlias.ToString(); - _useGdiPlusTSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); - _backgroundColorTSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); + _useGdiPlusTSB.Enabled = true; + _backgroundColorTSB.Enabled = true; } private void OnSaveToFile_Click(object sender, EventArgs e) @@ -103,7 +103,7 @@ private void GenerateImage() TextRenderingHint textRenderingHint = (TextRenderingHint)Enum.Parse(typeof(TextRenderingHint), _textRenderingHintTSCB.SelectedItem.ToString()); Image img; - if (_useGdiPlusTSB.Checked || HtmlRenderingHelper.IsRunningOnMono()) + if (_useGdiPlusTSB.Checked) { img = HtmlRender.RenderToImageGdiPlus(_html, _pictureBox.ClientSize, textRenderingHint, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoad); } diff --git a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj index 3485b7573..e6b47dcc7 100644 --- a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj +++ b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj @@ -1,14 +1,12 @@  - net462 + net8.0-windows WinExe TheArtOfDev.HtmlRenderer.Demo.WinForms HtmlRendererWinFormsDemo - publish\ true - AllRules.ruleset - false - true + true + true html.ico diff --git a/Source/Demo/WinForms/HtmlRenderingHelper.cs b/Source/Demo/WinForms/HtmlRenderingHelper.cs index 6be842af6..33b6ae5e7 100644 --- a/Source/Demo/WinForms/HtmlRenderingHelper.cs +++ b/Source/Demo/WinForms/HtmlRenderingHelper.cs @@ -32,15 +32,6 @@ internal static class HtmlRenderingHelper #endregion - - /// - /// Check if currently running in mono. - /// - public static bool IsRunningOnMono() - { - return Type.GetType("Mono.Runtime") != null; - } - /// /// Create image to be used to fill background so it will be clear that what's on top is transparent. /// diff --git a/Source/Demo/WinForms/MainControl.cs b/Source/Demo/WinForms/MainControl.cs index 696fc032c..c683e99e2 100644 --- a/Source/Demo/WinForms/MainControl.cs +++ b/Source/Demo/WinForms/MainControl.cs @@ -11,6 +11,7 @@ // "The Art of War" using System; +using System.ComponentModel; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -72,6 +73,8 @@ public MainControl() /// /// used ignore html editor updates when updating separately /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool UpdateLock { get { return _updateLock; } @@ -81,6 +84,8 @@ public bool UpdateLock /// /// In IE view if to show original html or the html generated from the html control /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool UseGeneratedHtml { get { return _useGeneratedHtml; } @@ -186,7 +191,7 @@ private void OnSamplesTreeViewAfterSelect(object sender, TreeViewEventArgs e) { _updateLock = true; - if (!HtmlRenderingHelper.IsRunningOnMono() && e.Node.Parent.Text != PerformanceSamplesTreeNodeName) + if (e.Node.Parent.Text != PerformanceSamplesTreeNodeName) SetColoredText(sample.Html); else _htmlEditor.Text = sample.Html; diff --git a/Source/Demo/WinForms/Program.cs b/Source/Demo/WinForms/Program.cs index f01eb6d0a..cba933ec4 100644 --- a/Source/Demo/WinForms/Program.cs +++ b/Source/Demo/WinForms/Program.cs @@ -14,6 +14,7 @@ using System.Globalization; using System.IO; using System.Reflection; +using System.Text; using System.Windows.Forms; namespace TheArtOfDev.HtmlRenderer.Demo.WinForms @@ -28,6 +29,8 @@ private static void Main() { AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly; + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DemoForm()); @@ -52,7 +55,7 @@ private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) if (stream != null) { byte[] assemblyRawBytes = new byte[stream.Length]; - stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length); + stream.ReadExactly(assemblyRawBytes); return Assembly.Load(assemblyRawBytes); } return null; diff --git a/Source/Demo/WinForms/Properties/AssemblyInfo.cs b/Source/Demo/WinForms/Properties/AssemblyInfo.cs deleted file mode 100644 index 2719715e7..000000000 --- a/Source/Demo/WinForms/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HTML Renderer WinForms Demo")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HTML Renderer WinForms Demo")] -[assembly: AssemblyCopyright("Copyright © 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("3098581d-210a-4748-bcda-4b9a6b34a91a")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props index 9574b2471..dfc83f317 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -1,15 +1,19 @@ - + HTML Renderer Arthur Teplitzki Arthur Teplitzki + Open source hosted on GitHub + Copyright © 2008-2025 + 1.6.0-dev + 1.6.0.0 + 1.6.0.0 README.md BSD-3-Clause https://codeplexarchive.org/project/HtmlRenderer html.png false See https://github.com/ArthurHub/HTML-Renderer/releases. - 1.6.0-dev false diff --git a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj index 524c96343..2ff483a96 100644 --- a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj +++ b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj @@ -1,10 +1,11 @@  - net462 + net8.0-windows Library TheArtOfDev.HtmlRenderer.PdfSharp - false - true + true + true + true @@ -25,9 +26,6 @@ Features and Benefits: PDF document generator from HTML snippet, 100% managed (C#), High performance library using PdfSharp. - - Properties\SharedAssemblyInfo.cs - @@ -35,5 +33,6 @@ Features and Benefits: + \ No newline at end of file diff --git a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj index 3080e1406..65d9f483f 100644 --- a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj +++ b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj @@ -1,11 +1,11 @@  - net462 + net8.0-windows Library TheArtOfDev.HtmlRenderer.WPF true - false - true + true + true @@ -31,9 +31,6 @@ Features and Benefits: * Extendable and configurable. Multipurpose (UI Controls / Image generation), 100% managed (C#), High performance HTML Rendering library for WPF. - - bin\Release.WPF\ - @@ -41,9 +38,6 @@ Features and Benefits: - - Properties\SharedAssemblyInfo.cs - \ No newline at end of file diff --git a/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs b/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs index 523870c2b..6b55d50f2 100644 --- a/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs +++ b/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs @@ -62,12 +62,10 @@ internal sealed class GraphicsAdapter : RGraphics /// private readonly bool _useGdiPlusTextRendering; -#if !MONO /// /// the initialized HDC used /// private IntPtr _hdc; -#endif /// /// if to release the graphics object on dispose @@ -107,11 +105,7 @@ public GraphicsAdapter(Graphics g, bool useGdiPlusTextRendering, bool releaseGra _g = g; _releaseGraphics = releaseGraphics; -#if MONO - _useGdiPlusTextRendering = true; -#else _useGdiPlusTextRendering = useGdiPlusTextRendering; -#endif } public override void PopClip() @@ -167,19 +161,13 @@ public override RSize MeasureString(string str, RFont font) { var height = realFont.Height; var descent = realFont.Size * realFont.FontFamily.GetCellDescent(realFont.Style) / realFont.FontFamily.GetEmHeight(realFont.Style); -#if !MONO fontAdapter.SetMetrics(height, (int)Math.Round((height - descent + .5f))); -#else - fontAdapter.SetMetrics(height, (int)Math.Round((height - descent + 1f))); -#endif - } return Utils.Convert(size); } else { -#if !MONO SetFont(font); var size = new Size(); Win32Utils.GetTextExtentPoint32(_hdc, str, str.Length, ref size); @@ -192,9 +180,6 @@ public override RSize MeasureString(string str, RFont font) } return Utils.Convert(size); -#else - throw new InvalidProgramException("Invalid Mono code"); -#endif } } @@ -220,14 +205,12 @@ public override void MeasureString(string str, RFont font, double maxWidth, out } else { -#if !MONO SetFont(font); var size = new Size(); Win32Utils.GetTextExtentExPoint(_hdc, str, str.Length, (int)Math.Round(maxWidth), _charFit, _charFitWidth, ref size); charFit = _charFit[0]; charFitWidth = charFit > 0 ? _charFitWidth[charFit - 1] : 0; -#endif } } @@ -242,7 +225,6 @@ public override void DrawString(string str, RFont font, RColor color, RPoint poi } else { -#if !MONO var pointConv = Utils.ConvertRound(point); var colorConv = Utils.Convert(color); @@ -260,7 +242,6 @@ public override void DrawString(string str, RFont font, RColor color, RPoint poi SetRtlAlignGdi(rtl); DrawTransparentText(_hdc, str, font, pointConv, Utils.ConvertRound(size), colorConv); } -#endif } } @@ -349,17 +330,14 @@ public override void DrawPolygon(RBrush brush, RPoint[] points) /// private void ReleaseHdc() { -#if !MONO if (_hdc != IntPtr.Zero) { Win32Utils.SelectClipRgn(_hdc, IntPtr.Zero); _g.ReleaseHdc(_hdc); _hdc = IntPtr.Zero; } -#endif } -#if !MONO /// /// Init HDC for the current graphics object to be used to call GDI directly. /// @@ -448,7 +426,6 @@ private static void DrawTransparentText(IntPtr hdc, string str, RFont font, Poin Win32Utils.ReleaseMemoryHdc(memoryHdc, dib); } } -#endif /// /// Change text align to Left-to-Right or Right-to-Left if required. diff --git a/Source/HtmlRenderer.WinForms/HtmlLabel.cs b/Source/HtmlRenderer.WinForms/HtmlLabel.cs index 8853490d2..283ef7360 100644 --- a/Source/HtmlRenderer.WinForms/HtmlLabel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlLabel.cs @@ -295,6 +295,7 @@ public virtual bool IsContextMenuEnabled [Browsable(true)] [Description("Set base stylesheet to be used by html rendered in the control.")] [Category("Appearance")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public virtual string BaseStylesheet { @@ -487,7 +488,7 @@ protected override void OnLayout(LayoutEventArgs levent) { if (_htmlContainer != null) { - Graphics g = Utils.CreateGraphics(this); + Graphics g = CreateGraphics(); if (g != null) { using (g) @@ -788,6 +789,7 @@ public override Cursor Cursor /// Not applicable. /// [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new bool UseWaitCursor { get { return base.UseWaitCursor; } diff --git a/Source/HtmlRenderer.WinForms/HtmlPanel.cs b/Source/HtmlRenderer.WinForms/HtmlPanel.cs index ce94b0ea9..a2f061874 100644 --- a/Source/HtmlRenderer.WinForms/HtmlPanel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlPanel.cs @@ -303,6 +303,7 @@ public virtual bool IsContextMenuEnabled [Browsable(true)] [Category("Appearance")] [Description("Set base stylesheet to be used by html rendered in the control.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public virtual string BaseStylesheet { @@ -418,10 +419,8 @@ public void ClearSelection() _htmlContainer.ClearSelection(); } - #region Private methods -#if !MONO /// /// Override to support border for the control. /// @@ -445,7 +444,6 @@ protected override CreateParams CreateParams return createParams; } } -#endif /// /// Perform the layout of the html in the control. @@ -473,7 +471,7 @@ protected void PerformHtmlLayout() { _htmlContainer.MaxSize = new SizeF(ClientSize.Width - Padding.Horizontal, 0); - Graphics g = Utils.CreateGraphics(this); + Graphics g = CreateGraphics(); if (g != null) { using (g) @@ -482,7 +480,6 @@ protected void PerformHtmlLayout() } } - AutoScrollMinSize = Size.Round(new SizeF(_htmlContainer.ActualSize.Width + Padding.Horizontal, _htmlContainer.ActualSize.Height)); } } @@ -708,15 +705,12 @@ protected virtual void InvokeMouseMove() { try { - // mono has issue throwing exception for no reason var mp = PointToClient(MousePosition); _htmlContainer.HandleMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, mp.X, mp.Y, 0)); } catch { -#if !MONO throw; -#endif } } @@ -741,7 +735,6 @@ protected override bool IsInputKey(Keys keyData) return base.IsInputKey(keyData); } -#if !MONO /// /// Override the proc processing method to set OS specific hand cursor. /// @@ -765,7 +758,6 @@ protected override void WndProc(ref Message m) } base.WndProc(ref m); } -#endif /// /// Release the html container resources. @@ -890,6 +882,7 @@ public override Cursor Cursor /// Not applicable. /// [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new bool UseWaitCursor { get { return base.UseWaitCursor; } diff --git a/Source/HtmlRenderer.WinForms/HtmlRender.cs b/Source/HtmlRenderer.WinForms/HtmlRender.cs index b7e24d81e..ca0f44532 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRender.cs +++ b/Source/HtmlRenderer.WinForms/HtmlRender.cs @@ -134,7 +134,6 @@ public static CssData ParseStyleSheet(string stylesheet, bool combineWithDefault return CssData.Parse(WinFormsAdapter.Instance, stylesheet, combineWithDefault); } -#if !MONO /// /// Measure the size (width and height) required to draw the given html under given max width restriction.
/// If no max width restriction is given the layout will use the maximum possible width required by the content, @@ -154,7 +153,6 @@ public static SizeF Measure(Graphics g, string html, float maxWidth = 0, CssData ArgChecker.AssertArgNotNull(g, "g"); return Measure(g, html, maxWidth, cssData, false, stylesheetLoad, imageLoad); } -#endif /// /// Measure the size (width and height) required to draw the given html under given max width restriction.
@@ -176,7 +174,6 @@ public static SizeF MeasureGdiPlus(Graphics g, string html, float maxWidth = 0, return Measure(g, html, maxWidth, cssData, true, stylesheetLoad, imageLoad); } -#if !MONO /// /// Renders the specified HTML source on the specified location and max width restriction.
/// Use GDI text rendering, note has no effect.
@@ -223,7 +220,6 @@ public static SizeF Render(Graphics g, string html, PointF location, SizeF maxSi ArgChecker.AssertArgNotNull(g, "g"); return RenderClip(g, html, location, maxSize, cssData, false, stylesheetLoad, imageLoad); } -#endif /// /// Renders the specified HTML source on the specified location and max size restriction.
@@ -272,8 +268,6 @@ public static SizeF RenderGdiPlus(Graphics g, string html, PointF location, Size return RenderClip(g, html, location, maxSize, cssData, true, stylesheetLoad, imageLoad); } -#if !MONO - public static Metafile RenderToMetafile(string html, float left = 0, float top = 0, float maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -511,7 +505,6 @@ public static void RenderToImage(Image image, string html, PointF location, Size return image; } } -#endif /// /// Renders the specified HTML into a new image of the requested size.
@@ -764,7 +757,6 @@ private static SizeF RenderHtml(Graphics g, string html, PointF location, SizeF return actualSize; } -#if !MONO /// /// Copy all the bitmap bits from memory bitmap buffer to the given image. /// @@ -779,7 +771,6 @@ private static void CopyBufferToImage(IntPtr memoryHdc, Image image) imageGraphics.ReleaseHdc(imgHdc); } } -#endif #endregion } diff --git a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj index 2e6c9dbf4..51aec7512 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj +++ b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj @@ -1,12 +1,11 @@  - net462 + net8.0-windows Library TheArtOfDev.HtmlRenderer.WinForms - publish\ true - false - true + true + true @@ -31,18 +30,7 @@ Features and Benefits: * Extendable and configurable. Multipurpose (UI Controls / Image generation), 100% managed (C#), High performance HTML Rendering library for WinForms. - - bin\Debug\ - AllRules.ruleset - - - bin\Release\ - AllRules.ruleset - - - Properties\SharedAssemblyInfo.cs - Component diff --git a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs index 40d7ab6ca..2a82209bd 100644 --- a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs +++ b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs @@ -53,8 +53,6 @@ public class HtmlToolTip : ToolTip ///
private string _tooltipCssClass = "htmltooltip"; -#if !MONO - /// /// the control that the tooltip is currently showing on.
/// Used for link handling. @@ -79,7 +77,6 @@ public class HtmlToolTip : ToolTip /// if clicked the event will be raised although the tooltip will be closed. ///
private bool _allowLinksHandling = true; -#endif #endregion @@ -104,22 +101,18 @@ public HtmlToolTip() Draw += OnToolTipDraw; Disposed += OnToolTipDisposed; -#if !MONO _linkHandlingTimer = new Timer(); _linkHandlingTimer.Tick += OnLinkHandlingTimerTick; _linkHandlingTimer.Interval = 40; _htmlContainer.LinkClicked += OnLinkClicked; -#endif } -#if !MONO /// /// Raised when the user clicks on a link in the html.
/// Allows canceling the execution of the link. ///
public event EventHandler LinkClicked; -#endif /// /// Raised when an error occurred during html rendering.
@@ -181,6 +174,7 @@ public TextRenderingHint TextRenderingHint [Browsable(true)] [Description("Set base stylesheet to be used by html rendered in the tooltip.")] [Category("Appearance")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public virtual string BaseStylesheet { @@ -200,13 +194,13 @@ public virtual string BaseStylesheet [Browsable(true)] [Description("The CSS class used for tooltip html root div.")] [Category("Appearance")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public virtual string TooltipCssClass { get { return _tooltipCssClass; } set { _tooltipCssClass = value; } } -#if !MONO /// /// If to handle links in the tooltip (default: false).
/// When set to true the mouse pointer will change to hand when hovering over a tooltip and @@ -221,7 +215,6 @@ public virtual bool AllowLinksHandling get { return _allowLinksHandling; } set { _allowLinksHandling = value; } } -#endif /// /// Gets or sets the max size the tooltip. @@ -230,6 +223,7 @@ public virtual bool AllowLinksHandling [Browsable(true)] [Category("Layout")] [Description("Restrict the max size of the shown tooltip (0 is not restricted)")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public virtual Size MaximumSize { get { return Size.Round(_htmlContainer.MaxSize); } @@ -262,14 +256,12 @@ protected virtual void OnToolTipPopup(PopupEventArgs e) var desiredHeight = (int)Math.Ceiling(MaximumSize.Height > 0 ? Math.Min(_htmlContainer.ActualSize.Height, MaximumSize.Height) : _htmlContainer.ActualSize.Height); e.ToolTipSize = new Size(desiredWidth, desiredHeight); -#if !MONO // start mouse handle timer if (_allowLinksHandling) { _associatedControl = e.AssociatedControl; _linkHandlingTimer.Start(); } -#endif } /// @@ -277,7 +269,6 @@ protected virtual void OnToolTipPopup(PopupEventArgs e) /// protected virtual void OnToolTipDraw(DrawToolTipEventArgs e) { -#if !MONO if (_tooltipHandle == IntPtr.Zero) { // get the handle of the tooltip window using the graphics device context @@ -287,7 +278,6 @@ protected virtual void OnToolTipDraw(DrawToolTipEventArgs e) AdjustTooltipPosition(e.AssociatedControl, e.Bounds.Size); } -#endif e.Graphics.Clear(Color.White); e.Graphics.TextRenderingHint = _textRenderingHint; @@ -313,13 +303,10 @@ protected virtual void AdjustTooltipPosition(Control associatedControl, Size siz if (mousePos.Y + size.Height + yOffset > screenBounds.Bottom) mousePos.Y = Math.Max(screenBounds.Bottom - size.Height - yOffset - 3, screenBounds.Top + 2); -#if !MONO // move the tooltip window to new location Win32Utils.MoveWindow(_tooltipHandle, mousePos.X, mousePos.Y + yOffset, size.Width, size.Height, false); -#endif } -#if !MONO /// /// Propagate the LinkClicked event from root container. /// @@ -329,7 +316,6 @@ protected virtual void OnLinkClicked(HtmlLinkClickedEventArgs e) if (handler != null) handler(this, e); } -#endif /// /// Propagate the Render Error event from root container. @@ -361,7 +347,6 @@ protected virtual void OnImageLoad(HtmlImageLoadEventArgs e) handler(this, e); } -#if !MONO /// /// Raised on link handling timer tick, used for: /// 1. Know when the tooltip is hidden by checking the visibility of the tooltip window. @@ -407,7 +392,6 @@ protected virtual void OnLinkHandlingTimerTick(EventArgs e) OnRenderError(this, new HtmlRenderErrorEventArgs(HtmlRenderErrorType.General, "Error in link handling for tooltip", ex)); } } -#endif /// /// Unsubscribe from events and dispose of . @@ -427,7 +411,6 @@ protected virtual void OnToolTipDisposed(EventArgs e) _htmlContainer = null; } -#if !MONO if (_linkHandlingTimer != null) { _linkHandlingTimer.Dispose(); @@ -436,7 +419,6 @@ protected virtual void OnToolTipDisposed(EventArgs e) if (_htmlContainer != null) _htmlContainer.LinkClicked -= OnLinkClicked; } -#endif } @@ -466,7 +448,6 @@ private void OnImageLoad(object sender, HtmlImageLoadEventArgs e) OnImageLoad(e); } -#if !MONO private void OnLinkClicked(object sender, HtmlLinkClickedEventArgs e) { OnLinkClicked(e); @@ -475,7 +456,6 @@ private void OnLinkHandlingTimerTick(object sender, EventArgs e) { OnLinkHandlingTimerTick(e); } -#endif private void OnToolTipDisposed(object sender, EventArgs e) { diff --git a/Source/HtmlRenderer.WinForms/Utilities/Utils.cs b/Source/HtmlRenderer.WinForms/Utilities/Utils.cs index 9f25b6045..026102976 100644 --- a/Source/HtmlRenderer.WinForms/Utilities/Utils.cs +++ b/Source/HtmlRenderer.WinForms/Utilities/Utils.cs @@ -12,7 +12,6 @@ using System; using System.Drawing; -using System.Windows.Forms; using TheArtOfDev.HtmlRenderer.Adapters.Entities; namespace TheArtOfDev.HtmlRenderer.WinForms.Utilities @@ -120,26 +119,5 @@ public static Color Convert(RColor c) { return Color.FromArgb(c.A, c.R, c.G, c.B); } - - /// - /// mono has issue throwing exception for no reason. - /// - /// the control to create graphics object from - /// new graphics object or null in mono if failed - public static Graphics CreateGraphics(Control control) - { -#if MONO - try - { - return control.CreateGraphics(); - } - catch - { - return null; - } -#else - return control.CreateGraphics(); -#endif - } } } \ No newline at end of file diff --git a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs index 33dddd53f..228e47658 100644 --- a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs +++ b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs @@ -10,7 +10,6 @@ // - Sun Tsu, // "The Art of War" -#if !MONO using System; using System.Drawing; using System.Runtime.InteropServices; @@ -248,5 +247,4 @@ internal struct TextMetric public byte tmPitchAndFamily; public byte tmCharSet; } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Source/HtmlRenderer.sln b/Source/HtmlRenderer.sln index 92aea3d46..c6594f4d7 100644 --- a/Source/HtmlRenderer.sln +++ b/Source/HtmlRenderer.sln @@ -1,23 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 18 -VisualStudioVersion = 18.1.11312.151 d18.0 +VisualStudioVersion = 18.1.11312.151 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demo", "Demo", "{E263EA16-2E6A-4269-A319-AA2F97ADA8E1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Demo.Common", "Demo\Common\HtmlRenderer.Demo.Common.csproj", "{2390B71F-9400-47F4-B23A-7F2649C87D35}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.Demo.Common", "Demo\Common\HtmlRenderer.Demo.Common.csproj", "{2390B71F-9400-47F4-B23A-7F2649C87D35}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Demo.WinForms", "Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj", "{8AD34FE8-8382-4A8A-B3AA-A0392ED42423}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.Demo.WinForms", "Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj", "{8AD34FE8-8382-4A8A-B3AA-A0392ED42423}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Demo.WPF", "Demo\WPF\HtmlRenderer.Demo.WPF.csproj", "{F02E0216-4AE3-474F-9381-FCB93411CDB0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.Demo.WPF", "Demo\WPF\HtmlRenderer.Demo.WPF.csproj", "{F02E0216-4AE3-474F-9381-FCB93411CDB0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.WinForms", "HtmlRenderer.WinForms\HtmlRenderer.WinForms.csproj", "{1B058920-24B4-4140-8AE7-C8C6C38CA52D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.WinForms", "HtmlRenderer.WinForms\HtmlRenderer.WinForms.csproj", "{1B058920-24B4-4140-8AE7-C8C6C38CA52D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.WPF", "HtmlRenderer.WPF\HtmlRenderer.WPF.csproj", "{7E4E8DB5-85AD-4388-BDCB-38C6F423B8B0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.WPF", "HtmlRenderer.WPF\HtmlRenderer.WPF.csproj", "{7E4E8DB5-85AD-4388-BDCB-38C6F423B8B0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer", "HtmlRenderer\HtmlRenderer.csproj", "{FE611685-391F-4E3E-B27E-D3150E51E49B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer", "HtmlRenderer\HtmlRenderer.csproj", "{FE611685-391F-4E3E-B27E-D3150E51E49B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.PdfSharp", "HtmlRenderer.PdfSharp\HtmlRenderer.PdfSharp.csproj", "{CA249F5D-9285-40A6-B217-5889EF79FD7E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.PdfSharp", "HtmlRenderer.PdfSharp\HtmlRenderer.PdfSharp.csproj", "{CA249F5D-9285-40A6-B217-5889EF79FD7E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -108,4 +108,7 @@ Global {8AD34FE8-8382-4A8A-B3AA-A0392ED42423} = {E263EA16-2E6A-4269-A319-AA2F97ADA8E1} {F02E0216-4AE3-474F-9381-FCB93411CDB0} = {E263EA16-2E6A-4269-A319-AA2F97ADA8E1} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {902788D6-3165-491D-B860-DF2F74E66C1D} + EndGlobalSection EndGlobal diff --git a/Source/HtmlRenderer/HtmlRenderer.csproj b/Source/HtmlRenderer/HtmlRenderer.csproj index b8576e129..273dcccf8 100644 --- a/Source/HtmlRenderer/HtmlRenderer.csproj +++ b/Source/HtmlRenderer/HtmlRenderer.csproj @@ -1,34 +1,31 @@  - net462 + netstandard2.0;net8.0 Library TheArtOfDev.HtmlRenderer - false - true + true + true HtmlRenderer.Core HTML Renderer Core html render renderer draw core - Cross framework (WinForms/WPF/PDF/Metro/Mono/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. + Cross framework (WinForms/WPF/PDF/Metro/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. The Core assembly of HTML Renderer does not bound to any rendering framework (WinForms/WPF/PDF/etc.). Can be used to create framework specific renderer using adapter extensibility object model. For existing implementations see: HtmlRenderer.WinForms, HtmlRenderer.WPF and HtmlRenderer.PdfSharp. - Cross framework (WinForms/WPF/PDF/Metro/Mono/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. + Cross framework (WinForms/WPF/PDF/Metro/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. - - Properties\SharedAssemblyInfo.cs - - + \ No newline at end of file diff --git a/Source/SharedAssemblyInfo.cs b/Source/SharedAssemblyInfo.cs deleted file mode 100644 index 64944c19b..000000000 --- a/Source/SharedAssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HTML Renderer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Open source hosted on GitHub")] -[assembly: AssemblyProduct("HTML Renderer")] -[assembly: AssemblyCopyright("Copyright © 2008-2025")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("ec8a9e7e-9a9d-43c3-aa97-f6f505b1d3ed")] - -// Version information for an assembly consists of the following four values: - -[assembly: AssemblyVersion("1.6.0.0")] \ No newline at end of file