Example #1
0
        public SettingsForm()
        {
            InitializeComponent();

            SuspendLayout();

            Language.SetControlLang(this);
            foreach (var label in groupColorsGroupBox.Controls.OfType <Label>())
            {
                if (string.IsNullOrEmpty(label.Text) || label.Text.EndsWith(":", StringComparison.Ordinal))
                {
                    continue;
                }
                label.Text += ':';
            }

            Icon = CacheData.GetSystemIcon(ImageResourceSymbol.SystemControl);

            transferPathBox.Text                = EnvironmentEx.GetVariablePathFull(Settings.TransferDir, false, false);
            transferPathBtn.BackgroundImage     = CacheData.GetSystemImage(ImageResourceSymbol.Directory);
            transferPathUndoBtn.BackgroundImage = CacheData.GetSystemImage(ImageResourceSymbol.Undo);
            if (Settings.TransferDir.EqualsEx(CorePaths.TransferDir))
            {
                transferPathUndoBtn.Enabled         = false;
                transferPathUndoBtn.BackgroundImage = transferPathUndoBtn.BackgroundImage.SwitchGrayScale(transferPathUndoBtn);
            }

            ResumeLayout(false);
        }
Example #2
0
        private void ScBtn_Click(object sender, EventArgs e)
        {
            var dir = PathEx.Combine(DirTB.Text);

            if (!Directory.Exists(dir))
            {
                return;
            }
            var path = PathEx.Combine(FilePathTB.Text);

            if (!File.Exists(path))
            {
                return;
            }
            var arguments = ArgsTB.Text;

            if (!string.IsNullOrWhiteSpace(arguments))
            {
                arguments = $" -- {arguments}";
            }
            arguments = string.Format(Resources.Args, EnvironmentEx.GetVariablePathFull(path, false), arguments).TrimEnd();
            var script  = PathEx.Combine(string.Format(Resources.ScriptPath, Path.GetFileName(path), new Crypto.Md5().EncryptFile(path)));
            var content = string.Format(Resources.ScriptDummy, EnvironmentEx.GetVariablePathFull(_appPath, false), EnvironmentEx.GetVariablePathFull(dir, false), arguments);

            File.WriteAllText(script, content);
            MessageBoxEx.Show(this, Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            ProcessEx.Start(Resources.ExplorerPath, Path.GetDirectoryName(script));
        }
        public SettingsForm()
        {
            InitializeComponent();

            Language.SetControlLang(this);
            foreach (var label in groupColorsGroupBox.Controls.OfType <Label>())
            {
                if (string.IsNullOrEmpty(label.Text) || label.Text.EndsWith(":"))
                {
                    continue;
                }
                label.Text += ':';
            }

            Icon = CacheData.GetSystemIcon(ResourcesEx.IconIndex.SystemControl);

            transferPathBox.Text                = EnvironmentEx.GetVariablePathFull(Settings.TransferDir, false, false);
            transferPathBtn.BackgroundImage     = CacheData.GetSystemImage(ResourcesEx.IconIndex.Directory);
            transferPathUndoBtn.BackgroundImage = CacheData.GetSystemImage(ResourcesEx.IconIndex.Undo);
            if (Settings.TransferDir.EqualsEx(CorePaths.TransferDir))
            {
                transferPathUndoBtn.Enabled         = false;
                transferPathUndoBtn.BackgroundImage = transferPathUndoBtn.BackgroundImage.SwitchGrayScale(transferPathUndoBtn);
            }

            appListGroupBox.ResumeLayout(false);
            appListGroupBox.PerformLayout();
            groupColorsGroupBox.ResumeLayout(false);
            ((ISupportInitialize)logoBox).EndInit();
            transferGroupBox.ResumeLayout(false);
            transferGroupBox.PerformLayout();
            advancedGroupBox.ResumeLayout(false);
            ResumeLayout(false);
        }
Example #4
0
        internal static void UpdateStartMenuShortcuts(IEnumerable <string> longAppNames)
        {
            var appNames = longAppNames?.ToArray();

            if (appNames?.Any() != true)
            {
                return;
            }
            try
            {
                var startMenuDir = PathEx.Combine(Environment.SpecialFolder.StartMenu, "Programs");
#if x86
                var shortcutPath = Path.Combine(startMenuDir, "Apps Launcher.lnk");
#else
                var shortcutPath = Path.Combine(startMenuDir, "Apps Launcher (64-bit).lnk");
#endif
                if (Directory.Exists(startMenuDir))
                {
                    var shortcuts = Directory.GetFiles(startMenuDir, "Apps Launcher*.lnk", SearchOption.TopDirectoryOnly);
                    if (shortcuts.Length > 0)
                    {
                        foreach (var shortcut in shortcuts)
                        {
                            File.Delete(shortcut);
                        }
                    }
                }
                if (!Directory.Exists(startMenuDir))
                {
                    Directory.CreateDirectory(startMenuDir);
                }
                FileEx.CreateShellLink(EnvironmentEx.GetVariablePathFull(PathEx.LocalPath, false), shortcutPath);
                startMenuDir = Path.Combine(startMenuDir, "Portable Apps");
                if (Directory.Exists(startMenuDir))
                {
                    var shortcuts = Directory.GetFiles(startMenuDir, "*.lnk", SearchOption.TopDirectoryOnly);
                    if (shortcuts.Length > 0)
                    {
                        foreach (var shortcut in shortcuts)
                        {
                            File.Delete(shortcut);
                        }
                    }
                }
                if (!Directory.Exists(startMenuDir))
                {
                    Directory.CreateDirectory(startMenuDir);
                }
                Parallel.ForEach(appNames, x => FileEx.CreateShellLink(EnvironmentEx.GetVariablePathFull(CacheData.FindAppData(x)?.FilePath, false, false), Path.Combine(startMenuDir, x)));
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
        }
Example #5
0
 private void TransferPathUndoBtn_Click(object sender, EventArgs e)
 {
     Settings.TransferDir = CorePaths.TransferDir;
     transferPathBox.Text = EnvironmentEx.GetVariablePathFull(Settings.TransferDir, false, false);
     if (transferPathUndoBtn.Enabled)
     {
         transferPathUndoBtn.Enabled         = false;
         transferPathUndoBtn.BackgroundImage = transferPathUndoBtn.BackgroundImage.SwitchGrayScale(transferPathUndoBtn);
     }
     MessageBoxEx.Show(this, Language.GetText(nameof(en_US.OperationCompletedMsg)), Resources.GlobalTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
 }
Example #6
0
 private void TransferPathBtn_Click(object sender, EventArgs e)
 {
     using (var dialog = new FolderBrowserDialog())
     {
         dialog.SelectedPath = Path.GetTempPath();
         if (dialog.ShowDialog() != DialogResult.OK)
         {
             MessageBoxEx.Show(this, Language.GetText(nameof(en_US.OperationCanceledMsg)), Resources.GlobalTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             return;
         }
         var transferDir = dialog.SelectedPath;
         if (transferDir.EqualsEx(Settings.TransferDir))
         {
             MessageBoxEx.Show(this, Language.GetText(nameof(en_US.OperationFailedMsg)), Resources.GlobalTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         var currentDrive  = PathEx.LocalPath.ToUpperInvariant().First();
         var transferDrive = transferDir.ToUpperInvariant().First();
         if (currentDrive.Equals(transferDrive))
         {
             MessageBoxEx.Show(this, Language.GetText(nameof(en_US.TransferDirMsg)), Resources.GlobalTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         var currentDir = Settings.TransferDir;
         Settings.TransferDir = transferDir;
         var dirChanged = !Settings.TransferDir.EqualsEx(currentDir);
         if (dirChanged)
         {
             transferPathBox.Text = EnvironmentEx.GetVariablePathFull(Settings.TransferDir, false, false);
             if (!transferPathUndoBtn.Enabled)
             {
                 transferPathUndoBtn.Enabled         = true;
                 transferPathUndoBtn.BackgroundImage = transferPathUndoBtn.BackgroundImage.SwitchGrayScale(transferPathUndoBtn);
             }
         }
         MessageBoxEx.Show(this, Language.GetText(dirChanged ? nameof(en_US.OperationCompletedMsg) : nameof(en_US.OperationFailedMsg)), Resources.GlobalTitle, MessageBoxButtons.OK, dirChanged ? MessageBoxIcon.Asterisk : MessageBoxIcon.Warning);
     }
 }
Example #7
0
        internal static void Enable(bool enabled, bool quiet = false)
        {
            if (!Elevation.IsAdministrator)
            {
                using (var process = ProcessEx.Start(PathEx.LocalPath, $"{ActionGuid.SystemIntegration} {enabled}", true, false))
                    if (process?.HasExited == false)
                    {
                        process.WaitForExit();
                    }
                return;
            }
            var varKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
            var varDir = Reg.ReadString(Registry.LocalMachine, varKey, Settings.EnvironmentVariable);
            var curDir = PathEx.LocalDir;

            if (!enabled || !varDir.EqualsEx(curDir))
            {
                var curPath    = EnvironmentEx.GetVariablePathFull(PathEx.LocalPath, false);
                var sendToPath = PathEx.Combine(Environment.SpecialFolder.SendTo, "Apps Launcher.lnk");
                if (enabled)
                {
                    Reg.Write(Registry.LocalMachine, varKey, Settings.EnvironmentVariable, curDir);
                    FileEx.CreateShellLink(curPath, sendToPath);
                }
                else
                {
                    Reg.RemoveEntry(Registry.LocalMachine, varKey, Settings.EnvironmentVariable);
                    PathEx.ForceDelete(sendToPath);
                }
                if (WinApi.NativeHelper.SendNotifyMessage((IntPtr)0xffff, (uint)WinApi.WindowMenuFlags.WmSettingChange, (UIntPtr)0, "Environment"))
                {
                    foreach (var baseKey in new[]
                    {
                        "*",
                        "Folder"
                    })
                    {
                        varKey = Path.Combine(baseKey, "shell\\portableapps");
                        if (enabled)
                        {
                            if (string.IsNullOrWhiteSpace(Reg.ReadString(Registry.ClassesRoot, varKey, null)))
                            {
                                Reg.Write(Registry.ClassesRoot, varKey, null, Language.GetText(nameof(en_US.shellText)));
                            }
                            Reg.Write(Registry.ClassesRoot, varKey, "Icon", $"\"{PathEx.LocalPath}\"");
                        }
                        else
                        {
                            Reg.RemoveSubKey(Registry.ClassesRoot, varKey);
                        }
                        varKey = Path.Combine(varKey, "command");
                        if (enabled)
                        {
                            Reg.Write(Registry.ClassesRoot, varKey, null, $"\"{PathEx.LocalPath}\" \"%1\"");
                        }
                        else
                        {
                            Reg.RemoveSubKey(Registry.ClassesRoot, varKey);
                        }
                    }
                    if (enabled)
                    {
                        if (TaskBar.Pin(PathEx.LocalPath))
                        {
                            var pinnedDir = PathEx.Combine(Environment.SpecialFolder.ApplicationData, "Microsoft", "Internet Explorer", "Quick Launch", "User Pinned", "TaskBar");
                            foreach (var file in Directory.GetFiles(pinnedDir, "*.lnk", SearchOption.TopDirectoryOnly))
                            {
                                if (!string.Equals(FileEx.GetShellLinkTarget(file), PathEx.LocalPath, StringComparison.CurrentCultureIgnoreCase))
                                {
                                    continue;
                                }
                                ProcessEx.SendHelper.Delete(file);
                                Environment.SetEnvironmentVariable(Settings.EnvironmentVariable, curDir, EnvironmentVariableTarget.Process);
                                FileEx.CreateShellLink(curPath, file);
                                break;
                            }
                        }
                    }
                    else
                    {
                        TaskBar.Unpin(PathEx.LocalPath);
                    }

                    if (enabled)
                    {
                        using (var process = ProcessEx.Start(PathEx.LocalPath, ActionGuid.FileTypeAssociationAll, true, false))
                            if (process?.HasExited == false)
                            {
                                process.WaitForExit();
                            }
                    }

                    if (!quiet)
                    {
                        MessageBox.Show(Language.GetText(nameof(en_US.OperationCompletedMsg)), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    return;
                }
            }
            if (!quiet)
            {
                MessageBox.Show(Language.GetText(nameof(en_US.OperationCanceledMsg)), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #8
0
        internal static void Associate(LocalAppData appData, bool quiet = false, Form owner = default)
        {
            if (appData?.Settings?.FileTypes?.Any() != true)
            {
                if (!quiet)
                {
                    MessageBoxEx.Show(owner, Language.GetText(nameof(en_US.associateBtnMsg)), Resources.GlobalTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return;
            }

            if (!Elevation.IsAdministrator)
            {
                if (owner != default)
                {
                    owner.TopMost = false;
                    owner.Enabled = false;
                    TaskBarProgress.SetState(owner.Handle, TaskBarProgressState.Indeterminate);
                }
                _bw?.Dispose();
                _bw         = new BackgroundWorker();
                _bw.DoWork += (sender, args) =>
                {
                    using (var process = ProcessEx.Start(PathEx.LocalPath, $"{ActionGuid.FileTypeAssociation} \"{appData.Key}\"", true, false))
                        if (!process?.HasExited == true)
                        {
                            process.WaitForExit();
                        }
                };
                _bw.RunWorkerCompleted += (sender, args) =>
                {
                    if (owner == default)
                    {
                        return;
                    }
                    TaskBarProgress.SetState(owner.Handle, TaskBarProgressState.NoProgress);
                    if (WinApi.NativeHelper.GetForegroundWindow() != owner.Handle)
                    {
                        WinApi.NativeHelper.SetForegroundWindow(owner.Handle);
                    }
                    owner.Enabled = true;
                    owner.TopMost = true;
                };
                _bw.RunWorkerAsync();
                return;
            }

            var assocData = new FileTypeAssocData
            {
                AppKey    = appData.Key,
                InstallId = Settings.SystemInstallId
            };

            using (var dialog = new IconBrowserDialog(Settings.IconResourcePath, Settings.Window.Colors.BaseDark, Settings.Window.Colors.ControlText, Settings.Window.Colors.Button, Settings.Window.Colors.ButtonText, Settings.Window.Colors.ButtonHover))
            {
                dialog.TopMost = true;
                dialog.Plus();
                dialog.ShowDialog();
                if (!string.IsNullOrEmpty(dialog.IconPath))
                {
                    assocData.IconPath = dialog.IconPath;
                    assocData.IconId   = dialog.IconId.ToString(CultureInfo.InvariantCulture);
                }
            }

            if (!FileEx.Exists(assocData.IconPath) || string.IsNullOrEmpty(assocData.IconId))
            {
                goto Cancel;
            }

            MessageBoxEx.ButtonText.OverrideEnabled = true;
            MessageBoxEx.ButtonText.Yes             = "App";
            MessageBoxEx.ButtonText.No     = "Launcher";
            MessageBoxEx.ButtonText.Cancel = Language.GetText(nameof(en_US.Cancel));
            var result = !quiet?MessageBoxEx.Show(Language.GetText(nameof(en_US.AssociateAppWayQuestion)), Resources.GlobalTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) : DialogResult.Yes;

            switch (result)
            {
            case DialogResult.Yes:
                assocData.StarterPath = EnvironmentEx.GetVariablePathFull(appData.FilePath, false, false);
                break;

            case DialogResult.No:
                assocData.StarterPath = EnvironmentEx.GetVariablePathFull(PathEx.LocalPath, false, false);
                break;

            default:
                goto Cancel;
            }

            if (FileEx.Exists(assocData.StarterPath))
            {
                appData.Settings.FileTypeAssoc = assocData;
            }
            else
            {
                goto Cancel;
            }

            assocData = appData.Settings?.FileTypeAssoc;
            assocData?.SystemRegistryAccess?.AssociateFileTypes(false);
            return;

Cancel:
            if (!quiet)
            {
                MessageBoxEx.Show(owner, Language.GetText(nameof(en_US.OperationCanceledMsg)), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public static void Find(out string javaPath)
        {
            // Read saved path from config.
            javaPath = null;
            if (File.Exists(Attributes.ConfigPath))
            {
                javaPath = Ini.ReadDirect("Java", "Path", Attributes.ConfigPath);
                if (!string.IsNullOrWhiteSpace(javaPath))
                {
                    javaPath = PathEx.Combine(javaPath);
                }
                if (File.Exists(javaPath))
                {
                    goto Found;
                }
            }

            // Try getting the default path from Portable Apps Suite JRE installation.
            try
            {
                var dir = EnvironmentEx.GetVariableValue("AppsSuiteDir");
                if (Directory.Exists(dir))
                {
#if x86
                    dir = Path.Combine(dir, "Apps", "CommonFiles", "Java");
#else
                    dir = Path.Combine(dir, "Apps", "CommonFiles", "Java64");
                    if (!Directory.Exists(dir))
                    {
                        Path.Combine(dir, "Apps", "CommonFiles", "Java");
                    }
#endif
                    if (Directory.Exists(dir))
                    {
                        javaPath = GetPath(dir);
                        if (File.Exists(javaPath))
                        {
                            goto Found;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }

            // Start searching for the portable JRE, starting in the current directory.
            try
            {
                var dir = PathEx.LocalDir;
                var drive = new DriveInfo(dir).RootDirectory.Root.Name;
                int count = 0, length = dir.Split(Path.DirectorySeparatorChar).Length;
                var subs = new[]
                {
#if x64
                    "_CommonFiles\\Java64",
                    "CommonFiles\\Java64",
#endif
                    "_CommonFiles\\Java",
                    "CommonFiles\\Java"
                };
                while (!drive.ContainsEx(dir) && ++count < length)
                {
                    foreach (var sub in subs)
                    {
                        var tmp = Path.Combine(dir, sub);
                        if (!Directory.Exists(tmp))
                        {
                            continue;
                        }
                        javaPath = GetPath(tmp);
                        if (File.Exists(javaPath))
                        {
                            goto Found;
                        }
                    }
                    dir = PathEx.Combine(dir, "..").TrimEnd(Path.DirectorySeparatorChar);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }

            // Try getting the default path from the global JRE installation.
            try
            {
                var dirs = new[]
                {
                    "%ProgramFiles%\\Java",
#if x64
                    "%ProgramFiles(x86)%\\Java",
#endif
                    "%ProgramData%\\Oracle\\Java\\javapath"
                };
                foreach (var dir in dirs.Select(PathEx.Combine))
                {
                    if (!Directory.Exists(dir))
                    {
                        continue;
                    }
                    javaPath = GetPath(dir);
                    if (File.Exists(javaPath))
                    {
                        goto Found;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }

            // If JRE was not found.
            MessageBox.Show(Strings.JavaWarnMessage, AssemblyInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            Environment.ExitCode = 1;
            Environment.Exit(Environment.ExitCode);

            // Else
Found:
            var envPath = EnvironmentEx.GetVariablePathFull(javaPath);
            Ini.WriteDirect(nameof(JavaHandler), "Path", envPath, Attributes.ConfigPath);

            var usageDir = PathEx.Combine("%UserProfile%\\.oracle_jre_usage");
            try
            {
                if (!Directory.Exists(usageDir))
                {
                    Directory.CreateDirectory(usageDir);
                }
                DirectoryEx.SetAttributes(usageDir, FileAttributes.Hidden);
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
            AppDomain.CurrentDomain.ProcessExit += (s, e) => DirectoryEx.TryDelete(usageDir);
        }
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            var appData = CacheData.FindAppData(appsBox.SelectedItem.ToString());

            if (appData != default(LocalAppData))
            {
                if (string.IsNullOrWhiteSpace(fileTypes.Text))
                {
                    appData.Settings.FileTypes = default(string[]);
                }
                else
                {
                    if (e == EventArgs.Empty || !FileTypesConflict())
                    {
                        var typesList = new List <string>();
                        foreach (var item in $"{fileTypes.Text},".Split(','))
                        {
                            if (string.IsNullOrWhiteSpace(item))
                            {
                                continue;
                            }
                            var type = new string(item.ToCharArray().Where(c => !Path.GetInvalidFileNameChars().Contains(c) && !char.IsWhiteSpace(c)).ToArray());
                            if (string.IsNullOrWhiteSpace(type) || type.Length < 1)
                            {
                                continue;
                            }
                            if (type.StartsWith("."))
                            {
                                while (type.Contains(".."))
                                {
                                    type = type.Replace("..", ".");
                                }
                                if (typesList.ContainsEx(type) || typesList.ContainsEx(type.Substring(1)))
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                if (typesList.ContainsEx(type) || typesList.ContainsEx($".{type}"))
                                {
                                    continue;
                                }
                            }
                            if (type.Length == 1 && type.StartsWith("."))
                            {
                                continue;
                            }
                            typesList.Add(type);
                        }
                        if (typesList.Any())
                        {
                            var comparer = new Comparison.AlphanumericComparer();
                            typesList                  = typesList.OrderBy(x => x, comparer).ToList();
                            fileTypes.Text             = typesList.Join(",");
                            appData.Settings.FileTypes = typesList.ToArray();
                        }
                    }
                    else
                    {
                        fileTypes.Text = appData.Settings.FileTypes.Join(',');
                    }
                }

                appData.Settings.StartArgsFirst = startArgsFirst.Text;
                appData.Settings.StartArgsLast  = startArgsLast.Text;

                appData.Settings.SortArgPaths = sortArgPathsCheck.Checked;
                appData.Settings.NoConfirm    = noConfirmCheck.Checked;
                appData.Settings.RunAsAdmin   = runAsAdminCheck.Checked;
                appData.Settings.NoUpdates    = noUpdatesCheck.Checked;
            }

            if (defBgCheck.Checked)
            {
                if (CacheData.CurrentImageBg != default(Image))
                {
                    CacheData.CurrentImageBg = default(Image);
                    if (Result != DialogResult.Yes)
                    {
                        Result = DialogResult.Yes;
                    }
                }
                bgLayout.SelectedIndex = 1;
            }

            Settings.Window.FadeInEffect   = (Settings.Window.FadeInEffectOptions)fadeInCombo.SelectedIndex;
            Settings.Window.FadeInDuration = (int)fadeInNum.Value;
            Settings.Window.Opacity        = (double)opacityNum.Value;

            Settings.Window.BackgroundImageLayout = (ImageLayout)bgLayout.SelectedIndex;

            Settings.Window.Colors.Base        = mainColorPanel.BackColor;
            Settings.Window.Colors.Control     = controlColorPanel.BackColor;
            Settings.Window.Colors.ControlText = controlTextColorPanel.BackColor;
            Settings.Window.Colors.Button      = btnColorPanel.BackColor;
            Settings.Window.Colors.ButtonHover = btnHoverColorPanel.BackColor;
            Settings.Window.Colors.ButtonText  = btnTextColorPanel.BackColor;

            Settings.Window.HideHScrollBar = hScrollBarCheck.Checked;
            Settings.Window.LargeImages    = showLargeImagesCheck.Checked;

            var dirList = new List <string>();

            if (!string.IsNullOrWhiteSpace(appDirs.Text))
            {
                var tmpDir = appDirs.Text + Environment.NewLine;
                foreach (var item in tmpDir.SplitNewLine())
                {
                    if (string.IsNullOrWhiteSpace(item))
                    {
                        continue;
                    }
                    var dir = PathEx.Combine(item);
                    try
                    {
                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }
                        dir = EnvironmentEx.GetVariablePathFull(dir);
                        if (!dirList.ContainsEx(dir))
                        {
                            dirList.Add(dir);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                }
                if (dirList.Count > 0)
                {
                    dirList.Sort();
                    appDirs.Text = dirList.Join(Environment.NewLine);
                }
            }
            Settings.AppDirs = dirList.ToArray();

            Settings.StartMenuIntegration = startMenuIntegration.SelectedIndex > 0;
            if (!Settings.StartMenuIntegration)
            {
                try
                {
                    var shortcutDirs = new[]
                    {
                        Environment.GetFolderPath(Environment.SpecialFolder.SendTo),
                        PathEx.Combine(Environment.SpecialFolder.StartMenu, "Programs")
                    };
                    foreach (var dir in shortcutDirs)
                    {
                        var shortcuts = Directory.GetFiles(dir, "Apps Launcher*.lnk", SearchOption.TopDirectoryOnly);
                        foreach (var shortcut in shortcuts)
                        {
                            if (File.Exists(shortcut))
                            {
                                File.Delete(shortcut);
                            }
                        }
                    }
                    var startMenuDir = Path.Combine(shortcutDirs.Last(), "Portable Apps");
                    if (Directory.Exists(startMenuDir))
                    {
                        Directory.Delete(startMenuDir, true);
                    }
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                }
            }

            Settings.Window.DefaultPosition = defaultPos.SelectedIndex;

            Settings.UpdateCheck   = (Settings.UpdateCheckOptions)updateCheck.SelectedIndex;
            Settings.UpdateChannel = (Settings.UpdateChannelOptions)updateChannel.SelectedIndex;

            var lang = setLang.SelectedItem.ToString();

            if (!Settings.Language.EqualsEx(lang))
            {
                if (Result != DialogResult.Yes)
                {
                    Result = DialogResult.Yes;
                }
                Settings.Language = lang;
                LoadSettings();
            }

            Settings.WriteToFile();

            MessageBoxEx.Show(this, Language.GetText(nameof(en_US.SavedSettings)), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
        private void LoadSettings()
        {
            if (!setLang.Items.Contains(Settings.Language))
            {
                Settings.Language = "en-US";
            }
            setLang.SelectedItem = Settings.Language;
            Language.UserLang    = Settings.Language;

            Language.SetControlLang(this);

            var title = Language.GetText(nameof(en_US.settingsBtn));

            if (!string.IsNullOrWhiteSpace(title))
            {
                Text = title;
            }

            for (var i = 0; i < fileTypesMenu.Items.Count; i++)
            {
                fileTypesMenu.Items[i].Text = Language.GetText(fileTypesMenu.Items[i].Name);
            }

            var decValue = (decimal)Settings.Window.Opacity;

            opacityNum.Value = decValue >= opacityNum.Minimum && decValue <= opacityNum.Maximum ? decValue : .95m;

            var intValue = (int)Settings.Window.FadeInEffect;

            fadeInCombo.SelectedIndex = intValue < fadeInCombo.Items.Count ? intValue : 0;

            intValue        = Settings.Window.FadeInDuration;
            fadeInNum.Value = intValue >= fadeInNum.Minimum && intValue <= fadeInNum.Maximum ? intValue : 100;

            defBgCheck.Checked = !File.Exists(CachePaths.CurrentImageBg);
            if (bgLayout.Items.Count > 0)
            {
                bgLayout.Items.Clear();
            }
            for (var i = 0; i < 5; i++)
            {
                bgLayout.Items.Add(Language.GetText($"{bgLayout.Name}Option{i}"));
            }

            intValue = (int)Settings.Window.BackgroundImageLayout;
            bgLayout.SelectedIndex = intValue > 0 && intValue < bgLayout.Items.Count ? intValue : 1;

            mainColorPanel.BackColor        = Settings.Window.Colors.Base;
            controlColorPanel.BackColor     = Settings.Window.Colors.Control;
            controlTextColorPanel.BackColor = Settings.Window.Colors.ControlText;
            btnColorPanel.BackColor         = Settings.Window.Colors.Button;
            btnHoverColorPanel.BackColor    = Settings.Window.Colors.ButtonHover;
            btnTextColorPanel.BackColor     = Settings.Window.Colors.ButtonText;

            hScrollBarCheck.Checked      = Settings.Window.HideHScrollBar;
            showLargeImagesCheck.Checked = Settings.Window.LargeImages;

            StylePreviewUpdate();

            appDirs.Text = Settings.AppDirs?.Where(x => !CorePaths.AppDirs.ContainsEx(x)).Select(x => EnvironmentEx.GetVariablePathFull(x)).Join(Environment.NewLine);

            if (startMenuIntegration.Items.Count > 0)
            {
                startMenuIntegration.Items.Clear();
            }
            for (var i = 0; i < 2; i++)
            {
                startMenuIntegration.Items.Add(Language.GetText($"{startMenuIntegration.Name}Option{i}"));
            }
            startMenuIntegration.SelectedIndex = Settings.StartMenuIntegration ? 1 : 0;

            if (defaultPos.Items.Count > 0)
            {
                defaultPos.Items.Clear();
            }
            for (var i = 0; i < 2; i++)
            {
                defaultPos.Items.Add(Language.GetText($"{defaultPos.Name}Option{i}"));
            }

            intValue = Settings.Window.DefaultPosition;
            defaultPos.SelectedIndex = intValue > 0 && intValue < defaultPos.Items.Count ? intValue : 0;
            if (updateCheck.Items.Count > 0)
            {
                updateCheck.Items.Clear();
            }
            for (var i = 0; i < 10; i++)
            {
                updateCheck.Items.Add(Language.GetText($"{updateCheck.Name}Option{i}"));
            }

            intValue = (int)Settings.UpdateCheck;
            updateCheck.SelectedIndex = intValue > 0 && intValue < updateCheck.Items.Count ? intValue : 0;
            if (updateChannel.Items.Count > 0)
            {
                updateChannel.Items.Clear();
            }
            for (var i = 0; i < 2; i++)
            {
                updateChannel.Items.Add(Language.GetText($"{updateChannel.Name}Option{i}"));
            }

            intValue = (int)Settings.UpdateChannel;
            updateChannel.SelectedIndex = intValue > 0 ? 1 : 0;

            if (!saveBtn.Focused)
            {
                saveBtn.Select();
            }
        }
Example #12
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            var section = Main.GetAppInfo(appsBox.SelectedItem.ToString()).ShortName;

            if (!string.IsNullOrWhiteSpace(section))
            {
                var types = string.Empty;
                if (!string.IsNullOrWhiteSpace(fileTypes.Text))
                {
                    if (e == EventArgs.Empty || !FileTypesConflict())
                    {
                        var typesList = new List <string>();
                        foreach (var item in $"{fileTypes.Text},".Split(','))
                        {
                            if (string.IsNullOrWhiteSpace(item))
                            {
                                continue;
                            }
                            var type = new string(item.ToCharArray().Where(c => !Path.GetInvalidFileNameChars().Contains(c) && !char.IsWhiteSpace(c)).ToArray());
                            if (string.IsNullOrWhiteSpace(type) || type.Length < 1)
                            {
                                continue;
                            }
                            if (type.StartsWith("."))
                            {
                                while (type.Contains(".."))
                                {
                                    type = type.Replace("..", ".");
                                }
                                if (typesList.ContainsEx(type) || typesList.ContainsEx(type.Substring(1)))
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                if (typesList.ContainsEx(type) || typesList.ContainsEx($".{type}"))
                                {
                                    continue;
                                }
                            }
                            if (type.Length == 1 && type.StartsWith("."))
                            {
                                continue;
                            }
                            typesList.Add(type);
                        }
                        if (typesList.Count > 0)
                        {
                            typesList.Sort();
                            types          = typesList.Join(",");
                            fileTypes.Text = types;
                        }
                    }
                    else
                    {
                        fileTypes.Text = Ini.Read(section, "FileTypes");
                    }
                }

                Ini.Write(section, "FileTypes", !string.IsNullOrWhiteSpace(types) ? types : null);

                Ini.Write(section, "StartArgs.First", !string.IsNullOrWhiteSpace(startArgsFirst.Text) ? startArgsFirst.Text.EncodeToBase64() : null);
                Ini.Write(section, "StartArgs.Last", !string.IsNullOrWhiteSpace(startArgsLast.Text) ? startArgsLast.Text.EncodeToBase64() : null);

                Ini.Write(section, "NoConfirm", noConfirmCheck.Checked ? (bool?)true : null);
                Ini.Write(section, "RunAsAdmin", runAsAdminCheck.Checked ? (bool?)true : null);
                Ini.Write(section, "NoUpdates", noUpdatesCheck.Checked ? (bool?)true : null);
            }

            if (defBgCheck.Checked)
            {
                try
                {
                    var bgPath = PathEx.Combine(Main.TmpDir, "ImageBg.dat");
                    if (File.Exists(bgPath))
                    {
                        File.Delete(bgPath);
                        _result = DialogResult.Yes;
                    }
                    Main.BackgroundImage   = Depiction.DimEmpty;
                    bgLayout.SelectedIndex = 1;
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                }
            }

            Ini.Write("Settings", "Window.Opacity", opacityNum.Value != 95 ? (int?)opacityNum.Value : null);
            Ini.Write("Settings", "Window.FadeInEffect", fadeInCombo.SelectedIndex != 0 ? (int?)fadeInCombo.SelectedIndex : null);
            Ini.Write("Settings", "Window.FadeInDuration", fadeInNum.Value != 100 ? (int?)fadeInNum.Value : null);
            Ini.Write("Settings", "Window.BackgroundImageLayout", bgLayout.SelectedIndex != 1 ? (int?)bgLayout.SelectedIndex : null);

            Ini.Write("Settings", "Window.CustomColors", _customColors?.Length > 0 ? _customColors : null);
            var color = mainColorPanel.BackColor;

            Ini.Write("Settings", "Window.Colors.Base", color != Main.Colors.System ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : null);
            color = controlColorPanel.BackColor;
            Ini.Write("Settings", "Window.Colors.Control", color != SystemColors.Window ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : null);
            color = controlTextColorPanel.BackColor;
            Ini.Write("Settings", "Window.Colors.ControlText", color != SystemColors.WindowText ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : null);
            color = btnColorPanel.BackColor;
            Ini.Write("Settings", "Window.Colors.Button", color != SystemColors.ButtonFace ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : null);
            color = btnHoverColorPanel.BackColor;
            Ini.Write("Settings", "Window.Colors.ButtonHover", color != ProfessionalColors.ButtonSelectedHighlight ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : null);
            color = btnTextColorPanel.BackColor;
            Ini.Write("Settings", "Window.Colors.ButtonText", color != SystemColors.ControlText ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : null);

            Ini.Write("Settings", "Window.HideHScrollBar", hScrollBarCheck.Checked ? (bool?)hScrollBarCheck.Checked : null);

            string dirs = null;

            if (!string.IsNullOrWhiteSpace(appDirs.Text))
            {
                var dirList = new List <string>();
                var tmpDir  = appDirs.Text + Environment.NewLine;
                foreach (var item in tmpDir.SplitNewLine())
                {
                    if (string.IsNullOrWhiteSpace(item))
                    {
                        continue;
                    }
                    var dir = PathEx.Combine(item);
                    try
                    {
                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }
                        dir = EnvironmentEx.GetVariablePathFull(dir);
                        if (!dirList.ContainsEx(dir))
                        {
                            dirList.Add(dir);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                }
                if (dirList.Count > 0)
                {
                    dirList.Sort();
                    dirs         = dirList.Join(Environment.NewLine);
                    appDirs.Text = dirs;
                }
            }

            Ini.Write("Settings", "AppDirs", !string.IsNullOrWhiteSpace(dirs) ? dirs.EncodeToBase64() : null);

            Ini.Write("Settings", "StartMenuIntegration", startMenuIntegration.SelectedIndex != 0 ? (bool?)true : null);
            if (startMenuIntegration.SelectedIndex == 0)
            {
                try
                {
                    var startMenuFolderPath = PathEx.Combine("%StartMenu%\\Programs");
#if x86
                    var launcherShortcutPath = Path.Combine(startMenuFolderPath, "Apps Launcher.lnk");
#else
                    var launcherShortcutPath = Path.Combine(startMenuFolderPath, "Apps Launcher (64-bit).lnk");
#endif
                    if (File.Exists(launcherShortcutPath))
                    {
                        File.Delete(launcherShortcutPath);
                    }
                    startMenuFolderPath = Path.Combine(startMenuFolderPath, "Portable Apps");
                    if (Directory.Exists(startMenuFolderPath))
                    {
                        Directory.Delete(startMenuFolderPath, true);
                    }
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                }
            }

            Ini.Write("Settings", "Window.DefaultPosition", defaultPos.SelectedIndex != 0 ? (int?)defaultPos.SelectedIndex : null);

            Ini.Write("Settings", "UpdateCheck", updateCheck.SelectedIndex != 4 ? (int?)updateCheck.SelectedIndex : null);
            Ini.Write("Settings", "UpdateChannel", updateChannel.SelectedIndex != 0 ? (int?)updateChannel.SelectedIndex : null);

            var lang = Ini.Read <string>("Settings", "Lang", Lang.SystemUi);
            if (!lang.EqualsEx(setLang.SelectedItem.ToString()))
            {
                Ini.Write("Settings", "Lang", !Lang.SystemUi.EqualsEx(setLang.SelectedItem.ToString()) ? setLang.SelectedItem : null);
                _result = DialogResult.Yes;
                LoadSettings();
            }

            Ini.WriteAll();
            MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.SavedSettings)), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
Example #13
0
        private void AppMenuItem_Click(object sender, EventArgs e)
        {
            if (appsListView.SelectedItems.Count == 0)
            {
                return;
            }
            var owner = sender as ToolStripMenuItem;

            switch (owner?.Name)
            {
            case "appMenuItem1":
            case "appMenuItem2":
            case "appMenuItem3":
                if (Opacity > 0)
                {
                    Opacity = 0;
                }
                switch (owner.Name)
                {
                case "appMenuItem1":
                case "appMenuItem2":
                    _appStartEventCalled = true;
                    Main.StartApp(appsListView.SelectedItems[0].Text, true, owner.Name.EqualsEx("appMenuItem2"));
                    break;

                case "appMenuItem3":
                    _appStartEventCalled = true;
                    Main.OpenAppLocation(appsListView.SelectedItems[0].Text, true);
                    break;
                }
                break;

            case "appMenuItem4":
                MessageBoxEx.CenterMousePointer = !ClientRectangle.Contains(PointToClient(MousePosition));
                var targetPath = EnvironmentEx.GetVariablePathFull(Main.GetAppPath(appsListView.SelectedItems[0].Text), false);
                var linkPath   = Path.Combine("%Desktop%", appsListView.SelectedItems[0].Text);
                if (Data.CreateShortcut(targetPath, linkPath))
                {
                    MessageBoxEx.Show(this, Lang.GetText($"{owner.Name}Msg0"), Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBoxEx.Show(this, Lang.GetText($"{owner.Name}Msg1"), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

            case "appMenuItem5":
                MessageBoxEx.CenterMousePointer = !ClientRectangle.Contains(PointToClient(MousePosition));
                var appPath = Main.GetAppPath(appsListView.SelectedItems[0].Text);
                if (Data.PinToTaskbar(appPath))
                {
                    MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.appMenuItem4Msg0)), Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.appMenuItem4Msg1)), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

            case "appMenuItem6":
                if (appsListView.SelectedItems.Count > 0)
                {
                    if (!appsListView.LabelEdit)
                    {
                        appsListView.LabelEdit = true;
                    }
                    appsListView.SelectedItems[0].BeginEdit();
                }
                break;

            case "appMenuItem7":
                MessageBoxEx.CenterMousePointer = !ClientRectangle.Contains(PointToClient(MousePosition));
                if (MessageBoxEx.Show(this, string.Format(Lang.GetText($"{owner.Name}Msg"), appsListView.SelectedItems[0].Text), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    MessageBoxEx.CenterMousePointer = !ClientRectangle.Contains(PointToClient(MousePosition));
                    try
                    {
                        var appInfo = Main.GetAppInfo(appsListView.SelectedItems[0].Text);
                        var appDir  = Main.GetAppLocation(appInfo.ShortName);
                        if (Directory.Exists(appDir))
                        {
                            try
                            {
                                var imgCachePath = PathEx.Combine(Main.TmpDir, "images.dat");
                                if (File.Exists(imgCachePath))
                                {
                                    File.Delete(imgCachePath);
                                }
                                Directory.Delete(appDir, true);
                            }
                            catch
                            {
                                if (!Data.ForceDelete(appDir))
                                {
                                    _appStartEventCalled = true;
                                    Data.ForceDelete(appDir, true);
                                }
                            }
                            Ini.RemoveSection(appInfo.ShortName);
                            Ini.WriteAll();
                            MenuViewForm_Update(false);
                            MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.OperationCompletedMsg)), Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            _appStartEventCalled = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                        MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.OperationFailedMsg)), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBoxEx.CenterMousePointer = !ClientRectangle.Contains(PointToClient(MousePosition));
                    MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.OperationCanceledMsg)), Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                break;
            }
            if (MessageBoxEx.CenterMousePointer)
            {
                MessageBoxEx.CenterMousePointer = false;
            }
        }
        internal static void Enable(bool enabled, bool quiet = false)
        {
            if (!Elevation.IsAdministrator)
            {
                using (var process = ProcessEx.Start(PathEx.LocalPath, $"{ActionGuid.SystemIntegration} {enabled} {quiet}", true, false))
                    if (process?.HasExited == false)
                    {
                        process.WaitForExit();
                    }
                return;
            }
            var varKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
            var varDir = Reg.ReadString(Registry.LocalMachine, varKey, Settings.EnvironmentVariable);
            var curDir = PathEx.LocalDir;

            if (!enabled || !varDir.EqualsEx(curDir))
            {
                var curPath    = EnvironmentEx.GetVariablePathFull(PathEx.LocalPath, false);
                var sendToPath = PathEx.Combine(Environment.SpecialFolder.SendTo, "Apps Launcher.lnk");
                if (enabled)
                {
                    Reg.Write(Registry.LocalMachine, varKey, Settings.EnvironmentVariable, curDir);
                    FileEx.CreateShellLink(curPath, sendToPath);
                }
                else
                {
                    Reg.RemoveEntry(Registry.LocalMachine, varKey, Settings.EnvironmentVariable);
                    PathEx.ForceDelete(sendToPath);
                }
                if (WinApi.NativeHelper.SendNotifyMessage((IntPtr)0xffff, (uint)WinApi.WindowMenuFlags.WmSettingChange, (UIntPtr)0, "Environment"))
                {
                    foreach (var baseKey in new[]
                    {
                        "*",
                        "Folder"
                    })
                    {
                        varKey = Path.Combine(baseKey, "shell\\portableapps");
                        if (enabled)
                        {
                            if (string.IsNullOrWhiteSpace(Reg.ReadString(Registry.ClassesRoot, varKey, null)))
                            {
                                Reg.Write(Registry.ClassesRoot, varKey, null, Language.GetText(nameof(en_US.shellText)));
                            }
                            Reg.Write(Registry.ClassesRoot, varKey, "Icon", $"\"{PathEx.LocalPath}\"");
                        }
                        else
                        {
                            Reg.RemoveSubKey(Registry.ClassesRoot, varKey);
                        }
                        varKey = Path.Combine(varKey, "command");
                        if (enabled)
                        {
                            Reg.Write(Registry.ClassesRoot, varKey, null, $"\"{PathEx.LocalPath}\" \"%1\"");
                        }
                        else
                        {
                            Reg.RemoveSubKey(Registry.ClassesRoot, varKey);
                        }
                    }
                    var desktopPath = PathEx.Combine(Environment.SpecialFolder.Desktop, "Apps Launcher.lnk");
                    if (enabled)
                    {
                        FileEx.CreateShellLink(curPath, desktopPath);
                    }
                    else
                    {
                        PathEx.ForceDelete(sendToPath);
                    }

                    if (enabled)
                    {
                        using (var process = ProcessEx.Start(PathEx.LocalPath, ActionGuid.FileTypeAssociationAll, true, false))
                            if (process?.HasExited == false)
                            {
                                process.WaitForExit();
                            }
                    }

                    if (!quiet)
                    {
                        MessageBox.Show(Language.GetText(nameof(en_US.OperationCompletedMsg)), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    return;
                }
            }
            if (!quiet)
            {
                MessageBox.Show(Language.GetText(nameof(en_US.OperationCanceledMsg)), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #15
0
        private void AppMenuItem_Click(object sender, EventArgs e)
        {
            var owner = sender as ToolStripMenuItem;

            switch (owner?.Name)
            {
            case "appMenuItem1":
                Main.StartApp(appsBox.SelectedItem.ToString(), true);
                break;

            case "appMenuItem2":
                Main.StartApp(appsBox.SelectedItem.ToString(), true, true);
                break;

            case "appMenuItem3":
                Main.OpenAppLocation(appsBox.SelectedItem.ToString());
                break;

            case "appMenuItem4":
                var targetPath = EnvironmentEx.GetVariablePathFull(Main.GetAppPath(appsBox.SelectedItem.ToString()), false);
                var linkPath   = Path.Combine("%Desktop%", appsBox.SelectedItem.ToString());
                if (Data.CreateShortcut(targetPath, linkPath, Main.ReceivedPathsStr))
                {
                    MessageBoxEx.Show(this, Lang.GetText($"{owner.Name}Msg0"), Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBoxEx.Show(this, Lang.GetText($"{owner.Name}Msg1"), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

            case "appMenuItem7":
                if (MessageBoxEx.Show(this, string.Format(Lang.GetText($"{owner.Name}Msg"), appsBox.SelectedItem), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    MessageBoxEx.CenterMousePointer = !ClientRectangle.Contains(PointToClient(MousePosition));
                    try
                    {
                        var appInfo = Main.GetAppInfo(appsBox.SelectedItem.ToString());
                        var appDir  = Main.GetAppLocation(appInfo.ShortName);
                        if (Directory.Exists(appDir))
                        {
                            try
                            {
                                var imgCachePath = PathEx.Combine(Main.TmpDir, "images.dat");
                                if (File.Exists(imgCachePath))
                                {
                                    File.Delete(imgCachePath);
                                }
                                Directory.Delete(appDir, true);
                            }
                            catch
                            {
                                if (!Data.ForceDelete(appDir))
                                {
                                    Data.ForceDelete(appDir, true);
                                }
                            }
                            Ini.RemoveSection(appInfo.ShortName);
                            Ini.WriteAll();
                            appsBox.Items.RemoveAt(appsBox.SelectedIndex);
                            if (appsBox.SelectedIndex < 0)
                            {
                                appsBox.SelectedIndex = 0;
                            }
                            MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.OperationCompletedMsg)), Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                        MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.OperationFailedMsg)), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBoxEx.CenterMousePointer = !ClientRectangle.Contains(PointToClient(MousePosition));
                    MessageBoxEx.Show(this, Lang.GetText(nameof(en_US.OperationCanceledMsg)), Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                break;
            }
        }