Esempio n. 1
0
        /// <inheritdoc />
        /// <summary>
        ///     Gets the context menu items.
        /// </summary>
        /// <param name="fileInfos">The file infos.</param>
        /// <returns>The context menu items for the provided file infos</returns>
        public IEnumerable <FrameworkElement> GetContextMenuItems(IEnumerable <FileInfo> fileInfos)
        {
            var menuItem = new MenuItem
            {
                Header = "Add to Applications"
            };

            foreach (var fileInfo in fileInfos)
            {
                menuItem.Click += (sender, args) =>
                {
                    var shellInfo    = ShellHelper.GetShellFileInfo(fileInfo.FullName);
                    var registerdApp = new LaunchableApplication
                    {
                        FullPath    = fileInfo.FullName,
                        DisplayName = shellInfo.DisplayName,
                        Description = shellInfo.Description
                    };
                    LaunchableApplicationService.Add(registerdApp);
                }
            }
            ;
            menuItem.Click += (sender, args) => LaunchableApplicationService.Save();
            return(new[] { menuItem });
        }