示例#1
0
        /// <summary>
        /// Gets the metro targets.
        /// </summary>
        /// <returns></returns>
        private IEnumerable <Target> GetMetroTargets()
        {
            if (this._includeMetro && this.HasMetroSupport)
            {
                return(MetroManager.GetApplications()
                       .Select(
                           app =>
                {
                    var target = new Target()
                    {
                        Name = app.Name,
                        Description = app.Description,
                        Path = app.AppUserModelId,
                        Icon = app.Icon,
                        Platform = TargetType.Metro,
                    };

                    target.AddAlias(target.Name);

                    var abbreviation = target.Name.GetAbbreviation();
                    if (abbreviation.Length > 1)
                    {
                        target.AddAlias(abbreviation);
                    }

                    return target;
                }));
            }

            return(new List <Target>());
        }
示例#2
0
        /// <summary>
        /// Gets the LNK target.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <returns></returns>
        private static Target GetLnkTarget(FileInfo file)
        {
            var lnkInfo = new LnkInfo(file.FullName);

            var target = new Target()
            {
                Name        = lnkInfo.Name,
                Description = GetFileDescription(lnkInfo.TargetPath),
                Path        = file.FullName,
                Icon        = lnkInfo.Icon,
                Platform    = GetFilePlatformType(lnkInfo.TargetPath)
            };

            target.AddAlias(GetPathAliasText(lnkInfo.TargetPath));

            return(target);
        }
示例#3
0
        /// <summary>
        /// Gets the desktop targets.
        /// </summary>
        /// <param name="directories">The directories.</param>
        /// <returns></returns>
        private IEnumerable <Target> GetDesktopTargets()
        {
            var targets = new List <Target>();

            foreach (var directory in this._directories)
            {
                if (Directory.Exists(directory))
                {
                    // Find all links that point to an executable, and add them to the list of targets.
                    foreach (var file in new DirectoryInfo(directory).GetFiles("*.*", SearchOption.AllDirectories))
                    {
                        var target = default(Target);

                        switch (file.Extension.ToUpperInvariant())
                        {
                        case ".LNK":
                            target = GetLnkTarget(file);
                            break;

                        case ".URL":
                            target = GetUrlTarget(file);
                            break;

                        default:
                        {
                            target = new Target()
                            {
                                Name        = file.Name.Replace(file.Extension, string.Empty),
                                Description = GetFileDescription(file.FullName),
                                Path        = file.FullName,
                                Icon        = IconExtractor.GetIcon(file.FullName),
                                Platform    = GetFilePlatformType(file.FullName)
                            };
                        }
                        break;
                        }

                        if (target != null)
                        {
                            // Add generic alias information
                            target.AddAlias(target.Name);

                            // Add abbreviated alias information. E.g.: "Visual Studio 2012" becomes "VS2"
                            var abbr = target.Name.GetAbbreviation(true);
                            if (abbr.Length > 1)
                            {
                                target.AddAlias(abbr);
                            }

                            // Add abbreviated alias information, with whole numbers. E.g.: "Visual Studio 2012" becomes "VS2012"
                            var abbrWholeNumbers = target.Name.GetAbbreviation(false);
                            if (abbrWholeNumbers.Length > 1)
                            {
                                target.AddAlias(abbrWholeNumbers);
                            }

                            target.AddAlias(GetPathAliasText(target.Path));

                            // Add this new target to our collection
                            targets.Add(target);
                        }
                    }
                }
            }

            return(targets);
        }