Beispiel #1
0
        private void backButton_Click(object sender, EventArgs e)
        {
            FileManagementHub view = new FileManagement.FileManagementHub();

            view.Show();
            Hide();
        }
Beispiel #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileManagement.FileManagementHub fmh = new FileManagement.FileManagementHub();
            fmh.Show();
            Hide();
            ////FileManagementHub open = new FileManagementHub();
            ////open.Show();
            ////this.Hide();
            ////string fileExtension = Path.GetExtension(nameOfFile);
            ////string tempFileName = System.IO.Path.GetTempFileName() + "." + fileExtension;
            //rtfBox.Clear();
            //OpenFileDialog open_dialog = new OpenFileDialog();
            //open_dialog.Filter = "Text Files;RTF;DOCX|*.txt;*.rtf;*.docx";
            //if (open_dialog.ShowDialog() == DialogResult.OK)
            //{
            //    var extension = Path.GetExtension(open_dialog.FileName);
            //    string rtfbox;
            //    switch (extension.ToLower())
            //    {
            //        case ".rtf":
            //            if (IsFileLock(open_dialog.FileName))
            //            {
            //                MessageBox.Show("File is in use!");
            //            }
            //            else
            //            {
            //                rtfbox = File.ReadAllText(open_dialog.FileName);     //Read content
            //                rtfBox.Rtf = rtfbox;                                //Display content in rtf file in rtb
            //            }

            //            break;
            //        case ".txt":
            //            if (IsFileLock(open_dialog.FileName))
            //            {
            //                MessageBox.Show("File is in use!");
            //            }
            //            else
            //            {
            //                rtfbox = File.ReadAllText(open_dialog.FileName);
            //                rtfBox.Text = rtfbox;
            //            }
            //            break;
            //        case ".docx":
            //            if (IsFileLock(open_dialog.FileName))
            //            {
            //                MessageBox.Show("File is in use!");
            //            }
            //            else
            //            {
            //                object readOnly = true;
            //                object fileName = open_dialog.FileName;
            //                object missing = System.Reflection.Missing.Value;
            //                var applicationWord = new Microsoft.Office.Interop.Word.Application();
            //                applicationWord.Visible = true;
            //                //object gg = applicationWord.DocumentBeforeSave();
            //                applicationWord.Options.SavePropertiesPrompt = false;
            //                applicationWord.Options.SaveNormalPrompt = false;
            //                applicationWord.DisplayAlerts = WdAlertLevel.wdAlertsNone;
            //                applicationWord.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
            //                //object doNotSaveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
            //                //applicationWord.ActiveDocument.Close(ref doNotSaveChanges, ref missing, ref missing);
            //            }


            //            break;
            //        default:
            //            throw new ArgumentOutOfRangeException(extension);
            //    }
            //}
        }