public MainWindow()
 {
     InitializeComponent();
     ViewModel                      = new MainViewModel(EFIEnvironment.GetEntries());
     ViewModel.RebootClick         += OnRebootClick;
     ViewModel.BootNextClick       += OnBootNextClick;
     ViewModel.CreateShortcutClick += OnCreateShortcut;
     BootEntries.DataContext        = ViewModel;
     this.Loaded                   += OnLoaded;
 }
Exemple #2
0
 private bool ProcessCommandLine()
 {
     string[] args = Environment.GetCommandLineArgs();
     if (args.Length > 1)
     {
         ushort entryId = 0;
         if (ushort.TryParse(args[1], out entryId))
         {
             BootEntry entry = EFIEnvironment.GetEntries().FirstOrDefault(e => e.Id == entryId);
             if (entry != null)
             {
                 DoReboot(entry, !args.Contains("quiet"));
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #3
0
 public static void DoReboot(BootEntry entry, bool confirmation = true)
 {
     if (confirmation)
     {
         string message = string.Format("Are you sure want to reboot to {0} right now?", entry.Name);
         if (MessageBoxResult.Yes != MessageBox.Show(message, "Reboot confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No))
         {
             return;
         }
     }
     EFIEnvironment.SetBootNext(entry);
     if (!NativeMethods.ExitWindowsEx(ExitWindows.Reboot,
                                      ShutdownReason.MajorApplication |
                                      ShutdownReason.MinorInstallation |
                                      ShutdownReason.FlagPlanned))
     {
         MessageBox.Show("Unable to reboot your computer", "Reboot failure", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #4
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (!EFIEnvironment.IsSupported())
            {
                MessageBox.Show("Only UEFI platform is supported", "Not supported", MessageBoxButton.OK, MessageBoxImage.Error);
                Shutdown();
                return;
            }
            try {
                PrivelegeHelper.ObtainSystemPrivileges();
            } catch (InvalidOperationException ex) {
                MessageBox.Show(string.Format("Unable to obtain system privileges: {0}", ex.Message), "Application error", MessageBoxButton.OK, MessageBoxImage.Error);
                Shutdown();
            }
            if (ProcessCommandLine())
            {
                Shutdown();
                return;
            }

            ThemeManager.ChangeAppStyle(this, ThemeManager.GetAccent("Yellow"), ThemeManager.GetAppTheme("BaseDark"));
            new MainWindow().Show();
        }
 private void OnBootNextClick(object sender, BootEntryEventArgs e)
 {
     EFIEnvironment.SetBootNext(e.BootEntry);
     ViewModel.MarkAsNext(e.BootEntry);
 }