Пример #1
0
        /// <summary>
        /// Creates a MainWindow displaying app settings and bootstrapping the whole application
        /// </summary>
        public MainWindow()
        {
            this.PrepareFS();

            InitializeComponent();

            this.StateChanged += this.WindowStateChanged;
            this.Loaded       += MainWindow_Loaded;

            if (AutorunManager.IsAlreadyAddedToCurrentUserStartup() || AutorunManager.IsAlreadyAddedToAllUsersStartup())
            {
                autostartlocal.IsChecked = true;
            }

            this.InitializeContextMenu();

            this.floatingWindow = new FloatingWindow();
        }
Пример #2
0
        private void Autostartlocal_IsCheckedChanged(object sender, EventArgs e)
        {
            ToggleSwitch self = (ToggleSwitch)sender;

            try
            {
                if ((bool)self.IsChecked)
                {
                    AutorunManager.AddToCurrentUserAutorun();
                }
                else
                {
                    AutorunManager.RemoveFromCurrentUserAutorun();
                }
            }
            catch (Exception ex)
            {
                // Revert the toggle, as the operation did not succeed
                self.IsChecked = !(bool)self.IsChecked;
                Console.WriteLine($"Error adding the app to the current user's autorun: {ex.ToString()}");
                this.ShowMessageAsync("Oops, something went wrong", $"An unexpected error occured: {ex.ToString()}");
            }
        }