public void PropertiesWithNotification() { MultiThreadingObservableCollection <IAlertItem> items = new MultiThreadingObservableCollection <IAlertItem>(); MockAlertDialogView view = new MockAlertDialogView(); AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items); Assert.AreEqual(items, viewModel.Items); Assert.AreEqual(0, viewModel.Items.Count); bool hasAlertSound = viewModel.HasAlertSound; AssertHelper.PropertyChangedEvent(viewModel, x => x.HasAlertSound, () => viewModel.HasAlertSound = !hasAlertSound); Assert.AreEqual(!hasAlertSound, viewModel.HasAlertSound); MultiThreadingObservableCollection <IAlertItem> newItems = new MultiThreadingObservableCollection <IAlertItem>(); newItems.Add( new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 1" } ); AssertHelper.PropertyChangedEvent(viewModel, x => x.Items, () => viewModel.AddItems(newItems)); Assert.AreEqual(1, viewModel.Items.Count); }
private void Alert() { var dialog = new AlertDialogViewModel("Attention", "This is an alert!"); var result = _dialogService.OpenDialog(dialog); Console.WriteLine(result); }
public void PropertiesWithNotification() { MultiThreadingObservableCollection<IAlertItem> items = new MultiThreadingObservableCollection<IAlertItem>(); MockAlertDialogView view = new MockAlertDialogView(); AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items); Assert.AreEqual(items, viewModel.Items); Assert.AreEqual(0, viewModel.Items.Count); bool hasAlertSound = viewModel.HasAlertSound; AssertHelper.PropertyChangedEvent(viewModel, x => x.HasAlertSound, () => viewModel.HasAlertSound = !hasAlertSound); Assert.AreEqual(!hasAlertSound, viewModel.HasAlertSound); MultiThreadingObservableCollection<IAlertItem> newItems = new MultiThreadingObservableCollection<IAlertItem>(); newItems.Add( new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 1" } ); AssertHelper.PropertyChangedEvent(viewModel, x => x.Items, () => viewModel.AddItems(newItems)); Assert.AreEqual(1, viewModel.Items.Count); }
public void AlertDialogViewModelCloseTest() { MultiThreadingObservableCollection <IAlertItem> items = new MultiThreadingObservableCollection <IAlertItem>(); items.Add(new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 1" } ); items.Add(new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 2" } ); items.Add(new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 3" } ); Assert.AreEqual(false, items[0].HasAlert); Assert.AreEqual(false, items[1].HasAlert); Assert.AreEqual(false, items[2].HasAlert); MockAlertDialogView view = new MockAlertDialogView(); AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items); Assert.AreEqual(items, viewModel.Items); object owner = new object(); view.ShowDialogAction = v => { viewModel.OKCommand.Execute(null); }; bool?dialogResult = viewModel.ShowDialog(owner); Assert.AreEqual(true, dialogResult); Assert.AreEqual(true, items[0].HasAlert); Assert.AreEqual(true, items[1].HasAlert); Assert.AreEqual(true, items[2].HasAlert); }
public void AlertDialogViewModelCloseTest() { MultiThreadingObservableCollection<IAlertItem> items = new MultiThreadingObservableCollection<IAlertItem>(); items.Add(new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 1" } ); items.Add(new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 2" } ); items.Add(new AlertItem { Time = DateTime.Now, AlertTime = DateTime.Now, Notice = "Test 3" } ); Assert.AreEqual(false, items[0].HasAlert); Assert.AreEqual(false, items[1].HasAlert); Assert.AreEqual(false, items[2].HasAlert); MockAlertDialogView view = new MockAlertDialogView(); AlertDialogViewModel viewModel = new AlertDialogViewModel(view, items); Assert.AreEqual(items, viewModel.Items); object owner = new object(); view.ShowDialogAction = v => { viewModel.OKCommand.Execute(null); }; bool? dialogResult = viewModel.ShowDialog(owner); Assert.AreEqual(true, dialogResult); Assert.AreEqual(true, items[0].HasAlert); Assert.AreEqual(true, items[1].HasAlert); Assert.AreEqual(true, items[2].HasAlert); }
public DialogServiceExampleViewModel(IDialogService dialogService) { this.dialogService = dialogService; this.openAlertDialog = new SimpleCommand(() => { this.openAlertDialog.Enabled = false; IAsyncResult <int> result = this.dialogService.ShowDialog("Dialog Service Example", "This is a dialog test.", "Yes", "No", null, true); result.Callbackable().OnCallback(r => { if (r.Result == AlertDialog.BUTTON_POSITIVE) { Debug.LogFormat("Click: Yes"); } else if (r.Result == AlertDialog.BUTTON_NEGATIVE) { Debug.LogFormat("Click: No"); } this.openAlertDialog.Enabled = true; }); }); this.openAlertDialog2 = new SimpleCommand(() => { this.openAlertDialog2.Enabled = false; AlertDialogViewModel viewModel = new AlertDialogViewModel(); viewModel.Title = "Dialog Service Example"; viewModel.Message = "This is a dialog test."; viewModel.ConfirmButtonText = "OK"; IAsyncResult <AlertDialogViewModel> result = this.dialogService.ShowDialog("UI/AlertDialog", viewModel); result.Callbackable().OnCallback(r => { AlertDialogViewModel vm = r.Result; if (vm.Result == AlertDialog.BUTTON_POSITIVE) { Debug.LogFormat("Click: OK"); } this.openAlertDialog2.Enabled = true; }); }); }
private void ShowAlert() { // Show the Alert dialg view to the user IAlertDialogView alertDialog = container.GetExportedValue <IAlertDialogView>(); List <IAlertItem> newAlertItem = this.dataService.AlertedItems.Where(c => !c.HasAlert).ToList();; if (this.alertDialogViewModel == null) { MultiThreadingObservableCollection <IAlertItem> items = new MultiThreadingObservableCollection <IAlertItem>(); this.alertDialogViewModel = new AlertDialogViewModel(alertDialog, items); } foreach (IAlertItem item in newAlertItem) { if (!this.alertDialogViewModel.Items.Contains(item)) { this.alertDialogViewModel.Items.Add(item); } } this.alertDialogViewModel.HasAlertSound = Settings.Default.HasAlertSound; this.alertDialogViewModel.ShowDialog(this.shellService.ShellView); }
public void Login() { if (Username.Equals("Username") || Password.Equals("Password")) { var warningDlg = new AlertDialogViewModel("WARNING", "YOU SHOULD INPUT USERNAME AND PASSWORD"); dialogService.OpenDialog(warningDlg); } else { XCAPI xcapi = new XCAPI(); string authResult = xcapi.Authenticate(Username, Password); if (authResult.Equals("Error")) { var warningDlg = new AlertDialogViewModel("WARNING", "APP OR SERVICE IS NOT WORKING WITH PROVIDER SERVICE, PLEASE CONTACT WITH PROVIDER"); dialogService.OpenDialog(warningDlg); } else if (authResult.Equals("Bad_Streaming_URL")) { var warning_dialog = new AlertDialogViewModel("Warning", "STREAMING URL OR YOUR IP IS NOT ALLOWED TO GET STREAMING, PLEASE USE VPN"); var result = dialogService.OpenDialog(warning_dialog); } else { JObject authUser = JObject.Parse(authResult); if ((int)authUser["user_info"]["auth"] == 0) { var warning_dialog = new AlertDialogViewModel("Warning", "INCORRECT USER NAME AND PASSWORD. PLEASE INPUT CORRECT ONE"); var result = dialogService.OpenDialog(warning_dialog); } else if ((int)long.Parse((string)authUser["user_info"]["active_cons"]) + 1 > (int)long.Parse((string)authUser["user_info"]["max_connections"])) { var warning_dialog = new AlertDialogViewModel("Warning", "YOU HAVE LIMITED CONNECTIONS, PLEASE EXTEND CONNECTION BY UPGRADING MEMBERSHIP"); var result = dialogService.OpenDialog(warning_dialog); } else if ((DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000) > (int)Int64.Parse((string)authUser["user_info"]["exp_date"]) || (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000) < (int)Int64.Parse((string)authUser["user_info"]["created_at"])) { var warning_dialog = new AlertDialogViewModel("Warning", "YOUR ACCOUNT IS EXPIRED ALREADY, PLEASE CONTACT TO PROVIDER"); var result = dialogService.OpenDialog(warning_dialog); } else if (!((string)authUser["user_info"]["status"]).Equals("Active")) { var warning_dialog = new AlertDialogViewModel("Warning", "YOUR ACCOUNT IS NOT ACTIVATED. PLEASE MAKE YOUR ACCOUNT ACTIVATE"); var result = dialogService.OpenDialog(warning_dialog); } else if (!((string)authUser["user_info"]["is_trial"]).Equals("0")) { var warning_dialog = new AlertDialogViewModel("Warning", "YOUR ACCOUNT IS NOT TRIAL NOW. PLEASE PURCHASE APP NOW"); var result = dialogService.OpenDialog(warning_dialog); } else { XCUser xcUser = new XCUser(); xcUser.username = (string)authUser["user_info"]["username"]; xcUser.password = (string)authUser["user_info"]["password"]; xcUser.auth = (int)authUser["user_info"]["auth"] > 0 ? true : false; xcUser.status = (string)authUser["user_info"]["status"]; xcUser.exp_date = (string)authUser["user_info"]["exp_date"]; xcUser.is_trial = (string)authUser["user_info"]["is_trial"]; xcUser.active_cons = (string)authUser["user_info"]["active_cons"]; xcUser.created_at = (string)authUser["user_info"]["created_at"]; xcUser.max_connections = (string)authUser["user_info"]["max_connections"]; xcUser.allowed_output_formats = authUser["user_info"]["allowed_output_formats"].ToObject <string[]>(); // Global.currentUser = xcUser; _eventAggregator.PublishOnUIThread(new AuthenticateSuccessMessage()); } } return; } }
/// <summary> /// Show alert message /// </summary> /// <param name="title">Display Title with character limit</param> /// <param name="msg">Display message with character limit</param> public void Alert(string title = null, string msg = null) { var viewModel = new AlertDialogViewModel(title.LimitLength(20), msg); ShowDialog(viewModel); }
/// <summary> /// A Custom Alert DialogBox that displays a Title and a single Message string /// </summary> /// <param name="title">Title</param> /// <param name="message">Message string</param> public static void Alert(string title, string message) { var dialog = new AlertDialogViewModel(title, message); var result = new DialogService().OpenDialog(dialog); }