private void GetRandomUsers(object obj)
        {
            Task.Run(async() => {
                this.LoadingMessageHUD = "Performing download...";
                this.IsLoadingHUD      = true;

                var result = await WebBll.GetRandomUsers();

                this.IsLoadingHUD = false;
                if (result.Error == null)
                {
                    RandomUsers = result.Response.ToObservable();
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() => {
                        DialogPrompt.ShowMessage(new Prompt()
                        {
                            Title   = "Error",
                            Message = result.Error.Message
                        });
                    });
                }
            });
        }
        public void GetPaginatedRandomUsers(object obj)
        {
            Task.Run(async() =>
            {
                this.LoadingMessageHUD = "Performing download...";
                this.IsLoadingHUD      = true;

                var result = await WebBll.GetPaginatedRandomUsers(pageIndex);
                pageIndex++;

                this.IsLoadingHUD = false;
                if (result.Error == null)
                {
                    using (var updated = PaginatedRandomUsers.BeginMassUpdate())
                    {
                        PaginatedRandomUsers.AddRange(result.Response);
                    }
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() => {
                        DialogPrompt.ShowMessage(new Prompt()
                        {
                            Title   = "Error",
                            Message = result.Error.Message
                        });
                    });
                }
            });
        }
Exemple #3
0
        private void LoadResources()
        {
            this.LoadingMessageHUD = "Loading...";
            this.IsLoadingHUD      = true;
            this.AppLogic.LoadRandomUsers().ContinueWith((result) => {
                this.IsLoadingHUD = false;
                var response      = result.Result;
                if (response.Error == null)
                {
                    Users = AppLogic.ObservableRandomUsers;

                    GenderChart = new DonutChart()
                    {
                        Entries = AppLogic.GetUsersByGender()
                    };
                    AgeChart = new BarChart()
                    {
                        Entries = AppLogic.GetUsersByAgeGroup()
                    };

                    Nationalities = AppLogic.GetUniqueNationalities().ToObservableCollection();
                }
                else
                {
                    DialogPrompt.ShowMessage(new Prompt()
                    {
                        Title   = "Error",
                        Message = response.Error.Message
                    });
                }
            });
        }
 private void HttpPostMethod(object obj)
 {
     Task.Run(async() => {
         var result = await WebBll.PostDataExample();
         if (result.Error == null)
         {
             var pp = result.Response;
             DialogPrompt.ShowMessage(new Prompt()
             {
                 Title   = "Success",
                 Message = $"The person's new id for {pp.FirstName} {pp.LastName}  is {pp.Id}"
             });
         }
         else
         {
             Device.BeginInvokeOnMainThread(() => {
                 DialogPrompt.ShowMessage(new Prompt()
                 {
                     Title   = "Error",
                     Message = result.Error.Message
                 });
             });
         }
     });
 }
Exemple #5
0
        public AppViewModel()
        {
            LoadAllPeople("AppViewModel", null).ContinueWith((t) => { });

            AddPerson = new CoreCommand(async(obj) =>
            {
                var result = await this.SqliteDb.AddOrUpdate <Person>(NewPerson);
                if (result.Success)
                {
                    NewPerson = new Person();
                    await LoadAllPeople("AddPerson", () =>
                    {
                        Navigation.PushNonAwaited <PageTwo>();
                    });
                }
                else
                {
                    DialogPrompt.ShowMessage(new Prompt()
                    {
                        Title   = "Error",
                        Message = result.Error.Message
                    });
                }
            });



            ViewPeople = new Command(async(obj) =>
            {
                await LoadAllPeople("ViewPeople", () => {
                    Navigation.PushNonAwaited <PageTwo>();
                });
            });
        }
        private async void ShowPrompt_ClosingWithGameStillOpened(Action successAction)
        {
            await Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(async() =>
            {
                var title = this.FindResource("Dialog_CloseGame_Title") as string;
                var content = this.FindResource("Dialog_CloseGame_Text") as string;

                var result = await DialogPrompt.ShowDialog_YesNoCancel(title, content);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    ConfigManager.GameManager.GameProcess.Kill();
                    AllowedToCloseWithGameOpen = true;
                    if (successAction != null)
                    {
                        successAction.Invoke();
                    }
                }
                else if (result == System.Windows.Forms.DialogResult.No)
                {
                    AllowedToCloseWithGameOpen = true;
                    if (successAction != null)
                    {
                        successAction.Invoke();
                    }
                }
                else if (result == System.Windows.Forms.DialogResult.Cancel)
                {
                    AllowedToCloseWithGameOpen = false;
                }
            }));
        }
        public AppViewModel()
        {
            LoadAllPeople("AppViewModel", null).ContinueWith((t) => { });

            AddPerson = new CoreCommand(async(obj) =>
            {
                var result = await this.LiteDb.Insert(NewPerson);
                if (result.Success)
                {
                    NewPerson = new Person();
                    await LoadAllPeople("AddPerson", async() =>
                    {
                        await Navigation.PushAsync(new PageTwo());
                    });
                }
                else
                {
                    DialogPrompt.ShowMessage(new Prompt()
                    {
                        Title   = "Error",
                        Message = result.Error.Message
                    });
                }
            });

            ViewPeople = new CoreCommand(async(obj) =>
            {
                await Navigation.PushAsync(new PageTwo());
            });
        }
        public override void OnViewMessageReceived(string key, object obj)
        {
            switch (key)
            {
            case CoreSettings.LoadResources:
                var result = DataBLL.GetCarouselData();
                if (result.Error == null)
                {
                    ItemSource = result.Response.ToObservable <CarouselBindingObject>();
                }

                CardCollection = DataBLL.GetCardViewList().ToObservable <CardViewContent>();
                break;

            case CoreSettings.ReleaseResources:
                break;

            case CoreSettings.PhoneCallBack:
                Device.BeginInvokeOnMainThread(() =>
                {
                    DialogPrompt.ShowMessage(new Prompt()
                    {
                        Title   = "Completed",
                        Message = "Phone call action has been complete and action logged"
                    });
                });
                break;
            }
        }
        private async void DeleteSkinPackButton_Click(object sender, RoutedEventArgs e)
        {
            MoreButton.ContextMenu.IsOpen = false;
            var skinPack = GetParent().LoadedSkinPacks.SelectedItem as MCSkinPack;

            if (skinPack == null)
            {
                return;
            }

            var title   = this.FindResource("Dialog_DeleteItem_Title") as string;
            var content = this.FindResource("Dialog_DeleteItem_Text") as string;
            var item    = this.FindResource("Dialog_Item_SkinPack_Text") as string;

            var result = await DialogPrompt.ShowDialog_YesNo(title, content, item, skinPack.DisplayName);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    Directory.Delete(skinPack.Directory, true);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }
                GetParent().ReloadSkinPacks();
            }
        }
 private void DialogClickMethod(object obj)
 {
     DialogPrompt.ShowMessage(new Prompt()
     {
         Title   = "Test",
         Message = "This is just a message"
     });
 }
 private void FABClickedMethod(object obj)
 {
     DialogPrompt.ShowMessage(new Prompt()
     {
         Title   = "FAB Button",
         Message = "The button was clicked"
     });
 }
        private void MakeCallMethod(object obj)
        {
            Task.Run(async() =>
            {
                try
                {
                    var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Phone);
                    if (status != PermissionStatus.Granted)
                    {
                        if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Phone))
                        {
                            DialogPrompt.ShowMessage(new Prompt()
                            {
                                Title   = "Permission",
                                Message = "The application needs access to the phone."
                            });
                        }

                        var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Phone });
                        status      = results[Permission.Location];
                    }

                    if (status == PermissionStatus.Granted)
                    {
                        Communication.PlaceCall(CommunicationNumber.ToString());
                    }
                    else if (status != PermissionStatus.Unknown)
                    {
                        Device.BeginInvokeOnMainThread(() => {
                            DialogPrompt.ShowMessage(new Prompt()
                            {
                                Title   = "Issue",
                                Message = "There was a problem accessing the phone."
                            });
                        });
                    }
                }
                catch (Exception)
                {
                    Device.BeginInvokeOnMainThread(() => {
                        DialogPrompt.ShowMessage(new Prompt()
                        {
                            Title   = "Error",
                            Message = "The application experience an error accessing the phone."
                        });
                    });
                }
            });
        }
        private async void DeleteInstallationButton_Click(object sender, RoutedEventArgs e)
        {
            var title   = this.FindResource("Dialog_DeleteItem_Title") as string;
            var content = this.FindResource("Dialog_DeleteItem_Text") as string;
            var item    = this.FindResource("Dialog_Item_Installation_Text") as string;

            MenuItem button       = sender as MenuItem;
            var      installation = button.DataContext as BLInstallation;
            var      result       = await DialogPrompt.ShowDialog_YesNo(title, content, item, installation.DisplayName_Full);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                LauncherModel.Default.Config.Installation_Delete(installation);
            }
        }
        public async void InvokeKillGame()
        {
            if (ConfigManager.GameManager.GameProcess != null)
            {
                var title   = Application.Current.FindResource("Dialog_KillGame_Title") as string;
                var content = Application.Current.FindResource("Dialog_KillGame_Text") as string;

                var result = await DialogPrompt.ShowDialog_YesNo(title, content);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    GameProcess.Kill();
                }
            }
        }
Exemple #15
0
        private async void RemoveProfileButton_Click(object sender, RoutedEventArgs e)
        {
            var profile = Properties.LauncherSettings.Default.CurrentProfile;

            var title   = this.FindResource("Dialog_DeleteItem_Title") as string;
            var content = this.FindResource("Dialog_DeleteItem_Text") as string;
            var item    = this.FindResource("Dialog_Item_Profile_Text") as string;

            var result = await DialogPrompt.ShowDialog_YesNo(title, content, item, profile);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                ConfigManager.RemoveProfile(profile);
            }
        }
        private async void DeleteInstallationButton_Click(object sender, RoutedEventArgs e)
        {
            var title   = this.FindResource("Dialog_DeleteItem_Title") as string;
            var content = this.FindResource("Dialog_DeleteItem_Text") as string;
            var item    = this.FindResource("Dialog_Item_Installation_Text") as string;

            MenuItem button       = sender as MenuItem;
            var      installation = button.DataContext as Classes.MCInstallation;
            var      result       = await DialogPrompt.ShowDialog_YesNo(title, content, item, installation.DisplayName);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                ConfigManager.DeleteInstallation(installation);
                ConfigManager.MainThread.RefreshInstallationList();
            }
        }
        private void BlurNewMethod(object obj)
        {
            BlurOverlay.Show();

            Device.BeginInvokeOnMainThread(() =>
            {
                DialogPrompt.ShowMessage(new Prompt()
                {
                    Title    = "Blurred Background",
                    Message  = "Click okay to close",
                    Callback = (result) =>
                    {
                        BlurOverlay.Hide();
                    }
                });
            });
        }
Exemple #18
0
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            MenuItem button = sender as MenuItem;
            var      mod    = button.DataContext as Classes.DungeonsMod;

            var title   = this.FindResource("Dialog_DeleteItem_Title") as string;
            var content = this.FindResource("Dialog_DeleteItem_Text") as string;
            var item    = "mod";

            var result = await DialogPrompt.ShowDialog_YesNo(title, content, item, mod.Name);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                mod.Delete();
                RefreshModsList();
            }
        }
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            Button button  = sender as Button;
            var    version = button.DataContext as Classes.MCVersion;

            var title   = this.FindResource("Dialog_DeleteItem_Title") as string;
            var content = this.FindResource("Dialog_DeleteItem_Text") as string;
            var item    = this.FindResource("Dialog_Item_Version_Text") as string;

            var result = await DialogPrompt.ShowDialog_YesNo(title, content, item, version.DisplayName);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                ConfigManager.GameManager.Remove(version);
                GetParent().RefreshVersionsList();
            }
        }
        public async Task AddToFavorites(RandomUser user)
        {
            var result = await this.SqliteDb.AddOrUpdate <RandomUser>(user);

            result.Error?.LogException();
            if (!result.Success)
            {
                DialogPrompt.ShowMessage(new Prompt()
                {
                    Title   = "Error",
                    Message = result.Error.Message
                });
            }
            else
            {
                Favorites.Add(user);
            }
        }
 private void BindingTextChangedMethod(object obj)
 {
     if (!string.IsNullOrEmpty(BindingTextValue) && BindingTextValue.Length > 2)
     {
         int num;
         var valid = int.TryParse(BindingTextValue, out num);
         if (!valid)
         {
             Device.BeginInvokeOnMainThread(() => {
                 DialogPrompt.ShowMessage(new Prompt()
                 {
                     Title   = "Error",
                     Message = "Can't you even follow directions?"
                 });
             });
         }
     }
 }
Exemple #22
0
        private async Task LoadAllPeople(string caller, Action callBack)
        {
            var allResult = await SqliteDb.GetAll <Person>();

            if (allResult.Error == null)
            {
                People = allResult.Response.ToObservable <Person>();
                callBack?.Invoke();
            }
            else
            {
                DialogPrompt.ShowMessage(new Prompt()
                {
                    Title   = "Error",
                    Message = allResult.Error.Message
                });
            }
        }
        public async Task RemoveFavorites(RandomUser user)
        {
            var result = await this.SqliteDb.DeleteByCorrelationID <RandomUser>(user.CorrelationID);

            result.Error?.LogException();
            if (!result.Success)
            {
                DialogPrompt.ShowMessage(new Prompt()
                {
                    Title   = "Error",
                    Message = result.Error.Message
                });
            }
            else
            {
                Favorites.Remove(user);
            }
        }
 private void EncryptTextMethod(object obj)
 {
     if (string.IsNullOrEmpty(EncryptedText))
     {
         if (!string.IsNullOrEmpty(ClearText))
         {
             var result = CryptoBLL.EncryptText(ClearText);
             if (result.Error == null)
             {
                 EncryptedText = result.Response;
                 ClearText     = string.Empty;
             }
             else
             {
                 Device.BeginInvokeOnMainThread(() => {
                     DialogPrompt.ShowMessage(new Prompt()
                     {
                         Title   = "Error",
                         Message = result.Error.Message
                     });
                 });
             }
         }
     }
     else
     {
         var result = CryptoBLL.DecryptText(EncryptedText);
         if (result.Error == null)
         {
             ClearText     = result.Response;
             EncryptedText = string.Empty;
         }
         else
         {
             Device.BeginInvokeOnMainThread(() => {
                 DialogPrompt.ShowMessage(new Prompt()
                 {
                     Title   = "Error",
                     Message = result.Error.Message
                 });
             });
         }
     }
 }
        private async Task SaveToPhone()
        {
            if (SelectedDeviceCalendar != null)
            {
                var evt = Appt.ToCalendarEvent();
                evt.DeviceCalendar = SelectedDeviceCalendar;
                var response = await CalendarEvent.CreateCalendarEvent(evt);

                if (response.result)
                {
                    try
                    {
                        var id = response.model.Id;
                        var c  = await CalendarEvent.GetCalendarEvent(id);

                        c.StartTime       = c.StartTime.AddHours(2);
                        c.EndTime         = c.EndTime.AddHours(2);
                        c.ReminderMinutes = 90;
                        c.Description     = "hello kitty";
                        var updateResponse = await CalendarEvent.UpdateCalendarEvent(c);

                        if (updateResponse.result)
                        {
                            var x = "success update";
                        }
                    }
                    catch (Exception ex)
                    {
                        var excep = ex;
                    }

                    Appt = new Appointment();
                }
                else
                {
                    DialogPrompt.ShowMessage(new Prompt()
                    {
                        Title   = "Calendar Event Failed",
                        Message = "There was an issues saving the calendar event"
                    });
                }
            }
        }
Exemple #26
0
 public override void OnInit()
 {
     Task.Run(async() =>
     {
         var results = await SqliteDb.GetAll <Person>();
         if (results.Success)
         {
             People = results.Response.ToObservable();
         }
         else
         {
             DialogPrompt.ShowMessage(new Prompt()
             {
                 Title        = "Error",
                 Message      = results.Error.Message,
                 ButtonTitles = new string[] { "Okay" }
             });
         }
     });
 }
Exemple #27
0
 public override void OnInit()
 {
     Device.BeginInvokeOnMainThread(async() => {
         LoadingMessageHUD = "Loading...";
         IsLoadingHUD      = true;
         var results       = await this.SomeLogic.GetRandomUsers();
         IsLoadingHUD      = false;
         if (results.ex == null)
         {
             Users = results.users.ToObservable();
         }
         else
         {
             DialogPrompt.ShowMessage(new Prompt()
             {
                 Title   = "Error",
                 Message = results.ex.Message
             });
         }
     });
 }
        private async void DeleteSkinButton_Click(object sender, RoutedEventArgs e)
        {
            var skinPack = GetParent().LoadedSkinPacks.SelectedItem as MCSkinPack;
            var skin     = GetParent().SkinPreviewList.SelectedItem as MCSkin;
            int index    = GetParent().SkinPreviewList.SelectedIndex;

            if (skin != null && skinPack != null)
            {
                var title   = this.FindResource("Dialog_DeleteItem_Title") as string;
                var content = this.FindResource("Dialog_DeleteItem_Text") as string;
                var item    = this.FindResource("Dialog_Item_Skin_Text") as string;

                var result = await DialogPrompt.ShowDialog_YesNo(title, content, item, skinPack.GetLocalizedSkinName(skin.localization_name));

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    skinPack.RemoveSkin(index);
                    GetParent().ReloadSkinPacks();
                }
            }
        }
 public override void OnViewMessageReceived(string key, object obj)
 {
     if (key == CoreSettings.DeletePersonTag && obj != null)
     {
         var pk = (string)obj;
         this.LiteDb.Delete <Person>(pk).ContinueWith(async(t) =>
         {
             if (t.Result.Success)
             {
                 await LoadAllPeople("OnViewMessageReceived", null);
             }
             else
             {
                 DialogPrompt.ShowMessage(new Prompt()
                 {
                     Title   = "Error",
                     Message = t.Result.Error.Message
                 });
             }
         });
     }
 }
        public void GetDbAppointments(object obj)
        {
            Task.Run(async() => {
                this.LoadingMessageHUD = "Sqlite loading...";
                this.IsLoadingHUD      = true;

                var result        = await DataBLL.GetAllAppointments();
                this.IsLoadingHUD = false;
                if (result.Error == null)
                {
                    Appointments = result.Response.ToObservable();
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() => {
                        DialogPrompt.ShowMessage(new Prompt()
                        {
                            Title   = "Error",
                            Message = result.Error.Message
                        });
                    });
                }
            });
        }