Ejemplo n.º 1
0
 public FLogin(DXpConfig _config, HTTPService _httpService)
 {
     InitializeComponent();
     config          = _config;
     httpService     = _httpService;
     tbCallsign.Text = config.callsign;
 }
Ejemplo n.º 2
0
        public FMain()
        {
#if DEBUG
            TextWriterTraceListener[] listeners = new TextWriterTraceListener[] {
                new TextWriterTraceListener("debug." + Guid.NewGuid() + ".log"),
                new TextWriterTraceListener(Console.Out)
            };
            foreach (TextWriterTraceListener listener in listeners)
            {
                listener.TraceOutputOptions |= TraceOptions.DateTime;
            }
            Trace.Listeners.AddRange(listeners);
            Trace.AutoFlush = true;
            Trace.TraceInformation("-----------------------START---------------------------------");
#endif
            config = new XmlConfigNS.XmlConfig <DXpConfig>();
            config.data.initialize();
            qsoFactory = new QSOFactory(config.data);
            InitializeComponent();
            udpListener.DataReceived += UDPDataReceived;
            udpListener.StartListener(12060);

            bsQSO = new BindingSource(blQSO, null);
            dgvQSO.AutoGenerateColumns = false;
            dgvQSO.DataSource          = bsQSO;
            for (int c = 0; c < DXpConfig.UserColumnsCount; c++)
            {
                UserColumnSettings cs  = config.data.userColumns != null && config.data.userColumns.Count > c ? config.data.userColumns[c] : null;
                DataGridViewColumn col = new DataGridViewTextBoxColumn();
                col.Name             = "userFieldColumn" + c.ToString();
                col.DataPropertyName = "userField" + c.ToString();
                col.Visible          = cs != null ? cs.show : false;
                col.HeaderText       = cs != null ? cs.name : "";
                dgvQSO.Columns.Add(col);
            }
            if (config.data.dgvQSOColumnsWidth != null)
            {
                for (int co = 0; co < dgvQSO.ColumnCount && co < config.data.dgvQSOColumnsWidth.Count(); co++)
                {
                    dgvQSO.Columns[co].Width = config.data.dgvQSOColumnsWidth[co];
                }
            }
            else
            {
                config.data.dgvQSOColumnsWidth = new List <int>();
            }
            if (config.data.dgvQSOColumnsWidth.Count < dgvQSO.ColumnCount)
            {
                for (int co = config.data.dgvQSOColumnsWidth.Count; co < dgvQSO.ColumnCount; co++)
                {
                    config.data.dgvQSOColumnsWidth.Add(dgvQSO.Columns[co].Width);
                }
                writeConfig();
            }

            bool       qsoEr;
            List <QSO> storedQSOs = ProtoBufSerialization.ReadListItems <QSO>(qsoFilePath, out qsoEr);
            if (storedQSOs.Count > 0)
            {
                Regex  reComaNoSpace   = new Regex(",(\\S)");
                string comaNoSpaceRepl = ", $1";
                Regex  reNoRegion      = new Regex("(\\w\\w)-(\\d\\d),\\s?(\\d\\d)");
                string noRegionRepl    = "$1-$2, $1-$3";
                Regex  reRDA           = new Regex("[A-Z][A-Z]-\\d\\d");
                foreach (QSO qso in storedQSOs)
                {
                    if (qso.freq.IndexOf('.') == -1)
                    {
                        qso.freq = QSO.formatFreq(qso.freq);
                        qsoEr    = true;
                    }
                    if (qso.rda != null)
                    {
                        MatchCollection rdaMatches = reRDA.Matches(qso.rda);
                        string          rda        = "";
                        if (rdaMatches.Count > 1)
                        {
                            qsoEr = true;
                        }
                        foreach (Match rdaMatch in rdaMatches)
                        {
                            if (rda != "")
                            {
                                rda += ", ";
                            }
                            rda += rdaMatch.Value;
                        }
                        qso.rda = rda;
                    }

                    /*
                     * if (qso.rda != null && reComaNoSpace.IsMatch(qso.rda))
                     * {
                     *  qso.rda = reComaNoSpace.Replace(qso.rda, comaNoSpaceRepl);
                     *  qsoEr = true;
                     * }
                     * if (qso.rda != null && reNoRegion.IsMatch(qso.rda))
                     * {
                     *  qso.rda = reNoRegion.Replace(qso.rda, noRegionRepl);
                     *  qsoEr = true;
                     * }*/
                    blQSO.Insert(0, qso);
                    updateQsoIndex(qso);
                }
                QSO lastQSO = storedQSOs.Last();
                if (lastQSO.rda == config.data.getOptionalColumnValue("RDA"))
                {
                    qsoFactory.no = lastQSO.no + 1;
                }
            }
            if (qsoEr)
            {
                ProtoBufSerialization.WriteList(qsoFilePath, storedQSOs, false);
            }
            config.data.optionalColumnValueChanged += optionalColumnValueChanged;
            gpsReader.locationChanged      += locationChanged;
            gpsReader.gpsConnectionChanged += gpsConnectionChanged;
            config.data.logIO += onLoggedIO;
            onLoggedIO(null, null);
            startGPSReader();
            http = new HTTPService(gpsReader, config.data);
            http.connectionStateChanged += onHTTPConnection;
            http.locationChanged        += locationChanged;
        }