Ejemplo n.º 1
0
        /// <summary>
        /// works at adding a new entry into the monitee list and storages.
        /// </summary>
        public void AddMonitoredItem()
        {
            //duplicate should not be added in listview.
            string[] items = new string[] { FolderSelectorBox.Text,
                                            ((DestinationBox.Text != "") ? DestinationBox.Text:_DefaultFolder) };

            ListViewItem listItems = new ListViewItem(items[0]);

            ListViewItem.ListViewSubItem subItem1;

            listItems.Checked = true;
            subItem1          = new ListViewItem.ListViewSubItem(listItems,
                                                                 items[1]);

            //listItems.SubItems.Add(subItem1);

            xmlData = new XMLData(items[0], items[1], XMLDataList.Type(items[0]));
            monitee = new FolderMonitor.Monitees.Monitee(items[0], items[1], XMLDataList.Type(items[0]));
            if (XMLDataList.InsertFile(xmlData) && MoniteeList.InsertMonitee(monitee))
            {
                if (!Monitees.MoniteeList.AddedExtra)
                {
                    Lists.Items.Add(listItems);
                    Monitees.MoniteeList.AddedExtra = false;
                }

                MessageBox.Show("Folder successfully added", "Success");
                HasChanged = true;
            }
            this.FolderSelectorBox.Text = "";
            this.DestinationBox.Text    = "";
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens the destination viewer dialog; sends monitee data to display.
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        void destinationViewBtn_Click(object sender, System.EventArgs e)
        {
            if ((this.Lists.Items.Count > 0) && (this.Lists.SelectedIndices.Count > 0))
            {
                System.Collections.IEnumerator iEnum = this.Lists.SelectedIndices.GetEnumerator();
                this.Lists.SelectedItems[0].Checked = true;
                while (iEnum.MoveNext())
                {
                    Monitees.Monitee  mon      = MoniteeList.FindMonitee(this.Lists.Items[(Int32.Parse(iEnum.Current.ToString()))].Text);
                    DestinationViewUI destView = new DestinationViewUI(mon);

                    destView.ShowDialog();
                }
            }
            else
            {
                Exceptions.Exception("selectmonitee");
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 public DestinationViewUI(Monitees.Monitee monitee)
 {
     InitializeComponent();
     this.monitee = monitee;
     LoadDestinations();
 }