コード例 #1
0
        private async void OnRemoveClick(object sender, EventArgs e)
        {
            NodeActionResult result = await _nodeDetailsViewModel.Remove();

            if (result == NodeActionResult.Cancelled)
            {
                return;
            }

            try
            {
                if (NavigateService.CanGoBack())
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
        }
コード例 #2
0
        private void OnOkClick(object sender, EventArgs e)
        {
            SetApplicationBar(false);

            try
            {
                // Enable or turn on the "Camera Uploads" service
                SettingsService.SaveSetting <bool>(SettingsResources.CameraUploadsIsEnabled, true);
                MediaService.SetAutoCameraUpload(true);

                if (NavigateService.PreviousPage != null)
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            finally
            {
                SetApplicationBar(true);
            }
        }
コード例 #3
0
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            try
            {
                if (NavigateService.PreviousPage != null)
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            finally
            {
                e.Cancel = true;
            }
        }
コード例 #4
0
        private void OnSkipClick(object sender, EventArgs e)
        {
            SetApplicationBar(false);

            try
            {
                if (NavigateService.PreviousPage != null)
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            finally
            {
                SetApplicationBar(true);
            }
        }
コード例 #5
0
        private async void OnUploadClick(object sender, System.EventArgs e)
        {
            string fileName = String.Format("WP_Selfie_{0}{1:D2}{2:D2}{3}{4}.jpg",
                                            DateTime.Now.Year,
                                            DateTime.Now.Month,
                                            DateTime.Now.Day,
                                            DateTime.Now.Hour,
                                            DateTime.Now.Minute);

            try
            {
                string newFilePath = Path.Combine(AppService.GetUploadDirectoryPath(true), fileName);
                using (var fs = new FileStream(newFilePath, FileMode.Create))
                {
                    await fs.WriteAsync(_previewSelfieViewModel.Selfie.ConvertToBytes().ToArray(), 0,
                                        _previewSelfieViewModel.Selfie.ConvertToBytes().Count());

                    await fs.FlushAsync();

                    fs.Close();
                }

                var uploadTransfer = new TransferObjectModel(SdkService.MegaSdk, App.CloudDrive.CurrentRootNode, MTransferType.TYPE_UPLOAD, newFilePath);
                TransfersService.MegaTransfers.Add(uploadTransfer);
                uploadTransfer.StartTransfer();

                App.CloudDrive.NoFolderUpAction = true;

                // Remove the `PhotoCameraPage` from the back stack and go back
                NavigationService.RemoveBackEntry();

                if (NavigateService.CanGoBack())
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (Exception)
            {
                new CustomMessageDialog(
                    AppMessages.UploadSelfieFailed_Title,
                    AppMessages.UploadSelfieFailed,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
            }
        }
コード例 #6
0
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            if (FolderLinkMenu.IsOpen)
            {
                e.Cancel = true;
            }

            // Check if multi select is active on current view and disable it if so
            e.Cancel = CheckMultiSelectActive(e.Cancel);

            // Check if we can go a folder up in the selected pivot view
            e.Cancel = CheckAndGoFolderUp(e.Cancel);

            if (!e.Cancel)
            {
                App.LinkInformation.Reset();

                try
                {
                    if (NavigateService.CanGoBack())
                    {
                        NavigateService.GoBack();
                    }
                    else
                    {
                        NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                    }
                }
                catch (InvalidOperationException exception)
                {
                    if (exception.Message.Contains("NavigateService - GoBack"))
                    {
                        NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                    }
                }
                finally
                {
                    e.Cancel = true;
                }
            }
        }
コード例 #7
0
        public void CancelAction()
        {
            App.LinkInformation.Reset();

            try
            {
                if (NavigateService.CanGoBack())
                {
                    NavigateService.GoBack();
                }
                else
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("NavigateService - GoBack"))
                {
                    NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
                }
            }
        }
コード例 #8
0
        private async void OnAcceptClick(object sender, System.EventArgs e)
        {
            if (LstMediaItems.CheckedItems == null || LstMediaItems.CheckedItems.Count < 1)
            {
                new CustomMessageDialog(
                    AppMessages.MinimalPictureSelection_Title,
                    AppMessages.MinimalPictureSelection,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                return;
            }

            ProgressService.SetProgressIndicator(true, ProgressMessages.PrepareUploads);
            SetControlState(false);

            // Set upload directory only once for speed improvement and if not exists, create dir
            var uploadDir = AppService.GetUploadDirectoryPath(true);

            foreach (var checkedItem in LstMediaItems.CheckedItems)
            {
                var item = (BaseMediaViewModel <Picture>)checkedItem;
                if (item == null)
                {
                    continue;
                }

                try
                {
                    string fileName = Path.GetFileName(item.Name);
                    if (fileName != null)
                    {
                        string newFilePath = Path.Combine(uploadDir, fileName);
                        using (var fs = new FileStream(newFilePath, FileMode.Create))
                        {
                            await item.BaseObject.GetImage().CopyToAsync(fs);

                            await fs.FlushAsync();

                            fs.Close();
                        }
                        var uploadTransfer = new TransferObjectModel(SdkService.MegaSdk, App.CloudDrive.CurrentRootNode, MTransferType.TYPE_UPLOAD, newFilePath);
                        TransfersService.MegaTransfers.Add(uploadTransfer);
                        uploadTransfer.StartTransfer();
                    }
                }
                catch (Exception)
                {
                    new CustomMessageDialog(
                        AppMessages.PrepareImageForUploadFailed_Title,
                        String.Format(AppMessages.PrepareImageForUploadFailed, item.Name),
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                }
            }

            ProgressService.SetProgressIndicator(false);
            SetControlState(true);

            App.CloudDrive.NoFolderUpAction = true;

            if (NavigateService.CanGoBack())
            {
                NavigateService.GoBack();
            }
            else
            {
                NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.Normal);
            }
        }