コード例 #1
0
        public ObservatoryFrm()
        {
            InitializeComponent();
            ExtendControl.DoubleBuffered(listEvent, true);
            Text                         = $"{Text} - v{Application.ProductVersion}";
            logMonitor                   = new LogMonitor();
            logMonitor.LogEntry         += LogEvent;
            Icon                         = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            columnSorter                 = new ListViewColumnSorter();
            listEvent.ListViewItemSorter = columnSorter;
            capiState                    = Properties.Observatory.Default.UseCapi ? CapiState.Enabled : CapiState.Disabled;
            CheckCapi(capiState);
            overlay = new EDOverlay();

            if (Properties.Observatory.Default.TTS)
            {
                speech = new SpeechSynthesizer();
                speech.SetOutputToDefaultAudioDevice();
            }

            try
            {
                string releasesResponse;

                var request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Get,
                    RequestUri = new Uri("https://api.github.com/repos/xjph/EliteObservatory/releases"),
                    Headers    = { { "User-Agent", "Xjph/EliteObservatory" } }
                };

                releasesResponse = HttpClient.SendRequest(request).Content.ReadAsStringAsync().Result;

                if (!string.IsNullOrEmpty(releasesResponse))
                {
                    JArray releases = (JArray)JsonConvert.DeserializeObject(releasesResponse, new JsonSerializerSettings()
                    {
                        DateParseHandling = DateParseHandling.None
                    });
                    foreach (JObject release in releases)
                    {
                        if (release["tag_name"].ToString().CompareTo($"v{Application.ProductVersion}") > 0)
                        {
                            linkUpdate.Enabled = true;
                            linkUpdate.Visible = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error checking for update: {ex.Message}");
            }
        }
コード例 #2
0
 private void cbxEDOverlay_CheckedChanged(object sender, EventArgs e)
 {
     settings.UseEDOverlay = ((CheckBox)sender).Checked;
     ShowHideTelegram();
     Save();
     if (!Loading && settings.UseEDOverlay)
     {
         EDOverlay overlay = new EDOverlay();
         overlay.Send("Observatory notifications", "Notifications enabled!");
     }
 }