Exemple #1
0
        /// <summary>
        /// Add a set of QSOs - all for the same callsign - to the list to be printed
        /// </summary>
        public int AddQSOs(LabelEntry label, List<Contact> entries)
        {
            // For each group of up to n QSOs, print on to one label
            int startIndex = 0;
            int labelsUsedHere = 0;
            while (startIndex < entries.Count)
            {
                List<Contact> labelContacts = entries.GetRange(startIndex, Math.Min(QsoPerLabel, entries.Count - startIndex));
                List<TableEntry> labelEntries = labelContacts.ConvertAll<TableEntry>(c => new TableEntry(c));

                label.QSOs = labelEntries.ToArray();
                m_MainTable.AddCell(PopulateCell(label));
                startIndex += QsoPerLabel;
                m_LabelsUsed++;
                labelsUsedHere++;
            }
            return labelsUsedHere;
        }
Exemple #2
0
        private void m_PrintQueuedCards_Click(object sender, EventArgs e)
        {
            string myCall = m_SelectedSource.Callsign;
            PdfEngine engine = new PdfEngine(m_PageLayout, myCall, (int)m_LabelOffset.Value);
            var contactsToPrint = m_ContactStore.GetContactsToQsl(m_SelectedSource.SourceID, m_QslMethod.Text);
            if (contactsToPrint.Count == 0)
            {
                MessageBox.Show("No QSOs to print");
            }
            else
            {
                var contactsByCallsign = contactsToPrint.GroupBy(c => c.Callsign).Select(g => g.ToList()).ToList();
                // Sort according to the QSL method we're using
                switch (m_QslMethod.Text)
                {
                    case "Bureau":
                        contactsByCallsign.Sort(new BureauSorter(contactsToPrint.Select(c => c.Callsign).Distinct()).Sort);
                        break;
                    case "Direct":
                        contactsByCallsign.Sort(DirectSorter);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("Unknown QSL method: " + m_QslMethod.Text);
                }

                foreach (List<Contact> contacts in contactsByCallsign)
                {
                    var contactsByLocation = contacts.GroupBy(c => c.LocationID);
                    foreach (var oneLocation in contactsByLocation)
                    {
                        Location l = m_ContactStore.LoadLocation(oneLocation.Key);

                        LabelEntry labelEntry = new LabelEntry
                        {
                            Callsign = contacts[0].Callsign,
                            MyCall = myCall
                        };

                        if (l != null)
                        {
                            labelEntry.Location = l;
                            engine.PrintFooter = true;
                        }
                        else
                        {
                            engine.PrintFooter = false;
                        }

                        engine.AddQSOs(labelEntry, oneLocation.ToList());
                    }
                }
                engine.PrintDocument(Path.Combine(m_OutputPath.Text, string.Format("QSL-{0}-{1}.pdf", myCall.Replace('/', '_'), DateTime.UtcNow.ToString("yyyy-MM-dd-HHmm"))));
                m_ContactStore.MarkQslsSent(contactsToPrint);
                m_LabelsUsed = 0;
            }
            m_TxtCallsign.Focus();
        }
Exemple #3
0
        private PdfPCell PopulateCell(LabelEntry label)
        {
            PdfPCell cell = GetCell();

            PdfPTable qsoTable = new PdfPTable(5);
            qsoTable.SetWidths(m_Layout.ColumnRelativeWidths);
            qsoTable.WidthPercentage = 100f;

            if (label.QSOs != null && label.QSOs.Length > 0)
            {
                AddCell(qsoTable, s_HeaderFont, "Date");
                AddCell(qsoTable, s_HeaderFont, "UTC");
                AddCell(qsoTable, s_HeaderFont, "MHz");
                AddCell(qsoTable, s_HeaderFont, "RST");
                AddCell(qsoTable, s_HeaderFont, "Mode");

                Phrase titlePhrase = new Phrase();
                titlePhrase.Leading = 14.0f;
                titlePhrase.Add(new Chunk(label.MyCall, s_MyCallFont));
                titlePhrase.Add(new Chunk(" confirms the following QSO(s) with ", s_TitleTextFont));
                titlePhrase.Add(new Chunk(label.Callsign, s_MyCallFont));
                titlePhrase.Add(new Chunk(":", s_TitleTextFont));
                cell.AddElement(titlePhrase);
                foreach (TableEntry qso in label.QSOs)
                {
                    AddCell(qsoTable, s_TableFont, qso.UtcTime.ToString("yyyy-MM-dd"));
                    AddCell(qsoTable, s_TableFont, qso.UtcTime.ToString("HHmm"));
                    AddCell(qsoTable, s_TableFont, qso.Band);
                    AddCell(qsoTable, s_TableFont, qso.Rst);
                    AddCell(qsoTable, s_TableFont, qso.Mode);
                }
            }
            cell.AddElement(qsoTable);

            if (PrintFooter)
            {
                Phrase footerPhrase = new Phrase();
                footerPhrase.Add(new Chunk(string.Format("IOTA: {0} ({1}); WAB: {2}; Locator: {3}", label.Location.IotaName, label.Location.IotaRef, label.Location.Wab, label.Location.Locator), s_FooterTextFont));
                cell.AddElement(footerPhrase);
            }

            return cell;
        }