Exemplo n.º 1
0
        public static ProgramSettings Load(string filePath = "settings.xml")
        {
            var    version         = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            string expectedVersion = $"{version.Major}.{version.Minor}";

            XmlSerializer reader = new XmlSerializer(typeof(ProgramSettings));

            using (StreamReader file = new StreamReader(filePath))
            {
                ProgramSettings loadedConfig = (ProgramSettings)reader.Deserialize(file);
                if (loadedConfig.version == expectedVersion)
                {
                    return(loadedConfig);
                }
                else
                {
                    throw new InvalidOperationException("incompatible config file version");
                }
            }
        }
Exemplo n.º 2
0
        public FormSettings(ProgramSettings settings)
        {
            InitializeComponent();
            this.settings = settings;

            tbServer.Text              = settings.ftpServerAddress;
            tbRemotePath.Text          = settings.ftpRemoteSubfolder;
            tbUsername.Text            = settings.ftpUsername;
            tbPassword.Text            = settings.DeObfuscate(settings.ftpObfuscatedPassword);
            tbWsprPath.Text            = settings.wsprLogFilePath;
            nudTargetWidth.Value       = settings.targetWidth;
            nudVerticalReduction.Value = settings.verticalReduction;
            nudFreqDisplayOffset.Value = settings.freqDisplayOffset;
            tbImageFileName.Text       = settings.grabFileName;
            cbShowFreqScale.Checked    = settings.showScaleOnAllGrabs;
            nudPxAbove.Value           = settings.grabSavePxAbove;
            nudPxBelow.Value           = settings.grabSavePxBelow;
            tbStationInfo.Text         = settings.stationInformation;
            cbRoll.Checked             = settings.roll;
            cbAgcMode.SelectedIndex    = settings.agcMode;
            nudAgcPower.Value          = (decimal)settings.agcPower;
        }
Exemplo n.º 3
0
        public FormMain()
        {
            InitializeComponent();

            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                return;
            }

            settings        = File.Exists("settings.xml") ? ProgramSettings.Load("settings.xml") : new ProgramSettings();
            lblVersion.Text = $"FSKview {version.Major}.{version.Minor}.{version.Build}";

            // start in center of screen occupying 80% of its height
            Height   = (int)(Screen.FromControl(this).Bounds.Height * .8);
            Location = new Point(
                x: Screen.FromControl(this).Bounds.Width / 2 - Width / 2,
                y: Screen.FromControl(this).Bounds.Height / 2 - Height / 2);

            // pre-populate listboxes
            cbWindow.Items.AddRange(FftSharp.Window.GetWindowNames());
            cmaps = Spectrogram.Colormap.GetColormaps();
            cbColormap.Items.AddRange(cmaps.Select(x => x.Name).ToArray());
            cbDialFreq.Items.AddRange(WsprBands.GetBands().Select(x => $"{x.name}: {x.dialFreq:N0} Hz").ToArray());

            // pre-select items based on saved settings
            audioControl1.SelectDevice(settings.audioDeviceIndex);
            cbWindow.SelectedIndex   = cbWindow.Items.IndexOf(settings.window);
            cbColormap.SelectedIndex = cbColormap.Items.IndexOf(settings.colormap);
            cbDialFreq.SelectedIndex = settings.wsprBandIndex;
            cbWspr.Checked           = settings.isWsprEnabled;
            cbFTP.Checked            = settings.isFtpEnabled;
            nudBrightness.Value      = (decimal)settings.brightness;

            // select on load
            ActiveControl = cbColormap;
        }
Exemplo n.º 4
0
        public static void Spectrogram(
            Spectrogram.Spectrogram spec, WsprBand band, List <WsprSpot> spots,
            Bitmap bmpSpectrogram, Bitmap bmpVericalScale,
            bool drawBandLines, bool drawVerticalLine, ProgramSettings settings)
        {
            using (Graphics gfx = Graphics.FromImage(bmpSpectrogram))
                using (Bitmap bmpIndexed = spec.GetBitmapMax(settings.brightness, reduction: settings.verticalReduction, roll: settings.roll))
                    using (Pen bandEdgePen = new Pen(Color.White)
                    {
                        DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
                    })
                        using (Pen grabEdgePen = new Pen(Color.Yellow)
                        {
                            DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
                        })
                            using (Pen rollPen = new Pen(Color.White))
                                using (var font = new Font("consolas", 10, FontStyle.Bold))
                                    using (var sfMiddleCenter = new StringFormat {
                                        LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center
                                    })
                                        using (var sfUpperLeft = new StringFormat {
                                            LineAlignment = StringAlignment.Near, Alignment = StringAlignment.Near
                                        })
                                        {
                                            // copy source bitmaps onto this display bitmap
                                            gfx.DrawImage(bmpIndexed, 0, 0);
                                            gfx.DrawImage(bmpVericalScale, spec.Width, 0);

                                            int wsprBandTopPx    = spec.PixelY(band.upperFreq - band.dialFreq, settings.verticalReduction) + 1;
                                            int wsprBandBottomPx = spec.PixelY(band.lowerFreq - band.dialFreq, settings.verticalReduction) + 1;
                                            int qrssBandBottomPx = spec.PixelY(band.lowerFreq - band.dialFreq - 200, settings.verticalReduction) + 1;
                                            int grabTopPx        = wsprBandTopPx - settings.grabSavePxAbove;
                                            int grabBotPx        = qrssBandBottomPx + settings.grabSavePxBelow;
                                            if (drawBandLines)
                                            {
                                                gfx.DrawLine(bandEdgePen, 0, wsprBandTopPx, spec.Width, wsprBandTopPx);
                                                gfx.DrawLine(bandEdgePen, 0, wsprBandBottomPx, spec.Width, wsprBandBottomPx);
                                                gfx.DrawLine(bandEdgePen, 0, qrssBandBottomPx, spec.Width, qrssBandBottomPx);
                                                gfx.DrawLine(grabEdgePen, 0, grabTopPx - 1, spec.Width, grabTopPx - 1);
                                                gfx.DrawLine(grabEdgePen, 0, grabBotPx, spec.Width, grabBotPx);
                                            }

                                            if (settings.roll && drawVerticalLine)
                                            {
                                                gfx.DrawLine(rollPen, spec.NextColumnIndex, 0, spec.NextColumnIndex, spec.Height);
                                            }

                                            if (settings.isWsprEnabled == false)
                                            {
                                                return;
                                            }

                                            // plot spots in a single segment (the 2m block within a 10m time frame)
                                            for (int segment = 0; segment < 5; segment++)
                                            {
                                                WsprSpot[] segmentSpots = spots
                                                                          .Where(x => x.segment == segment)                                        // only this segment
                                                                          .Where(x => Math.Abs(x.frequencyHz - band.dialFreq) < 1e5)               // only this band
                                                                          .OrderBy(x => x.strength).GroupBy(x => x.callsign).Select(x => x.Last()) // only strongest
                                                                          .OrderBy(x => x.frequencyHz).Reverse().ToArray();                        // top to bottom

                                                int segmentX = spec.Width * segment / 5;
                                                if (settings.roll == false && segmentSpots.Length > 0)
                                                {
                                                    segmentX = (int)(spec.Width - segmentSpots[0].ageSec / spec.SecPerPx) + 10;
                                                }

                                                for (int spotIndex = 0; spotIndex < segmentSpots.Length; spotIndex++)
                                                {
                                                    WsprSpot spot = segmentSpots[spotIndex];

                                                    int r = 7;
                                                    int y = spec.PixelY(spot.frequencyHz - band.dialFreq, settings.verticalReduction);

                                                    // draw the marker
                                                    if (spot.isWspr)
                                                    {
                                                        int xSpot = segmentX + r * 2 * (spotIndex % 8 + 1);

                                                        // determine where to place the marker
                                                        gfx.FillEllipse(Brushes.Black, xSpot - r, y - r, r * 2, r * 2);
                                                        gfx.DrawString($"{spotIndex + 1}", font, Brushes.White, xSpot + 0.5f, y + 1, sfMiddleCenter);

                                                        // draw the key label at the top of the band edge
                                                        DrawStringWithShadow(gfx, $"{spotIndex + 1}: {spot.callsign} ({spot.strength} dB) ",
                                                                             segmentX, wsprBandTopPx - settings.grabSavePxAbove + 13 * spotIndex,
                                                                             font, sfUpperLeft, Brushes.White, Brushes.Black);
                                                    }
                                                    else
                                                    {
                                                        // draw the callsign exactly where the spot is on the spectrogram
                                                        int xSpot = (int)(segmentX + (spot.dt.Minute % 2 * 60 + spot.dt.Second) / spec.SecPerPx);
                                                        DrawStringWithShadow(gfx, spot.callsign, xSpot, y, font, sfUpperLeft, Brushes.White, Brushes.Black);
                                                    }
                                                }
                                            }
                                        }
        }