示例#1
0
        /// <summary>
        /// DragDrop: gets the filename of the object drawn over the control.
        /// Checks the filename, if its contents can be shown in the cloud.
        /// Estimates the language of the text file and the probabilty that it is plain text or HTML.
        /// Reads the file appropriately and shows the words in the cloud.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TagCloudControl_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                Array a = (Array)e.Data.GetData(DataFormats.FileDrop);
                if (a != null)
                {
                    // get the drag & drop filename
                    string filename = a.GetValue(0).ToString();

                    // check, if it is a non-showable file format
                    if (FileFormats.IsGraphicFile(filename) || FileFormats.IsAudioFile(filename) || FileFormats.IsVideoFile(filename) ||
                        FileFormats.IsCompressedFile(filename) || FileFormats.IsProgramFile(filename) || FileFormats.IsDocumentFile(filename) ||
                        FileFormats.IsSystemFile(filename) || FileFormats.IsDatabaseFile(filename))
                    {
                        MessageBox.Show("Sorry, but\n" + filename + "\nhas a contents, that can not be shown in the cloud.", "No display in cloud", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    bool         ishtml;
                    TextLanguage language;
                    // check text / HTML and German / English
                    TXTHandling.GetFileTypeAndLanguage(filename, out ishtml, out language);
                    if (ishtml)
                    {
                        ReadHTMLFile(filename, language);
                    }
                    else
                    {
                        ReadTxtFile(filename, language);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in DragDrop function: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }