Пример #1
0
        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));
            });
        }
Пример #2
0
        public void SelectFile(FileViewModel selected)
        {
            if (selected.IsExpandable)
            {
                FileCollection.SelectedFile = selected;
                FileCollection.ExpandFile(selected);
                return;
            }

            if (selected.IsOpenable)
            {
                FileCollection.SelectedFile = selected;
                OpenFilePopup(selected);
                return;
            }

        }
Пример #3
0
        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);
            });
        }
Пример #5
0
 private void OpenFilePopup(FileViewModel file)
 {
     if (OnOpenFilePopup != null)
         OnOpenFilePopup(file, Tracker);
 }
Пример #6
0
 private void ViewModel_OnOpenFilePopup(FileViewModel file, ProgressTracker tracker)
 {
     var videoFilePopup = new VideoFilePopup(file);
     SetupPopup(videoFilePopup);
 }
Пример #7
0
        public void GetStreamUrl(FileViewModel context, Action<Uri> action)
        {
            var transaction = ProgressTracker.StartNewTransaction();

            RestApi.StreamFile(context.File.FileID, response =>
            {
                ProgressTracker.CompleteTransaction(transaction);
                action(response.ResponseUri);
            });
        }
Пример #8
0
        public void ConvertToMp4(FileViewModel context, Action action)
        {
            var transaction = ProgressTracker.StartNewTransaction();

            RestApi.FileToMp4(context.File.FileID, response =>
            {
                ProgressTracker.CompleteTransaction(transaction);
                action();
            });
        }
Пример #9
0
        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);
            });
        }