static void Recursive(DirectoryInfo currentDirectory, DirectoryInfo inputRoot, DirectoryInfo newModelsDirectory, string prefix) { Console.WriteLine("Processing " + currentDirectory.FullName); var files = currentDirectory.GetFiles(); if (!files.Any(z => z.Name == Names.FaceFileName)) { foreach (var d in currentDirectory.GetDirectories()) { Recursive(d, inputRoot, newModelsDirectory, prefix); } return; } var tutoFile = files.Where(z => z.Name == "local.tuto").FirstOrDefault(); if (tutoFile == null) { Console.WriteLine("No tuto file is found. Press any key"); Console.ReadKey(); return; } var hash = Videotheque.ComputeHash(currentDirectory, Names.FaceFileName, Names.HashFileName, true); var container = HeadedJsonFormat.Read <FileContainer>(tutoFile, "Tuto local file", 3); container.MontageModel.SetHash(hash); var relativePath = prefix + MyPath.RelativeTo(tutoFile.Directory.FullName, inputRoot.FullName); container.MontageModel.DisplayedRawLocation = relativePath; var fname = Path.Combine(newModelsDirectory.FullName, MyPath.CreateHierarchicalName(relativePath) + "." + Names.ModelExtension); HeadedJsonFormat.Write(new FileInfo(fname), container); }
public static void SaveLayer <TData>(Item root, DirectoryInfo directory) { var fileName = GetFileName <TData>(); var file = new FileInfo(Path.Combine(directory.FullName, fileName)); var layer = GetLayer <TData>(root); HeadedJsonFormat.Write(file, GetHeader <TData>(), 1, layer); }
static void wnd_Closed(object sender, EventArgs e) { var catalog = (sender as Window).DataContext as Tuto.TreeEditor.PublishViewModel; var response = MessageBox.Show("Save changes?", "Tuto.Publishing", MessageBoxButton.YesNo, MessageBoxImage.Question); if (response != MessageBoxResult.No) { var data = catalog.Commit(); HeadedJsonFormat.Write(currentDirectory, data); (Application.MainWindow.DataContext as MainViewModel).Reload(); } Application.MainWindow.Show(); }
public List <YoutubeClip> GetYoutubeClips() { List <YoutubeClip> clips = new List <YoutubeClip>(); try { clips = YoutubeApisProcessor.Current.GetAllClips(); HeadedJsonFormat.Write(new DirectoryInfo(Environment.CurrentDirectory), clips); return(clips); } catch (Exception e) { MessageBox.Show("Loading video from Youtube failed."); return(null); } }
public void Save() { foreach (var e in Videotheque.Episodes) { var clip = YoutubeClipData.Records.Where(z => z.Guid == e.Item2.Guid).FirstOrDefault(); if (clip == null) { continue; } if (clip.Data.Id == e.Item2.YoutubeId) { continue; } e.Item2.YoutubeId = clip.Data.Id; e.Item1.Save(); } HeadedJsonFormat.Write(Location, this); }
static void Main(string[] args) { const string Path = @"C:\Users\Yura\Desktop\TestMontage\Models"; var dir = new DirectoryInfo(Path); foreach (var e in dir.GetFiles()) { FileContainer model = null; try { model = HeadedJsonFormat.Read <FileContainer>(e); } catch { continue; } var times = StartGit(dir, e); model.MontageModel.Information.LastModificationTime = times.First(); model.MontageModel.Information.CreationTime = times.Last(); HeadedJsonFormat.Write <FileContainer>(e, model); } }