Esempio n. 1
0
 internal void OpenFile(string path, string content)
 {
     if (!string.IsNullOrEmpty(LoadedFile))
     {
         UpdateOffsetOnNotes();
     }
     foreach (var item in Notes.Values)
     {
         for (int i = 0; i < item.Files.Count; i++)
         {
             item.ListFiles[i].IsOpen = (item.Files[i].Path == path) ? 10 : 0;
         }
         //item.Files.ForEach(x => x.IsOpen = (x.Path == path) ? 10 : 0);
     }
     ParentControl.TextBox.MainControl.FilePath = "";
     try
     {
         //can write Blocks.Clear;
         ParentControl.TextBox.MainControl.Document = new FlowDocument();
         var range = new TextRange(ParentControl.TextBox.MainControl.Document.ContentStart, ParentControl.TextBox.MainControl.Document.ContentEnd);
         using (var fStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read))
         {
             range.Load(fStream, DataFormats.XamlPackage);
             string folder = Path.GetDirectoryName(path);
             OnFileOpen(folder + "\\", content);
             LoadedFile    = folder + "\\" + content + ".not";
             CurentFile    = path;
             CurentProject = Notes[Directory.GetParent(folder).Name];
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return;
     }
     ParentControl.TextBox.MainControl.FilePath = path;
     ParentControl.TextBox.MainControl.UpdateWordCount();
     ParentControl.updateDefaultValue();
     ParentControl.TextBox.UpdateLayout();
 }