Exemplo n.º 1
0
 /// <summary>
 /// Method that is called when the MainWindow is closing
 /// </summary>
 /// <param name="sender">The object that called this method</param>
 /// <param name="e">The CancelEventArgs</param>
 private void MainWindow_OnClosing(object sender, CancelEventArgs e)
 {
     try
     {
         if (Properties.Settings.Default.HideOnClose && Visibility == Visibility.Visible)
         {
             Hide();
             e.Cancel = true;
         }
         else
         {
             // Save properties
             Properties.Settings.Default.Save();
             // De-register any hotkeys, if applicable
             _hotKeyController?.Dispose();
             // Dispose the RamController object gracefully
             _ramController?.Dispose();
             TbiIcon?.Dispose();
             // Dispose of the LogController object gracefully
             _logController.Dispose();
         }
     }
     catch (Exception ex)
     {
         _logController.AddLog(new ErrorLog(ex.Message));
         MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Method that is called when a RAM clearing has occurred and statistics could be shown to the user
        /// </summary>
        private void RamClearingCompleted()
        {
            double ramSavings = _ramController.RamSavings / 1024 / 1024;
            string message;

            if (ramSavings < 0)
            {
                ramSavings = Math.Abs(ramSavings);
                _logController.AddLog(new RamLog("RAM usage increase: " + ramSavings.ToString("F2") + " MB"));
                message = ((string)Application.Current.FindResource("RamUsageIncreased"))?.Replace("%", ramSavings.ToString("F2"));
            }
            else
            {
                _logController.AddLog(new RamLog("RAM usage decrease: " + ramSavings.ToString("F2") + " MB"));
                message = ((string)Application.Current.FindResource("RamUsageSaved"))?.Replace("%", ramSavings.ToString("F2"));
            }

            if (!Properties.Settings.Default.RamCleaningMessage)
            {
                return;
            }
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (Visibility)
            {
            default:
                MessageBox.Show(message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
                break;

            case Visibility.Hidden when TbiIcon.Visibility == Visibility.Visible:
                TbiIcon.ShowBalloonTip("MemPlus", message, BalloonIcon.Info);
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Change the language of MemPlus
        /// </summary>
        internal void LoadLanguage()
        {
            GuiManager.ChangeLanguage(_logController);

            try
            {
                _updateManager?.SetStringVariables(LoadUpdateManagerStrings());
                TbiIcon?.InvalidateVisual();
            }
            catch (Exception ex)
            {
                _logController.AddLog(new ErrorLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Method that is called when the MainWindow is closing
 /// </summary>
 /// <param name="sender">The object that called this method</param>
 /// <param name="e">The CancelEventArgs</param>
 private void MainWindow_OnClosing(object sender, CancelEventArgs e)
 {
     if (Properties.Settings.Default.HideOnClose && Visibility == Visibility.Visible)
     {
         Hide();
         e.Cancel = true;
     }
     else
     {
         // Unregister any hotkeys, if applicable
         _hotKeyController?.Dispose();
         // Disable the RAM Monitor to prevent exceptions from being thrown
         _ramController?.DisableMonitor();
         TbiIcon?.Dispose();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Change the language of MemPlus
        /// </summary>
        internal void LoadLanguage()
        {
            _logController.AddLog(new ApplicationLog("Changing language"));
            ResourceDictionary dict = new ResourceDictionary();
            Uri langUri             = new Uri("..\\Resources\\Languages\\en_US.xaml", UriKind.Relative);

            try
            {
                switch (Properties.Settings.Default.SelectedLanguage)
                {
                case 1:
                    langUri = new Uri("..\\Resources\\Languages\\nl_BE.xaml", UriKind.Relative);
                    break;

                case 2:
                    langUri = new Uri("..\\Resources\\Languages\\es_ES.xaml", UriKind.Relative);
                    break;

                case 3:
                    langUri = new Uri("..\\Resources\\Languages\\gl_ES.xaml", UriKind.Relative);
                    break;
                }
            }
            catch (Exception ex)
            {
                langUri = new Uri("..\\Resources\\Languages\\en.xaml", UriKind.Relative);
                _logController.AddLog(new ApplicationLog(ex.Message));
                MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
            }


            dict.Source = langUri;
            Application.Current.Resources.MergedDictionaries.Clear();
            Application.Current.Resources.MergedDictionaries.Add(dict);

            _updateManager?.SetStringVariables(LoadUpdateManagerStrings());
            TbiIcon?.InvalidateVisual();

            _logController.AddLog(new ApplicationLog("Done changing language"));
        }