예제 #1
0
        /// <summary>
        /// Searches through monitee lists to find monitee with specified name.
        /// </summary>
        /// <param name="moniteeName">the name of monitee to be found</param>
        /// <returns>the monitee</returns>
        public static Monitee FindMonitee(string moniteeName)
        {
            MoniteeListEntry current = Head;

            while (current != null)
            {
                if (current.Data.Name == moniteeName)
                {
                    return(current.Data);
                }
                current = current.Next;
            }
            return(null);
        }
예제 #2
0
        internal static bool RemoveDestination(Monitee monitee, string destination)
        {
            MoniteeListEntry current = head;

            if (monitee == null || monitee.Destinations == null || monitee.Destinations.Length == 0)
            {
                return(false);
            }
            while (current != null && (current.Data.Name != monitee.Name))
            {
                current = current.Next;
            }

            if (current == null)
            {
                return(false);
            }
            current.Data.RemoveDestination(destination);
            return(true);
        }
예제 #3
0
        /// <summary>
        /// Inserts a monitee to monitor.
        /// </summary>
        /// <param name="monitee">The monitee</param>
        /// <returns></returns>
        internal static bool InsertMonitee(Monitee monitee)
        {
            if (monitee.Name != "" || monitee.Destinations[0] != "")
            {
                MoniteeListEntry mon = new MoniteeListEntry(monitee);

                MoniteeListEntry current = head;
                while (current != null)
                {
                    if (current.Data.Name == monitee.Name)
                    {
                        for (int i = 0; i < current.Data.Index; i++)
                        {
                            if (current.Data.Destinations[i] == monitee.Destinations[0])
                            {
                                return(false);
                            }
                        }
                        current.Data.Destinations = monitee.Destinations;
                        AddedExtra = true;
                        Console.WriteLine("added extra destination");
                        return(AddedExtra);
                    }
                    current = current.Next;
                }
                Console.WriteLine("adding items");
                if (head == null)
                {
                    head = mon;
                    tail = mon;
                }
                else
                {
                    tail.Next = mon;
                    tail      = mon;
                }
                length++;
                return(true);
            }
            return(false);
        }
예제 #4
0
        /// <summary>
        /// Checks all the destination folders of the monitee to ensure new instance is not a duplicate.
        /// </summary>
        /// <param name="path">destination folder of the monitee</param>
        /// <returns>true if "path" is a duplicate; false if not a duplicate</returns>
        private bool CheckDuplicate(string path)
        {
            Monitees.MoniteeListEntry current = MoniteeList.Head;
            while (current != null)
            {
                if (current.Data.Name == path)
                {
                    for (int i = 0; i < current.Data.Index; i++)
                    {
                        if (DelimitPath(current.Data.Destinations[i]).Equals(
                                DelimitPath(((this.DestinationBox.Text == "") ? _DefaultFolder : this.DestinationBox.Text))))
                        {
                            return(true);
                        }
                    }
                }
                current = current.Next;
            }

            return(false);
        }
예제 #5
0
 internal void PopulateTree()
 {
     Monitees.MoniteeListEntry current = MoniteeList.Head;
     System.Console.WriteLine("Beginning tree generation...");
     while (current != null)
     {
         TreeNode moniteeNode = new TreeNode(current.Data.Name);
         moniteeNode.Checked = true;
         System.Console.WriteLine("Adding {0} to the tree", current.Data.Name);
         foreach (string destination in current.Data.Destinations)
         {
             TreeNode destNodes = new TreeNode(destination);
             destNodes.Checked = true;
             moniteeNode.Nodes.Add(destNodes);
         }
         moniteeNode.ToolTipText = "Click the '+' icon or double-click to expand.";
         this.tView.Nodes.Add(moniteeNode);
         current.Data.TreeNode = moniteeNode;
         current = current.Next;
     }
 }
예제 #6
0
        internal static bool RemoveMonitee(string monitee)
        {
            MoniteeListEntry current  = head;
            MoniteeListEntry previous = null;

            if (monitee == "")
            {
                return(false);
            }

            while (current != null && (current.Data.Name != monitee))
            {
                previous = current;
                current  = current.Next;
            }

            if (current == null)
            {
                return(false);
            }
            if (current == head)
            {
                head = current.Next;
            }
            else if (current == tail)
            {
                tail = null;
            }
            else
            {
                if (previous != null)
                {
                    previous.Next = current.Next;
                }
            }
            return(true);
        }
예제 #7
0
        /// <summary>
        /// Uses the full list of items to populate listbox and monitee list.
        /// </summary>
        internal void PopulateList()
        {
            if (MoniteeList.Head != null)
            {
                ListViewItem.ListViewSubItem subItem1;

                /*for (int i = 0; i < monitees.Count; i++)
                 * {
                 *  string[] items = ((string)monitees[i]).Split(';');
                 *
                 *  System.Windows.Forms.ListViewItem listItems = new ListViewItem(items[0]);
                 *  listItems.Checked = true;
                 *  subItem1 = new ListViewItem.ListViewSubItem(listItems,
                 *      items[1]);
                 *  listItems.SubItems.Add(subItem1);
                 *  len++;
                 *  Lists.Items.Add(listItems);
                 * }*/

                FolderMonitor.Monitees.MoniteeListEntry current = MoniteeList.Head;
                while (current != null)
                {
                    ListViewItem listItem = new ListViewItem(current.Data.Name);
                    listItem.Checked = true;

                    Console.WriteLine("Adding {0} to the listview", current.Data.Name);
                    //subItem1 = new ListViewItem.ListViewSubItem(listItems,
                    //    current.Data.Destination[0]);
                    //listItems.SubItems.Add(subItem1);
                    Lists.Items.Add(listItem);
                    current.Data.ListItem = listItem;
                    current = current.Next;
                }
                MoniteeList.AddedExtra = false;
            }
        }