Esempio n. 1
0
        private void Window_Activated(object sender, EventArgs e)
        {
            FileWatcher_ToUpdate = Enumerable.ToList(Enumerable.Distinct(FileWatcher_ToUpdate));
            if (FileWatcher_ToUpdate.Count == 0 || FileWatcher_Updating)
            {
                return;
            }
            string str1 = "Following files has changed:\n";

            foreach (RDAFile rdaFile in FileWatcher_ToUpdate)
            {
                str1 = str1 + rdaFile.FileName + "\n";
            }
            string Message = str1 + "\nDo you want to update the RDA File Items?";

            FileWatcher_Updating = true;
            if (MessageWindow.Show(Message, MessageWindow.MessageWindowType.YesNo) == MessageBoxResult.Yes)
            {
                foreach (RDAFile rdaFile in FileWatcher_ToUpdate)
                {
                    string str2 = DirectoryExtension.GetTempWorkingDirectory() + "\\" + rdaFile.FileName;
                    string str3 = StringExtension.MakeUnique(Path.ChangeExtension(str2, null) + "$", Path.GetExtension(str2), (d => File.Exists(d)));
                    File.Copy(str2, str3);
                    rdaFile.SetFile(str3);
                }
            }
            FileWatcher_Updating = false;
            FileWatcher_ToUpdate.Clear();
        }
Esempio n. 2
0
 private void FileWatcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (!(e.FullPath.Replace(DirectoryExtension.GetTempWorkingDirectory(), "").Trim('\\') == File.FileName.Replace("/", "\\")) || MainWindow.CurrentMainWindow.FileWatcher_ToUpdate.Contains(File))
     {
         return;
     }
     MainWindow.CurrentMainWindow.FileWatcher_ToUpdate.Add(File);
 }
Esempio n. 3
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();
        }
Esempio n. 4
0
 private void ResetDocument()
 {
     CurrentFileName     = "";
     file_Save.IsEnabled = true;
     if (FileWatcher != null)
     {
         FileWatcher.Dispose();
     }
     FileWatcher = new FileSystemWatcher();
     FileWatcher.IncludeSubdirectories = true;
     FileWatcher.NotifyFilter          = NotifyFilters.LastWrite;
     CurrentReader.Dispose();
     DirectoryExtension.CleanDirectory(DirectoryExtension.GetTempWorkingDirectory());
     FileWatcher.Path = DirectoryExtension.GetTempWorkingDirectory();
     FileWatcher.EnableRaisingEvents = true;
 }
Esempio n. 5
0
 private void context_Open_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!System.IO.File.Exists(DirectoryExtension.GetTempWorkingDirectory() + "\\" + File.FileName))
         {
             File.ExtractToRoot(DirectoryExtension.GetTempWorkingDirectory());
         }
         Process.Start(DirectoryExtension.GetTempWorkingDirectory() + "\\" + File.FileName);
         MainWindow.CurrentMainWindow.FileWatcher.Changed += new FileSystemEventHandler(FileWatcher_Changed);
         MainWindow.CurrentMainWindow.FileWatcher.Deleted += new FileSystemEventHandler(FileWatcher_Deleted);
     }
     catch (Exception ex)
     {
         int num = (int)MessageWindow.Show(ex.Message);
     }
 }
 public static void SetFile(this RDAFile rdafile, string file, bool deleteOldFileInTemp)
 {
     rdafile.SetFile(file);
     if (!deleteOldFileInTemp)
     {
         return;
     }
     if (!File.Exists(DirectoryExtension.GetTempWorkingDirectory() + "\\" + rdafile.FileName))
     {
         return;
     }
     try
     {
         File.Delete(DirectoryExtension.GetTempWorkingDirectory() + "\\" + rdafile.FileName);
     }
     catch (Exception)
     {
     }
 }
Esempio n. 7
0
 private void MainWindow_Closing(object sender, CancelEventArgs e)
 {
     if (WindowState == WindowState.Normal)
     {
         Settings.Default.Window_Width  = Width;
         Settings.Default.Window_Height = Height;
         Settings.Default.Window_X      = Left;
         Settings.Default.Window_Y      = Top;
     }
     Settings.Default.Window_IsMaximized = WindowState == WindowState.Maximized;
     Settings.Default.Save();
     ResetDocument();
     try
     {
         Directory.Delete(DirectoryExtension.GetTempWorkingDirectory(), true);
     }
     catch (Exception)
     {
     }
 }