Exemplo n.º 1
0
        private void OpenFileRAWOnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter  = FileChecker.FileDialogRawFilter;
            ofd.FileOk += (o, args) =>
            {
                if (FileChecker.IsBinary(ofd.FileName))
                {
                    MessageBox.Show("Binary files are not supported at this time.", "File is binary");
                    return;
                }

                if (FileChecker.IsTooBig(ofd.FileName))
                {
                    if (MessageBox.Show("Files with a size over 10MB are not supported.\nOpen anyways? (Program may freeze or stop working)", "File too big", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }

                new MainWindow(ofd.FileName, typeof(TextEditor.TextEditorControl)).Show();
                Close();
            };
            ofd.ShowDialog();
        }
Exemplo n.º 2
0
        private void ListBoxItemOnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem item       = sender as ListBoxItem;
            EditorFile  editorFile = item.DataContext as EditorFile;
            Type        type       = editorFile.GetEditorType();

            if (!typeof(IEditorControl).IsAssignableFrom(type))
            {
                if (MessageBox.Show("Invalid entry in history!\nDo you want to remove it from recently opened files?", "Invalid entry", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    FileHistory.Remove(editorFile);
                }
                return;
            }
            if (!File.Exists(editorFile.Path))
            {
                if (MessageBox.Show("The file does not exist anymore!\nDo you want to remove it from recently opened files?", "Missing file", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    FileHistory.Remove(editorFile);
                }
                return;
            }

            // TODO Check if file type is supported by editor before calling this part

            /*
             * if (FileChecker.IsBinary(editorFile.Path))
             * {
             *  if (MessageBox.Show("Binary files are not supported at this time.\nDo you want to remove it from recently opened files?", "File is binary", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             *      FileHistory.Remove(editorFile);
             *  return;
             * }
             */

            if (FileChecker.IsTooBig(editorFile.Path))
            {
                if (MessageBox.Show("Files with a size over 10MB are not supported.\nOpen anyways? (Program may freeze or stop working)", "File too big", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            new MainWindow(editorFile.Path, type).Show();
            Close();
        }