示例#1
0
        private void AddProgram(IEnumerable<string> files)
        {
            Profile profile = cmbProfiles.SelectedItem as Profile;
            if (profile != null)
            {
                List<string> failedFiles = new List<string>();
                var _programs = profile.Entries;
                foreach (string file in files)
                {
                    ProgramEntry entry = new ProgramEntry();

                    string realPath = file;
                    FileInfo info = new FileInfo(realPath);
                    if (info.Extension.ToLower() == ".lnk")
                        realPath = ShortcutParser.Parse(realPath);
                    entry.Path = realPath;
                    entry.Name = file;

                    if (_programs.Count(x => x.Path == realPath) > 0)
                    {
                        failedFiles.Add(realPath);
                        continue;
                    }

                    FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(realPath);

                    if (!string.IsNullOrWhiteSpace(versionInfo.FileDescription))
                        entry.Name = versionInfo.FileDescription;

                    entry.SetImage(ProgramEntry.IconFromFilePath(realPath));
                    _programs.Insert(0, entry);
                }
                if (failedFiles.Count > 0)
                {
                    MessageBox.Show("The program(s) have already been added:" +
                        string.Join(Environment.NewLine, failedFiles.ToArray()),
                        "Failed to add program", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                lstPrograms.SelectedIndex = 0;
                SaveProfiles();
                CreateJumpTasks();
            }
        }
示例#2
0
        /// <summary>
        /// Launches the specified program entry
        /// </summary>
        /// <param name="entry">The program entry to launch</param>
        public void LaunchProgram(ProgramEntry entry)
        {
            LaunchProgram(entry.Path);
            entry.LastRan = DateTime.Now;
            RecentApps.Put(entry);

            // TODO: Remove this
            int index = Entries.IndexOf(entry);
            Entries.Move(index, 0);
        }