示例#1
0
        /// <summary>
        /// Switches to another user control
        /// </summary>
        /// <param name="control">A user control to show</param>
        public static void SwithToControl(UserControl control)
        {
            var main = (MainWindow)Application.Current.MainWindow;

            if (main.TransitionControl.Content is Calculator)
            {
                (main.TransitionControl.Content as Calculator).SaveMemSession();
                ConfigFileHelpers.SerializeFunctionUsageStats();
                ConfigFileHelpers.SerializeConstantUsageStats();
                Properties.Settings.Default.Save();
            }
            var dispose = main.TransitionControl.Content as IDisposable;

            if (dispose != null)
            {
                dispose.Dispose();
            }
            main.TransitionControl.Content = null;
            foreach (Flyout flyout in main.Flyouts.Items)
            {
                flyout.IsOpen = false;
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            main.TransitionControl.Content = control;
        }
示例#2
0
 private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     e.Cancel = !WindowManager.CloseAll();
     if (TransitionControl.Content is Calculator)
     {
         ConfigFileHelpers.SerializeFunctionUsageStats();
         ConfigFileHelpers.SerializeConstantUsageStats();
     }
     App.SaveSettings();
     Properties.Settings.Default.Save();
 }