示例#1
0
 private void NewFile()
 {
     Title             = GetTitle();
     label_Status.Text = "";
     ResetDocument();
     CurrentReader = new RDAReader();
     RebuildTreeView();
 }
示例#2
0
        private void OpenFile(string fileName, bool isreadonly)
        {
            RDAReader reader = new RDAReader();

            ResetDocument();
            CurrentFileName = fileName;
            if (!isreadonly)
            {
                fileName = DirectoryExtension.GetTempWorkingDirectory() + "\\" + Path.GetFileName(fileName);
            }
            else
            {
                file_Save.IsEnabled = false;
            }
            CurrentReader   = reader;
            reader.FileName = fileName;
            progressBar_Status.Visibility = Visibility.Visible;
            Title = GetTitle() + " - " + Path.GetFileName(reader.FileName);
            reader.backgroundWorker = new BackgroundWorker();
            reader.backgroundWorker.WorkerReportsProgress = true;
            reader.backgroundWorker.ProgressChanged      += (sender2, e2) => DispatcherExtension.Dispatch(System.Windows.Application.Current, () =>
            {
                progressBar_Status.Value = e2.ProgressPercentage;
                label_Status.Text        = reader.backgroundWorkerLastMessage;
            });
            reader.backgroundWorker.DoWork += (sender2, e2) =>
            {
                try
                {
                    if (!isreadonly)
                    {
                        DispatcherExtension.Dispatch(System.Windows.Application.Current, () => label_Status.Text = "Copying *.rda file to a temparary directory ...");
                        FileSystem.CopyFile(CurrentFileName, fileName, UIOption.AllDialogs, UICancelOption.ThrowException);
                    }
                    reader.ReadRDAFile();
                }
                catch (Exception ex)
                {
                    DispatcherExtension.Dispatch(System.Windows.Application.Current, () =>
                    {
                        int num = (int)MessageWindow.Show(ex.Message);
                        NewFile();
                    });
                }
            };
            reader.backgroundWorker.RunWorkerCompleted += (sender2, e2) =>
            {
                progressBar_Status.Visibility = Visibility.Collapsed;
                RebuildTreeView();
            };
            reader.backgroundWorker.RunWorkerAsync();
        }