Exemplo n.º 1
0
        /// <summary>
        /// Main form closing event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing && !isClosing)
            {
                e.Cancel = true;
                this.Hide();
            }
            else
            {
                if (listener.IsRunning())
                {
                    listener.Stop();
                }

                try
                {
                    var settingsPersister = new SettingsPersister();
                    var name    = Assembly.GetEntryAssembly().GetName().Name;
                    var company = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(
                                       Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute), false))
                                  .Company;

                    settingsPersister.SaveSettings(settings,
                                                   Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), company), name));
                }
                catch (Exception exception)
                {
                    Logger.Warn($"{nameof(MainForm_FormClosing)} exception", exception);
                }


                notifyIconTray.Dispose();
            }
        }
        public ScannerPanel(ISharpControl control)
        {
            InitializeComponent();

            _controlInterface = control;

            if (LicenseManager.UsageMode==LicenseUsageMode.Runtime)
            {
                _settingsPersister = new SettingsPersister();
                _entries = _settingsPersister.ReadStoredFrequencies();
                _groups = GetGroupsFromEntries();
                ProcessGroups(null);
            }

            /*
            foreach (DataGridViewColumn column in frequencyDataGridView.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }*/

            _scanner = new Scanner(_controlInterface, ScanNextFrequencyCallback, ScanNextFrequencyTimeLeftCallback);
            _scanner.SetScanStateChangedCallback = ScanStateChanged;
            _controlInterface.PropertyChanged += PropertyChangedEventHandler;

            memoryEntryBindingSource.DataSource = _displayedEntries;

            #if(DEBUG)
            SetupDebugSession("BOS");
            #endif
        }
Exemplo n.º 3
0
    public void Load_should_create_settings_file_if_not_exists(
        [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fileSystem,
        [Frozen] IResourcePaths paths,
        SettingsPersister sut)
    {
        paths.SettingsPath.Returns("test_path");

        sut.Load();

        fileSystem.AllFiles.Should().ContainSingle(x => x.EndsWith(paths.SettingsPath));
    }
Exemplo n.º 4
0
        public static async Task CheckForNewVersion(bool isStartup, bool forceUpdate = false)
        {
            Settings settings = SettingsPersister.Retrieve();

            if (forceUpdate)
            {
                settings.UpdateInfo = null;
            }

            if (CheckForUpdates(settings))
            {
                settings.UpdateInfo.LastCheckedForUpdates = DateTime.Now;

                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("User-Agent", "KML2SQL.Updater");
                HttpResponseMessage response = await client.GetAsync(apiUrl);

                if (response.IsSuccessStatusCode)
                {
                    SemVersion latestVersion = await GetLatestVersion(response);

                    SemVersion thisVersion = SemVersion.Parse(GetCurrentVersion());
                    if (latestVersion > thisVersion && ShouldNag(settings, latestVersion))
                    {
                        settings.UpdateInfo.LastTimeNagged = DateTime.Now;
                        MessageBoxResult mbResult = MessageBox.Show(
                            "A new version is availbe. Press 'Yes' to go to the download page, Cancel to skip, or 'No' to not be reminded unless an even newer version comes out.",
                            "New Version Available!",
                            MessageBoxButton.YesNoCancel);
                        if (mbResult == MessageBoxResult.Yes)
                        {
                            Process.Start(downloadUrl);
                        }
                        if (mbResult == MessageBoxResult.No)
                        {
                            settings.UpdateInfo.DontNag = true;
                        }
                    }
                    else if (!isStartup)
                    {
                        MessageBox.Show("Your app is fully updated", "No updates found", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                SettingsPersister.Persist(settings);
            }
            else if (!isStartup)
            {
                MessageBox.Show("Your app is fully updated", "No updates found", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Main form load event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            //Ignore server certificate check
            ServicePointManager.Expect100Continue = false;
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };


            rssItemBindingSource.DataSource = rssItems;

            previewForm.Visible = false;
            previewForm.Owner   = this;


            userAgents.AddRange(Properties.Resources.UserAgents.Split(new string[] { "\r\n" },
                                                                      StringSplitOptions.RemoveEmptyEntries));



            var appDataPath = GetAppDataPath();

            themes       = ThemeManager.LoadThemes(Path.Combine(appDataPath, "Themes"));
            currentTheme = themes[0];

            try
            {
                var settingsPersister = new SettingsPersister();
                settings = settingsPersister.ReadSettings(appDataPath);
            }
            catch (Exception exception)
            {
                Logger.Warn($"{nameof(MainForm_Load)} exception", exception);
            }


            //Start background worker
            listener         = new RssListener(settings, userAgents);
            listener.NewRss += OnNewRss;


            startStopToolStripMenuItem_Click(null, EventArgs.Empty);

            CreateThemeMainMenu();

            CreateTrayContextMenu();

            ModifyMainFormStyle();

            InitHotKey();
        }
Exemplo n.º 6
0
    public void Load_defaults_when_file_does_not_exist(
        [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fileSystem,
        [Frozen(Matching.ImplementedInterfaces)] YamlSerializerFactory serializerFactory,
        [Frozen(Matching.ImplementedInterfaces)] SettingsProvider settingsProvider,
        [Frozen] IResourcePaths paths,
        SettingsPersister sut)
    {
        paths.SettingsPath.Returns("test_path");

        sut.Load();

        var expectedSettings = new SettingsValues();

        settingsProvider.Settings.Should().BeEquivalentTo(expectedSettings);
    }
Exemplo n.º 7
0
        public FrequencyManagerPanel(ISharpControl control)
        {
            InitializeComponent();

            _controlInterface = control;

            if (LicenseManager.UsageMode==LicenseUsageMode.Runtime)
            {
                _settingsPersister = new SettingsPersister();
                _entries = _settingsPersister.ReadStoredFrequencies();
                _groups = GetGroupsFromEntries();
                ProcessGroups(null);
            }

            memoryEntryBindingSource.DataSource = _displayedEntries;            
        }
Exemplo n.º 8
0
 public FrequencyManagerPanel(ISharpControl control)
 {
     this.InitializeComponent();
       this._controlInterface = control;
       this._controlInterface.SpectrumAnalyzerCustomPaint += new CustomPaintEventHandler(this.controlInterface_SpectrumAnalyzerCustomPaint);
       this._controlInterface.PropertyChanged += new PropertyChangedEventHandler(this.controlInterface_PropertyChanged);
       if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
       {
     this._settingsPersister = new SettingsPersister();
     this._entries = this._settingsPersister.ReadStoredFrequencies();
     this._groups = this.GetGroupsFromEntries();
     this.ProcessGroups((string) null);
       }
       this.memoryEntryBindingSource.DataSource = (object) this._displayedEntries;
       this.showBookmarksCheckBox.Checked = Utils.GetBooleanSetting("showBookmarks");
 }
        public ControllerTestForm()
        {
            InitializeComponent();

            oscPortTextBox.Text   = "9123";
            oscStopButton.Enabled = false;

            DateTime t1 = DateTime.Now;

            SettingsPersister.ReadOptions();
            TimeSpan ts = DateTime.Now - t1;

            Tracer.WriteLine("ReadOptions() took " + ts.Milliseconds + " ms");

            Tracer.setInterface(statusBar, statusBar2, null); // mainProgressBar);
            Tracer.WriteLine("GUI up");

            periodicMaintenanceTimer          = new System.Windows.Forms.Timer();
            periodicMaintenanceTimer.Interval = 500;
            periodicMaintenanceTimer.Tick    += new EventHandler(periodicMaintenance);
            periodicMaintenanceTimer.Start();

            Tracer.WriteLine("OK: Maintenance ON");

            // put Osc_DLL.dll in C:\Windows

            string oscilloscopeIniFile = Project.startupPath + "..\\..\\LibOscilloscope\\Scope_Desk.ini";

            oscilloscope = Oscilloscope.Create(oscilloscopeIniFile, null);

            if (oscilloscope != null)
            {
                Tracer.Trace("loaded oscilloscope DLL");
                oscilloscope.Show();        // appears in separate window
            }
            else
            {
                Tracer.Error("Couldn't load oscilloscope DLL");
                Tracer.Error("Make sure " + oscilloscopeIniFile + " is in place");
                Tracer.Error("Make sure C:\\WINDOWS\\Osc_DLL.dll is in place and registered with regsvr32");
            }
        }
Exemplo n.º 10
0
    public void Load_data_correctly_when_file_exists(
        [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fileSystem,
        [Frozen] IYamlSerializerFactory serializerFactory,
        [Frozen] IResourcePaths paths,
        SettingsPersister sut)
    {
        // For this test, it doesn't really matter if the YAML data matches what SettingsValue expects;
        // this test only ensures that the data deserialized is from the actual correct file.
        var expectedYamlData = @"
repository:
  clone_url: http://the_url.com
";
        var deserializer     = Substitute.For <IDeserializer>();

        serializerFactory.CreateDeserializer().Returns(deserializer);
        paths.SettingsPath.Returns("test_path");
        fileSystem.AddFile(paths.SettingsPath, new MockFileData(expectedYamlData));

        sut.Load();

        deserializer.Received().Deserialize <SettingsValues>(expectedYamlData);
    }
        public static async Task CheckForNewVersion()
        {
            var settings = SettingsPersister.Retrieve();

            if (CheckForUpdates(settings))
            {
                settings.UpdateInfo.LastCheckedForUpdates = DateTime.Now;
                var client = new HttpClient();
                //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
                client.DefaultRequestHeaders.Add("User-Agent", "Pharylon");
                var response = await client.GetAsync(apiUrl);

                if (response.IsSuccessStatusCode)
                {
                    var latestVersion = await GetLatestVersion(response);

                    var thisVersion = SemVersion.Parse(GetCurrentVersion());
                    if (latestVersion > thisVersion && ShouldNag(settings, latestVersion))
                    {
                        settings.UpdateInfo.LastTimeNagged = DateTime.Now;
                        var mbResult = MessageBox.Show(
                            "A new version is availbe. Press 'Yes' to go to the download page, Cancel to skip, or 'No' to not be reminded unless an even newer version comes out.",
                            "New Version Available!",
                            MessageBoxButton.YesNoCancel);
                        if (mbResult == MessageBoxResult.Yes)
                        {
                            Process.Start(downloadUrl);
                        }
                        if (mbResult == MessageBoxResult.No)
                        {
                            settings.UpdateInfo.DontNag = true;
                        }
                    }
                }
                SettingsPersister.Persist(settings);
            }
        }