Beispiel #1
0
    private void GetDirectoryFiles()
    {
        /// Get a list of all of the files in the directory
        /// Look through these files
        /// Populate the dropdown list
        /// Populate the next/ previous list.
        ///
        /// The listOfFiles array is only 1000.
        /// TODO Error catching for lists longer than 1000
        ListStore ClearList = new ListStore(typeof(string));

        ItemChooser.Model = ClearList;

        //  Clear the array so that it can be repopulated.
        Array.Clear(this.listOfFiles, 0, this.listOfFiles.Length);

        string itemNumber, title;          // The item number (for use elsewhere)


        //  Get a list of the xml files in the current directory
        this.listOfFiles = Directory.GetFiles(@"./", "*.xml");

        // If there are no files, write one.
        if (this.listOfFiles.Length == 0)                                       // If the array lenght == 0
        {
            WriteXMLFile("1", "Sample", "Sample");                              // Write the sample file
            this.listOfFiles = Directory.GetFiles(@"./", "*.xml");              // Then repopulate the array.
        }

        // Set an array for the listbox titles. (As long as the list of files length)
        string [] listboxTitles      = new string [this.listOfFiles.Length];
        int       listboxTitlesIndex = 0;

        // For each of the directory items - put them in the list.
        foreach (string name in this.listOfFiles)
        {
            itemNumber = extractIndexFromFilename(name);

            // Get the information from the Item number
            Tuple <string, string> dataTuple = new Tuple <string, string>("", "");
            dataTuple = getXMLEntry(itemNumber);
            title     = dataTuple.Item1;

            // Add the item to the dropdown list
            ItemChooser.AppendText(title);
            ItemChooser.Active = 0;

            // Add the item to the array
            listboxTitles[listboxTitlesIndex] = title;
            listboxTitlesIndex++;
        }

        // Set the current item to the first item.
        this.currentItemIndex = 0;
    }
Beispiel #2
0
 private void ItemChooser_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     if (ItemChooser.GetItemCheckState(e.Index) == CheckState.Checked)
     {
         ItemList.Items.Remove((ItemChooser.Items[e.Index] as Tolt).Name);
     }
     else
     {
         ItemList.Items.Add((ItemChooser.Items[e.Index] as Tolt).Name);
     }
 }