private bool GemSettings() { if (!Directory.Exists(SavePathTB.Text)) { MessageBox.Show("Katalog findes ikke: " + SavePathTB.Text, "Fejl", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } settings.brugernavn = BrugernavnTB.Text; settings.password = PasswordTB.Text.Trim(); settings.aktiveringskode = AktiveringTB.Text.Trim(); settings.savepath = SavePathTB.Text + (SavePathTB.Text.EndsWith("\\") ? "" : "\\"); settings.mailserver = MailDNSTB.Text; settings.mailserverport = string.IsNullOrEmpty(MailPortTB.Text) ? 0 : int.Parse(MailPortTB.Text); settings.mailserveruser = MailUserTB.Text; settings.mailserverpassword = MailPasswdTB.Text; settings.mailfrom = MailFromTB.Text; settings.mailto = MailToTB.Text; settings.mailserverssl = MailSSLCB.IsChecked.GetValueOrDefault(); settings.downloadonly = downloadonlyCB.IsChecked.GetValueOrDefault(); settings.startminimeret = StartMinimizedCB.IsChecked.GetValueOrDefault(); settings.autorun = auturunCB.IsChecked.GetValueOrDefault(); if (string.IsNullOrEmpty(settings.deviceid)) { settings.deviceid = Guid.NewGuid().ToString(); } if (string.IsNullOrEmpty(settings.response)) { settings.response = settings.GetRandomHexNumber(64); } if (!SendTestMail()) { return(false); } var eBoks = new Eboks(); if (!eBoks.GetSessionForAccountRest()) { MessageBox.Show("Opsætning kunne ikke verificeres.", "Fejl", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } settings.Save(); Konfigok = true; return(true); }
private void MarkerAltSomHentetButton_OnClick(object sender, RoutedEventArgs e) { if (GemSettings()) { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; var eboks = new Eboks(); var notification = new NotifyIcon(); settings.opbyghentet = true; var progress = new Progress <string>( s => Console.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " " + s)); eboks.DownloadFromEBoks(progress); settings.opbyghentet = false; Mouse.OverrideCursor = null; } }