Пример #1
0
        /// <summary>
        /// Gets all the running tasks as OrbitItems
        /// </summary>
        /// <param name="device">Direct3D Device to load resources to</param>
        /// <returns>An array of OrbitItems</returns>
        public static OrbitItem[] GetTasks(Device device)
        {
            ExcludedWindow[] ExclusionList = LoadExcludedClassWindows();
            IntPtr[]         TasksList     = WindowsTaskManager.GetWindowHandles(ExclusionList);
            if (TasksList == null)
            {
                return new OrbitItem[] { new EmptyItem(device) }
            }
            ;

            // actually catalog them
            OrbitItem[] ItemRegistry = new OrbitItem[TasksList.Length];

            int a = 0;

            foreach (IntPtr Handle in TasksList)
            {
                ItemRegistry[a] = new TaskItem(device, new WindowInformation(WindowsTaskManager.GetWindowText(Handle), Handle));

                if (ItemRegistry[a] != null)
                {
                    ItemRegistry[a].Parent = "Orbit";
                    ItemRegistry[a].Line   = 0;
                }
                a++;
            }

            return(ItemRegistry);
        }
Пример #2
0
        /// <summary>
        /// Verifies if an item is equal to another
        /// </summary>
        /// <param name="Item">Item to compare with</param>
        /// <returns>True if this item equals the one specified</returns>
        public virtual bool Equals(OrbitItem Item)
        {
            if (this.Name == Item.Name &&
                this.Description == Item.Description)
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Gets the OrbitItems from this item
        /// </summary>
        /// <returns>An Array of OrbitItems</returns>
        /// <remarks>This will not load thumbnail previews for image files. It's up to the calling method to call the thumbnail acquiring method.</remarks>
        public override OrbitItem[] GetItems()
        {
            // bail out if directory doesn't exist
            if (!System.IO.Directory.Exists(Path))
            {
                return(null);
            }

            try
            {
                LoadedPercentage = 0.0f;
                // Get directory list
                string[] Dirs  = System.IO.Directory.GetDirectories(Path);
                string[] Files = System.IO.Directory.GetFiles(Path);

                // checking if all items are accessible
                int i             = 0;
                int ItemQuantity  = 0;
                int FilesQuantity = 0;
                Microsoft.Win32.RegistryKey Rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced");
                bool ShowHidden = (int)Rk.GetValue("Hidden") == 1;
                bool ShowSystem = (int)Rk.GetValue("ShowSuperHidden") == 1;
                if (!(ShowHidden && ShowSystem))
                {
                    while (i < Dirs.Length)
                    {
                        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Dirs[i]);
                        if (this.IsFileSystemItemShown(di.Attributes, ShowSystem, ShowHidden))
                        {
                            ItemQuantity++;
                        }

                        i++;
                    }
                    i = 0;
                    while (i < Files.Length)
                    {
                        System.IO.FileInfo fi = new System.IO.FileInfo(Files[i]);
                        if (this.IsFileSystemItemShown(fi.Attributes, ShowSystem, ShowHidden))
                        {
                            FilesQuantity++;
                        }
                        i++;
                    }
                }
                else
                {
                    ItemQuantity  = Dirs.Length;
                    FilesQuantity = Files.Length;
                }

                // create an empty item if folder is empty
                if (ItemQuantity + FilesQuantity == 0)
                {
                    LoadedPercentage = 0;
                    return(new OrbitItem[] { new EmptyItem(display) });
                }

                // allocate room for new items
                OrbitItem[] ItemRegistry = new OrbitItem[ItemQuantity + FilesQuantity];

                // Load item
                i = 0;
                int a = 0;
                while (i < Dirs.Length)
                {
                    try
                    {
                        if (!(ShowHidden && ShowSystem))
                        {
                            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Dirs[i]);
                            if (!this.IsFileSystemItemShown(di.Attributes, ShowSystem, ShowHidden))
                            {
                                i++;
                                continue;
                            }
                        }
                        ItemRegistry[a]        = new FileSystemDirectoryItem(display, Dirs[i]);
                        ItemRegistry[a].Parent = this.Name;
                        LoadedPercentage       = (float)(a) / (Dirs.Length + Files.Length);
                        OnPaint();
                        a++;
                    }
                    catch (Exception) {}
                    i++;
                }
                i = 0;
                a = 0;
                while (i < Files.Length)
                {
                    if (!(ShowHidden && ShowSystem))
                    {
                        System.IO.FileInfo fi = new System.IO.FileInfo(Files[i]);
                        if (!this.IsFileSystemItemShown(fi.Attributes, ShowSystem, ShowHidden))
                        {
                            i++;
                            continue;
                        }
                    }
                    ItemRegistry[ItemQuantity + a]        = new FileSystemFileItem(display, Files[i]);
                    ItemRegistry[ItemQuantity + a].Parent = this.Name;
                    LoadedPercentage = (float)(Dirs.Length + a) / (Dirs.Length + Files.Length);
                    OnPaint();
                    i++;
                    a++;
                }

                LoadedPercentage = 0;

                return(ItemRegistry);
            }
            catch (Exception)
            {
                LoadedPercentage = 0;
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// Gets the OrbitItems from this item
        /// </summary>
        /// <returns>An Array of OrbitItems</returns>
        public override OrbitItem[] GetItems()
        {
            // bail out if dir no longer exists
            if (!System.IO.Directory.Exists(ItemPath))
            {
                return(null);
            }

            try
            {
                LoadedPercentage = 0.0f;
                // Get directory list
                string[] Dirs = System.IO.Directory.GetDirectories(ItemPath);
                int      i    = 0;

                // find out how many of those directories are items
                int ItemQuantity = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(System.IO.Path.Combine(Dirs[i], "item.ini")))
                    {
                        ItemQuantity++;
                    }
                    i++;
                }
                // if there are no items, create an empty item
                if (i == 0)
                {
                    LoadedPercentage = 0;
                    return(new OrbitItem[] { new EmptyItem(display) });
                }

                // allocate space
                OrbitItem[] ItemRegistry = new OrbitItem[ItemQuantity];

                // Load item if there's an item configuration
                i = 0;
                int s = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(Dirs[i] + "\\item.ini"))
                    {
                        // if has an ini
                        // load the item
                        ItemRegistry[i - s] = OrbitItemLoader.FromIni(display, System.IO.Path.Combine(Dirs[i], "item.ini"));
                        // set the parent name
                        if (ItemRegistry[i - s] != null)
                        {
                            ItemRegistry[i - s].Parent = this.Name;
                            ItemRegistry[i - s].Line   = 0;
                        }
                    }
                    else
                    {
                        // if not, take note that yet another index is NOT an item
                        s++;
                    }
                    LoadedPercentage = (float)i / Dirs.Length;
                    OnPaint();
                    i++;
                }

                LoadedPercentage = 0;

                // return the just loaded array
                return(ItemRegistry);
            }
            catch (Exception)
            {
                // return null if failed
                LoadedPercentage = 0;
                return(null);
            }
        }
Пример #5
0
        /// <summary>
        /// Loads the first loop
        /// </summary>
        /// <param name="Device">Direct3D Device to load the resources into</param>
        /// <param name="Path">Path to the INI file to load this item from</param>
        /// <returns>An OrbitItem object corresponding to the root loop</returns>
        public static OrbitItem[] LoadOrbitFolder(Device Device, string Path)
        {
            // bail out if dir no longer exists
            if (!System.IO.Directory.Exists(Path))
            {
                return(null);
            }

            try
            {
                // Get directory list
                string[] Dirs = System.IO.Directory.GetDirectories(Path);
                int      i    = 0;

                // find out how many of those directories are items
                int ItemQuantity = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(System.IO.Path.Combine(Dirs[i], "item.ini")))
                    {
                        ItemQuantity++;
                    }
                    i++;
                }
                // if there are no items, create an empty item
                if (i == 0)
                {
                    return(null);
                }

                // allocate space
                OrbitItem[] ItemRegistry = new OrbitItem[ItemQuantity];

                // Load item if there's an item configuration
                i = 0;
                int s = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(Dirs[i] + "\\item.ini"))
                    {
                        // if has an ini
                        // load the item
                        ItemRegistry[i - s] = OrbitItemLoader.FromIni(Device, System.IO.Path.Combine(Dirs[i], "item.ini"));
                        // set the parent name
                        if (ItemRegistry[i - s] != null)
                        {
                            ItemRegistry[i - s].Parent = "Orbit";
                            ItemRegistry[i - s].Line   = 0;
                        }
                    }
                    else
                    {
                        // if not, take note that yet another index is NOT an item
                        s++;
                    }
                    i++;
                }

                // return the just loaded array
                return(ItemRegistry);
            }
            catch (Exception)
            {
                // return null if failed
                return(null);
            }
        }