예제 #1
0
        private void OnDownloadFolderLinkClick(object sender, EventArgs e)
        {
            // Needed on every UI interaction
            SdkService.MegaSdkFolderLinks.retryPendingConnections();

            // Extra check to avoid NullReferenceException
            if (_folderLinkViewModel == null || _folderLinkViewModel.FolderLinkRootNode == null)
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.AM_DownloadFailed_Title,
                    AppMessages.AM_DownloadFolderLinkFailed,
                    App.AppInformation,
                    MessageDialogButtons.Ok);

                customMessageDialog.OkOrYesButtonTapped += (new_sender, args) => CancelAction();

                customMessageDialog.ShowDialog();
                return;
            }

            App.LinkInformation.SelectedNodes.Add(_folderLinkViewModel.FolderLinkRootNode);
            App.LinkInformation.LinkAction = LinkAction.Download;

            if (!_folderLinkViewModel.IsUserOnline())
            {
                return;
            }

            _folderLinkViewModel.FolderLinkRootNode.Download(TransfersService.MegaTransfers);
        }
예제 #2
0
        public async Task <bool> MultipleDeleteContacts()
        {
            int count = MegaContactsList.Count(n => n.IsMultiSelected);

            if (count < 1)
            {
                return(false);
            }

            var customMessageDialog = new CustomMessageDialog(
                AppMessages.DeleteMultipleContactsQuestion_Title,
                String.Format(AppMessages.DeleteMultipleContactsQuestion, count),
                App.AppInformation,
                MessageDialogButtons.OkCancel);

            customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveContact));

                var helperList = new List <Contact>(count);
                helperList.AddRange(MegaContactsList.Where(n => n.IsMultiSelected));

                foreach (var contact in helperList)
                {
                    MegaSdk.removeContact(MegaSdk.getContact(contact.Email), new RemoveContactRequestListener(this, contact));
                }

                Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(false));
                this.IsMultiSelectActive = false;
            };

            return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes);
        }
예제 #3
0
        private void OnImportFolderLinkClick(object sender, EventArgs e)
        {
            // Needed on every UI interaction
            SdkService.MegaSdkFolderLinks.retryPendingConnections();

            // Extra check to avoid NullReferenceException
            if (_folderLinkViewModel == null || _folderLinkViewModel.FolderLinkRootNode == null)
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.AM_ImportFailed_Title,
                    AppMessages.AM_ImportFolderLinkFailed,
                    App.AppInformation,
                    MessageDialogButtons.Ok);

                customMessageDialog.OkOrYesButtonTapped += (new_sender, args) => CancelAction();

                customMessageDialog.ShowDialog();
                return;
            }

            App.LinkInformation.SelectedNodes.Add(_folderLinkViewModel.FolderLinkRootNode);
            App.LinkInformation.LinkAction = LinkAction.Import;

            NavigateService.NavigateTo(typeof(MainPage), NavigationParameter.ImportFolderLink);
        }
예제 #4
0
        private void ExtractFile(TreeIter iter, string filename)
        {
            waitWindow = new WaitWindow(this, "Extracting", filename);
            waitWindow.Show();

            ThreadNotify done = new ThreadNotify(new ReadyEvent(() =>
            {
                waitWindow.Destroy();
                waitWindow = null;
            }));

            ThreadNotify error = new ThreadNotify(new ReadyEvent(() =>
            {
                waitWindow.Destroy();
                waitWindow = null;

                CustomMessageDialog msg =
                    new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                msg.Run();
                msg.Destroy();
            }));

            Packer.Item item = packStore.GetValue(iter, 0) as Packer.Item;
            new Thread(new ThreadStart(() =>
            {
                if (fileSystem.Extract(item, filename))
                {
                    done.WakeupMain();
                }
                else
                {
                    error.WakeupMain();
                }
            })).Start();
        }
예제 #5
0
        private void ShowErrorMesageAndNavigate(String title, String message)
        {
            var customMessageDialog = new CustomMessageDialog(
                title, message, App.AppInformation, MessageDialogButtons.Ok);

            customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                                                       NavigateService.NavigateTo(NavigateToPage, NavigationParameter);

            customMessageDialog.ShowDialog();
        }
예제 #6
0
        private async Task Button1CommandAction()
        {
            var dialog = new CustomMessageDialog
            {
                Title       = this.Title,
                Message     = this.Message,
                Button1Text = "Click Me Arial",
                FontFamily  = new FontFamily("Arial"),
                FontWeight  = FontWeights.Black
            };

            await dialog.ShowAsync();
        }
        /// <summary>
        /// Generic method to show dialog with a folder link alert message.
        /// </summary>
        /// <param name="title">Title of the alert dialog.</param>
        /// <param name="message">Message of the alert dialog.</param>
        private void GenericFolderLinkAlert(String title, String message)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var customMessageDialog = new CustomMessageDialog(
                    title, message, App.AppInformation,
                    MessageDialogButtons.Ok);

                customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                                                           _folderLinkViewModel._folderLinkPage.CancelAction();

                customMessageDialog.ShowDialog();
            });
        }
예제 #8
0
 private void AppendFiles(TreeIter destIter, string path)
 {
     try
     {
         Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly).ToList()
         .ForEach(file => AppendFile(destIter, file));
     }
     catch (UnauthorizedAccessException)
     {
         CustomMessageDialog msg =
             new CustomMessageDialog(this, MessageType.Error, String.Format("Access denied to {0}", path));
         msg.Run();
         msg.Destroy();
     }
 }
예제 #9
0
        private async Task Button2CommandAction()
        {
            var dialog = new CustomMessageDialog
            {
                Title             = this.Title,
                Message           = this.Message,
                ButtonBorderBrush = new SolidColorBrush().FromHex("#14f5a9"),
                ButtonForeground  = new SolidColorBrush().FromHex("#babaca"),
                Button1Text       = "Click Me",
                Button2Text       = "Or Me!",
                FontFamily        = new FontFamily("Arial")
            };

            await dialog.ShowAsync();
        }
예제 #10
0
        public async Task <bool> MultipleRemoveItems()
        {
            int count = ChildNodes.Count(n => n.IsMultiSelected);

            if (count < 1)
            {
                return(false);
            }

            if (this.CurrentDisplayMode == DriveDisplayMode.RubbishBin ||
                (this.CurrentDisplayMode == DriveDisplayMode.MultiSelect &&
                 this.PreviousDisplayMode == DriveDisplayMode.RubbishBin))
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.MultiSelectRemoveQuestion_Title,
                    String.Format(AppMessages.MultiSelectRemoveQuestion, count),
                    App.AppInformation,
                    MessageDialogButtons.OkCancel,
                    MessageDialogImage.RubbishBin);

                customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveNode));
                    RemoveOrRubbish(count);
                };

                return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes);
            }
            else
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.MultiMoveToRubbishBinQuestion_Title,
                    String.Format(AppMessages.MultiMoveToRubbishBinQuestion, count),
                    App.AppInformation,
                    MessageDialogButtons.OkCancel,
                    MessageDialogImage.RubbishBin);

                customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.NodeToTrash));
                    RemoveOrRubbish(count);
                };

                return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes);
            }
        }
예제 #11
0
        private void AppendFile(TreeIter destIter, string filename)
        {
            Gtk.Application.Invoke((sender, e) => waitWindow.FileText = filename);

            Packer.Item fileItem = NewItem(destIter, filename);
            if (fileSystem.Add(fileItem))
            {
                AppendItem(destIter, fileItem);
            }
            else
            {
                CustomMessageDialog msg =
                    new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                msg.Run();
                msg.Destroy();
            }
        }
예제 #12
0
        private void DeleteContact(object obj)
        {
            if (FocusedContact != null)
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.DeleteContactQuestion_Title,
                    String.Format(AppMessages.DeleteContactQuestion, FocusedContact.Email),
                    App.AppInformation,
                    MessageDialogButtons.OkCancel);

                customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                {
                    MegaSdk.removeContact(MegaSdk.getContact(FocusedContact.Email), new RemoveContactRequestListener(this, FocusedContact));
                };

                customMessageDialog.ShowDialog();
            }
        }
예제 #13
0
        public void onAccountUpdate(MegaSDK api)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var customMessageDialog = new CustomMessageDialog(
                    AppMessages.AccountUpdated_Title,
                    AppMessages.AccountUpdate,
                    App.AppInformation,
                    MessageDialogButtons.YesNo);

                customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                {
                    NavigateService.NavigateTo(typeof(MyAccountPage), NavigationParameter.Normal);
                };

                customMessageDialog.ShowDialog();
            });
        }
예제 #14
0
        public async void OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;

            Key key = e.ImeProcessedKey == Key.None ? e.Key : e.ImeProcessedKey;

            int vkCode = KeyInterop.VirtualKeyFromKey(key);

            int result = _profileSwitchKeyTableManager.SetSwitchKeyByIndex(_fromIdx, _toIdx, vkCode);

            //Use WindowManager rather than directly access to view
            CustomMessageDialog customMessageDialog;

            switch (result)
            {
            case -2:
                customMessageDialog
                    = new CustomMessageDialog($"{key} is already reserved for activation key.");
                customMessageDialog.ShowDialog();

                break;

            case -1:
                customMessageDialog
                    = new CustomMessageDialog($"{key} is already used for other switch key.");
                customMessageDialog.ShowDialog();

                break;

            case 0:
                customMessageDialog
                    = new CustomMessageDialog($"{key} is already registerd as a hotkey of this profile");
                customMessageDialog.ShowDialog();

                break;

            default:
                await _profileSwitchKeyTableManager.SaveTableAsync();

                NotifyOfPropertyChange(() => SwitchKey);

                break;
            }
        }
예제 #15
0
        public async void OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;

            var key           = e.ImeProcessedKey == Key.None ? e.Key : e.ImeProcessedKey;
            var activationKey = KeyInterop.VirtualKeyFromKey(key);

            if (_applicationModel.SetActivationKey(activationKey))
            {
                await _jsonSavefileManager.SaveAsync(_options, AppConstants.OPTION_SAVE_NAME);

                NotifyOfPropertyChange(() => ActivationKey);

                return;
            }

            CustomMessageDialog dialog = new CustomMessageDialog("This key is already registered in switchkey table!");

            dialog.ShowDialog();
        }
예제 #16
0
        public void CleanRubbishBin()
        {
            if (this.RubbishBin.ChildNodes.Count < 1)
            {
                return;
            }

            var customMessageDialog = new CustomMessageDialog(
                UiResources.ClearRubbishBin,
                AppMessages.CleanRubbishBinQuestion,
                App.AppInformation,
                MessageDialogButtons.OkCancel,
                MessageDialogImage.RubbishBin);

            customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
            {
                MegaSdk.cleanRubbishBin(new CleanRubbishBinRequestListener());
            };

            customMessageDialog.ShowDialog();
        }
예제 #17
0
        private async Task SaveOrEditAsync(Hotkey hotkey)
        {
            int result = CurrentProfile.AddOrEditHotkeyIfExisting(hotkey);

            if (result >= 0)
            {
                await _profileManager.SaveProfileAsync(CurrentProfile).ConfigureAwait(false);
            }

            switch (result)
            {
            case -1:
                CustomMessageDialog messageDialog
                    = new CustomMessageDialog("No more hotkey is available");
                messageDialog.ShowDialog();
                break;

            case 0:
                await _eventAggregator.PublishOnUIThreadAsync(new HotkeyModifiedEvent
                {
                    Hotkey        = hotkey,
                    ModifiedEvent = EHotkeyModifiedEvent.Modified
                });

                break;

            case 1:
                await _eventAggregator.PublishOnUIThreadAsync(new HotkeyModifiedEvent
                {
                    Hotkey        = hotkey,
                    ModifiedEvent = EHotkeyModifiedEvent.Added
                });

                break;

            default:
                break;
            }
        }
예제 #18
0
        private void OpenPack(string filename)
        {
            if (Packer.Create(System.IO.Path.GetExtension(filename), out fileSystem))
            {
                waitWindow = new WaitWindow(this, "Opening", filename);
                waitWindow.Show();

                ThreadNotify done = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;
                }));

                ThreadNotify error = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;

                    CustomMessageDialog msg =
                        new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                    msg.Run();
                    msg.Destroy();
                }));

                new Thread(new ThreadStart(() =>
                {
                    if (fileSystem.Open(filename))
                    {
                        RebuildPackTree(fileSystem.ListFiles());
                        ChangePackActionSensitive(true);
                        done.WakeupMain();
                    }
                    else
                    {
                        error.WakeupMain();
                    }
                })).Start();
            }
        }
예제 #19
0
        private void AppendFolders(TreeIter destIter, string path)
        {
            try
            {
                Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly).ToList()
                .ForEach(folder =>
                {
                    Packer.Item folderItem = NewItem(destIter, folder);
                    TreeIter folderIter    = AppendItem(destIter, folderItem);
                    AppendFolders(folderIter, folder);
                });

                AppendFiles(destIter, path);
            }
            catch (UnauthorizedAccessException)
            {
                CustomMessageDialog msg =
                    new CustomMessageDialog(this, MessageType.Error, String.Format("Access denied to {0}", path));
                msg.Run();
                msg.Destroy();
            }
        }
예제 #20
0
        public async Task ShowAsync(string message, string title, params UICommand[] dialogCommands)
        {
            // Only show one dialog at a time.
            if (!IsShowing)
            {
                var messageDialog = new CustomMessageDialog(message, title);

                if (dialogCommands != null)
                {
                    var commands = dialogCommands;

                    foreach (var command in commands)
                    {
                        messageDialog.Commands.Add(command);
                    }
                }

                IsShowing = true;
                await messageDialog.ShowAsync();

                IsShowing = false;
            }
        }
예제 #21
0
        public static void ShowDialogAsync(string msg, bool isModeDialog = false)
        {
            //var dialog = new MessageDialogView()
            //{
            //    Message = { Text = msg },
            //};

            CustomMessageDialog customMessageDialog = new CustomMessageDialog()
            {
                Message = { Text = msg },
            };

            //await DialogHost.Show(dialog, "rootDialog");

            if (isModeDialog)
            {
                customMessageDialog.ShowDialog();
            }
            else
            {
                customMessageDialog.Show();
            }
        }
예제 #22
0
        /// <summary>
        /// Returns if there is a network available and the user is online (logged in).
        /// <para>If there is not a network available, show the corresponding error message if enabled.</para>
        /// <para>If the user is not logged in, also Navigates to the "LoginPage".</para>
        /// </summary>
        /// <param name="showMessageDialog">
        /// Boolean parameter to indicate if show error messages.
        /// <para>Default value is false.</para>
        /// </param>
        /// <returns>True if the user is online. False in other case.</returns>
        public bool IsUserOnline(bool showMessageDialog = false)
        {
            if (!NetworkService.IsNetworkAvailable(showMessageDialog))
            {
                return(false);
            }

            bool isOnline = Convert.ToBoolean(App.MegaSdk.isLoggedIn());

            if (!isOnline)
            {
                if (showMessageDialog)
                {
                    OnUiThread(() =>
                    {
                        var customMessageDialog = new CustomMessageDialog(
                            AppMessages.UserNotOnline_Title,
                            AppMessages.UserNotOnline,
                            App.AppInformation,
                            MessageDialogButtons.Ok);

                        customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                                                                   NavigateService.NavigateTo(typeof(LoginPage), NavigationParameter.Normal);

                        customMessageDialog.ShowDialog();
                    });
                }
                else
                {
                    OnUiThread(() =>
                               NavigateService.NavigateTo(typeof(LoginPage), NavigationParameter.Normal));
                }
            }

            return(isOnline);
        }
예제 #23
0
        /// <summary>
        /// Change the API URL.
        /// </summary>
        private static async void ChangeApiUrl()
        {
            StopChangeApiUrlTimer();

            var useStagingServer = SettingsService.LoadSetting <bool>(SettingsResources.UseStagingServer, false);

            if (!useStagingServer)
            {
                var confirmDialog = new CustomMessageDialog("Change to a testing server?",
                                                            "Are you sure you want to change to a testing server? Your account may run irrecoverable problems.",
                                                            App.AppInformation, MessageDialogButtons.OkCancel);

                var result = await confirmDialog.ShowDialogAsync();

                confirmDialog.CloseDialog();
                if (result != MessageDialogResult.OkYes)
                {
                    return;
                }
            }

            useStagingServer = !useStagingServer;

            var newApiUrl = useStagingServer ?
                            AppResources.AR_StagingUrl : AppResources.AR_ApiUrl;

            MegaSdk.changeApiUrl(newApiUrl);
            MegaSdkFolderLinks.changeApiUrl(newApiUrl);

            SettingsService.SaveSetting <bool>(SettingsResources.UseStagingServer, useStagingServer);

            // If the user is logged in, do a new login with the current session
            if (Convert.ToBoolean(MegaSdk.isLoggedIn()))
            {
                bool fastLoginResult;
                try
                {
                    var fastLogin = new FastLoginRequestListenerAsync();
                    fastLoginResult = await fastLogin.ExecuteAsync(() =>
                                                                   MegaSdk.fastLogin(SettingsService.LoadSetting <string>(SettingsResources.UserMegaSession), fastLogin));
                }
                // Do nothing, app is already logging out
                catch (BadSessionIdException)
                {
                    LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Login failed. Bad session ID.");
                    return;
                }

                if (fastLoginResult)
                {
                    // Fetch nodes from MEGA
                    var fetchNodes       = new FetchNodesRequestListenerAsync();
                    var fetchNodesResult = await fetchNodes.ExecuteAsync(() => MegaSdk.fetchNodes(fetchNodes));

                    if (fetchNodesResult != FetchNodesResult.Success)
                    {
                        LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Fetch nodes failed.");
                        new CustomMessageDialog(AppMessages.FetchingNodesFailed_Title, AppMessages.FetchingNodesFailed,
                                                App.AppInformation, MessageDialogButtons.Ok).ShowDialog();
                    }
                }
                else
                {
                    LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Resume session failed.");
                    new CustomMessageDialog(UiResources.UI_ResumeSession, AppMessages.AM_ResumeSessionFailed,
                                            App.AppInformation, MessageDialogButtons.Ok).ShowDialog();
                }
            }

            // Reset the "Camera Uploads" service if is enabled
            if (MediaService.GetAutoCameraUploadStatus())
            {
                LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Resetting CAMERA UPLOADS service (API URL changed)");
                SettingsService.SaveSetting(SettingsResources.CameraUploadsIsEnabled,
                                            MediaService.SetAutoCameraUpload(true));
            }

            new CustomMessageDialog(null, "API URL changed",
                                    App.AppInformation, MessageDialogButtons.Ok).ShowDialog();

            OnApiUrlChanged();
        }
예제 #24
0
        private void HandleSaveAction()
        {
            if (fileSystem == null)
            {
                return;
            }

            CustomFileChooserDialog dlg =
                new CustomFileChooserDialog(this, "Save pack", FileChooserAction.Save);

            dlg.FileChooser.SelectMultiple = false;

            using (Gtk.FileFilter filter = new Gtk.FileFilter())
            {
                filter.Name = fileSystem.Extension.ToUpper();
                filter.AddPattern("*." + fileSystem.Extension.ToLower());
                dlg.FileChooser.AddFilter(filter);
            }

            using (Gtk.FileFilter filter = new Gtk.FileFilter())
            {
                filter.Name = "All";
                filter.AddPattern("*.*");
                dlg.FileChooser.AddFilter(filter);
            }

            dlg.Ok += (sender, e) =>
            {
                string filename = dlg.FileChooser.Filename;

                waitWindow = new WaitWindow(this, "Saving", filename);
                waitWindow.Show();

                ThreadNotify done = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;
                }));

                ThreadNotify error = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;

                    CustomMessageDialog msg =
                        new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                    msg.Run();
                    msg.Destroy();
                }));

                new Thread(new ThreadStart(() =>
                {
                    if (fileSystem.Save(filename))
                    {
                        done.WakeupMain();
                    }
                    else
                    {
                        error.WakeupMain();
                    }
                })).Start();

                dlg.Destroy();
            };
            dlg.Cancel += (sender, e) => dlg.Destroy();
            dlg.Show();
        }
예제 #25
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Subscribe to the NetworkAvailabilityChanged event
            DeviceNetworkInformation.NetworkAvailabilityChanged +=
                new EventHandler <NetworkNotificationEventArgs>(NetworkAvailabilityChanged);

            if (App.AppInformation.IsStartupModeActivate)
            {
                // Needed on every UI interaction
                SdkService.MegaSdkFolderLinks.retryPendingConnections();

                if (!App.AppInformation.HasPinLockIntroduced && SettingsService.LoadSetting <bool>(SettingsResources.UserPinLockIsEnabled))
                {
                    NavigateService.NavigateTo(typeof(PasswordPage), NavigationParameter.Normal, this.GetType());
                    return;
                }

                App.AppInformation.IsStartupModeActivate = false;

                #if WINDOWS_PHONE_81
                // Check to see if some folder has been picked
                var app = Application.Current as App;
                if (app != null && app.FolderPickerContinuationArgs != null)
                {
                    FolderService.ContinueFolderOpenPicker(app.FolderPickerContinuationArgs,
                                                           _folderLinkViewModel.FolderLink);
                }
                #endif
            }

            if (!NetworkService.IsNetworkAvailable())
            {
                UpdateGUI(false);
                return;
            }

            // Initialize the application bar of this page
            SetApplicationBarData();

            if (!App.LinkInformation.HasFetchedNodesFolderLink)
            {
                if (!String.IsNullOrWhiteSpace(App.LinkInformation.ActiveLink))
                {
                    SdkService.MegaSdkFolderLinks.loginToFolder(App.LinkInformation.ActiveLink,
                                                                new LoginToFolderRequestListener(_folderLinkViewModel));
                }
                else
                {
                    var customMessageDialog = new CustomMessageDialog(
                        AppMessages.AM_OpenLinkFailed_Title,
                        AppMessages.AM_InvalidLink,
                        App.AppInformation,
                        MessageDialogButtons.Ok);

                    customMessageDialog.OkOrYesButtonTapped += (sender, args) => CancelAction();

                    customMessageDialog.ShowDialog();
                    return;
                }
            }
            else
            {
                if (e.NavigationMode != NavigationMode.Back)
                {
                    _folderLinkViewModel.LoadFolders();

                    if (App.LinkInformation.LinkAction == LinkAction.Download)
                    {
                        _folderLinkViewModel.FolderLink.MultipleDownload(App.LinkInformation.DownloadPath);
                    }
                }
            }
        }
예제 #26
0
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]);
                ProgressService.SetProgressIndicator(false);
                this._confirmAccountViewModel.ControlState = true;

                if (request.getType() == MRequestType.TYPE_QUERY_SIGNUP_LINK)
                {
                    switch (e.getErrorCode())
                    {
                    case MErrorType.API_OK:     // Valid and operative confirmation link
                        if (request.getFlag())  // Auto confirmed account.
                        {
                            ShowErrorMesageAndNavigate(AppMessages.AlreadyConfirmedAccount_Title,
                                                       AppMessages.AlreadyConfirmedAccount);
                            break;
                        }
                        this._confirmAccountViewModel.Email = request.getEmail();
                        break;

                    case MErrorType.API_ENOENT:     // Already confirmed account
                        ShowErrorMesageAndNavigate(AppMessages.AlreadyConfirmedAccount_Title,
                                                   AppMessages.AlreadyConfirmedAccount);
                        break;

                    case MErrorType.API_EINCOMPLETE:     // Incomplete confirmation link
                        ShowErrorMesageAndNavigate(AppMessages.ConfirmAccountFailed_Title,
                                                   AppMessages.AM_IncompleteConfirmationLink);
                        break;

                    case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota
                    case MErrorType.API_EOVERQUOTA:      // Storage overquota error
                        base.onRequestFinish(api, request, e);
                        break;

                    default:     // Other error
                        ShowDefaultErrorMessage(e);
                        break;
                    }
                }
                else if (request.getType() == MRequestType.TYPE_CONFIRM_ACCOUNT)
                {
                    switch (e.getErrorCode())
                    {
                    case MErrorType.API_OK:     // Successfull confirmation process
                        var customMessageDialog = new CustomMessageDialog(
                            SuccessMessageTitle, SuccessMessage,
                            App.AppInformation, MessageDialogButtons.Ok);

                        customMessageDialog.OkOrYesButtonTapped += (sender, args) =>
                                                                   OnSuccesAction(api, request);

                        customMessageDialog.ShowDialog();
                        break;

                    case MErrorType.API_ENOENT:     // Wrong password
                    case MErrorType.API_EKEY:       // Wrong password
                        new CustomMessageDialog(
                            AppMessages.WrongPassword_Title,
                            AppMessages.WrongPassword,
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                        break;

                    case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota
                    case MErrorType.API_EOVERQUOTA:      // Storage overquota error
                        base.onRequestFinish(api, request, e);
                        break;

                    default:     // Other error
                        ShowDefaultErrorMessage(e);
                        break;
                    }
                }
            });
        }
예제 #27
0
        public static bool Init(string[] args)
        {
            string appName = Assembly.GetExecutingAssembly().GetName().Name;

            // check gtk
            if (!ThemeHelper.CheckGtk())
            {
                return(false);
            }
            ThemeHelper.ApplyCustomTheme(args);

            // init gtk app
            Application.Init(appName, ref args);

            // check windows platform
            if (!Gui.PlatformUtils.IsWindows)
            {
                CustomMessageDialog dlg = new CustomMessageDialog(
                    null, MessageType.Error,
                    "Your OS is not supported on this version!");
                dlg.Ok += (sender, e) => Application.Quit();
                dlg.Show();
                Application.Run();
                return(false);
            }

            // load dgle
            IEngineCore pEngineCore = null;

            if (!Engine.GetEngine(DLL_PATH, out pEngineCore))
            {
                CustomMessageDialog dlg = new CustomMessageDialog(
                    null, MessageType.Error,
                    "Couldn't load \"{0}\"!", DLL_NAME);
                dlg.Ok += (sender, e) => Application.Quit();
                dlg.Show();
                Application.Run();
                return(false);
            }

            Core = pEngineCore;

            // init dgle with force no window
            TEngineWindow eng_win = new TEngineWindow();

            Core.InitializeEngine(
                IntPtr.Zero, appName, ref eng_win, 33,
                E_ENGINE_INIT_FLAGS.EIF_FORCE_NO_WINDOW | E_ENGINE_INIT_FLAGS.EIF_NO_SPLASH);
            //Core.ConsoleVisible(false);

            // init virtual file systems from dgle
            try
            {
                Packer.Init();
            }
            catch
            {
                CustomMessageDialog dlg = new CustomMessageDialog(
                    null, MessageType.Error, ButtonsType.Ok,
                    "Failed to load file systems from DGLE!");
                dlg.Ok += (sender, e) =>
                          Program.Stop();
                dlg.Show();

                return(false);
            }

            // init main win
            MainWindow win = new MainWindow();

            win.Show();
            win.DeleteEvent += (o, a) =>
            {
                Stop();
                a.RetVal = true;
            };

            return(true);
        }