using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;
using System.Drawing.Printing;
using System.Diagnostics;

namespace FastReport
{
    public class ReportScript
    {
        private void Vente_StartReport(object sender, EventArgs e)
        {
            String installedPrinters = "";
            var sessionId = Process.GetCurrentProcess().SessionId;
            foreach (string installedPrinter in PrinterSettings.InstalledPrinters)
            {
                // een printer definiëren voor lokaal gebruik
                if (installedPrinter.Contains("Ticket"))
                    Report.PrintSettings.Printer = installedPrinter;

                // om het rapport af te drukken in de huidige Terminal Server sessie.
                if (installedPrinter.Contains("Ticket") && installedPrinter.Contains("(redirection de " + sessionId.ToString().Trim() + ")"))
                    Report.PrintSettings.Printer = installedPrinter;
            }
        }
    }
}