#region PDFsharp - A .NET library for processing PDF // // Authors: // Stefan Lange // // Copyright (c) 2005-2017 empira Software GmbH, Cologne Area (Germany) // // http://www.pdfsharp.com // http://sourceforge.net/projects/pdfsharp // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #endregion using System; #if GDI using System.Drawing; #endif #if WPF using System.Windows; #endif using System.Diagnostics; using PdfSharp.Drawing; using PdfSharp.Fonts; namespace PdfSharp.Internal { /// /// A bunch of internal helper functions. /// internal static class DiagnosticsHelper { public static void HandleNotImplemented(string message) { string text = "Not implemented: " + message; switch (Diagnostics.NotImplementedBehaviour) { case NotImplementedBehaviour.DoNothing: break; case NotImplementedBehaviour.Log: Logger.Log(text); break; case NotImplementedBehaviour.Throw: ThrowNotImplementedException(text); break; default: throw new ArgumentOutOfRangeException(); } } /// /// Indirectly throws NotImplementedException. /// Required because PDFsharp Release builds tread warnings as errors and /// throwing NotImplementedException may lead to unreachable code which /// crashes the build. /// public static void ThrowNotImplementedException(string message) { throw new NotImplementedException(message); } } internal static class Logger { public static void Log(string format, params object[] args) { Debug.WriteLine("Log..."); } } class Logging { } class Tracing { [Conditional("DEBUG")] public void Foo() { } } /// /// Helper class around the Debugger class. /// public static class DebugBreak { /// /// Call Debugger.Break() if a debugger is attached. /// public static void Break() { Break(false); } /// /// Call Debugger.Break() if a debugger is attached or when always is set to true. /// public static void Break(bool always) { #if DEBUG if (always || Debugger.IsAttached) Debugger.Break(); #endif } } /// /// Internal stuff for development of PDFsharp. /// public static class FontsDevHelper { /// /// Creates font and enforces bold/italic simulation. /// public static XFont CreateSpecialFont(string familyName, double emSize, XFontStyle style, XPdfFontOptions pdfOptions, XStyleSimulations styleSimulations) { return new XFont(familyName, emSize, style, pdfOptions, styleSimulations); } /// /// Dumps the font caches to a string. /// public static string GetFontCachesState() { return FontFactory.GetFontCachesState(); } } }