/// <summary> /// Check the password typed by the user /// </summary> private void CheckPassword() { if (string.IsNullOrWhiteSpace(this.Password)) { return; } this.ControlState = false; this.SecondaryButtonState = false; this.passwordChecked = SdkService.MegaSdk.checkPassword(this.Password); if (!this.passwordChecked) { this.ControlState = true; this.WarningColor = (SolidColorBrush)Application.Current.Resources["MegaRedColorBrush"]; this.WarningText = ResourceService.AppMessages.GetString("AM_TestPasswordWarning"); this.failedAttempts++; if (this.failedAttempts < MaxAttempts) { return; } // I user has exceeded the number of attempts, close // this dialog and show the "Change password" dialog this.OnHideDialog(); DialogService.ShowChangePasswordDialog(); return; } if (!this.AtLogout) { this.DialogStyle = (Style)Application.Current.Resources["MegaContentDialogStyle"]; } this.CloseButtonVisibility = Visibility.Collapsed; this.WarningColor = new SolidColorBrush(UiService.GetColorFromHex("#00C0A5")); this.WarningText = ResourceService.AppMessages.GetString("AM_TestPasswordSuccess"); this.SecondaryButtonCommand = this.CloseCommand; this.SecondaryButtonState = true; this.SecondaryButtonText = this.AtLogout ? ResourceService.UiResources.GetString("UI_Logout") : ResourceService.UiResources.GetString("UI_Close"); }
/// <summary> /// Invoked when occurs an unhandled exception. /// </summary> /// <param name="sender">The source of the unhandled exception.</param> /// <param name="e">Details about the unhandled exception.</param> private async void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { try { // Save the exception in a local variable to preserve the stack trace var exception = e.Exception; // An unhandled exception has occurred. Break into the debugger if (Debugger.IsAttached) { Debugger.Break(); } if (isAborting) { return; } e.Handled = true; string message = string.Format("{0}{1}{1}{2}", ResourceService.AppMessages.GetString("AM_ApplicationErrorParagraph1"), Environment.NewLine, ResourceService.AppMessages.GetString("AM_ApplicationErrorParagraph2")); await UiService.OnUiThreadAsync(async() => { var result = await DialogService.ShowOkCancelAsync( ResourceService.AppMessages.GetString("AM_ApplicationError_Title"), message, TwoButtonsDialogType.YesNo); if (result) { await DebugService.ComposeErrorReportEmailAsync(exception); } }); } catch (Exception ex) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Error managing an unhandled exception.", ex); } finally { // Reenabling auto crash ForceAppCrash(e.Exception); } }
public void SetUp(PlayerService playerService, FightingGameService fgService, UiService uiService) { this.playerService = playerService; this.fgService = fgService; this.uiService = uiService; char0 = playerService.GetFGChar(0); char1 = playerService.GetFGChar(1); char0.SetOpponentCharacter(char1); char1.SetOpponentCharacter(char0); char0.RegisterOnHealthChangeCallback(OnPlayerHealthChange(0)); char1.RegisterOnHealthChangeCallback(OnPlayerHealthChange(1)); char0.RegisterOnEmptyHealthCallback(OnPlayerEmptyHealth); char1.RegisterOnEmptyHealthCallback(OnPlayerEmptyHealth); }
public void onAccountUpdate(MegaSDK api) { UiService.OnUiThread(async() => { var result = await DialogService.ShowOkCancelAsync( ResourceService.AppMessages.GetString("AM_AccountUpdated_Title"), ResourceService.AppMessages.GetString("AM_AccountUpdate"), TwoButtonsDialogType.YesNo); if (!result) { return; } NavigateService.Instance.Navigate(typeof(MyAccountPage), false, NavigationObject.Create(typeof(MainViewModel), NavigationActionType.Default)); }); }
public override void Execute(IDiagramNode diagramNode) { var roslynModelNode = diagramNode?.ModelNode as IRoslynModelNode; if (roslynModelNode == null) { throw new Exception("DiagramNode or ModelNode is null or not an IRoslynModelNode."); } if (ModelService.HasSource(roslynModelNode)) { ModelService.ShowSource(roslynModelNode); } else { UiService.ShowPopupMessage(NoSourceMessage, NoSourceMessageDuration); } }
public IEnumerable <IResult> Populate() { yield return(UiService.ShowBusy()); var result = DataService.FetchList <EmployeeInfoList, Employee>(null); yield return(result); yield return(UiService.HideBusy()); if (ReferenceEquals(null, result.Error)) { Items = result.Result; } else { yield return(UiService.ShowWindowsMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
public IEnumerable <IResult> CancelRequest() { yield return(UiService.ShowBusy()); var result = DataService.Delete(_selectedItem, x => x.RequestNumber); yield return(result); yield return(UiService.HideBusy()); if (ReferenceEquals(null, result.Error)) { yield return(new SequentialResult(Populate().GetEnumerator())); } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
public void SetApplicationBar(bool isEnabled) { if (this.ApplicationBar == null) { return; } if (_loginAndCreateAccountViewModelContainer == null) { _loginAndCreateAccountViewModelContainer = new LoginAndCreateAccountViewModelContainer(this); } // Change and translate the current application bar _loginAndCreateAccountViewModelContainer.ChangeMenu( this.ApplicationBar.Buttons, this.ApplicationBar.MenuItems); UiService.ChangeAppBarStatus(this.ApplicationBar.Buttons, this.ApplicationBar.MenuItems, isEnabled); }
private async Task <IReadOnlyList <IDiagramNode> > ShowProgressAndAddItemsAsync(IReadOnlyList <IRoslynModelNode> modelEntities) { IReadOnlyList <IDiagramNode> diagramNodes = null; using (var progressDialog = await UiService.CreateProgressDialogAsync("Adding model items:", modelEntities.Count)) { await progressDialog.ShowWithDelayAsync(); try { diagramNodes = await ShowEntitiesAsync(modelEntities, progressDialog.CancellationToken, progressDialog.Progress); } catch (OperationCanceledException) { } } return(diagramNodes); }
public FolderLinkPage() { _folderLinkViewModel = new FolderLinkViewModel(SdkService.MegaSdkFolderLinks, App.AppInformation, this); this.DataContext = _folderLinkViewModel; InitializeComponent(); FolderLinkBreadCrumb.BreadCrumbTap += BreadCrumbControlOnOnBreadCrumbTap; FolderLinkBreadCrumb.HomeTap += BreadCrumbControlOnOnHomeTap; _folderLinkViewModel.CommandStatusChanged += (sender, args) => { if (ApplicationBar == null) { return; } UiService.ChangeAppBarStatus(ApplicationBar.Buttons, ApplicationBar.MenuItems, args.Status); }; }
public void BackToTitleOnClick() { if (UiService.IsUIElementOpen(Constants.UI.RightWindow)) { UiService.GetOpenUIElement(Constants.UI.RightWindow).Close(); } if (UiService.IsUIElementOpen(Constants.UI.TopWindow)) { UiService.GetOpenUIElement(Constants.UI.TopWindow).Close(); } if (UiService.IsUIElementOpen(Constants.UI.BottomWindow)) { UiService.GetOpenUIElement(Constants.UI.BottomWindow).Close(); } Close(); }
public IEnumerable <IResult> CancelRequest() { yield return(UiService.ShowBusy()); var result = DataService.Delete(Item, x => x.RequestNumber); yield return(result); yield return(UiService.HideBusy()); if (ReferenceEquals(null, result.Error)) { TryClose(); } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
public override async Task ExecuteAsync() { var modelEntity = await ModelService.AddCurrentSymbolAsync(); if (modelEntity == null) { return; } var diagramNodes = await ExtendModelAndDiagramAsync(modelEntity); if (diagramNodes == null) { return; } UiService.ShowDiagramWindow(); UiService.FollowDiagramNodes(diagramNodes); }
public IEnumerable <IResult> Populate() { yield return(UiService.ShowBusy()); var result = DataService.Fetch <BusinessObjects.Employees.EmployeeSituation> (Context.CurrentEmployee.EmployeeId); yield return(result); yield return(UiService.HideBusy()); if (result.Error == null) { Item = result.Result; } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
private IEnumerable <IResult> ChangeSelecedItemState(VacationRequestState toState) { yield return(UiService.ShowBusy()); var result = DataService.Execute( new ChangeVacationRequestStateCommand(SelectedItem.RequestNumber, toState)); yield return(result); yield return(UiService.HideBusy()); if (ReferenceEquals(null, result.Error)) { yield return(new SequentialResult(Populate().GetEnumerator())); } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
public IEnumerable <IResult> SaveRequest() { yield return(UiService.ShowBusy()); _item.EmployeeId = Context.CurrentEmployee.EmployeeId; var result = DataService.Update(_item); yield return(result); yield return(UiService.HideBusy()); if (result.Error == null) { Item = result.Result; UpdateTitle(); } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
public void onTransferStart(MegaSDK api, MTransfer transfer) { // Extra checking to avoid NullReferenceException if (transfer == null) { return; } UiService.OnUiThread(() => { var megaTransfer = TransferService.AddTransferToList(TransferService.MegaTransfers, transfer); if (megaTransfer != null) { megaTransfer.Transfer = transfer; megaTransfer.IsBusy = api.areTransfersPaused((int)transfer.getType()) ? false : true; megaTransfer.TransferState = api.areTransfersPaused((int)transfer.getType()) ? MTransferState.STATE_QUEUED : transfer.getState(); megaTransfer.TotalBytes = transfer.getTotalBytes(); megaTransfer.TransferPriority = transfer.getPriority(); } }); }
public IEnumerable <IResult> Populate() { yield return(UiService.ShowBusy()); var vmIdentity = (VmIdentity)ApplicationContext.User.Identity; // TODO: what if the cast fails? var result = DataService.Fetch <Employee>(vmIdentity.EmployeeId); yield return(result); yield return(UiService.HideBusy()); if (result.Error == null) { CurrentEmployee = result.Result; } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
public IEnumerable <IResult> OpenDetailsForCreatingRequest() { yield return(UiService.ShowBusy()); var result = DataService.Create <VacationRequest>(); yield return(result); yield return(UiService.HideBusy()); if (ReferenceEquals(null, result.Error)) { yield return(UiService.ShowChild <MyRequestDetailsViewModel>() .In <IShellViewModel>() .Configure(x => x.Item = result.Result)); } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
/// <summary> /// Get the thumbnail of the node /// </summary> private async void GetThumbnail() { if (FileService.FileExists(this.ThumbnailPath)) { this.ThumbnailImageUri = new Uri(this.ThumbnailPath); } else if (Convert.ToBoolean(this.MegaSdk.isLoggedIn()) || this.ParentContainerType == ContainerType.FolderLink) { var getThumbnail = new GetThumbnailRequestListenerAsync(); var result = await getThumbnail.ExecuteAsync(() => { this.MegaSdk.getThumbnail(this.OriginalMNode, this.ThumbnailPath, getThumbnail); }); if (result) { UiService.OnUiThread(() => this.ThumbnailImageUri = new Uri(this.ThumbnailPath)); } } }
/// <summary> /// This function is called when a transfer fails by a default error. /// It does the needed actions to process this kind of error. /// </summary> /// <param name="transfer"></param> private void ProcessDefaultError(MTransfer transfer) { string message, title = string.Empty; switch (transfer.getType()) { case MTransferType.TYPE_DOWNLOAD: title = ResourceService.AppMessages.GetString("AM_DownloadFailed_Title"); if (transfer.isFolderTransfer()) { message = ResourceService.AppMessages.GetString("AM_DownloadFolderFailed"); } else { message = ResourceService.AppMessages.GetString("AM_DownloadFileFailed"); } break; case MTransferType.TYPE_UPLOAD: title = ResourceService.AppMessages.GetString("AM_UploadFailed_Title"); if (transfer.isFolderTransfer()) { message = ResourceService.AppMessages.GetString("AM_UploadFolderFailed"); } else { message = ResourceService.AppMessages.GetString("AM_UploadFileFailed"); } break; default: throw new ArgumentOutOfRangeException(); } UiService.OnUiThread(async() => { await DialogService.ShowAlertAsync(title, string.Format(message, transfer.getFileName())); }); }
/// <summary> /// Changes the view mode for the folder content. /// </summary> private void ChangeView() { if (this.FolderRootNode == null) { return; } switch (this.ViewMode) { case FolderContentViewMode.ListView: UiService.SetViewMode(this.FolderRootNode.Base64Handle, FolderContentViewMode.GridView); SetView(FolderContentViewMode.GridView); break; case FolderContentViewMode.GridView: UiService.SetViewMode(this.FolderRootNode.Base64Handle, FolderContentViewMode.ListView); SetView(FolderContentViewMode.ListView); break; } this.OnChangeViewEvent(); }
/// <summary> /// Method called when a network status changed event is triggered /// </summary> /// <param name="sender">Object that sent the event</param> protected override async void OnNetworkStatusChanged(object sender) { base.OnNetworkStatusChanged(sender); this.ViewModel?.ContentViewModel?.UpdateNetworkStatus(); // If no network connection, nothing to do if (!NetworkService.HasInternetAccess()) { return; } // Check if the user has an active and online session if (!await AppService.CheckActiveAndOnlineSessionAsync(true)) { return; } // If user is not already logged in, resume the session if (!Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn())) { UiService.OnUiThread(async() => { if (!await this.ViewModel?.FastLoginAsync()) { return; } if (this.ViewModel?.ContentViewModel is CloudDriveViewModel) { var contentViewModel = this.ViewModel.ContentViewModel as CloudDriveViewModel; if (!contentViewModel.ActiveFolderView.IsLoaded) { contentViewModel.LoadFolders(); } } }); } }
public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e) { UiService.OnUiThread(() => apiErrorTimer?.Stop()); switch (e.getErrorCode()) { case MErrorType.API_EGOINGOVERQUOTA: // Not enough storage quota LogService.Log(MLogLevel.LOG_LEVEL_INFO, string.Format("Not enough storage quota ({0})", e.getErrorCode().ToString())); UiService.OnUiThread(() => DialogService.ShowStorageOverquotaAlert(true)); break; case MErrorType.API_EOVERQUOTA: // Storage overquota error LogService.Log(MLogLevel.LOG_LEVEL_INFO, string.Format("Storage quota exceeded ({0})", e.getErrorCode().ToString())); UiService.OnUiThread(() => { AccountService.AccountDetails.IsInStorageOverquota = true; DialogService.ShowStorageOverquotaAlert(false); }); break; } }
public IEnumerable <IResult> Populate() { yield return(UiService.ShowBusy()); var criteria = new VacationRequestSearchCriteria { States = new[] { VacationRequestState.Approved }, }; var result = DataService.FetchList <VacationRequestInfoList, VacationRequest>(criteria); yield return(result); yield return(UiService.HideBusy()); if (ReferenceEquals(null, result.Error)) { Items = result.Result; } else { yield return(UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption)); } }
/// <summary> /// Gets the contact avatar /// </summary> public async void GetContactAvatar() { var contactAvatarRequestListener = new GetUserAvatarRequestListenerAsync(); var contactAvatarResult = await contactAvatarRequestListener.ExecuteAsync(() => this.MegaSdk.getUserAvatar(this.MegaUser, this.AvatarPath, contactAvatarRequestListener)); if (contactAvatarResult) { UiService.OnUiThread(() => { var img = new BitmapImage() { CreateOptions = BitmapCreateOptions.IgnoreImageCache, UriSource = new Uri(this.AvatarPath) }; this.AvatarUri = img.UriSource; }); } else { UiService.OnUiThread(() => this.AvatarUri = null); } }
public void SetApplicationBarData(bool isEnabled = true) { if (_folderLinkViewModel == null) { _folderLinkViewModel = new FolderLinkViewModel(SdkService.MegaSdkFolderLinks, App.AppInformation, this); } // Set the Application Bar to one of the available menu resources in this page SetAppbarResources(_folderLinkViewModel.FolderLink.CurrentDisplayMode); // Change and translate the current application bar _folderLinkViewModel.ChangeMenu(_folderLinkViewModel.FolderLink, this.ApplicationBar.Buttons, this.ApplicationBar.MenuItems); UiService.ChangeAppBarStatus(this.ApplicationBar.Buttons, this.ApplicationBar.MenuItems, isEnabled); // Button "cancel" should be enabled always if (_folderLinkViewModel.FolderLink.CurrentDisplayMode == DriveDisplayMode.FolderLink) { ((ApplicationBarIconButton)this.ApplicationBar.Buttons[2]).IsEnabled = true; } }
public ContactRequestViewModel(MContactRequest contactRequest, ContactRequestsListViewModel contactRequestsList) { MegaContactRequest = contactRequest; Handle = contactRequest.getHandle(); SourceEmail = contactRequest.getSourceEmail(); SourceMessage = contactRequest.getSourceMessage(); TargetEmail = contactRequest.getTargetEmail(); CreationTime = contactRequest.getCreationTime(); ModificationTime = contactRequest.getModificationTime(); Status = contactRequest.getStatus(); IsOutgoing = contactRequest.isOutgoing(); AvatarColor = UiService.GetColorFromHex( SdkService.MegaSdk.getUserHandleAvatarColor(Handle.ToString())); this.ContactRequestsList = contactRequestsList; this.AcceptContactRequestCommand = new RelayCommand(AcceptContact); this.IgnoreContactRequestCommand = new RelayCommand(IgnoreContact); this.DeclineContactRequestCommand = new RelayCommand(DeclineContact); this.RemindContactRequestCommand = new RelayCommand(RemindContact); this.CancelContactRequestCommand = new RelayCommand(CancelContact); }
/// <summary> /// A method to force get all nodes as we sometimes get into a state where the root is missing. /// </summary> /// <param name="uiService">The ui service on the current device</param> /// <returns>All nodes on the screen</returns> private IList <Node> ForceGetAllNodes(UiService uiService) { var maxTries = 20; var tries = 0; while (true) { try { uiService.UpdateCachedNodes(); return(uiService.CachedNodes); } catch (UiNodeNotFoundException) { if (tries >= maxTries) { throw; } tries++; } } }
private async Task <IReadOnlyList <IDiagramNode> > ExtendModelAndDiagramAsync(IRoslynModelNode modelNode) { IReadOnlyList <IDiagramNode> diagramNodes = null; using (var progressDialog = await UiService.CreateProgressDialogAsync("Extending model with entities:")) { await progressDialog.ShowWithDelayAsync(); try { await ExtendModelWithRelatedEntitiesAsync(modelNode, progressDialog.CancellationToken, progressDialog.Progress); progressDialog.Reset("Adding diagram nodes:"); diagramNodes = await ExtendDiagramAsync(modelNode, progressDialog.CancellationToken, progressDialog.Progress); } catch (OperationCanceledException) { } } return(diagramNodes); }