Пример #1
0
 ///<summary>Call this method to return a custom value for DateTime_.Now. If not called, will return the real DateTime.Now.</summary>
 public static void SetNow(Func <DateTime> getNow)
 {
     if (!ODBuild.IsDebug())
     {
         throw new Exception("Not allowed to change DateTime_.Now in release.");
     }
     IsNowModified = true;
     _getNow       = getNow;
 }
Пример #2
0
 ///<summary>Gets a PrintDocument that has some added functionality.  All printing in Open Dental should use this method (or an ODprintout object) for printing.</summary>
 ///<param name="printPageEventHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
 ///<param name="printSit">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="auditPatNum">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="auditDescription">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
 ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
 ///<param name="paperSize">When set, this will override the default paperSize of "new PaperSize("default",850,1100)".</param>
 ///<param name="totalPages">When creating an ODprintout for print previewing, this defines the total number of pages.</param>
 ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
 ///<param name="duplex">Typically set when performing double-sided printing.</param>
 ///<param name="copies">Gets or sets the number of copies of the document to print.</param>
 ///<param name="totalPages">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed. Defaults to 1.</param>
 ///<param name="printOrPreviewExceptionDelegate">Any custom delegate that the calling method wants to happen when printing or previewing throws an exception.</param>
 ///<param name="tryPreviewDelegate">Required to be implemented if the calling method needs the ability to preview.</param>
 ///<param name="tryPrintOrDebugPreviewDelegate">Same as tryPreviewDelegate, but defines isPreview based on if program is in DEBUG mode.</param>
 ///<returns>A new ODprintout with the given args that serves as a conduit safe printing and previewing methods.</returns>
 public ODprintout(PrintPageEventHandler printPageEventHandler = null, PrintSituation printSit = PrintSituation.Default, long auditPatNum = 0, string auditDescription   = ""
                   , Margins margins = null, PrintoutOrigin printoutOrigin = PrintoutOrigin.Default, PaperSize paperSize = null, PrintoutOrientation printoutOrientation = PrintoutOrientation.Default
                   , Duplex duplex   = Duplex.Default, short copies        = 1, int totalPages = 1) : base()
 {
     CurPrintout = this;
     _printDoc   = new PrintDocument();
     //if(InitPrintSettings!=null) {
     //	_printDoc.PrinterSettings=InitPrintSettings;
     //	InitPrintSettings=null;
     //}
     Situation        = printSit;
     AuditPatNum      = auditPatNum;
     AuditDescription = auditDescription;
     TotalPages       = totalPages;
     if (!HasValidSettings)
     {
         return;
     }
     _printDoc.PrintPage += printPageEventHandler;
     if (printoutOrientation != PrintoutOrientation.Default)
     {
         _printDoc.DefaultPageSettings.Landscape = (printoutOrientation == PrintoutOrientation.Landscape)?true:false;
     }
     if (printoutOrigin != PrintoutOrigin.Default)
     {
         _printDoc.OriginAtMargins = (printoutOrigin == PrintoutOrigin.AtMargin)?true:false;
     }
     _printDoc.DefaultPageSettings.Margins = (margins ?? new Margins(25, 25, 40, 40));
     if (paperSize == null)
     {
         //This prevents a bug caused by some printer drivers not reporting their papersize.
         //But remember that other countries use A4 paper instead of 8 1/2 x 11.
         if ((InvalidMinDefaultPageWidth != -1 && _printDoc.DefaultPageSettings.PrintableArea.Width <= InvalidMinDefaultPageWidth) ||
             (InvalidMinDefaultPageHeight != -1 && _printDoc.DefaultPageSettings.PrintableArea.Height <= InvalidMinDefaultPageHeight))
         {
             _printDoc.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
         }
         InvalidMinDefaultPageHeight = 0;
         InvalidMinDefaultPageWidth  = -1;
     }
     else
     {
         _printDoc.DefaultPageSettings.PaperSize = paperSize;
     }
     _printDoc.PrinterSettings.Copies = copies;
     if (duplex != Duplex.Default)
     {
         _printDoc.PrinterSettings.Duplex = duplex;
     }
     if (ODBuild.IsWeb())
     {
         //https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Printing/PrintDocument.cs,3f3c2622b65be86a
         //The PrintController property will create a PrintControllerWithStatusDialog if no print controller is explictly set.
         _printDoc.PrintController = new StandardPrintController();              //Default PrintController shows a dialog that locks up web.
     }
 }
Пример #3
0
 ///<summary>Write the given text to the given file.
 ///If using a WEB compiled version of Open Dental, pass through to the odcloud client for File IO.</summary>
 public static void WriteAllText(string filePath, string text)
 {
     if (ODBuild.IsWeb())
     {
         ODCloudClient.LaunchFileWithODCloudClient(extraFilePath: filePath, extraFileData: text);
     }
     else
     {
         File.WriteAllText(filePath, text);
     }
 }
Пример #4
0
 ///<summary>Writes the text to the user's clipboard.</summary>
 public static void SetClipboard(string text)
 {
     if (ODBuild.IsWeb())
     {
         ODCloudClient.SendDataToBrowser(text, (int)ODCloudClient.BrowserAction.SetClipboard);
     }
     else
     {
         Clipboard.SetText(text);
     }
 }
Пример #5
0
 ///<summary>Start the given process.
 ///If using a WEB compiled version of Open Dental, pass through to the odcloud client to start the process locally.</summary>
 public static void ProcessStart(Process process)
 {
     if (ODBuild.IsWeb())
     {
         //We will only use the FileName and Arguments from the process's StartInfo.  Only non-web builds utilize the entire process.
         ProcessStart(process.StartInfo.FileName, process.StartInfo.Arguments);
     }
     else
     {
         process.Start();
     }
 }
Пример #6
0
 ///<summary>Write the given text to the given file, then start a new process with the given path.
 ///If using a WEB compiled version of Open Dental, pass through to the odcloud client for File IO and to start the process locally.</summary>
 public static Process WriteAllTextThenStart(string filePath, string fileText, string processPath, string commandLineArgs)
 {
     if (ODBuild.IsWeb())
     {
         ODCloudClient.LaunchFileWithODCloudClient(processPath, commandLineArgs, filePath, fileText);
         return(null);
     }
     else
     {
         File.WriteAllText(filePath, fileText);
         return(Process.Start(processPath, commandLineArgs));
     }
 }
Пример #7
0
 ///<summary>Write the given text to the given file, then start a new process with the given path.
 ///If using a WEB compiled version of Open Dental, pass through to the odcloud client for File IO and to start the process locally.</summary>
 public static Process WriteAllTextThenStart(string filePath, string fileText, Encoding encoding, string processPath, string commandLineArgs)
 {
     if (ODBuild.IsWeb())
     {
         //Purposefully omit encoding.  This can be an enhancement if needed.
         ODCloudClient.LaunchFileWithODCloudClient(processPath, commandLineArgs, filePath, fileText);
         return(null);
     }
     else
     {
         File.WriteAllText(filePath, fileText, encoding);
         return(Process.Start(processPath, commandLineArgs));
     }
 }
Пример #8
0
 ///<summary>Start a new process with the given path and arguments.
 ///If using a WEB compiled version of Open Dental, pass through to the odcloud client to start the process locally.</summary>
 ///<param name="doWaitForODCloudClientResponse">If true, will wait for ODCloudClient and throw any exceptions from it.</param>
 ///<param name="createDirIfNeeded">If included, will create the directory if it doesn't exist.</param>
 public static Process ProcessStart(string path, string commandLineArgs = "", bool doWaitForODCloudClientResponse = false, string createDirIfNeeded = "")
 {
     if (ODBuild.IsWeb())
     {
         ODCloudClient.LaunchFileWithODCloudClient(path, commandLineArgs, doWaitForResponse: doWaitForODCloudClientResponse,
                                                   createDirIfNeeded: createDirIfNeeded);
         return(null);
     }
     if (!string.IsNullOrEmpty(createDirIfNeeded) && !Directory.Exists(createDirIfNeeded))
     {
         Directory.CreateDirectory(createDirIfNeeded);
     }
     return(Process.Start(path, commandLineArgs));
 }
Пример #9
0
 ///<summary>Write the given filebytes and launches a file.</summary>
 ///<param name="filePath">The location to write the bytes to.</param>
 ///<param name="fileBytes">The bytes to write to the file.</param>
 ///<param name="processPath">The path of the file to launch.</param>
 ///<param name="commandLineArgs">Command line arguments to pass to processPath.</param>
 public static Process WriteAllBytesThenStart(string filePath, byte[] fileBytes, string processPath, string commandLineArgs)
 {
     if (ODBuild.IsWeb())
     {
         string byteString = Convert.ToBase64String(fileBytes);
         ODCloudClient.LaunchFileWithODCloudClient(processPath, commandLineArgs, filePath, byteString, "binary");
         return(null);
     }
     else
     {
         File.WriteAllBytes(filePath, fileBytes);
         if (!string.IsNullOrEmpty(processPath))
         {
             return(Process.Start(processPath, commandLineArgs));
         }
         return(Process.Start(filePath, commandLineArgs));
     }
 }