public static AddEditVideoViewModel CreateForEditVideo(long ownerId, long videoId, VKClient.Common.Backend.DataObjects.Video video = null)
        {
            AddEditVideoViewModel vm = new AddEditVideoViewModel();

            vm._ownerId      = ownerId;
            vm._videoId      = videoId;
            vm._isInEditMode = true;
            if (video != null)
            {
                vm.InitializeWithVideo(video);
            }
            else
            {
                VideoService.Instance.GetVideoById(ownerId, videoId, "", delegate(BackendResult <List <VKClient.Common.Backend.DataObjects.Video>, ResultCode> res)
                {
                    if (res.ResultCode == ResultCode.Succeeded)
                    {
                        VKClient.Common.Backend.DataObjects.Video vid = Enumerable.First <VKClient.Common.Backend.DataObjects.Video>(res.ResultData);
                        Execute.ExecuteOnUIThread(delegate
                        {
                            vm.InitializeWithVideo(vid);
                        });
                    }
                });
            }
            return(vm);
        }
        private async void PrepareVideo()
        {
            try
            {
                if (this._filePath != "")
                {
                    AddEditVideoViewModel addEditVideoViewModel = this;
                    StorageFile           arg_5D_0 = addEditVideoViewModel._sf;
                    StorageFile           sf       = await StorageFile.GetFileFromPathAsync(this._filePath);

                    addEditVideoViewModel._sf = sf;
                    addEditVideoViewModel     = null;
                }
                else
                {
                    this._sf = AddEditVideoViewModel.PickedExternalFile;
                }
                await this._sf.Properties.GetVideoPropertiesAsync();

                StorageItemThumbnail windowsRuntimeStream = await this._sf.GetThumbnailAsync(ThumbnailMode.VideosView);

                this._localThumbPath = "/" + Guid.NewGuid().ToString();
                ImageCache.Current.TrySetImageForUri(this._localThumbPath, windowsRuntimeStream.AsStream());
                this.NotifyPropertyChanged <string>(() => this.LocalThumbPath);
            }
            catch (Exception var_7_261)
            {
                Logger.Instance.Error("Failed to prepare video data", var_7_261);
            }
        }
        public static AddEditVideoViewModel CreateForNewVideo(string filePath, long ownerId)
        {
            AddEditVideoViewModel editVideoViewModel = new AddEditVideoViewModel();

            editVideoViewModel._ownerId  = ownerId;
            editVideoViewModel._filePath = filePath;
            EditPrivacyViewModel privacyViewModel1 = new EditPrivacyViewModel(CommonResources.AddEditVideo_WhoCanView, new PrivacyInfo(), "", null);

            editVideoViewModel.ViewVideoPrivacyVM = privacyViewModel1;
            EditPrivacyViewModel privacyViewModel2 = new EditPrivacyViewModel(CommonResources.AddEditVideo_WhoCanComment, new PrivacyInfo(), "", null);

            editVideoViewModel.CommentVideoPrivacyVM = privacyViewModel2;
            editVideoViewModel.PrepareVideo();
            return(editVideoViewModel);
        }
        public async void Save(Action <bool> resultCallback)
        {
            if (!this._isSaving)
            {
                this.IsSaving = true;
                if (!this._isInEditMode)
                {
                    try
                    {
                        if (this._sf == null)
                        {
                            if (this._filePath != "")
                            {
                                AddEditVideoViewModel addEditVideoViewModel = this;
                                StorageFile           arg_B8_0 = addEditVideoViewModel._sf;
                                StorageFile           sf       = await StorageFile.GetFileFromPathAsync(this._filePath);

                                addEditVideoViewModel._sf = sf;
                                addEditVideoViewModel     = null;
                            }
                            else
                            {
                                this._sf = AddEditVideoViewModel.PickedExternalFile;
                                AddEditVideoViewModel.PickedExternalFile = null;
                            }
                        }
                        Stream stream = (await this._sf.OpenAsync(0)).AsStreamForRead();
                        this._c = new Cancellation();
                        VideoService.Instance.UploadVideo(stream, false, 0, (this._ownerId < 0L) ? (-this._ownerId) : 0, this.Name, this.Description, delegate(BackendResult <SaveVideoResponse, ResultCode> res)
                        {
                            this.IsSaving = false;
                            if (res.ResultCode == ResultCode.Succeeded)
                            {
                                EventAggregator.Current.Publish(new VideoAddedDeleted
                                {
                                    IsAdded = true,
                                    VideoId = res.ResultData.video_id,
                                    OwnerId = res.ResultData.owner_id
                                });
                                resultCallback.Invoke(true);
                                return;
                            }
                            this.Progress = 0.0;
                            resultCallback.Invoke(false);
                        }, delegate(double progress)
                        {
                            this.Progress = progress;
                        }, this._c, this.ViewVideoPrivacyVM.GetAsPrivacyInfo(), this.CommentVideoPrivacyVM.GetAsPrivacyInfo());
                        goto IL_309;
                    }
                    catch (Exception)
                    {
                        this.IsSaving = false;
                        resultCallback.Invoke(false);
                        goto IL_309;
                    }
                }
                VideoService.Instance.EditVideo(this._videoId, (this._ownerId < 0L) ? (-this._ownerId) : 0, this.Name, this.Description, this.ViewVideoPrivacyVM.GetAsPrivacyInfo(), this.CommentVideoPrivacyVM.GetAsPrivacyInfo(), delegate(BackendResult <ResponseWithId, ResultCode> res)
                {
                    this.IsSaving = false;
                    if (res.ResultCode == ResultCode.Succeeded)
                    {
                        this.FireEditedEvent();
                        resultCallback.Invoke(true);
                        return;
                    }
                    resultCallback.Invoke(false);
                });
                IL_309 :;
            }
        }