Example #1
0
        static void Main(string[] args)
        {
            BlackAndWhitePrinter bawPrinter = new BlackAndWhitePrinter();
            Secretary            eva        = new Secretary(bawPrinter);

            eva.Print("Secretary's bill");

            Console.WriteLine();

            ColourPrinter cPrinter    = new ColourPrinter();
            Director      herrSchulte = new Director(cPrinter);

            herrSchulte.Print("Director's order");

            Console.WriteLine();

            MatrixPrinter mPrinter = new MatrixPrinter();
            Trainee       kevin    = new Trainee(mPrinter);

            kevin.Print("Trainee's project");

            Console.WriteLine();

            PDFPrinter pdfPrinter = new PDFPrinter();
            Developer  heiko      = new Developer(pdfPrinter);

            heiko.Print("Developer's source code");

            Console.ReadKey();
        }
 private void ButtonPrint_Click(object sender, RoutedEventArgs e)
 {
     if (null != pdf_renderer_control_stats && null != pdf_renderer_control_stats.pdf_document)
     {
         PDFPrinter.Print(pdf_renderer_control_stats.pdf_document, pdf_renderer_control_stats.pdf_document.PDFRenderer, "PDFRenderer");
     }
 }
        private void ProcessFiles(String Destination)
        {
            while (State == EXPDFConverterState.Working && !_Aborting)
            {
                FileConversionUpdate _FileConversionUpdate = null;

                try
                {
                    _FileConversionUpdate = new FileConversionUpdate(_FileConversionQueue.GetNext( ));

                    _DocumentsToPrint.Add(_ConvertDocument(_FileConversionUpdate, Destination));

                    _InvokeFileProgressUpdateEvent(_FileConversionUpdate);
                }
                catch (Exception Ex)
                {
                    if (_FileConversionUpdate is null)
                    {
                        _FileConversionUpdate = new FileConversionUpdate(null);

                        _FileConversionUpdate.AddTransformation(new FileTransformation(EFileTransformation.Failed,
                                                                                       _FileConversionUpdate.Original,
                                                                                       null,
                                                                                       new StateEventArgs(ESourceState.Unstable, Ex)));
                    }

                    _InvokeFileProgressUpdateEvent(_FileConversionUpdate);
                }


                if (_FileConversionQueue.PercentItterated == 1)
                {
                    if (PrintDocuments)
                    {
                        Parallel.ForEach <String>(_DocumentsToPrint,
                                                  new Action <String, ParallelLoopState>((String _Document, ParallelLoopState state) =>
                        {
                            if (_Aborting)
                            {
                                state.Break( );
                            }
                            else
                            {
                                if (!String.IsNullOrEmpty(_Document))
                                {
                                    PDFPrinter.Print(_Document, Settings.Default.SelectedPrinter);
                                    Log.Commit("Sent To Printer:\t" + _Document);
                                }
                            }
                        }));

                        Log.Commit( );
                        Log.Commit( );
                    }

                    SetState(EXPDFConverterState.Available);
                }
            }
        }
        private void ButtonPrint_Click(object sender, RoutedEventArgs e)
        {
            PDFDocument pdf_document = GetPDFDocument();

            ASSERT.Test(pdf_document != null);

            if (null != pdf_document)
            {
                PDFPrinter.Print(pdf_document, "PDFRenderer");
            }
        }
 void OK()
 {
     foreach (var item in PDFFilesToPrint)
     {
         if (item.ToLower().Contains(".pdf") && PDFPrinter != null)
         {
             PDFPrinter.Print(item, SelectedPrinter, IsSetDuplex);
         }
         else if (ExcelPrinter != null)
         {
             ExcelPrinter.Print(item, SelectedPrinter, IsSetDuplex);
         }
     }
 }
Example #6
0
 private void buttonSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         this.Close();
         LocalParameters.username = txtBoxName.Text;
         PDFPrinter pdfPrint = new PDFPrinter();
         pdfPrint.PrintPDF();
         localCon.LocalAddRecord();
         LocalParameters.RestoreParameters();
         LogWriter.LogWrite("Added to SQLite DB.");
     }
     catch (Exception g)
     {
         MessageBox.Show(g.Message);
         LogWriter.LogWrite(g.ToString());
     }
 }
Example #7
0
        private static void OpenClosed()
        {
            //MessyCode
            WriteLine("Basic implementation");
            ReadLine();
            PDFPrinter generatePDF = new PDFPrinter();

            generatePDF.GenerateSurveyPDF(12);
            ReadLine();

            //CleanCode
            IPrinter friendlyPrinter = new FriendlyMessagePrinter();

            WriteLine("Friendly implementation");
            ReadLine();
            friendlyPrinter.GenerateSurveyPDF(29);
            ReadLine();
            IPrinter basicPrinter = new BasicMessagePrinter();

            WriteLine("Basic implementation");
            ReadLine();
            basicPrinter.GenerateSurveyPDF(40);
            ReadLine();
        }
 public void PrintPDF()
 {
     PDFPrinter printer = new PDFPrinter();//smell - Rectangle has a dependnecy on PDFPrinter
     //etc
 }
 public Developer(PDFPrinter printer)
 {
     this._Printer = printer;
 }
 public PDFPrintCommand(PDFPrinter printer)
 {
     this._Printer = printer;
 }
        static void Main(string[] args)
        {
            #region EMPLOYEES

            Secretary eva         = new Secretary();
            Director  herrSchulte = new Director();
            Developer heiko       = new Developer();
            Trainee   kevin       = new Trainee();

            #endregion

            #region PRINTER

            BlackAndWhitePrinter bwPrinter  = new BlackAndWhitePrinter();
            ColourPrinter        cPrinter   = new ColourPrinter();
            MatrixPrinter        mPrinter   = new MatrixPrinter();
            PDFPrinter           pdfPrinter = new PDFPrinter();

            #endregion

            #region PRINT COMMANDS

            IPrintCommand blackAndWhitePrintCommand = new BlackAndWhitePrintCommand(bwPrinter);
            IPrintCommand colourPrintCommand        = new ColourPrintCommand(cPrinter);
            IPrintCommand matrixPrintCommand        = new MatrixPrintCommand(mPrinter);
            IPrintCommand pdfPrintCommand           = new PDFPrintCommand(pdfPrinter);

            PrintQueueCommand printQueueCommand = new PrintQueueCommand();
            printQueueCommand.AddCommand(blackAndWhitePrintCommand);
            printQueueCommand.AddCommand(colourPrintCommand);
            printQueueCommand.AddCommand(matrixPrintCommand);
            printQueueCommand.AddCommand(pdfPrintCommand);

            IPrintCommand directorPrintCommand = new DirectorPrintCommand(eva);

            #endregion

            eva.PrintCommand = blackAndWhitePrintCommand;
            eva.Print("Eva's bill");

            Console.WriteLine();

            eva.PrintCommand = colourPrintCommand;
            eva.Print("Eva's bill");

            Console.WriteLine();

            heiko.PrintCommand = pdfPrintCommand;
            heiko.Print("Heiko's source code");

            Console.WriteLine();

            heiko.PrintCommand = matrixPrintCommand;
            heiko.Print("Heiko's source code");

            Console.WriteLine();

            kevin.PrintCommand = printQueueCommand;
            kevin.Print("Kevin's print queue.");

            Console.WriteLine();

            herrSchulte.PrintCommand = directorPrintCommand;
            herrSchulte.Print("Order 666");

            Console.ReadKey();
        }