Exemple #1
0
        public void OnCreateShortcut(object sender, BootEntryEventArgs e)
        {
            string message = string.Format("Do you want to create a shortcut to {0} WITHOUT reboot confirmation?", e.BootEntry.Name);
            var    status  = MessageBox.Show(message, "Reboot confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel);

            if (status == MessageBoxResult.Cancel)
            {
                return;
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.FileName = string.Join(string.Empty, e.BootEntry.Name.Split(Path.GetInvalidFileNameChars()));
            saveFileDialog.Filter   = "Shortcut (*.lnk)|*.lnk";
            if (saveFileDialog.ShowDialog() == true)
            {
                using (ShellLink shortcut = new ShellLink()) {
                    shortcut.Target           = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    shortcut.WorkingDirectory = Path.GetDirectoryName(shortcut.Target);
                    shortcut.Description      = string.Format("Boot to {0}", e.BootEntry.Name);
                    shortcut.DisplayMode      = ShellLink.LinkDisplayMode.edmNormal;
                    if (status == MessageBoxResult.Yes)
                    {
                        shortcut.Arguments = string.Format("{0} quiet", e.BootEntry.Id);
                    }
                    else
                    {
                        shortcut.Arguments = string.Format("{0}", e.BootEntry.Id);
                    }
                    shortcut.Save(saveFileDialog.FileName);
                }
            }
        }
 public void OnRebootClick(object sender, BootEntryEventArgs e)
 {
     App.DoReboot(e.BootEntry);
 }
 private void OnBootNextClick(object sender, BootEntryEventArgs e)
 {
     EFIEnvironment.SetBootNext(e.BootEntry);
     ViewModel.MarkAsNext(e.BootEntry);
 }