예제 #1
0
        public void RemoveAppConfirm(ApplicationInfo app)
        {
            if (app != null)
            {
                string menu;
                if (app.Category.Type == AppCategoryType.QuickLaunch)
                {
                    menu = Localization.DisplayString.sAppGrabber_QuickLaunch;
                }
                else
                {
                    menu = Localization.DisplayString.sProgramsMenu;
                }

                CairoMessage.ShowOkCancel(string.Format(Localization.DisplayString.sProgramsMenu_RemoveInfo, app.Name, menu),
                                          Localization.DisplayString.sProgramsMenu_RemoveTitle, CairoMessageImage.Warning,
                                          Localization.DisplayString.sProgramsMenu_Remove, Localization.DisplayString.sInterface_Cancel,
                                          result =>
                {
                    if (result == true)
                    {
                        app.Category.Remove(app);
                        Save();
                    }
                });
            }
        }
예제 #2
0
        public void RemoveAppConfirm(ApplicationInfo app, CairoMessage.DialogResultDelegate resultCallback)
        {
            if (app == null)
            {
                return;
            }

            string menu;

            if (app.Category.Type == AppCategoryType.QuickLaunch)
            {
                menu = DisplayString.sAppGrabber_QuickLaunch;
            }
            else
            {
                menu = DisplayString.sProgramsMenu;
            }

            CairoMessage.ShowOkCancel(string.Format(DisplayString.sProgramsMenu_RemoveInfo, app.Name, menu),
                                      DisplayString.sProgramsMenu_RemoveTitle, CairoMessageImage.Warning,
                                      DisplayString.sProgramsMenu_Remove, DisplayString.sInterface_Cancel,
                                      result =>
            {
                if (result == true)
                {
                    app.Category.Remove(app);
                    Save();
                }

                resultCallback?.Invoke(result);
            });
        }
예제 #3
0
        /* Helper methods */
        public void LaunchProgram(ApplicationInfo app)
        {
            if (app != null)
            {
                // so that we only prompt to always run as admin if it's done consecutively
                if (app.AskAlwaysAdmin)
                {
                    app.AskAlwaysAdmin = false;
                    Save();
                }

                if (!app.IsStoreApp && app.AlwaysAdmin)
                {
                    Shell.StartProcess(app.Path, "", "runas");
                }
                else if (Shell.IsCairoRunningAsShell && app.Target.ToLower().EndsWith("explorer.exe"))
                {
                    // special case: if we are shell and launching explorer, give it a parameter so that it doesn't do shell things.
                    // this opens My Computer
                    if (!Shell.StartProcess(app.Path, "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"))
                    {
                        CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error);
                    }
                }
                else if (!Shell.StartProcess(app.Path))
                {
                    CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error);
                }
            }
        }
예제 #4
0
        public void LaunchProgramAdmin(ApplicationInfo app)
        {
            if (app != null)
            {
                if (!app.IsStoreApp)
                {
                    if (!app.AlwaysAdmin)
                    {
                        if (app.AskAlwaysAdmin)
                        {
                            app.AskAlwaysAdmin = false;

                            bool?always = CairoMessage.Show(String.Format(Localization.DisplayString.sProgramsMenu_AlwaysAdminInfo, app.Name), Localization.DisplayString.sProgramsMenu_AlwaysAdminTitle, MessageBoxButton.YesNo, MessageBoxImage.Question);

                            if (always == true)
                            {
                                app.AlwaysAdmin = true;
                            }
                        }
                        else
                        {
                            app.AskAlwaysAdmin = true;
                        }

                        Save();
                    }

                    Shell.StartProcess(app.Path, "", "runas");
                }
                else
                {
                    LaunchProgram(app);
                }
            }
        }
예제 #5
0
 public void LaunchProgramVerb(ApplicationInfo app, string verb)
 {
     if (!Shell.StartProcess(app.Path, "", verb))
     {
         CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #6
0
        public void RenameAppDialog(ApplicationInfo app, CairoMessage.DialogResultDelegate resultCallback)
        {
            if (app == null)
            {
                return;
            }

            Common.MessageControls.Input inputControl = new Common.MessageControls.Input();
            inputControl.Initialize(app.Name);

            CairoMessage.ShowControl(string.Format(DisplayString.sProgramsMenu_RenameAppInfo, app.Name),
                                     string.Format(DisplayString.sProgramsMenu_RenameTitle, app.Name),
                                     app.GetIconImageSource(app.IsStoreApp ? IconSize.Jumbo : IconSize.ExtraLarge),
                                     app.IsStoreApp,
                                     inputControl,
                                     DisplayString.sInterface_Rename,
                                     DisplayString.sInterface_Cancel,
                                     (bool?result) =>
            {
                if (result == true)
                {
                    Rename(app, inputControl.Text);
                }

                resultCallback?.Invoke(result);
            });
        }
예제 #7
0
        public void LaunchProgram(ApplicationInfo app)
        {
            if (app == null)
            {
                return;
            }

            // so that we only prompt to always run as admin if it's done consecutively
            if (app.AskAlwaysAdmin)
            {
                app.AskAlwaysAdmin = false;
                Save();
            }

            if (app.AllowRunAsAdmin && app.AlwaysAdmin)
            {
                LaunchProgramVerb(app, "runas");
            }
            else if (EnvironmentHelper.IsAppRunningAsShell && app.Target.ToLower().EndsWith("explorer.exe"))
            {
                // special case: if we are shell and launching explorer, give it a parameter so that it doesn't do shell things.
                if (!ShellHelper.StartProcess(app.Path, ShellFolderPath.ComputerFolder.Value))
                {
                    CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error);
                }
            }
            else if (!ShellHelper.StartProcess(app.Path, workingDirectory: getAppParentDirectory(app)))
            {
                CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error);
            }
        }
예제 #8
0
        public static void PerformAction(string verb, string fileName)
        {
            switch (verb)
            {
            case Actions.Open:
                ShellHelper.StartProcess(fileName);
                return;

            case Actions.Delete:
                string displayName = ShellHelper.GetDisplayName(fileName);
                CairoMessage.ShowOkCancel(string.Format(Localization.DisplayString.sDesktop_DeleteInfo, displayName),
                                          Localization.DisplayString.sDesktop_DeleteTitle, CairoMessageImage.Warning,
                                          Localization.DisplayString.sInterface_Delete, Localization.DisplayString.sInterface_Cancel,
                                          result =>
                {
                    if (result == true)
                    {
                        ShellHelper.SendToRecycleBin(fileName);
                    }
                });
                return;

            case Actions.Properties:
                ShellHelper.ShowFileProperties(fileName);
                return;

            case Actions.Copy:
                StringCollection scPath = new StringCollection();
                scPath.Add(fileName);
                System.Windows.Forms.Clipboard.SetFileDropList(scPath);
                return;

            case Actions.AddStack:
                StacksManager.Instance.AddLocation(fileName);
                return;

            case Actions.RemoveStack:
                StacksManager.Instance.RemoveLocation(fileName);
                return;

            case Actions.OpenWithShell:
                FolderHelper.OpenWithShell(fileName);
                break;

            case Actions.Personalize:
                ShellHelper.StartProcess("Rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,2");
                break;

            case Actions.DisplaySettings:
                ShellHelper.StartProcess("Rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,3");
                break;

            default:
                ShellHelper.StartProcess(fileName, "", verb);
                break;
            }
        }
예제 #9
0
        public void ExecuteOpenSearchResult(object sender, ExecutedRoutedEventArgs e)
        {
            var searchObj = (SearchResult)e.Parameter;

            if (!Shell.StartProcess(searchObj.Path))
            {
                CairoMessage.Show(Localization.DisplayString.sSearch_Error, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #10
0
 public void LaunchProgramVerb(ApplicationInfo app, string verb)
 {
     if (app != null)
     {
         if (!ShellHelper.StartProcess(app.Path, "", verb))
         {
             CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error);
         }
     }
 }
예제 #11
0
 public static void ShowAppProperties(ApplicationInfo app)
 {
     if (app.IsStoreApp)
     {
         CairoMessage.ShowAlert(Localization.DisplayString.sProgramsMenu_UWPInfo, app.Name, MessageBoxImage.None);
     }
     else
     {
         Shell.ShowFileProperties(app.Path);
     }
 }
예제 #12
0
 public static void ShowAppProperties(ApplicationInfo app)
 {
     if (app != null)
     {
         if (app.IsStoreApp)
         {
             CairoMessage.Show(Localization.DisplayString.sProgramsMenu_UWPInfo, app.Name, app.GetIconImageSource(IconSize.Jumbo, false), true);
         }
         else
         {
             Shell.ShowFileProperties(app.Path);
         }
     }
 }
예제 #13
0
 private void MenuItem_OnClick(object sender, RoutedEventArgs e)
 {
     if (sender is MenuItem menuItem)
     {
         if (menuItem.CommandParameter is ManagedShell.Common.SupportingClasses.SearchResult searchObj)
         {
             if (!ShellHelper.StartProcess(searchObj.Path))
             {
                 CairoMessage.Show(Localization.DisplayString.sSearch_Error,
                                   Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error);
             }
         }
     }
 }
예제 #14
0
        public void ShowAppProperties(ApplicationInfo app)
        {
            if (app == null)
            {
                return;
            }

            if (app.IsStoreApp)
            {
                CairoMessage.Show(DisplayString.sProgramsMenu_UWPInfo, app.Name, app.GetIconImageSource(IconSize.Jumbo), true);
            }
            else
            {
                ShellHelper.ShowFileProperties(app.Path);
            }
        }
예제 #15
0
        /* Helper methods */
        public void LaunchProgram(ApplicationInfo app)
        {
            // so that we only prompt to always run as admin if it's done consecutively
            if (app.AskAlwaysAdmin)
            {
                app.AskAlwaysAdmin = false;
                Save();
            }

            if (!app.IsStoreApp && app.AlwaysAdmin)
            {
                Shell.StartProcess(app.Path, "", "runas");
            }
            else if (!Shell.StartProcess(app.Path))
            {
                CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #16
0
        public void RemoveAppConfirm(ApplicationInfo app)
        {
            string menu;

            if (app.Category.Type == AppCategoryType.QuickLaunch)
            {
                menu = Localization.DisplayString.sAppGrabber_QuickLaunch;
            }
            else
            {
                menu = Localization.DisplayString.sProgramsMenu;
            }
            bool?deleteChoice = CairoMessage.ShowOkCancel(String.Format(Localization.DisplayString.sProgramsMenu_RemoveInfo, app.Name, menu), Localization.DisplayString.sProgramsMenu_RemoveTitle, "Resources/cairoIcon.png", Localization.DisplayString.sProgramsMenu_Remove, Localization.DisplayString.sInterface_Cancel);

            if (deleteChoice.HasValue && deleteChoice.Value)
            {
                app.Category.Remove(app);
                Save();
            }
        }
예제 #17
0
        public void LaunchProgramAdmin(ApplicationInfo app)
        {
            if (app != null)
            {
                if (!app.IsStoreApp)
                {
                    if (!app.AlwaysAdmin)
                    {
                        if (app.AskAlwaysAdmin)
                        {
                            app.AskAlwaysAdmin = false;

                            CairoMessage.Show(string.Format(DisplayString.sProgramsMenu_AlwaysAdminInfo, app.Name),
                                              DisplayString.sProgramsMenu_AlwaysAdminTitle,
                                              MessageBoxButton.YesNo, CairoMessageImage.Information,
                                              result =>
                            {
                                if (result == true)
                                {
                                    app.AlwaysAdmin = true;
                                }
                            });
                        }
                        else
                        {
                            app.AskAlwaysAdmin = true;
                        }

                        Save();
                    }

                    ShellHelper.StartProcess(app.Path, "", "runas");
                }
                else
                {
                    LaunchProgram(app);
                }
            }
        }
예제 #18
0
        public void LaunchProgramAdmin(ApplicationInfo app)
        {
            if (app == null)
            {
                return;
            }

            if (!app.AllowRunAsAdmin)
            {
                LaunchProgram(app);
                return;
            }

            if (!app.AlwaysAdmin && app.AskAlwaysAdmin)
            {
                app.AskAlwaysAdmin = false;
                Save();

                CairoMessage.Show(string.Format(DisplayString.sProgramsMenu_AlwaysAdminInfo, app.Name),
                                  DisplayString.sProgramsMenu_AlwaysAdminTitle,
                                  MessageBoxButton.YesNo, CairoMessageImage.Information,
                                  result =>
                {
                    if (result == true)
                    {
                        app.AlwaysAdmin = true;
                        Save();
                    }
                });
            }
            else if (!app.AlwaysAdmin)
            {
                app.AskAlwaysAdmin = true;
                Save();
            }

            LaunchProgramVerb(app, "runas");
        }
예제 #19
0
        public static void PerformAction(string verb, string fileName)
        {
            var desktopManager    = CairoApplication.Current.Host.Services.GetService <DesktopManager>();
            var settingsUiService = CairoApplication.Current.Host.Services.GetService <ISettingsUIService>();

            switch (verb)
            {
            case Actions.Open:
                desktopManager.IsOverlayOpen = false;
                ShellHelper.StartProcess(fileName);
                return;

            case Actions.OpenWith:
                desktopManager.IsOverlayOpen = false;
                ShellHelper.ShowOpenWithDialog(fileName);
                return;

            case Actions.Delete:
                string displayName = ShellHelper.GetDisplayName(fileName);
                CairoMessage.ShowOkCancel(string.Format(Localization.DisplayString.sDesktop_DeleteInfo, displayName),
                                          Localization.DisplayString.sDesktop_DeleteTitle, CairoMessageImage.Warning,
                                          Localization.DisplayString.sInterface_Delete, Localization.DisplayString.sInterface_Cancel,
                                          result =>
                {
                    if (result == true)
                    {
                        ShellHelper.SendToRecycleBin(fileName);
                    }
                });
                return;

            case Actions.Properties:
                ShellHelper.ShowFileProperties(fileName);
                desktopManager.IsOverlayOpen = false;
                return;

            case Actions.Copy:
                StringCollection scPath = new StringCollection();
                scPath.Add(fileName);
                System.Windows.Forms.Clipboard.SetFileDropList(scPath);
                return;

            case DirectoryActions.AddStack:
                StacksManager.Instance.AddLocation(fileName);
                return;

            case DirectoryActions.RemoveStack:
                StacksManager.Instance.StackLocations.Remove(new SystemDirectory(fileName, _dispatcher));
                return;

            case Actions.OpenWithShell:
                FolderHelper.OpenWithShell(fileName);
                break;

            case Actions.Personalize when EnvironmentHelper.IsAppRunningAsShell:
                settingsUiService?.Show("desktop");
                break;

            case Actions.Personalize:
                ShellHelper.StartProcess("Rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,2");
                break;

            case Actions.DisplaySettings:
                ShellHelper.StartProcess("Rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,3");
                break;

            default:
                ShellHelper.StartProcess(fileName, "", verb);
                break;
            }
        }