public VideoFilePopup(FileViewModel context) { InitializeComponent(); DataContext = context; CurrentFile = context; Visible = true; //Put.io assumes that if the file format is of MP4 then we can use it if (FileNativeMp4()) { ConvertMp4.IsEnabled = false; DownloadMp4.IsEnabled = true; StreamMp4.IsEnabled = true; return; } App.ViewModel.FileCollection.GetMp4Status(context, (mp4Available, percentDone) => { if (mp4Available == Mp4Status.InQueue || mp4Available == Mp4Status.Converting) Task.Factory.StartNew(ConversionInProgress); UpdateUi(() => SetupButtons(mp4Available, percentDone)); }); }
public void SelectFile(FileViewModel selected) { if (selected.IsExpandable) { FileCollection.SelectedFile = selected; FileCollection.ExpandFile(selected); return; } if (selected.IsOpenable) { FileCollection.SelectedFile = selected; OpenFilePopup(selected); return; } }
public void ExpandFile(FileViewModel file) { if (file.File.ContentType != ContentType.Directory) return; if (file.Children != null) { CurrentFileList = file.Children; return; } var transactionID = ProgressTracker.StartNewTransaction(); RestApi.ListFiles(file.File.FileID, response => { file.Children = OrderCollection(response.Data.ToModelList(Invoker, Settings, ProgressTracker)); CurrentFileList = file.Children; ProgressTracker.CompleteTransaction(transactionID); }); }
public void ExpandFile(FileViewModel file) { if (file.File.ContentType != ContentType.Directory) { return; } if (file.Children != null) { CurrentFileList = file.Children; return; } var transactionID = ProgressTracker.StartNewTransaction(); RestApi.ListFiles(file.File.FileID, response => { file.Children = OrderCollection(response.Data.ToModelList(Invoker, Settings, ProgressTracker)); CurrentFileList = file.Children; ProgressTracker.CompleteTransaction(transactionID); }); }
private void OpenFilePopup(FileViewModel file) { if (OnOpenFilePopup != null) OnOpenFilePopup(file, Tracker); }
private void ViewModel_OnOpenFilePopup(FileViewModel file, ProgressTracker tracker) { var videoFilePopup = new VideoFilePopup(file); SetupPopup(videoFilePopup); }
public void GetStreamUrl(FileViewModel context, Action<Uri> action) { var transaction = ProgressTracker.StartNewTransaction(); RestApi.StreamFile(context.File.FileID, response => { ProgressTracker.CompleteTransaction(transaction); action(response.ResponseUri); }); }
public void ConvertToMp4(FileViewModel context, Action action) { var transaction = ProgressTracker.StartNewTransaction(); RestApi.FileToMp4(context.File.FileID, response => { ProgressTracker.CompleteTransaction(transaction); action(); }); }
public void GetMp4Status(FileViewModel context, Action<Mp4Status, int> action) { var transaction = ProgressTracker.StartNewTransaction(); RestApi.Mp4Status(context.File.FileID, response => { ProgressTracker.CompleteTransaction(transaction); action(response.Data.ToMp4Status(), response.Data.mp4.percent_done); }); }