Example #1
0
        internal CustomShortcut(
            string shortcutName,
            string targetPath,
            string targetArguments,
            CustomShortcutType shortcutType,
            WindowType windowType,
            string shortcutRootFolder,
            string basicIconToUse = null,
            string workingFolder  = null
            )
        {
            var vbsFolderPath =
                DirectoryUtils.GetUniqueDirName(CustomShortcutGetters.CustomShortcutVbsPath + shortcutName) + "\\";
            var shortcutPath = $"{shortcutRootFolder}{new DirectoryInfo(vbsFolderPath).Name}\\{shortcutName}.lnk";


            ShortcutName    = shortcutName.CleanInvalidFilenameChars();
            ShortcutItem    = new ShortcutItem(shortcutPath);
            TargetPath      = targetPath;
            TargetArguments = targetArguments;
            ShortcutType    = shortcutType;
            VbsFolderPath   = vbsFolderPath;
            WorkingFolder   = workingFolder;
            WindowType      = windowType;

            Directory.CreateDirectory(VbsFolderPath);

            if (basicIconToUse != null && File.Exists(basicIconToUse))
            {
                BasicShortcutIcon = basicIconToUse;
            }
        }
        internal CustomShortcut(
            string shortcutName,
            string targetPath,
            string targetArguments,
            CustomShortcutType shortcutType,
            WindowType windowType,
            string shortcutRootFolder,
            string basicIconToUse = null,
            string workingFolder = null
            )
        {
            var vbsFolderPath =
                DirectoryUtils.GetUniqueDirName(CustomShortcutGetters.CustomShortcutVbsPath + shortcutName) + "\\";
            var shortcutPath = $"{shortcutRootFolder}{new DirectoryInfo(vbsFolderPath).Name}\\{shortcutName}.lnk";


            ShortcutName = shortcutName.CleanInvalidFilenameChars();
            ShortcutItem = new ShortcutItem(shortcutPath);
            TargetPath = targetPath;
            TargetArguments = targetArguments;
            ShortcutType = shortcutType;
            VbsFolderPath = vbsFolderPath;
            WorkingFolder = workingFolder;
            WindowType = windowType;

            Directory.CreateDirectory(VbsFolderPath);

            if (basicIconToUse != null && File.Exists(basicIconToUse)) BasicShortcutIcon = basicIconToUse;
        }
Example #3
0
        private void GenerateFullShortcut(
            string targetPath,
            string targetArguments,
            CustomShortcutType shortcutType,
            string basicShortcutIcon = null,
            string workingFolder     = null,
            WindowType windowType    = WindowType.ActiveAndDisplayed
            )
        {
            var shortcutName = txtShortcutName.Text.CleanInvalidFilenameChars();

            byte[] imageToUse;

            try
            {
                ValidateFields(shortcutName, targetPath, out imageToUse);
            }
            catch (ValidationFailureException)
            {
                return;
            }

            //build our new custom shortcut
            var customShortcut = new CustomShortcut(shortcutName, targetPath, targetArguments, shortcutType, windowType,
                                                    radShortcutLocation.PathSelection(), basicShortcutIcon, workingFolder);

            //If we didn't specify a shortcut icon path, make one
            if (string.IsNullOrWhiteSpace(basicShortcutIcon))
            {
                customShortcut.BuildCustomShortcut(pctCurrentIcon.Image);
            }
            else
            {
                customShortcut.BuildCustomShortcut();
            }


            //Iconify a TileIconifier shortcut for this with default settings
            var newShortcutItem = customShortcut.ShortcutItem;

            newShortcutItem.Properties.CurrentState.MediumImage.SetImage(imageToUse,
                                                                         ShortcutConstantsAndEnums.MediumShortcutDisplaySize);
            newShortcutItem.Properties.CurrentState.SmallImage.SetImage(imageToUse,
                                                                        ShortcutConstantsAndEnums.SmallShortcutDisplaySize);
            var iconify = new TileIcon(newShortcutItem);

            iconify.RunIconify();

            //confirm to the user the shortcut has been created
            MessageBox.Show(
                $"A shortcut for {shortcutName.QuoteWrap()} has been created in your start menu under TileIconify. The item will need to be pinned manually.",
                @"Shortcut created!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #4
0
 public CustomShortcut(
     string shortcutName,
     string shortcutPath,
     string targetPath,
     string targetArguments,
     CustomShortcutType shortcutType,
     string basicShortcutIcon = null,
     string vbsFilePath       = null,
     string vbsFolderPath     = null)
 {
     ShortcutName      = shortcutName.CleanInvalidFilenameChars();
     ShortcutItem      = new ShortcutItem(shortcutPath);
     TargetPath        = targetPath;
     TargetArguments   = targetArguments;
     ShortcutType      = shortcutType;
     BasicShortcutIcon = basicShortcutIcon;
     VbsFilePath       = vbsFilePath;
     VbsFolderPath     = vbsFolderPath;
 }