Example #1
0
        public List <Result> ContextMenus(IPublicAPI api)
        {
            var contextMenus = new List <Result>
            {
                new Result
                {
                    Title  = api.GetTranslation("wox_plugin_program_run_as_administrator"),
                    Action = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            Verb             = "runas"
                        };
                        var hide = Main.StartProcess(info);
                        return(hide);
                    },
                    IcoPath = "Images/cmd.png"
                },
                new Result
                {
                    Title  = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                    Action = _ =>
                    {
                        var hide = Main.StartProcess(new ProcessStartInfo(ParentDirectory));
                        return(hide);
                    },
                    IcoPath = "Images/folder.png"
                }
            };

            return(contextMenus);
        }
 private Result ConvertQuestionToResult(Question question)
 {
     return(new Result
     {
         Title = question.Title,
         SubTitle = GetSubTitle(question),
         IcoPath = GetIcon(question),
         Action = context =>
         {
             var link = question.Link;
             if (!question.Link.ToLower().StartsWith("http"))
             {
                 link = "http://" + link;
             }
             try
             {
                 Process.Start(link);
                 return true;
             }
             catch (Exception exc)
             {
                 _woxPluginApi.ShowMsg(_woxPluginApi.GetTranslation("wox_plugin_so_results_error_open_link"));
                 return false;
             }
         }
     });
 }
Example #3
0
            public List <Result> ContextMenus(IPublicAPI api)
            {
                var contextMenus = new List <Result>
                {
                    new Result
                    {
                        Title = api.GetTranslation("flowlauncher_plugin_program_open_containing_folder"),

                        Action = _ =>
                        {
                            Main.Context.API.OpenDirectory(Package.Location);

                            return(true);
                        },

                        IcoPath = "Images/folder.png"
                    }
                };

                if (CanRunElevated)
                {
                    contextMenus.Add(new Result
                    {
                        Title  = api.GetTranslation("flowlauncher_plugin_program_run_as_administrator"),
                        Action = _ =>
                        {
                            LaunchElevated();
                            return(true);
                        },
                        IcoPath = "Images/cmd.png"
                    });
                }

                return(contextMenus);
            }
Example #4
0
            public Result Result(string query, IPublicAPI api)
            {
                var score = Score(query);

                if (score <= 0)
                { // no need to create result if score is 0
                    return(null);
                }

                var result = new Result
                {
                    SubTitle    = SetSubtitle(api),
                    Icon        = Logo,
                    Score       = score,
                    ContextData = this,
                    Action      = e =>
                    {
                        Launch(api);
                        return(true);
                    }
                };

                // To set the title to always be the displayname of the packaged application
                result.Title = DisplayName;
                result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;


                var toolTipTitle = string.Format("{0} : {1}", api.GetTranslation("powertoys_run_plugin_program_file_name"), result.Title);
                var toolTipText  = string.Format("{0} : {1}", api.GetTranslation("powertoys_run_plugin_program_file_path"), Package.Location);

                result.ToolTipData = new ToolTipData(toolTipTitle, toolTipText);

                return(result);
            }
Example #5
0
        public List <Result> ContextMenus(IPublicAPI api)
        {
            var contextMenus = new List <Result>
            {
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_run_as_different_user"),
                    Action = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info));

                        return(true);
                    },
                    IcoPath = "Images/user.png",
                    Glyph   = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe7ee"),
                },
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_run_as_administrator"),
                    Action = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            Verb             = "runas",
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(Process.Start, info));

                        return(true);
                    },
                    IcoPath = "Images/cmd.png",
                    Glyph   = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe7ef"),
                },
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_open_containing_folder"),
                    Action = _ =>
                    {
                        Main.Context.API.OpenDirectory(ParentDirectory, FullPath);

                        return(true);
                    },
                    IcoPath = "Images/folder.png",
                    Glyph   = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe838"),
                }
            };

            return(contextMenus);
        }
Example #6
0
        public List <Result> ContextMenus(IPublicAPI api)
        {
            var contextMenus = new List <Result>
            {
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_run_as_different_user"),
                    Action = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info));

                        return(true);
                    },
                    IcoPath = "Images/user.png"
                },
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_run_as_administrator"),
                    Action = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            Verb             = "runas",
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(Process.Start, info));

                        return(true);
                    },
                    IcoPath = "Images/cmd.png"
                },
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_open_containing_folder"),
                    Action = _ =>
                    {
                        Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));

                        return(true);
                    },
                    IcoPath = "Images/folder.png"
                }
            };

            return(contextMenus);
        }
Example #7
0
            public List <ContextMenuResult> ContextMenus(IPublicAPI api)
            {
                var contextMenus = new List <ContextMenuResult>();

                if (CanRunElevated)
                {
                    contextMenus.Add(
                        new ContextMenuResult
                    {
                        PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                        Title                = api.GetTranslation("wox_plugin_program_run_as_administrator"),
                        Glyph                = "\xE7EF",
                        FontFamily           = "Segoe MDL2 Assets",
                        AcceleratorKey       = "Enter",
                        AcceleratorModifiers = "Control,Shift",
                        Action               = _ =>
                        {
                            string command = "shell:AppsFolder\\" + UniqueIdentifier;
                            command.Trim();
                            command = Environment.ExpandEnvironmentVariables(command);

                            var info             = ShellCommand.SetProcessStartInfo(command, verb: "runas");
                            info.UseShellExecute = true;

                            Process.Start(info);
                            return(true);
                        }
                    }
                        );
                }
                contextMenus.Add(
                    new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                    Glyph                = "\xE838",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = "E",
                    AcceleratorModifiers = "Control,Shift",
                    Action               = _ =>
                    {
                        Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));

                        return(true);
                    }
                });


                return(contextMenus);
            }
Example #8
0
            public List <Result> ContextMenus(IPublicAPI api)
            {
                var contextMenus = new List <Result>
                {
                    new Result
                    {
                        Title = api.GetTranslation("flowlauncher_plugin_program_open_containing_folder"),

                        Action = _ =>
                        {
                            Main.StartProcess(Process.Start,
                                              new ProcessStartInfo(
                                                  !string.IsNullOrEmpty(Main._settings.CustomizedExplorer)
                                                    ? Main._settings.CustomizedExplorer
                                                    : Settings.Explorer,
                                                  Main._settings.CustomizedArgs
                                                  .Replace("%s", $"\"{Package.Location}\"")
                                                  .Trim()));

                            return(true);
                        },

                        IcoPath = "Images/folder.png"
                    }
                };

                return(contextMenus);
            }
Example #9
0
        public List <ContextMenuResult> ContextMenus(IPublicAPI api)
        {
            var contextMenus = new List <ContextMenuResult>
            {
                new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_run_as_administrator"),
                    Glyph                = "\xE7EF",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = "Enter",
                    AcceleratorModifiers = "Control,Shift",
                    Action               = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            Verb             = "runas",
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(Process.Start, info));

                        return(true);
                    }
                },
                new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                    Glyph                = "\xE838",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = "E",
                    AcceleratorModifiers = "Control,Shift",
                    Action               = _ =>
                    {
                        Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));

                        return(true);
                    }
                }
            };

            return(contextMenus);
        }
Example #10
0
 private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(_searchSource.Title))
     {
         var warning = _api.GetTranslation("wox_plugin_websearch_input_title");
         MessageBox.Show(warning);
     }
     else if (string.IsNullOrEmpty(_searchSource.Url))
     {
         var warning = _api.GetTranslation("wox_plugin_websearch_input_url");
         MessageBox.Show(warning);
     }
     else if (string.IsNullOrEmpty(_searchSource.ActionKeyword))
     {
         var warning = _api.GetTranslation("wox_plugin_websearch_input_action_keyword");
         MessageBox.Show(warning);
     }
     else if (_action == Action.Add)
     {
         AddSearchSource();
     }
     else if (_action == Action.Edit)
     {
         EditSearchSource();
     }
 }
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (lbxFolders.SelectedItem is FolderLink selectedFolder)
            {
                string msg = string.Format(CultureInfo.InvariantCulture, _woxAPI.GetTranslation("wox_plugin_folder_delete_folder_link"), selectedFolder.Path);

                if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    _settings.FolderLinks.Remove(selectedFolder);
                    lbxFolders.Items.Refresh();
                }
            }
            else
            {
                string warning = _woxAPI.GetTranslation("wox_plugin_folder_select_folder_link_warning");
                MessageBox.Show(warning);
            }
        }
Example #12
0
 // Function to set the subtitle based on the Type of application
 public string SetSubtitle(uint AppType, IPublicAPI api)
 {
     if (AppType == (uint)ApplicationTypes.WIN32_APPLICATION)
     {
         return(api.GetTranslation("powertoys_run_plugin_program_win32_application"));
     }
     else if (AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
     {
         return(api.GetTranslation("powertoys_run_plugin_program_internet_shortcut_application"));
     }
     else if (AppType == (uint)ApplicationTypes.WEB_APPLICATION)
     {
         return(api.GetTranslation("powertoys_run_plugin_program_web_application"));
     }
     else
     {
         return(String.Empty);
     }
 }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var selectedFolder = lbxFolders.SelectedItem as FolderLink;

            if (selectedFolder != null)
            {
                string msg = string.Format(flowlauncherAPI.GetTranslation("flowlauncher_plugin_folder_delete_folder_link"), selectedFolder.Path);

                if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    _settings.FolderLinks.Remove(selectedFolder);
                    lbxFolders.Items.Refresh();
                }
            }
            else
            {
                string warning = flowlauncherAPI.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
                MessageBox.Show(warning);
            }
        }
 private void OnChooseClick(object sender, RoutedEventArgs e)
 {
     var fileBrowserDialog = new OpenFileDialog();
     fileBrowserDialog.Filter = _woxAPI.GetTranslation("wox_plugin_url_plugin_filter"); ;
     fileBrowserDialog.CheckFileExists = true;
     fileBrowserDialog.CheckPathExists = true;
     if (fileBrowserDialog.ShowDialog() == true)
     {
         browserPathBox.Text = fileBrowserDialog.FileName;
         _settings.BrowserPath = fileBrowserDialog.FileName;
     }
 }
Example #15
0
            public List <Result> ContextMenus(IPublicAPI api)
            {
                var contextMenus = new List <Result>
                {
                    new Result
                    {
                        Title  = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                        Action = _ =>
                        {
                            var hide = Main.StartProcess(new ProcessStartInfo(Package.Location));
                            return(hide);
                        },
                        IcoPath = "Images/folder.png"
                    }
                };

                return(contextMenus);
            }
Example #16
0
            public List <ContextMenuResult> ContextMenus(IPublicAPI api)
            {
                var contextMenus = new List <ContextMenuResult>
                {
                    new ContextMenuResult
                    {
                        PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                        Title                = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                        Glyph                = "\xE838",
                        FontFamily           = "Segoe MDL2 Assets",
                        AcceleratorKey       = "E",
                        AcceleratorModifiers = "Control,Shift",
                        Action               = _ =>
                        {
                            Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));

                            return(true);
                        }
                    }
                };

                return(contextMenus);
            }
Example #17
0
 // Function to set the subtitle based on the Type of application
 private string SetSubtitle(IPublicAPI api)
 {
     return(api.GetTranslation("powertoys_run_plugin_program_packaged_application"));
 }
Example #18
0
        public List <Result> ContextMenus(IPublicAPI api)
        {
            var contextMenus = new List <Result>
            {
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_run_as_different_user"),
                    Action = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info));

                        return(true);
                    },
                    IcoPath = "Images/user.png"
                },
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_run_as_administrator"),
                    Action = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            Verb             = "runas",
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(Process.Start, info));

                        return(true);
                    },
                    IcoPath = "Images/cmd.png"
                },
                new Result
                {
                    Title  = api.GetTranslation("flowlauncher_plugin_program_open_containing_folder"),
                    Action = _ =>
                    {
                        var args = !string.IsNullOrWhiteSpace(Main._settings.CustomizedArgs)
                                    ? Main._settings.CustomizedArgs
                                   .Replace("%s", $"\"{ParentDirectory}\"")
                                   .Replace("%f", $"\"{FullPath}\"")
                                    : Main._settings.CustomizedExplorer == Settings.Explorer
                                        ? $"/select,\"{FullPath}\""
                                        : Settings.ExplorerArgs;

                        Main.StartProcess(Process.Start,
                                          new ProcessStartInfo(
                                              !string.IsNullOrWhiteSpace(Main._settings.CustomizedExplorer)
                                                ? Main._settings.CustomizedExplorer
                                                : Settings.Explorer,
                                              args));

                        return(true);
                    },
                    IcoPath = "Images/folder.png"
                }
            };

            return(contextMenus);
        }
Example #19
0
 public List<Result> ContextMenus(IPublicAPI api)
 {
     var contextMenus = new List<Result>
     {
         new Result
         {
             Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
             Action = _ =>
             {
                 var info = new ProcessStartInfo
                 {
                     FileName = FullPath,
                     WorkingDirectory = ParentDirectory,
                     Verb = "runas"
                 };
                 var hide = Main.StartProcess(info);
                 return hide;
             },
             IcoPath = "Images/cmd.png"
         },
         new Result
         {
             Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
             Action = _ =>
             {
                 var hide = Main.StartProcess(new ProcessStartInfo(ParentDirectory));
                 return hide;
             },
             IcoPath = "Images/folder.png"
         }
     };
     return contextMenus;
 }
Example #20
0
        public Result Result(string query, IPublicAPI api)
        {
            var score = Score(query);

            if (score <= 0)
            { // no need to create result if this is zero
                return(null);
            }

            if (!hasArguments)
            {
                var noArgumentScoreModifier = 5;
                score += noArgumentScoreModifier;
            }
            else
            {
                // Filter Web Applications when searching for the main application
                if (FilterWebApplication(query))
                {
                    return(null);
                }
            }

            // NOTE: This is to display run commands only when there is an exact match, like in start menu
            if (!QueryEqualsNameForRunCommands(query))
            {
                return(null);
            }

            var result = new Result
            {
                SubTitle    = SetSubtitle(api),
                IcoPath     = IcoPath,
                Score       = score,
                ContextData = this,
                Action      = e =>
                {
                    var info = new ProcessStartInfo
                    {
                        FileName         = LnkResolvedPath ?? FullPath,
                        WorkingDirectory = ParentDirectory,
                        UseShellExecute  = true
                    };

                    Main.StartProcess(Process.Start, info);

                    return(true);
                }
            };

            // To set the title for the result to always be the name of the application
            result.Title = Name;
            result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;

            var toolTipTitle = string.Format("{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_name"), result.Title);
            var toolTipText  = string.Format("{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_path"), FullPath);

            result.ToolTipData = new ToolTipData(toolTipTitle, toolTipText);

            return(result);
        }
Example #21
0
 public List<Result> ContextMenus(IPublicAPI api)
 {
     var contextMenus = new List<Result>
     {
         new Result
         {
             Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
             Action = _ =>
             {
                 var hide = Main.StartProcess(new ProcessStartInfo(Package.Location));
                 return hide;
             },
             IcoPath = "Images/folder.png"
         }
     };
     return contextMenus;
 }
Example #22
0
            public List <ContextMenuResult> ContextMenus(IPublicAPI api)
            {
                var contextMenus = new List <ContextMenuResult>();

                if (CanRunElevated)
                {
                    contextMenus.Add(
                        new ContextMenuResult
                    {
                        PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                        Title                = api.GetTranslation("wox_plugin_program_run_as_administrator"),
                        Glyph                = "\xE7EF",
                        FontFamily           = "Segoe MDL2 Assets",
                        AcceleratorKey       = Key.Enter,
                        AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
                        Action               = _ =>
                        {
                            string command = "shell:AppsFolder\\" + UniqueIdentifier;
                            command.Trim();
                            command = Environment.ExpandEnvironmentVariables(command);

                            var info             = ShellCommand.SetProcessStartInfo(command, verb: "runas");
                            info.UseShellExecute = true;

                            Process.Start(info);
                            return(true);
                        }
                    }
                        );
                }
                contextMenus.Add(
                    new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                    Glyph                = "\xE838",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = Key.E,
                    AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
                    Action               = _ =>
                    {
                        Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));

                        return(true);
                    }
                });

                contextMenus.Add(new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_open_in_console"),
                    Glyph                = "\xE756",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = Key.C,
                    AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
                    Action               = (context) =>
                    {
                        try
                        {
                            Helper.OpenInConsole(Package.Location);
                            return(true);
                        }
                        catch (Exception e)
                        {
                            Log.Exception($"|Microsoft.Plugin.Program.UWP.ContextMenu| Failed to open {Name} in console, {e.Message}", e);
                            return(false);
                        }
                    }
                });

                return(contextMenus);
            }
Example #23
0
            public Result Result(string query, IPublicAPI api)
            {
                string      title;
                MatchResult matchResult;

                // We suppose Name won't be null
                if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description))
                {
                    title       = Name;
                    matchResult = StringMatcher.FuzzySearch(query, title);
                }
                else if (Description.StartsWith(Name))
                {
                    title       = Description;
                    matchResult = StringMatcher.FuzzySearch(query, Description);
                }
                else
                {
                    title = $"{Name}: {Description}";
                    var nameMatch       = StringMatcher.FuzzySearch(query, Name);
                    var desciptionMatch = StringMatcher.FuzzySearch(query, Description);
                    if (desciptionMatch.Score > nameMatch.Score)
                    {
                        for (int i = 0; i < desciptionMatch.MatchData.Count; i++)
                        {
                            desciptionMatch.MatchData[i] += Name.Length + 2; // 2 is ": "
                        }
                        matchResult = desciptionMatch;
                    }
                    else
                    {
                        matchResult = nameMatch;
                    }
                }

                if (!matchResult.Success)
                {
                    return(null);
                }

                var result = new Result
                {
                    Title              = title,
                    SubTitle           = Main._settings.HideAppsPath ? string.Empty : Package.Location,
                    Icon               = Logo,
                    Score              = matchResult.Score,
                    TitleHighlightData = matchResult.MatchData,
                    ContextData        = this,
                    Action             = e =>
                    {
                        var elevated = (
                            e.SpecialKeyState.CtrlPressed &&
                            e.SpecialKeyState.ShiftPressed &&
                            !e.SpecialKeyState.AltPressed &&
                            !e.SpecialKeyState.WinPressed
                            );

                        if (elevated && CanRunElevated)
                        {
                            LaunchElevated();
                        }
                        else
                        {
                            Launch(api);

                            if (elevated)
                            {
                                var title   = "Plugin: Program";
                                var message = api.GetTranslation("flowlauncher_plugin_program_run_as_administrator_not_supported_message");
                                api.ShowMsg(title, message, string.Empty);
                            }
                        }

                        return(true);
                    }
                };


                return(result);
            }
Example #24
0
        public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
        {
            try
            {
                UpdateInfo newUpdateInfo;

                if (!silentUpdate)
                {
                    api.ShowMsg(api.GetTranslation("pleaseWait"),
                                api.GetTranslation("update_flowlauncher_update_check"));
                }

                using var updateManager = await GitHubUpdateManager(GitHubRepository).ConfigureAwait(false);


                // UpdateApp CheckForUpdate will return value only if the app is squirrel installed
                newUpdateInfo = await updateManager.CheckForUpdate().NonNull().ConfigureAwait(false);

                var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
                var currentVersion    = Version.Parse(Constant.Version);

                Log.Info($"|Updater.UpdateApp|Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");

                if (newReleaseVersion <= currentVersion)
                {
                    if (!silentUpdate)
                    {
                        MessageBox.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
                    }
                    return;
                }

                if (!silentUpdate)
                {
                    api.ShowMsg(api.GetTranslation("update_flowlauncher_update_found"),
                                api.GetTranslation("update_flowlauncher_updating"));
                }

                await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply).ConfigureAwait(false);

                await updateManager.ApplyReleases(newUpdateInfo).ConfigureAwait(false);

                if (DataLocation.PortableDataLocationInUse())
                {
                    var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
                    FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination);
                    if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination))
                    {
                        MessageBox.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
                                                      DataLocation.PortableDataPath,
                                                      targetDestination));
                    }
                }
                else
                {
                    await updateManager.CreateUninstallerRegistryEntry().ConfigureAwait(false);
                }

                var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());

                Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");

                if (MessageBox.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    UpdateManager.RestartApp(Constant.ApplicationFileName);
                }
            }
            catch (Exception e) when(e is HttpRequestException || e is WebException || e is SocketException || e is TaskCanceledException)
            {
                Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
                api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
                            api.GetTranslation("update_flowlauncher_check_connection"));
                return;
            }
        }
Example #25
0
        public List <ContextMenuResult> ContextMenus(IPublicAPI api)
        {
            // To add a context menu only to open file location as Internet shortcut applications do not have the functionality to run as admin
            if (AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
            {
                var contextMenuItems = new List <ContextMenuResult>
                {
                    new ContextMenuResult
                    {
                        PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                        Title                = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                        Glyph                = "\xE838",
                        FontFamily           = "Segoe MDL2 Assets",
                        AcceleratorKey       = Key.E,
                        AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
                        Action               = _ =>
                        {
                            Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));
                            return(true);
                        }
                    }
                };
                return(contextMenuItems);
            }

            var contextMenus = new List <ContextMenuResult>
            {
                new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_run_as_administrator"),
                    Glyph                = "\xE7EF",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = Key.Enter,
                    AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
                    Action               = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            Verb             = "runas",
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(Process.Start, info));

                        return(true);
                    }
                },
                new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                    Glyph                = "\xE838",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = Key.E,
                    AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
                    Action               = _ =>
                    {
                        Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));

                        return(true);
                    }
                }
            };

            return(contextMenus);
        }
Example #26
0
        public List <ContextMenuResult> ContextMenus(IPublicAPI api)
        {
            var contextMenus = new List <ContextMenuResult>();

            if (AppType != (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
            {
                contextMenus.Add(new ContextMenuResult
                {
                    PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                    Title                = api.GetTranslation("wox_plugin_program_run_as_administrator"),
                    Glyph                = "\xE7EF",
                    FontFamily           = "Segoe MDL2 Assets",
                    AcceleratorKey       = Key.Enter,
                    AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
                    Action               = _ =>
                    {
                        var info = new ProcessStartInfo
                        {
                            FileName         = FullPath,
                            WorkingDirectory = ParentDirectory,
                            Verb             = "runas",
                            UseShellExecute  = true
                        };

                        Task.Run(() => Main.StartProcess(Process.Start, info));

                        return(true);
                    }
                });
            }

            contextMenus.Add(
                new ContextMenuResult
            {
                PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                Title                = api.GetTranslation("wox_plugin_program_open_containing_folder"),
                Glyph                = "\xE838",
                FontFamily           = "Segoe MDL2 Assets",
                AcceleratorKey       = Key.E,
                AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
                Action               = _ =>
                {
                    Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));
                    return(true);
                }
            });

            contextMenus.Add(
                new ContextMenuResult
            {
                PluginName           = Assembly.GetExecutingAssembly().GetName().Name,
                Title                = api.GetTranslation("wox_plugin_program_open_in_console"),
                Glyph                = "\xE756",
                FontFamily           = "Segoe MDL2 Assets",
                AcceleratorKey       = Key.C,
                AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
                Action               = (context) =>
                {
                    try
                    {
                        Helper.OpenInConsole(ParentDirectory);
                        return(true);
                    }
                    catch (Exception e)
                    {
                        Log.Exception($"|Microsoft.Plugin.Program.Win32.ContextMenu| Failed to open {Name} in console, {e.Message}", e);
                        return(false);
                    }
                }
            });

            return(contextMenus);
        }