/// <summary> /// Adds a new OrbitItem to the list /// </summary> /// <param name="item">OrbitItem to add</param> public void Add(OrbitItem item) { if (item == null) { return; } // create our new node OrbitItemLinkNode newNode = new OrbitItemLinkNode(); newNode.Item = item; // place it after the last node newNode.Previous = LastNode; if (_Length == 0) { // adding the first node LastNode = newNode; FirstNode = newNode; } else { // adding to the last node // update the previously last node LastNode.Next = newNode; } // keep updated track of the last node and how many nodes are there LastNode = newNode; _Length++; //System.Diagnostics.Debug.WriteLine("Added \""+item.Name+"\""); }
/// <summary> /// Moves an OrbitItem in the list /// </summary> /// <param name="item">OrbitItem to be moved</param> /// <param name="index">Index for that item to be placed in</param> /// <param name="place">Position of this new item relative to the existing item on that index</param> public void Move(OrbitItem item, int index, RelativePlace place) { if (item == null || index >= _Length || index < 0) { return; } // finding our to-be-moved and where-to nodes OrbitItemLinkNode nodeToMove = Find(item); OrbitItemLinkNode nodeToPlace = Find(index); Remove(nodeToMove); if (place == RelativePlace.Before) { // place it before that node nodeToMove.Previous = nodeToPlace.Previous; nodeToMove.Next = nodeToPlace; // update the nodes around the newly placed node if (nodeToPlace.Previous != null) { nodeToPlace.Previous.Next = nodeToMove; } // keep track of first node if (FirstNode == nodeToMove.Next) { FirstNode = nodeToMove; } } else { // place it after that node nodeToMove.Next = nodeToPlace.Next; nodeToMove.Previous = nodeToPlace; // update the nodes around the newly placed node if (nodeToPlace.Next != null) { nodeToPlace.Next.Previous = nodeToMove; } // keep track of last node if (LastNode == nodeToMove.Previous) { LastNode = nodeToMove; } } }
/// <summary> /// Returns the index of an item in the registry /// </summary> /// <param name="item">Item to be found</param> /// <returns>The index of the OrbitItem in the registry</returns> public int IndexOf(OrbitItem item) { return(ItemRegistry.IndexOf(item)); /*int a=-1; * if(item==null) * return a; * * int i=0; * while (i<ItemRegistry.Length) * { * if(ItemRegistry[i].Equals(item)) * { * a=i; * break; * } * i++; * } * return a;*/ }
/// <summary> /// Starts the pop up counter for the given item /// </summary> /// <param name="item">Item to open when the timer runs out</param> public void Run(OrbitItem item) { if (item == null) { return; } if (_CountThread != null) { _Enabled = false; _CountThread.Abort(); } _Item = item; _Enabled = true; _CountThread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc)); _CountThread.Name = "FolderPop"; _CountThread.Start(); //System.Windows.Forms.MessageBox.Show("over!"); }
/// <summary> /// Finds the index of an OrbitItem in the list /// </summary> /// <param name="item">OrbitItem to search for</param> /// <returns>Index of the OrbitItem. -1 if not found</returns> public int IndexOf(OrbitItem item) { if (item == null || FirstNode == null) { return(-1); } OrbitItemLinkNode node = FirstNode; int i = 0; while (node != null) { if (node.Item.Equals(item)) { return(i); } node = node.Next; i++; } return(-1); }
/// <summary> /// Returns the index of an item in the registry /// </summary> /// <param name="item">Item to be found</param> /// <returns>The index of the OrbitItem in the registry</returns> public int IndexOf(OrbitItem item) { int a = -1; if (item == null) { return(a); } int i = 0; while (i < ItemRegistry.Length) { //if(ItemRegistry[i].Equals(item)) if (ItemRegistry[i] == item) { a = i; break; } i++; } return(a); }
/// <summary> /// Unloads an item (for internal use) /// </summary> /// <param name="index">Index of the OrbitItem to unload</param> public void Remove(int index) { try { // remove from the list OrbitItem item = ItemRegistry[index]; ItemRegistry.Remove(index); // update our line metrics LineRegistry[item.Line].Count--; UpdateLineMetrics(item.Line); // dispose the item if (item != null) { item.Dispose(); } } catch (Exception) { throw; } }
/// <summary> /// Loads a dir (a line) resizing the registry only once and filling the items /// </summary> /// <param name="parentItem">Item in the registry to expand the registry from</param> public void ExpandFrom(OrbitItem parentItem) { // bail out if not the right type of item // TODO: block non IEnumeratorItem objects //if(!ParentItem.GetType().i) //throw new InvalidCastException("Not IEnumeratorItem"); try { // get the items for that folder OrbitItem[] NewItems = ((IEnumeratorItem)parentItem).GetItems(); // bail out if returned null if (NewItems == null) { return; } // allocate space and move to that spot int AllocOffset = AllocateItem(NewItems.Length); // add the new items to the registry int i = 0; while (i < NewItems.Length) { // set some properties NewItems[i].Line = this.LineRegistry.Length; NewItems[i].Parent = parentItem.Name; NewItems[i].Paint += new EventHandler(PreviewableItem_Paint); // add ItemRegistry[AllocOffset + i] = NewItems[i]; i++; } // registering new line // find out the next level // task folder items don't string Path = Global.Configuration.Locations.ItemsPath; if (parentItem is StoredLoaderItem || parentItem is FileSystemDirectoryItem) { // get the path if (parentItem.GetType() == typeof(FolderItem)) { Path = ((StoredOrbitItem)parentItem).ItemPath; } /*if(parentItem.GetType()==typeof(TasksFolderItem)) * Path=Global.Configuration.Runtime.CurrentLevel;*/ // assign the level if (Path.LastIndexOf("\\") == Path.Length - 1) { Global.Configuration.Runtime.CurrentLevel = Path.Substring(0, Path.Length - 1); } else { Global.Configuration.Runtime.CurrentLevel = Path; } } this.RegisterNewLine(NewItems.Length, Path, parentItem.RotationOffset); // take screenshots if available and selected if (Global.Configuration.Appearance.ShowImageThumbnails) { ThumbnailSync TS = new ThumbnailSync(NewItems, this.LineRegistry.Length - 1); } } catch (Exception) { throw; } }
/// <summary> /// Removes an OrbitItem from the list /// </summary> /// <param name="item">OrbitItem to be removed</param> /// <remarks>This is the slowest of all three overloads. If you already know the node you want to remove, please use the Remove(OrbitItemLinkNode node) overload. If you have to search for it, then don't bother. This is what this overload will do</remarks> public void Remove(OrbitItem item) { // remove from the index Remove(IndexOf(item)); }
private OrbitItemLinkNode Find(OrbitItem item) { return(Find(IndexOf(item))); }