示例#1
0
 public PrintSettingsHandler(swc.PrintDialog dialog)
 {
     Control           = dialog.PrintTicket;
     PrintQueue        = dialog.PrintQueue;
     MaximumPageRange  = new Range((int)dialog.MinPage, (int)(dialog.MaxPage - dialog.MinPage) + 1);
     SelectedPageRange = dialog.PageRange.ToEto();
     PrintSelection    = dialog.PageRangeSelection.ToEto();
 }
示例#2
0
 public PrintSettingsHandler()
 {
     Control           = new sp.PrintTicket();
     PrintQueue        = new swc.PrintDialog().PrintQueue;
     MaximumPageRange  = new Range(1, 1);
     SelectedPageRange = new Range(1, 1);
     Collate           = true;
     PrintSelection    = PrintSelection.AllPages;
 }
        public ACA.LabelX.Toolbox.PrintGroupItem GetLabelPrintGroupByName(string sName)
        {
            GlobalDataStore.Logger.Debug("RemClientControlObject.GetLabelPrintGroupByName");
            string   AppPath = GlobalDataStore.AppPath;
            string   RemotingConfigFilePath = AppPath + @"\ACALabelXClient.config.xml";
            FileInfo fi;

            fi = new FileInfo(RemotingConfigFilePath);

            if (!fi.Exists)
            {
                throw new LabelXRemClientControlOjectException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath));
            }
            // if (!File.Exists(RemotingConfigFilePath))
            //     throw new LabelXRemClientControlOjectException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath));
            PrintGroupItem pgItem = null;

            lock (GlobalDataStore.LockClass)
            {
                XPathDocument  theDoc;
                XPathNavigator nav;
                string         sHelp;

                try
                {
                    theDoc = new XPathDocument(RemotingConfigFilePath);
                }
                catch (System.Xml.XmlException e1)
                {
                    ApplicationException e2;
                    e2 = new ApplicationException(string.Format("XML syntax error in {0}: {1}", RemotingConfigFilePath, e1.Message), e1);
                    throw e2;
                }

                nav = theDoc.CreateNavigator();

                XPathNodeIterator nit;



                nit = nav.Select("/configuration/general-settings/print-groups/print-group[@name='" + sName + "']");
                if (nit != null)
                {
                    nit.MoveNext();
                    pgItem = new PrintGroupItem();
                    pgItem.GroupPrinters = new PrinterItems();
                    pgItem.Name          = nit.Current.GetAttribute("name", string.Empty);
                    pgItem.Enabled       = nit.Current.GetAttribute("enabled", string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase);

                    nit = nav.Select("/configuration/general-settings/print-groups/print-group[@name='" + sName + "']/printer");
                    while (nit.MoveNext())
                    {
                        PrinterItem pit;
                        pit = new PrinterItem();

                        sHelp        = nit.Current.GetAttribute("name", string.Empty);
                        pit.LongName = sHelp;
                        sHelp        = nit.Current.GetAttribute("enabled", string.Empty);
                        pit.Enabled  = sHelp.Equals("true", StringComparison.OrdinalIgnoreCase);

                        //Retrieve some other data for this printer...
                        System.Printing.LocalPrintServer localServer;
                        localServer = new System.Printing.LocalPrintServer();
                        System.Printing.PrintQueueCollection        col;
                        System.Printing.EnumeratedPrintQueueTypes[] myEnum =
                        { EnumeratedPrintQueueTypes.Connections
                          , EnumeratedPrintQueueTypes.Local };
                        col = localServer.GetPrintQueues(myEnum);
                        System.Printing.PrintQueue theQueue = null;
                        foreach (System.Printing.PrintQueue q in col)
                        {
                            if (q.FullName.Equals(pit.LongName, StringComparison.OrdinalIgnoreCase))
                            {
                                theQueue = q;
                                break;
                            }
                        }

                        if (theQueue != null)
                        {
                            pit.QueueLength           = theQueue.NumberOfJobs;
                            pit.ShortName             = theQueue.Name;
                            pit.Online                = !theQueue.IsOffline;
                            pit.NeedsUserIntervention = theQueue.NeedUserIntervention;
                            //
                            //theQueue.NeedUserIntervention;
                        }
                        else
                        {
                            pit.QueueLength           = 0;
                            pit.NeedsUserIntervention = false;
                            pit.ShortName             = pit.LongName;
                            pit.Online = true;
                        }
                        if (col != null)
                        {
                            col.Dispose();
                            col = null;
                        }
                        if (theQueue != null)
                        {
                            theQueue.Dispose();
                            theQueue = null;
                        }

                        if (nit.Current.HasChildren)
                        {
                            //nit.Current.MoveToFirstChild();
                            nit.Current.MoveToFirstChild();
                            //MoveToNext("tray", nav.LookupNamespace(nav.Prefix)))
                            do
                            {
                                PrinterTrayItem ptit;
                                ptit                      = new PrinterTrayItem();
                                ptit.TrayName             = nit.Current.GetAttribute("name", string.Empty);
                                ptit.CurrentPapertypeName = nit.Current.GetAttribute("papertype", string.Empty);
                                pit.Trays.Add(ptit);
                            } while (nit.Current.MoveToNext("tray", nav.LookupNamespace(nav.Prefix)));
                            nit.Current.MoveToParent();
                        }
                        //pit.CurrentPapertypeName = nit.Current.GetAttribute("papertype",string.Empty);
                        //pit.Tray = nit.Current.GetAttribute("tray", string.Empty);
                        pgItem.GroupPrinters.Add(pit);
                        localServer.Dispose();
                    }
                }
            }
            return(pgItem);
        }