private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e) { try { if (e.SelectedItem == null) { return; } var item = (MasterPageItem)e.SelectedItem; if (item.id == 5) { Navigation.PushAsync(new KnowCmPage()); } else { Detail = new MainTabPage(item.id); } IsPresented = false; navigationDrawerList.SelectedItem = null; }catch (Exception ex) { XFToast.ShortMessage(ex.Message); } }
private async void DataGet() { if (string.IsNullOrWhiteSpace(Barrel.Current.Get(Url)) && !CrossConnectivity.Current.IsConnected) { XFToast.ShortMessage("No Previous data or Internet"); searbar.IsVisible = false; } else { try { searbar.IsVisible = true; newlist = await MoneyCache.GetAsync <List <NepNews> >(Url); foreach (NepNews n in newlist) { n.desc = Constants.ScrubHtml(n.description); n.desc = new String(n.desc.Take(200).ToArray()) + "..."; } NewsCollection = new ObservableCollection <NepNews>(newlist); listView.ItemsSource = NewsCollection; listView.Opacity = 0; await listView.FadeTo(1, 1000, Easing.SpringIn); }catch (Exception ex) { } } listView.EndRefresh(); }
private async void Btnstart_Clicked(object sender, EventArgs e) { if (subjectPick.SelectedIndex != -1) { if (coursePick.SelectedIndex != -1) { await Navigation.PushAsync(new StartQuizPage(courseId)); } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please select any course", "Ok"); } else { XFToast.ShortMessage("Please select any course"); } } } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please select any subject", "Ok"); } else { XFToast.ShortMessage("Please select any subject"); } } SetBusyIndicator(false); }
public async Task <bool> CheckName(string name, bool flag) { if (!string.IsNullOrEmpty(name)) { return(true); } else { if (flag) { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please enter the Name", "Ok"); } else { XFToast.ShortMessage("Please enter the Name"); } } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please enter the User Name", "Ok"); } else { XFToast.ShortMessage("Please enter the User Name"); } } return(false); } }
private async void ShowExitDialog() { XFToast.LongMessage("Press back again to exit"); await Task.Delay(1000); _canClose = false; }
public async void BtnDangSimClicked(object sender, EventArgs e) { var confirm = await DisplayAlert("Xác nhận", "Bạn có muốn bán tất cả sim vừa import không", "Đồng ý", "Đóng"); if (!confirm) { return; } gridLoading.IsVisible = true; ApiResponse response = await ApiHelper.Put("api/sim/postsimlist", _simList.Select(x => x.Id).ToArray()); if (response.IsSuccess) { await Navigation.PopAsync(false); MySimListViewModel mySimListViewModel = Shell.Current.BindingContext as MySimListViewModel; mySimListViewModel.RefreshCommand.Execute(null); XFToast.ShortMessage("Đăng sim thành công"); } else { await DisplayAlert("", response.Message, "Đóng"); } gridLoading.IsVisible = false; }
private async void BtnLogin_Clicked(object sender, EventArgs e) { SetBusyIndicator(true); userinfo = new UserInfo { UserName = entUserName.Text, Password = entPassword.Text }; if (await LoginValidation(entUserName.Text, entPassword.Text)) { // PostLogin(url,userinfo); UserInfo data = await c.SaveUser(userinfo, url); if (!data.Equals(null)) { if (data.Messages.Equals("Successful")) { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Login Successful", "Ok"); } else { XFToast.ShortMessage("Login Successful"); } App.Current.MainPage = new NavigationPage(new MasterPage()); SetBusyIndicator(false); } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Invalid Credentia", "Ok"); } else { XFToast.ShortMessage("Invalid Credential"); } SetBusyIndicator(false); } } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Invalid Credentia", "Ok"); } else { XFToast.ShortMessage("Invalid Credential"); } SetBusyIndicator(false); } } SetBusyIndicator(false); // Loading.IsVisible = true; }
private async void DataGet() { if (string.IsNullOrWhiteSpace(Barrel.Current.Get(Url)) && !CrossConnectivity.Current.IsConnected) { XFToast.ShortMessage("No Previous data or Internet"); } else { try { messagelist = await MoneyCache.GetAsync <List <Notifications> >(Url); foreach (Notifications n in messagelist) { n.temp = DateTime.Parse(n.start_date); } NewsCollection = new ObservableCollection <Notifications>(messagelist); timelineListView.ItemsSource = NewsCollection; timelineListView.Opacity = 0; await timelineListView.FadeTo(1, 1000, Easing.SpringIn); }catch (Exception ex) { } } timelineListView.EndRefresh(); }
private async void DataGet() { if (string.IsNullOrWhiteSpace(Barrel.Current.Get(Url)) && !CrossConnectivity.Current.IsConnected) { XFToast.ShortMessage("No Previous data or Internet"); searbar.IsVisible = false; } else { try { searbar.IsVisible = true; videolist = await MoneyCache.GetAsync2 <List <Video> >(Url); foreach (Video n in videolist) { n.link = Constants.ScrubHtml2(n.link); } NewsCollection = new ObservableCollection <Video>(videolist); listView.ItemsSource = NewsCollection; listView.Opacity = 0; await listView.FadeTo(1, 1000, Easing.SpringIn); } catch (Exception ex) { } } listView.EndRefresh(); }
public async Task <bool> CheckPhoneNo(string phoneNo) { if (!string.IsNullOrEmpty(phoneNo)) { if (phoneNo.Length == 10) { return(true); } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please enter proper mobile No", "Ok"); } else { XFToast.ShortMessage("Please enter proper mobile No"); } return(false); } } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please enter the Mobile No.", "Ok"); } else { XFToast.ShortMessage("Please enter the Mobile No."); } return(false); } }
async void UpBlue_Tapped(object sender, System.EventArgs e) { //show answer. PageDown.IsVisible = false; await PageDown.TranslateTo(0, 0, 500, Easing.SinIn); var a = answerList.Where(item => item.IsSelected == item.IsCorrect).Select(wrappedItem => new { wrappedItem.Answer, wrappedItem.IsCorrect, wrappedItem.IsSelected }).ToList(); var b = answerList.Where(item => item.IsSelected == true).Select(wrappedItem => new { wrappedItem.Answer, wrappedItem.IsCorrect, wrappedItem.IsSelected }).ToList(); if (b.Count != 0) { if (a.Count == answerList.Count) { rightAns.IsVisible = true; wrongAns.IsVisible = false; PageDown.IsVisible = true; stackMain.IsEnabled = false; txtrightAns.Text = "Congrats Your Answer Is Right"; } else { var correctAns = answerList.Where(item => item.IsCorrect == true).Select(wrappedItem => wrappedItem.Answer).ToList(); string answer = ""; for (int x = 0; x < correctAns.Count(); x++) { answer = answer + correctAns[x] + ", "; } rightAns.IsVisible = false; wrongAns.IsVisible = true; PageDown.IsVisible = true; stackMain.IsEnabled = false; txtwrongAns.Text = "Your Right Answer Is :" + answer; } } else { PageDown.IsVisible = false; if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Select any answer", "Ok"); } else { XFToast.ShortMessage("Select any answer"); } } }
public async void DownloadGoogleSheetTemplate_Clicked(object sender, EventArgs a) { gridLoading.IsVisible = true; try { PermissionStatus storagePermission = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); if (storagePermission != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage)) { await DisplayAlert("Quyền truy cập", "Sim Here cần quyền truy cập vào bộ nhớ để lưu template", "Đồng ý"); } if (Device.RuntimePlatform == Device.iOS) { storagePermission = await PermissionHelper.CheckPermissions(Permission.Storage, "Quyền truy cập bộ nhớ", "Sim Here cần quyền truy cập vào bộ nhớ để lưu template"); } else { var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage); storagePermission = results[Permission.Storage]; } } if (storagePermission == PermissionStatus.Granted) { HttpClient client = BsdHttpClient.Instance(); HttpResponseMessage response = await client.GetAsync(Configuration.AppConfig.API_IP + "import_template.xlsx", HttpCompletionOption.ResponseHeadersRead); var streamToReadFrom = await response.Content.ReadAsByteArrayAsync(); var service = DependencyService.Get <IFileService>(); string folderName = Device.RuntimePlatform == Device.iOS ? "" : "Download/SimHere"; service.SaveFile("import_template.xlsx", streamToReadFrom, folderName); if (Device.RuntimePlatform == Device.iOS) { service.OpenFile("import_template.xlsx", folderName); } else { XFToast.ShortMessage("Tải template thành công"); } } } catch { await DisplayAlert("", "Tải thất bại", "Đóng"); } gridLoading.IsVisible = false; }
public async void ImportFile(object sender, ItemTappedEventArgs e) { gridLoading.IsVisible = true; var file = e.Item as GoogleSheetFileListResponse; var response = await ApiHelper.Post($"api/googlesheet/import/{file.id}?access_token={viewModel.Access_Token}", null, true); if (response.IsSuccess) { modalDriveFiles.IsVisible = false; XFToast.ShortMessage("Import thành công"); } else { await DisplayAlert("", response.Message, "Đóng"); } gridLoading.IsVisible = false; }
private async void BtnCancleClicked(object sender, EventArgs e) { gridLoading.IsVisible = true; await ApiHelper.Put("api/sim/status", new AddUpdateSimViewModel() { Sim = new Sim() { Status = 0, Id = SimId } }, true); await Shell.Current.Navigation.PopAsync(); await Shell.Current.Navigation.PushAsync(new PostSim(SimId), false); XFToast.ShortMessage("Huỷ thành công !"); }
public static async Task <T> GetAsync <T>(string url, int days = 100, bool forceRefresh = false) { var json = string.Empty; HttpClient client = new HttpClient(); try { //check if we are connected, else check to see if we have valid data if (CrossConnectivity.Current.IsConnected) { json = await client.GetStringAsync(url); if (string.IsNullOrWhiteSpace(json)) { json = Barrel.Current.Get(url); } if (!string.IsNullOrWhiteSpace(json)) { json = Constants.ScrubHtml3(json); Barrel.Current.Add(url, json, TimeSpan.FromDays(days)); } } else if (!forceRefresh && !Barrel.Current.IsExpired(url)) { json = Barrel.Current.Get(url); } return(await Task.Run(() => JsonConvert.DeserializeObject <T>(json))); } catch (Exception ex) { XFToast.ShortMessage("Couldn't retrieve data"); json = Barrel.Current.Get(url); if (!string.IsNullOrWhiteSpace(json)) { return(await Task.Run(() => JsonConvert.DeserializeObject <T>(json))); } else { return(default(T)); } } }
async void LoadSchedule(object sender, EventArgs e) { if ((Xamarin.Forms.Application.Current.Properties["Class"].ToString() != (Classes.SelectedIndex + 1).ToString()) && (Xamarin.Forms.Application.Current.Properties["ClassNumber"].ToString() != (Classes.SelectedIndex + 1).ToString())) { try { string ClassNumber = (Classes.SelectedIndex + 1).ToString(); string url = "http://www.zse.srem.pl/index.php?opcja=modules/plan_lekcji/pokaz_plan"; HtmlWeb web = new HtmlWeb(); HtmlDocument version = await Task.Run(() => web.Load(url)); var versionNode = version.DocumentNode.SelectSingleNode("//div[@class='col-md-12']/a"); url = versionNode.GetAttributeValue("href", "http://www.zse.srem.pl/plan_lekcji/b/index.html"); string[] url_pieces = url.Substring(7).Split('/'); string ScheduleLetter = url_pieces[2]; App.Current.Properties["ScheduleLetter"] = ScheduleLetter; await App.Current.SavePropertiesAsync(); url = url.Replace("index", "plany/o" + ClassNumber); HtmlDocument htmldoc = await Task.Run(() => web.Load(url)); htmldoc.DocumentNode.InnerHtml = htmldoc.DocumentNode.SelectSingleNode("//table[@class='tabela']").InnerHtml; htmldoc.Save(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/plan.html"); Xamarin.Forms.Application.Current.Properties["Class"] = Classes.Items[Classes.SelectedIndex].ToLower(); Xamarin.Forms.Application.Current.Properties["ClassNumber"] = Classes.SelectedIndex + 1; Xamarin.Forms.Application.Current.Properties["changed"] = true; await App.Current.SavePropertiesAsync(); XFToast.ShortMessage("Pomyślnie zapisano!"); } catch (Exception ex) { XFToast.ShortMessage("Błąd podczas zapisywania."); Debug.WriteLine(ex); } } if (int.Parse(Xamarin.Forms.Application.Current.Properties["startscreen"].ToString()) != default_option.SelectedIndex) { Xamarin.Forms.Application.Current.Properties["startscreen"] = default_option.SelectedIndex; await App.Current.SavePropertiesAsync(); XFToast.ShortMessage("Pomyślnie zapisano!"); } }
private async void btnDiffLevel_Clicked(object sender, EventArgs e) { var action = await DisplayActionSheet("Choose Difficulty level", "Cancel", null, GetButtons(3)); if (action == null || action == "Cancel") { return; } var newDifficulyLevel = (DifficultyLevel)Enum.Parse(typeof(DifficultyLevel), action.Replace("» ", "").Trim()); if (newDifficulyLevel == level) { return; } ClasicGameSetting.DifficultyLevel = newDifficulyLevel; new ClassicGameRunner().Start(); btnDiffLevel.Text = action; XFToast.LongMessage($"Difficulty level is set to {action}"); }
private async void listView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } var dataCard = e.SelectedItem as News; if (CrossConnectivity.Current.IsConnected) { await Navigation.PushAsync(new NewsDetailPage(dataCard), true); } else { XFToast.ShortMessage("No Internet Connection"); } listView.SelectedItem = null; }
private async void btnPlayerMode_Clicked(object sender, EventArgs e) { var action = await DisplayActionSheet("Choose Player mode", "Cancel", null, GetButtons(1)); if (action == null || action == "Cancel") { return; } action = action.Replace("» ", "").Trim(); bool is2Players = (action == "2 Players"); if (is2Players == ClasicGameSetting.Is2Players) { return; } ClasicGameSetting.Is2Players = is2Players; new ClassicGameRunner().Start(); XFToast.LongMessage($"Game is set to {action} mode"); }
public async Task <bool> LoginValidation(string username, string password) { if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { return(true); } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please enter the UserName and Password", "Ok"); } else { XFToast.ShortMessage("Please enter the UserName and Password "); } return(false); } }
public async void GetDataCourse() { SetBusyIndicator(true); CourseList = new List <CourseInfo>(); CourseList.Clear(); coursePick.Items.Clear(); string url = "http://13.126.189.26:10008/api/Get_CourseList/" + subjectId; JObject data = c.GetDetail(url); IList <JToken> results = data["list"].Children().ToList(); if (results.Count != 0) { foreach (JToken result in results) { System.Diagnostics.Debug.WriteLine(result); //just to check my json data. CourseInfo searchResult = JsonConvert.DeserializeObject <CourseInfo>(result.ToString()); //get exception on this line. coursePick.Items.Add(searchResult.CourseName); coursePick.IsEnabled = true; CourseList.Add(searchResult); } } else { if (Device.OS == TargetPlatform.iOS) { coursePick.IsEnabled = false; await DisplayAlert("Message", "No Courses in this subject", "Ok"); } else { coursePick.IsEnabled = false; XFToast.ShortMessage("No Courses in this subject"); } //coursePick.Items.Add("No Courses in this subject ):"); //coursePick.SelectedIndex = -1; } SetBusyIndicator(false); }
private async void btnFirstMove_Clicked(object sender, EventArgs e) { var action = await DisplayActionSheet("Choose who should move first", "Cancel", null, GetButtons(4)); if (action == null || action == "Cancel") { return; } action = action.Replace("» ", "").Trim(); bool newFirstMove = (action == "CPU"); if (newFirstMove == moveFirst) { return; } ClasicGameSetting.FirstMove = newFirstMove; new ClassicGameRunner().Start(); btnFirstMove.Text = action; XFToast.LongMessage($"First move is set to {action}"); }
public BioPage() { InitializeComponent(); view.Opacity = 0; if (string.IsNullOrWhiteSpace(Barrel.Current.Get(Url)) && !CrossConnectivity.Current.IsConnected) { XFToast.ShortMessage("No Previous data or Internet"); } else { DataGet(); } CrossConnectivity.Current.ConnectivityChanged += async(sender, args) => { if (args.IsConnected) { DataGet(); } }; }
public async Task <bool> CheckEmailId(string emailId) { if (!string.IsNullOrEmpty(emailId)) { Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(emailId); if (match.Success) { return(true); } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please enter proper EmailId", "Ok"); } else { XFToast.ShortMessage("Please enter proper EmailId"); } return(false); } } else { if (Device.OS == TargetPlatform.iOS) { await DisplayAlert("Message", "Please enter the EmailId", "Ok"); } else { XFToast.ShortMessage("Please enter the EmailId"); } return(false); } }
public async void BtnDeleteSimClicked(object sender, EventArgs e) { var confirm = await DisplayAlert("Xác nhận", "Bạn có muốn xóa sim đã import không", "Đồng ý", "Đóng"); if (!confirm) { return; } gridLoading.IsVisible = true; ApiResponse response = await ApiHelper.Delete("api/sim?Ids=" + string.Join(",", _simList.Select(x => x.Id).ToArray())); if (response.IsSuccess) { await Navigation.PopAsync(false); XFToast.ShortMessage("Xoá sim thành công"); } else { await DisplayAlert("", response.Message, "Đóng"); } gridLoading.IsVisible = false; }