Beispiel #1
0
        private void ImportClubLog(object sender, EventArgs e)
        {
            PdfEngine addressLabelEngine = new PdfEngine (new LayoutAvery7160(), m_OurCallsign.Text, (int)m_LabelOffset.Value);

            ClubLogCSVHandler csvHandler = new ClubLogCSVHandler (m_ContactStore, addressLabelEngine);
            ClubLogQslAdifHandler adifHandler = new ClubLogQslAdifHandler(m_ContactStore, addressLabelEngine);

            string importPath;
            using (OpenFileDialog ofd = new OpenFileDialog ())
            {
                ofd.Filter = "Club Log OQRS Files (*.csv, *.adi)|*.csv;*.adi";
                DialogResult dr = ofd.ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.OK)
                    return;
                importPath = ofd.FileName;
            }

            int labelsToPrint;
            if (importPath.EndsWith(".csv", StringComparison.InvariantCultureIgnoreCase))
                labelsToPrint = csvHandler.ProcessFile(importPath);
            else
                labelsToPrint = adifHandler.ProcessFile(importPath);

            if (labelsToPrint > 0)
                addressLabelEngine.PrintDocument(Path.Combine(m_OutputPath.Text, string.Format("Address-{0}-{1}.pdf", m_OurCallsign.Text.Replace('/', '_'), DateTime.UtcNow.ToString("yyyy-MM-dd-HHmm"))));
            else
                MessageBox.Show("No address labels to print");

            UpdateLabelsUsed();
        }
Beispiel #2
0
        public void CheckAddressLabel()
        {
            QslEngine.PdfEngine pdfe = new PdfEngine (new LayoutAvery7160(), "M0VFC", 0);
            for (int i = 0; i < 23; i++)
                pdfe.AddAddressLabel(new Address { Callsign = "M0VFC", Name = "Robert Chipperfield", AddressLines = new[] { "12", "Some street", "Some village", "Some town", "County", "Country"}});

            pdfe.PrintDocument(@"C:\temp\addresslabel.pdf");
        }
Beispiel #3
0
 public ClubLogCSVHandler(ContactStore contactStore, PdfEngine engine)
 {
     m_ContactStore = contactStore;
     m_PdfEngine = engine;
 }
Beispiel #4
0
 private void UpdateLabelsUsed()
 {
     PdfEngine engine = new PdfEngine(m_PageLayout, m_SelectedSource.Callsign, 0);
     var contactsToPrint = m_ContactStore.GetContactsToQsl(m_SelectedSource.SourceID, m_QslMethod.Text);
     int labelsUsed = 0;
     foreach (var contacts in contactsToPrint.GroupBy(c => c.Callsign))
     {
         labelsUsed += engine.CalculateLabelCount(contacts.ToList());
     }
     m_LabelsUsed = labelsUsed;
     m_UpdateLabelsUsed.Text = string.Format("&Labels used: {0}", labelsUsed);
 }
Beispiel #5
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();
        }
Beispiel #6
0
        private void m_MarkSelectedAsReceived_Click(object sender, EventArgs e)
        {
            if (m_VisibleContacts == null || m_VisibleContacts.Count == 0)
                return;

            PdfEngine engine = new PdfEngine(m_PageLayout, m_SelectedSource.Callsign, 0);
            List<Contact> contactsToPrint = new List<Contact>();
            for (int row = 0; row < m_VisibleContacts.Count; row++)
            {
                DataGridViewRow gridRow = m_ContactsGrid.Rows[row];
                bool selected = (bool)gridRow.Cells[0].Value;
                if (selected)
                {
                    Contact c = m_VisibleContacts[row];
                    c.QslRxDate = DateTime.UtcNow;
                    c.QslTxDate = null; // Need to mark as "not sent" again, or it won't get reprinted
                    c.QslMethod = m_QslMethod.Text;
                    m_ContactStore.SaveContact(c);
                    contactsToPrint.Add(c);
                }
            }
            m_LabelsUsed += engine.CalculateLabelCount(contactsToPrint);
            m_UpdateLabelsUsed.Text = string.Format("&Labels used: {0}", m_LabelsUsed);

            UpdateGrid();
            m_TxtCallsign.Text = string.Empty;
            m_TxtCallsign.Focus();
        }