Пример #1
0
        private void LoadPrnInfo()
        {
            LoadComplete = false;
            LoadStarted  = true;

            Console.WriteLine("{0}: --> Printers load begin", DateTime.Now.ToString("HH:mm:ss fff"));

            foreach (string prnName in PrinterSettings.InstalledPrinters)
            {
                Console.WriteLine("{0}: ---> Printers load: {1}", DateTime.Now.ToString("HH:mm:ss fff"), prnName);

                var prn = new Dialogs.PrinterOp(prnName, null);
                Dialogs.PrinterInfo prnInfo = prn.GetInfo();

                List[prnName] = prnInfo;

                if (Updated != null)
                {
                    Updated(this, new InfoArgs(prnInfo));
                }
            }

            LoadComplete = true;
            LoadStarted  = false;

            if (Loaded != null)
            {
                Loaded(this, new EventArgs());
            }

            Console.WriteLine("{0}: --> Printers load end", DateTime.Now.ToString("HH:mm:ss fff"));
        }
Пример #2
0
        public PrintAllDialog(int[] docIDs, PrintAllFoldersType folderType)
        {
            switch (folderType)
            {
            case PrintAllFoldersType.WorkFolder:
            case PrintAllFoldersType.SearchFolder:
            case PrintAllFoldersType.InquiryFolder:
                values = new int[docIDs.Length];
                docIDs.CopyTo(values, 0);
                break;

            case PrintAllFoldersType.ArchivFolder:
                break;
            }

            using (
                var dialog = new DocPrintDialog(0, Environment.Settings.Folders.Add("Print"), 0,
                                                Environment.StringResources.GetString("Dialog_PrintAllDialog_Title1")))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    printImage  = dialog.PrintImage;
                    mainOnly    = dialog.PrintOnlyMain;
                    eForm       = dialog.PrintEForm;
                    orientation = dialog.Orientation;
                    scaleMode   = dialog.ScaleMode;
                    annotations = dialog.Annotations;
                    copiescount = dialog.CopiesCount;
                    prn         = new PrinterOp(DocPrintDialog.Printer, this);
                    printerInfo = Environment.Printers.List[DocPrintDialog.Printer] as PrinterInfo ?? prn.GetInfo();
                }
            }

            if (printImage || eForm)
            {
                InitializeComponent();
            }
            else
            {
                Load  += PrintAllDialog_Load;
                values = null;
                return;
            }

            InitLayoutProperties();
        }
Пример #3
0
        public PrintAllDialog(int[] values)
        {
            this.values = values;
            using (
                var dialog = new DocPrintDialog(0, Environment.Settings.Folders.Add("Print"), 0,
                                                Environment.StringResources.GetString("Dialog_PrintAllDialog_Title1"))
            {
                PrintImage = false
            })
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    printImage  = dialog.PrintImage;
                    mainOnly    = dialog.PrintOnlyMain;
                    eForm       = dialog.PrintEForm;
                    orientation = dialog.Orientation;
                    scaleMode   = dialog.ScaleMode;
                    annotations = dialog.Annotations;
                    copiescount = dialog.CopiesCount;
                    prn         = new PrinterOp(DocPrintDialog.Printer, this);
                    printerInfo = Environment.Printers.List[DocPrintDialog.Printer] as PrinterInfo ?? prn.GetInfo();
                }
            }

            if (printImage || eForm)
            {
                InitializeComponent();
            }
            else
            {
                Load  += PrintAllDialog_Load;
                values = null;
                return;
            }

            InitLayout();
        }
Пример #4
0
 public InfoArgs(Dialogs.PrinterInfo info)
 {
     Info = info;
 }
Пример #5
0
        public PrinterInfo GetInfo()
        {
            var info = new PrinterInfo
            {
                Name          = printerName,
                Comment       = "",
                DriverName    = "",
                Location      = "",
                PortName      = "",
                PrinterStatus = ""
            };

            try
            {
                using (
                    var printObject = new ManagementObject("Win32_Printer.DeviceID='" + printerName + "'"))
                {
                    // тип (им¤ драйвера)
                    PropertyData propData = printObject.Properties["DriverName"];
                    if (propData.Value != null)
                    {
                        info.DriverName = propData.Value.ToString();
                    }

                    // им¤ порта
                    propData = printObject.Properties["PortName"];
                    if (propData.Value != null)
                    {
                        info.PortName = propData.Value.ToString();
                    }

                    // место
                    propData = printObject.Properties["Location"];
                    if (propData.Value != null)
                    {
                        info.Location = propData.Value.ToString();
                    }

                    if ((System.Environment.OSVersion.Version.Major == 5 &&
                         System.Environment.OSVersion.Version.Minor > 0) ||
                        System.Environment.OSVersion.Version.Major > 5)
                    {
                        // комментарий
                        propData = printObject.Properties["Comment"];
                        if (propData.Value != null)
                        {
                            info.Comment = propData.Value.ToString();
                        }
                    }

                    int resol = 0;
                    propData = printObject.Properties["HorizontalResolution"];
                    {
                        if (propData.Value != null && int.TryParse(propData.Value.ToString(), out resol))
                        {
                            info.HorizontalResolution = resol;
                        }
                        else
                        {
                            info.HorizontalResolution = 96;
                        }
                    }

                    propData = printObject.Properties["VerticalResolution"];
                    {
                        if (propData.Value != null && int.TryParse(propData.Value.ToString(), out resol))
                        {
                            info.VerticalResolution = resol;
                        }
                        else
                        {
                            info.VerticalResolution = 96;
                        }
                    }
                }
            }
            catch
            {
            }

            return(info);
        }
Пример #6
0
        public PrintAllDialog(int folderID, int empID, PrintAllFoldersType folderType)
        {
            switch (folderType)
            {
            case PrintAllFoldersType.WorkFolder:
                using (
                    var dt = Environment.DocData.GetWorkFolderDocs(folderID, empID,
                                                                   Environment.CurCultureInfo.
                                                                   TwoLetterISOLanguageName))
                {
                    if (dt.Rows.Count > 0)
                    {
                        values = new int[dt.Rows.Count];
                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = (int)dt.Rows[i][Environment.DocData.IDField];
                        }
                    }
                    else
                    {
                        Load  += PrintAllDialog_Load;
                        values = null;
                        return;
                    }
                    dt.Dispose();
                }
                break;

            case PrintAllFoldersType.ArchivFolder:
                break;

            case PrintAllFoldersType.SearchFolder:
                using (
                    var dt = Environment.DocData.GetFoundDocs(Environment.CurCultureInfo.Name, empID,
                                                              Environment.UserSettings.PersonID))
                {
                    if (dt.Rows.Count > 0)
                    {
                        values = new int[dt.Rows.Count];
                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = (int)dt.Rows[i][Environment.DocData.IDField];
                        }
                    }
                    else
                    {
                        Load  += PrintAllDialog_Load;
                        values = null;
                        return;
                    }
                    dt.Dispose();
                }
                break;

            case PrintAllFoldersType.InquiryFolder:
                string xml = Environment.QueryData.GetField(Environment.QueryData.XMLField, folderID).ToString();
                string sql = Data.DALC.Documents.Search.Options.GetSQL(xml);
                using (
                    DataTable dt = Environment.DocData.GetQueryDocs(sql,
                                                                    Environment.CurCultureInfo.
                                                                    TwoLetterISOLanguageName, empID,
                                                                    Environment.UserSettings.PersonID))
                {
                    if (dt.Rows.Count > 0)
                    {
                        values = new int[dt.Rows.Count];
                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = (int)dt.Rows[i][Environment.DocData.IDField];
                        }
                    }
                    else
                    {
                        Load  += PrintAllDialog_Load;
                        values = null;
                        return;
                    }
                    dt.Dispose();
                }
                break;
            }

            using (
                var dialog = new DocPrintDialog(0, Environment.Settings.Folders.Add("Print"), values,
                                                Environment.StringResources.GetString("Dialog_PrintAllDialog_Title1")))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    printImage  = dialog.PrintImage;
                    mainOnly    = dialog.PrintOnlyMain;
                    eForm       = dialog.PrintEForm;
                    orientation = dialog.Orientation;
                    scaleMode   = dialog.ScaleMode;
                    annotations = dialog.Annotations;
                    copiescount = dialog.CopiesCount;
                    prn         = new PrinterOp(DocPrintDialog.Printer, this);
                    printerInfo = Environment.Printers.List[DocPrintDialog.Printer] as PrinterInfo ?? prn.GetInfo();
                }
            }

            if (printImage || eForm)
            {
                InitializeComponent();
            }
            else
            {
                Load  += PrintAllDialog_Load;
                values = null;
                return;
            }

            InitLayoutProperties();
        }