Beispiel #1
0
        private async void UploadButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var uploadItem = UploadStoryUc.UploadItem;
                if (uploadItem == null)
                {
                    Helper.ShowNotify("Please select at least one image or video.", 5500);
                    return;
                }
                if (UploadStoryUc.Editing)
                {
                    Helper.ShowNotify("Your photo/video needs edit, edit it first and then try again.", 5500);
                    return;
                }
                ConvertionGrid.Visibility = Visibility.Visible;
                LoadingUc.Start();
                var converted = await Convertions.ConvertFilesAsync(new List <StorageUploadItem> {
                    uploadItem
                });

                ConvertionGrid.Visibility = Visibility.Collapsed;
                LoadingUc.Stop();
                var su = new StorageUpload();
                su.SetUploadItem(converted, "");
                Helper.ShowNotify("Convertion is done now you can use Minista\r\n" +
                                  "We will upload your media(s) to story in background.", 6000);
                Helpers.NavigationService.GoBack();
            }
            catch { }
        }
Beispiel #2
0
        public async void SetFile(StorageFile file)
        {
            try
            {
                Editing = true;
                CanCrop = false;
                LoadingUc.Start();
                ResetEditor();
                if (file.IsVideo())
                {
                    VideoButton.Visibility = Visibility.Visible;
                    IsVideo      = true;
                    FileToUpload = file;

                    ThumbnailFile = await file.GetSnapshotFromD3D(TimeSpan.Zero, true);

                    ThumbnailFile       = await new PhotoHelper().SaveToImage(ThumbnailFile, false);
                    CropGrid.Opacity    = 1;
                    CropGrid.Visibility = Visibility.Visible;
                    await Editor.SetFileAsync(ThumbnailFile);

                    MainCanvas.Visibility = Visibility.Collapsed;

                    await Task.Delay(1500);

                    CanCrop = true;
                    //LoadingUc.Stop();
                }
                else
                {
                    VideoButton.Visibility = Visibility.Collapsed;
                    IsVideo       = false;
                    ThumbnailFile = null;

                    FileToUpload = await new PhotoHelper().SaveToImage(file, false);

                    CropGrid.Opacity    = 1;
                    CropGrid.Visibility = Visibility.Visible;
                    await Editor.SetFileAsync(FileToUpload);

                    MainCanvas.Visibility = Visibility.Collapsed;
                    await Task.Delay(1500);

                    CanCrop = true;
                    //LoadingUc.Stop();
                }
            }
            finally
            {
                LoadingUc.Stop();
            }
        }
Beispiel #3
0
        private async void UploadButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (UploadUcList.Count == 0)
                {
                    Helper.ShowNotify("Please select at least one image or video.", 5500);
                    return;
                }
                int  index   = 0;
                bool editing = false;
                int  ix      = 0;
                foreach (var item in UploadUcList)
                {
                    if (item.Editing)
                    {
                        editing = true;
                        index   = ix;
                        break;
                    }
                    ix++;
                }
                if (editing)
                {
                    Helper.ShowNotify("Some of your photo(s)/video(s) needs edit, edit them first and then try again.", 5500);
                    LV.SelectedIndex = index;
                    //FlipView.SelectedIndex = index;
                    return;
                }
                var list = new List <StorageUploadItem>();
                foreach (var item in UploadUcList)
                {
                    list.Add(item.UploadItem);
                }
                ConvertionGrid.Visibility = Visibility.Visible;
                LoadingUc.Start();
                var converted = await Convertions.ConvertFilesAsync(list);

                ConvertionGrid.Visibility = Visibility.Collapsed;
                LoadingUc.Stop();
                var su = new StorageUpload();
                su.SetUploadItem(converted, CaptionText.Text);
                Helper.ShowNotify("Convertion is done now you can use Minista\r\n" +
                                  "We will upload your media(s) in background.", 6000);
                Helpers.NavigationService.GoBack();
            }
            catch { }
        }
Beispiel #4
0
        public async Task SetFileAsync(StorageFile file)
        {
            try
            {
                Editing = true;
                CanCrop = false;
                LoadingUc.Start();
                if (file.IsVideo())
                {
                    VideoButton.Visibility = Visibility.Visible;
                    IsVideo       = true;
                    FileToUpload  = file;
                    ThumbnailFile = await file.GetSnapshotFromD3D(TimeSpan.Zero, true);

                    ThumbnailFile = await new PhotoHelper().SaveToImage(ThumbnailFile, false);

                    double width = 0, height = 0;
                    var    decoder = await BitmapDecoder.CreateAsync(await ThumbnailFile.OpenReadAsync());

                    width  = decoder.PixelWidth;
                    height = decoder.PixelHeight;
                    var wRatio = AspectRatioHelper.GetAspectRatioForMedia(width, height);
                    var hRatio = AspectRatioHelper.GetAspectRatioForMedia(height, width);
                    MainCanvas.Visibility = Visibility.Collapsed;

                    AspectRatioSlider.Value  = wRatio;
                    ImageCropper.AspectRatio = wRatio;
                    ImageCropper.CropShape   = CropShape.Rectangular;
                    await ImageCropper.LoadImageFromFile(ThumbnailFile);

                    CropGrid.Visibility = Visibility.Visible;

                    await Task.Delay(1500);

                    ImageCropper.AspectRatio = DefaultAspectRatio;
                    AspectRatioSlider.Value  = DefaultAspectRatio;
                    CanCrop = true;
                    LoadingUc.Stop();
                }
                else
                {
                    VideoButton.Visibility = Visibility.Collapsed;
                    IsVideo       = false;
                    ThumbnailFile = null;
                    BitmapDecoder = null;
                    var    editNeeded = false;
                    double width = 0, height = 0;
                    var    decoder = await BitmapDecoder.CreateAsync(await file.OpenReadAsync());

                    width  = decoder.PixelWidth;
                    height = decoder.PixelHeight;
                    var wRatio = AspectRatioHelper.GetAspectRatioForMedia(width, height);
                    var hRatio = AspectRatioHelper.GetAspectRatioForMedia(height, width);
                    if (wRatio > 1.91 && wRatio < 0.8)
                    {
                        editNeeded = true;
                    }
                    else
                    {
                        if (hRatio > 1.91 && hRatio < 0.8)
                        {
                            editNeeded = true;
                        }
                    }
                    if (height > width)
                    {
                        editNeeded = true;
                    }

                    //in paeini comment bod
                    FileToUpload = await new PhotoHelper().SaveToImage(file, false);

                    if (!editNeeded)
                    {
                        CropGrid.Visibility = Visibility.Visible;

                        MainCanvas.Visibility = Visibility.Collapsed;

                        AspectRatioSlider.Value  = wRatio;
                        ImageCropper.AspectRatio = wRatio;
                        ImageCropper.CropShape   = CropShape.Rectangular;
                        await ImageCropper.LoadImageFromFile(file);
                    }
                    else
                    {
                        CropGrid.Visibility      = Visibility.Visible;
                        MainCanvas.Visibility    = Visibility.Collapsed;
                        AspectRatioSlider.Value  = DefaultAspectRatio;
                        ImageCropper.AspectRatio = DefaultAspectRatio;
                        ImageCropper.CropShape   = CropShape.Rectangular;
                        await ImageCropper.LoadImageFromFile(file);
                    }
                    //await Task.Delay(1500);
                    CanCrop = true;
                    LoadingUc.Stop();
                }
            }
            catch { }
        }
Beispiel #5
0
        private async void UploadButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (UploadUcListX.Count == 0)
                {
                    Helper.ShowNotify("Please select at least one image or video.", 5500);
                    return;
                }
                int  index   = 0;
                bool editing = false;
                int  ix      = 0;
                //foreach (var item in UploadUcList)
                //{
                //    if (item.Editing)
                //    {
                //        editing = true;
                //        index = ix;
                //        break;
                //    }
                //    ix++;
                //}

                foreach (var item in UploadUcListX)
                {
                    if (item.PlusVisibility == Visibility.Collapsed)
                    {
                        if (item.UploadUc.Editing)
                        {
                            editing = true;
                            index   = ix;
                            break;
                        }
                        ix++;
                    }
                }
                if (editing)
                {
                    Helper.ShowNotify("Some of your photo(s)/video(s) needs edit, edit them first and then try again.", 5500);
                    //LV.SelectedIndex = index;
                    CPresenter.Content = UploadUcListX[index].UploadUc;
                    //FlipView.SelectedIndex = index;
                    return;
                }
                var list = new List <StorageUploadItem>();

                foreach (var item in UploadUcListX)
                {
                    if (item.PlusVisibility == Visibility.Collapsed)
                    {
                        var itemX = item.UploadUc.UploadItem;
                        itemX.Location        = CurrentLocation;
                        itemX.DisableComments = ToggleTurnOffCommenting.IsOn;
                        list.Add(itemX);
                    }
                }
                ConvertionGrid.Visibility = Visibility.Visible;
                LoadingUc.Start();
                var converted = await Convertions.ConvertFilesAsync(list);

                ConvertionGrid.Visibility = Visibility.Collapsed;
                LoadingUc.Stop();
                var su = new StorageUpload();
                su.SetUploadItem(converted, CaptionText.Text);
                Helper.ShowNotify("Convertion is done now you can use Minista\r\n" +
                                  "We will upload your media(s) in background.", 6000);

                ShowNextButton();
                Helpers.NavigationService.GoBack();
            }
            catch { }
        }
Beispiel #6
0
        private async void ImportFiles(IReadOnlyList <StorageFile> files, bool appendFiles = false)
        {
            try
            {
                if (files == null)
                {
                    return;
                }
                if (files.Count > 0)
                {
                    if (!appendFiles)
                    {
                        //UploadUcList.Clear();
                        UploadUcListX.Clear();
                        CurrentLocation         = null;
                        NextButton.IsEnabled    = true;
                        NextButton.Visibility   = Visibility.Visible;
                        UploadButton.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        var plusItem = UploadUcListX.FirstOrDefault(x => x.PlusVisibility == Visibility.Visible);
                        if (plusItem != null)
                        {
                            UploadUcListX.Remove(plusItem);
                        }
                    }
                    LoadingUc.Start();
                    foreach (var file in files)
                    {
                        var item = new UploadUcItem
                        {
                            CloseVisibility = Visibility.Visible
                        };
                        var uc = new UploadUc
                        {
                            HorizontalAlignment = HorizontalAlignment.Stretch,
                            VerticalAlignment   = VerticalAlignment.Stretch
                        };
                        uc.SetNewFile(file);
                        item.UploadUc = uc;
                        UploadUcListX.Add(item);
                        //item.SetThumbIfExists();
                        //UploadUcList.Add(uc);
                    }
                    await Task.Delay(500);

                    var tasks = new List <Task>();
                    foreach (var item in UploadUcListX)
                    {
                        try
                        {
                            if (item.Loadings != null && !item.Started)
                            {
                                item.Started = true;
                                item.Loadings.Start();
                                //tasks.Add(item.UploadUc.InitFileAsync());
                            }
                        }
                        catch { }
                    }
                    await Task.Delay(3000);

                    if (UploadUcListX.Count < 9)
                    {
                        var item = new UploadUcItem
                        {
                            VideoVisibility = Visibility.Collapsed,
                            PlusVisibility  = Visibility.Visible
                        };
                        UploadUcListX.Add(item);
                    }
                    if (!appendFiles && UploadUcListX.Count > 0)
                    {
                        CPresenter.Content = UploadUcListX[0].UploadUc;
                    }

                    //await Task.WhenAll(tasks);
                    int ix = 0;
                    foreach (var item in UploadUcListX)
                    {
                        CPresenter.Content = UploadUcListX[ix].UploadUc;

                        if (item.PlusVisibility == Visibility.Collapsed)
                        {
                            await item.UploadUc.InitFile();
                        }
                        item.SetThumbIfExists();
                        ix++;
                    }

                    LoadingUc.Stop();
                }
            }
            catch (Exception ex) { ex.PrintException("ImportFiles(IReadOnlyList<StorageFile>"); }
        }
Beispiel #7
0
 public void ShowLoading()
 {
     LoadingUc.Start();
     //LoadingPb.IsActive = true;
     //LoadingGrid.Visibility = Visibility.Visible;
 }