public IEnumerable <DesktopItem> DesktopItemsFromID(string id)
        {
            IEnumerable <DesktopItem> result = DesktopItems
                                               .Where(item => item.DesktopID.Equals(id, StringComparison.CurrentCultureIgnoreCase));

            return(result.Any() ? result : Enumerable.Empty <DesktopItem> ());
        }
示例#2
0
 /// <summary>
 /// Find a DesktopItem by specifying a path to a .desktop file.
 /// </summary>
 /// <returns>
 /// The DesktopItem, if any exists.
 /// </returns>
 /// <param name='file'>
 /// A path to a .desktop file.
 /// </param>
 public DesktopItem DesktopItemFromDesktopFile(string file)
 {
     return(DesktopItems
            .Where(item => item.Path.Equals(file, StringComparison.CurrentCultureIgnoreCase))
            .DefaultIfEmpty(null)
            .First());
 }
示例#3
0
 /// <summary>
 /// This event rises when a new file or folder was removed from the Desktop folder
 /// </summary>
 private void DesktopFileWatcher_Deleted(object sender, FileSystemEventArgs e)
 {
     mainDispatcher.Invoke(new Action(() =>
     {
         DesktopItems.Remove(desktopItemsData[e.FullPath]);
         desktopItemsData.Remove(e.FullPath);
     }));
     cacheManager.SaveCacheData();
 }
        /// <summary>
        /// Find a DesktopItem by specifying a path to a .desktop file.
        /// </summary>
        /// <returns>
        /// The DesktopItem, if any exists.
        /// </returns>
        /// <param name='file'>
        /// A path to a .desktop file.
        /// </param>
        public DesktopItem DesktopItemFromDesktopFile(string file)
        {
            // this creates an object for each application
            Log <DesktopItemService> .Info("Loading from file {0}", file);

            return(DesktopItems
                   .Where(item => item.Path.Equals(file, StringComparison.CurrentCultureIgnoreCase))
                   .DefaultIfEmpty(null)
                   .First());
        }
示例#5
0
        public static void Init(bool disableHelpers)
        {
            if (!disableHelpers)
            {
                Helpers.Initialize();
            }
            Theme.Initialize();
            WindowMatcher.Initialize();
            DesktopItems.Initialize();
            NotificationService.Initialize();

            Log <DockServices> .Info("Dock services initialized.");
        }
        public void RegisterDesktopItem(DesktopItem item)
        {
            // check if this item is in either the registered or unregistered items
            if (DesktopItems.Contains(item))
            {
                return;
            }

            // if this item isn't in our desktop item list, we need to add it as an unregistered item
            UnregisteredItems.Add(item);

            // and make sure we process it
            // FIXME: do we really need to reload _every_ desktop file here? Probably only need to process the new one..
            DesktopItemsChanged();
        }
示例#7
0
        /// <summary>
        /// This event rises when a new file or folder inside the Desktop folder was renamed
        /// </summary>
        private void DesktopFileWatcher_Renamed(object sender, RenamedEventArgs e)
        {
            ItemData oldItem  = desktopItemsData[e.OldFullPath];
            int      index    = DesktopItems.IndexOf(oldItem);
            string   newTitle = Path.GetFileNameWithoutExtension(e.Name);
            ItemData newItem  = new ItemData(newTitle, e.FullPath, oldItem.ImageData);

            desktopItemsData.Remove(e.OldFullPath);

            mainDispatcher.Invoke(new Action(() =>
            {
                DesktopItems[index]          = newItem;
                desktopItemsData[e.FullPath] = newItem;
            }));
            cacheManager.SaveCacheData();
        }