Exemplo n.º 1
0
        void fileList_Click(object sender, EventArgs e)
        {
            // If readonly, do nothing
            if (read_only)
            {
                return;
            }

            // Get the files in the diretcory
            if (mets_directory.IndexOf("http:") >= 0)
            {
                MessageBox.Show("You cannot modify this list when updating from UFDC.     ", "UFDC Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Does the file exists?
            if (!Directory.Exists(mets_directory))
            {
                MessageBox.Show("METS directory no longer exists!     ", "METS Directory Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string[]         allFiles      = Directory.GetFiles(mets_directory, searchPattern);
            StringCollection possibleFiles = new StringCollection();

            foreach (string thisFile in allFiles)
            {
                string upperFile = thisFile.ToUpper();
                if ((upperFile.IndexOf(".TXT") < 0) && (upperFile.IndexOf(".PRO") < 0) && (upperFile.IndexOf(".XML") < 0) && (upperFile.IndexOf(".METS") < 0))
                {
                    possibleFiles.Add((new FileInfo(thisFile)).Name);
                }
            }

            // Also create the collection of files currently included
            StringCollection includedFiles = new StringCollection();

            foreach (string thisFile in fileList.Items)
            {
                includedFiles.Add(thisFile);
                if (!possibleFiles.Contains(thisFile))
                {
                    possibleFiles.Add(thisFile);
                }
            }

            // Show the selection form
            MetaTemplate.Forms.Download_Label_Form select = new MetaTemplate.Forms.Download_Label_Form(possibleFiles, includedFiles, show_filter_options, xp_theme, file_labels);
            DialogResult results = select.ShowDialog();

            // Get the new selections
            if (results == DialogResult.OK)
            {
                bool newItems = false;
                fileList.Items.Clear();
                foreach (string newFile in select.Checked_Files)
                {
                    fileList.Items.Add(newFile);
                    if (!includedFiles.Contains(newFile))
                    {
                        newItems = true;
                    }
                }

                if (!newItems)
                {
                    if (includedFiles.Count != select.Checked_Files.Length)
                    {
                        newItems = true;
                    }
                }

                if (newItems)
                {
                    OnDataChanged();
                }
            }
        }
        void fileList_Click(object sender, EventArgs e)
        {
            // If readonly, do nothing
            if (read_only)
                return;

            // Get the files in the diretcory
            if (mets_directory.IndexOf("http:") >= 0)
            {
                MessageBox.Show("You cannot modify this list when updating from UFDC.     ","UFDC Update", MessageBoxButtons.OK, MessageBoxIcon.Information );
                return;
            }

            // Does the file exists?
            if ( !Directory.Exists( mets_directory ))
            {
                MessageBox.Show("METS directory no longer exists!     ", "METS Directory Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return;
            }

            string[] allFiles = Directory.GetFiles(mets_directory, searchPattern );
            StringCollection possibleFiles = new StringCollection();
            foreach (string thisFile in allFiles)
            {
                string upperFile = thisFile.ToUpper();
                if ((upperFile.IndexOf(".TXT") < 0) && (upperFile.IndexOf(".PRO") < 0) && (upperFile.IndexOf(".XML") < 0) && (upperFile.IndexOf(".METS") < 0))
                {
                    possibleFiles.Add((new FileInfo(thisFile)).Name);
                }
            }

            // Also create the collection of files currently included
            StringCollection includedFiles = new StringCollection();
            foreach (string thisFile in fileList.Items)
            {
                includedFiles.Add(thisFile);
                if (!possibleFiles.Contains(thisFile))
                    possibleFiles.Add(thisFile);
            }

            // Show the selection form
            MetaTemplate.Forms.Download_Label_Form select = new MetaTemplate.Forms.Download_Label_Form(possibleFiles, includedFiles, show_filter_options, xp_theme, file_labels);
            DialogResult results = select.ShowDialog();

            // Get the new selections
            if (results == DialogResult.OK)
            {
                bool newItems = false;
                fileList.Items.Clear();
                foreach (string newFile in select.Checked_Files)
                {
                    fileList.Items.Add(newFile);
                    if (!includedFiles.Contains(newFile))
                        newItems = true;
                }

                if (!newItems)
                {
                    if (includedFiles.Count != select.Checked_Files.Length)
                        newItems = true;
                }

                if (newItems)
                {
                    OnDataChanged();
                }
            }
        }