private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            await Save(true);

            BacktraceLogger.UpdateSettings();
            BacktraceLogger.Log(new BacktraceReport("New client settings"));
            Close();
        }
Пример #2
0
        private async Task <string> SquirrelUpdate(bool showInfo)
        {
            try
            {
                using (UpdateManager _manager = new UpdateManager(ConfigurationManager.AppSettings["CurrentReleaseURL"]))
                {
                    UpdateInfo _update = await _manager.CheckForUpdate();

                    if (_update.ReleasesToApply.Any())
                    {
                        Version _newVersion = _update.ReleasesToApply.OrderByDescending(r => r.Version).First().Version.Version;

                        Update _updateWindow = new Update();
                        _updateWindow.Show();

                        await _manager.UpdateApp((p) => _updateWindow.SetProgress(p));

                        _updateWindow.Close();

                        return(Utilities.Paths.Exe(_newVersion));
                    }
                    else if (showInfo)
                    {
                        MessageBox.Show(Framework.Resources.UpdateSuccessText, Framework.Resources.AppName, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                    }
                }
            }
            catch (WebException webException)
            {
                if (showInfo)
                {
                    MessageBox.Show(Framework.Resources.UpdateErrorText, Framework.Resources.UpdateErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                }
                BacktraceLogger.Log(new Backtrace.Model.BacktraceReport(webException));
            }
            catch (Exception e)
            {
                BacktraceLogger.Log(new Backtrace.Model.BacktraceReport(e));
                Framework.Settings.Instance.AutoUpdate = false;
                Framework.Settings.Instance.Save();

                using (EventLog _log = new EventLog("Application"))
                {
                    _log.Source = Framework.Resources.AppName;
                    _log.WriteEntry(e.ToString(), EventLogEntryType.Error, 100, 1);
                }

                MessageBox.Show(Framework.Resources.UpdateErrorFatalText, Framework.Resources.UpdateErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
            }

            return(null);
        }
        public Settings(Sidebar sidebar)
        {
            InitializeComponent();

            DataContext = Model = new SettingsModel(sidebar);
            try
            {
                Owner = sidebar;
                ShowDialog();
            }catch (Exception e)
            {
                BacktraceLogger.Log(new BacktraceReport(e));
            }
        }
Пример #4
0
        protected async override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // ERROR HANDLING
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_Error);
#endif
            System.Threading.Thread.CurrentThread.Name = "SidebarDiagnosticMainThread";
            // LANGUAGE
            Culture.SetDefault();
            Culture.SetCurrent(true);

            // UPDATE
            #if !DEBUG
            if (Framework.Settings.Instance.AutoUpdate)
            {
                await AppUpdate(false);
            }
            #endif

            // SETTINGS
            CheckSettings();

            // VERSION
            Version _version = Assembly.GetExecutingAssembly().GetName().Version;
            string  _vstring = _version.ToString(3);

            // TRAY ICON
            TrayIcon                      = (TaskbarIcon)FindResource("TrayIcon");
            TrayIcon.ToolTipText          = string.Format("{0} v{1}", Framework.Resources.AppName, _vstring);
            TrayIcon.TrayContextMenuOpen += TrayIcon_TrayContextMenuOpen;

            // SETUP LOGGER
            BacktraceLogger logger = new BacktraceLogger(Framework.Settings.Instance);

            // START APP
            if (Framework.Settings.Instance.InitialSetup)
            {
                new Setup();
            }
            else
            {
                BacktraceLogger.Log(new Backtrace.Model.BacktraceReport("Settings already exists"));
                StartApp(false);
            }
        }