protected override void OnApplyTemplate() { base.OnApplyTemplate(); // Handle back button if (GetTemplateChild("PageBackButton") is View backButton) { BackButton = backButton; TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += BackButton_Tapped; BackButton.GestureRecognizers.Add(tapGestureRecognizer); BackButton.IsVisible = !ShowMinimumContents; } // Handle page header visibility if (GetTemplateChild("PageTitle") is StackLayout pageTitleLayout) { pageTitleLayout.IsVisible = !ShowMinimumContents; } // Handle title extra button if (GetTemplateChild("PageTitleExtraButton") is Label titleExtraButton) { TitleExtraButton = titleExtraButton; TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += TitleExtraButton_Tapped; TitleExtraButton.GestureRecognizers.Add(tapGestureRecognizer); } // Handle top margin if (ShowTopMargin) { if (GetTemplateChild("PageRoot") is StackLayout pageRoot) { pageRoot.Margin = new Thickness(0, TopMargin + DemoUtilities.Instance.SafeAreaTop, 0, 0); if (CornersRadius > 0) { RoundCornersEffect.SetCornerRadius(pageRoot, CornersRadius); } } if (GetTemplateChild("TopPadding") is BoxView topPadding) { topPadding.HeightRequest = 0; } } if (GetTemplateChild("PageFooter") is SvgImage pageFooter) { pageFooter.HorizontalOptions = new LayoutOptions(FooterLogoHorizontalOptions, false); pageFooter.IsVisible = !ShowMinimumContents; } // Handle Ads visibility if (GetTemplateChild("Ads") is AdsView ads) { ads.IsVisible = !ShowMinimumContents; } }
void refrsh(int ty) { stk.Children.Clear(); DataRow[] fr; if (ty >= 0) { fr = dt_Question.Select("q_type=" + ty); } else { fr = dt_Question.Select(); } string typ = ""; for (int i = 0; i < fr.Length; i++) { //Frame frm1 = new Frame //{ // Margin = new Thickness(10, 5, 10, 5), // Padding = 0, // CornerRadius =7, // HasShadow = true, // Visual = VisualMarker.Default , // HeightRequest = 160, // HorizontalOptions = LayoutOptions.FillAndExpand, // BackgroundColor = Color.White, // BorderColor = Color.FromHex("#D6D6D6"), //}; StackLayout frm1 = new StackLayout { Margin = new Thickness(10, 5, 10, 5), HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.White, }; RoundCornersEffect.SetCornerRadius(frm1, 7); StackLayout stk1 = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var c1 = new Parm { Q_id = Convert.ToInt32(fr[i]["q_id"]), Ctk = stk1 }; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, new Binding("stackClick", 0)); tapGestureRecognizer.BindingContext = this; tapGestureRecognizer.CommandParameter = c1; stk1.GestureRecognizers.Add(tapGestureRecognizer); //DEscription Label lb2 = new Label { Margin = 5, Text = fr[i]["q_text"].ToString(), TextColor = Color.FromHex("#393939"), FontSize = 16, VerticalOptions = LayoutOptions.CenterAndExpand, }; //Footer Grid grd1 = new Grid { ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA") }; grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); StackLayout st1 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; typ = ExamType.Items[Convert.ToInt32(fr[i]["q_type"].ToString())]; Label lbb1_g1 = new Label { Text = typ, TextColor = Color.FromHex("#393939"), FontSize = 16, HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g1 = new Label { Text = "Type", TextColor = Color.FromHex("#AAAAAA"), FontSize = 13, HorizontalOptions = LayoutOptions.CenterAndExpand, }; st1.Children.Add(lbb1_g1); st1.Children.Add(lbb2_g1); StackLayout stk_g1 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g1.Children.Add(st1); BoxView bx = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g1.Children.Add(bx); StackLayout st2 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lbb1_g2 = new Label { Text = fr[i]["q_mark"].ToString(), TextColor = Color.FromHex("#393939"), FontSize = 16, HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g2 = new Label { Text = "Mark", TextColor = Color.FromHex("#AAAAAA"), FontSize = 13, HorizontalOptions = LayoutOptions.CenterAndExpand, }; st2.Children.Add(lbb1_g2); st2.Children.Add(lbb2_g2); StackLayout stk_g2 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g2.Children.Add(st2); BoxView bx2 = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g2.Children.Add(bx2); Label lbb1_g3 = new Label { Text = fr[i]["q_name"].ToString(), TextColor = Color.FromHex("#1941A2"), FontSize = 16, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, }; StackLayout stk_g3 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g3.Children.Add(lbb1_g3); grd1.Children.Add(stk_g1, 0, 0); grd1.Children.Add(stk_g2, 1, 0); grd1.Children.Add(stk_g3, 2, 0); stk1.Children.Add(lb2); stk1.Children.Add(grd1); frm1.Children.Add(stk1); stk.Children.Add(frm1); } if (fr.Length == 0) { AnimationView nose = new AnimationView { Animation = "examjson2.json", AutoPlay = true, IsVisible = true, Loop = true, WidthRequest = 300, HeightRequest = 300, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; stk.Children.Add(nose); } }
public PreviewBusinessCardPage(ContactModel contactItem, int indexInCollection) { InitializeComponent(); #if __IOS__ HasSystemPadding = false; #endif BindingContext = this; ContactItem = contactItem; _contactIndex = indexInCollection; if (profileImageView == null) { Grid grid = (Grid)carouselView.ItemsSource.GetItem(0); baseFrontImageView = grid.Children[0] as Image; grid = (Grid)grid.Children.Where((a) => a is Grid).GetItem(0); profileImageView = (SvgImage)grid.Children[0]; } RoundCornersEffect.SetCornerRadius(profileImageView, (int)(profileImageView.HeightRequest / 2)); Grid frontImageGrid = (carouselView.ItemsSource.GetItem(1) as Grid); frontImageView = frontImageGrid.Children[0] as Image; backImageContainer = (carouselView.ItemsSource.GetItem(2) as Grid); Grid backImageViewGrid = backImageContainer.Children[0] as Grid; backImageView = backImageViewGrid.Children[0] as Image; addBackImageContainer = backImageContainer.Children[1] as Grid; frontImageView.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { HideQuickActionControls(); ImageViewerPage imageViewerPage = new ImageViewerPage(ContactItem, ContactItem.Picture, ImageType.FrontImage); imageViewerPage.ImageModified += ImageViewerPage_ImageModified; await PopupNavigation.Instance.PushAsync(imageViewerPage); }) }); backImageView.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { HideQuickActionControls(); ImageViewerPage imageViewerPage = new ImageViewerPage(ContactItem, ContactItem.BackImage, ImageType.BackImage); imageViewerPage.ImageModified += ImageViewerPage_ImageModified; await PopupNavigation.Instance.PushAsync(imageViewerPage); }) }); profileImageView.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { if (String.IsNullOrEmpty(ContactItem.ProfileImage)) { var results = await DependencyService.Get <IPermissions>().VerifyPermissionsAsync(false, PermissionType.Camera); if (results == null || results[PermissionType.Camera] != PermissionStatus.Granted) { return; } CameraPage cameraPage = new CameraPage(CameraOperationType.Profile); cameraPage.PictureTaken += this.CameraPictureTaken; HomePage.Instance.PushCameraPage(cameraPage); } else { HideQuickActionControls(); ImageViewerPage imageViewerPage = new ImageViewerPage(ContactItem, ContactItem.ProfileImage, ImageType.ProfileImage); imageViewerPage.ImageModified += ImageViewerPage_ImageModified; await PopupNavigation.Instance.PushAsync(imageViewerPage); } }) }); Image backsideImage = addBackImageContainer.Children[0] as Image; backsideImage.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { var results = await DependencyService.Get <IPermissions>().VerifyPermissionsAsync(false, PermissionType.Camera); if (results == null || results[PermissionType.Camera] != PermissionStatus.Granted) { return; } CameraPage cameraPage = new CameraPage(CameraOperationType.BackImage); cameraPage.PictureTaken += this.CameraPictureTaken; HomePage.Instance.PushCameraPage(cameraPage); }) }); if (!String.IsNullOrEmpty(ContactItem.BackImage)) { SetBackImage(); } if (!String.IsNullOrEmpty(ContactItem.ProfileImage)) { profileImageView.Source = ContactItem.ProfileImage; } ContactModelToFields(); ContactListView.ItemsSource = ContactFields; }
protected override async void OnAppearing() { var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { if (CrossConnectivity.Current.IsConnected) { try { string tt = "https://onlineexamination.a2hosted.com/OnlineExamination/Ref_Exam.php?courses_id=" + Course.course_id; var content = await App.con.GetStringAsync(tt); var tr = JsonConvert.DeserializeObject <IList <ExamClass2> >(content); if (tr is null) { examjson.Animation = "examjson2.json"; return; } ObservableCollection <ExamClass2> trends = new ObservableCollection <ExamClass2>(tr); dt_exam.Rows.Clear(); stk.Children.Clear(); CultureInfo us = new CultureInfo("en-US"); System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("en-US"); string time = DateTime.Now.ToString("h:mm:ss tt"); double hr1, hr2, mn1, mn2, sc1, sc2; int finsh = 0; DateTime oDate2, tim2, oDate, tim; string mo2, da2, ye2; string mo, da, ye; string stt = ""; for (int i = 0; i < trends.Count; i++) { finsh = 0; oDate2 = trends[i].Dat; mo2 = oDate2.Date.Month.ToString(); da2 = oDate2.Date.Day.ToString(); ye2 = oDate2.Date.Year.ToString(); tim2 = trends[i].Tim; stt = trends[i].Stat; if (oDate2.Date == DateTime.Now.Date) { hr1 = tim2.TimeOfDay.Hours; hr2 = DateTime.Now.TimeOfDay.Hours; if (hr1 < hr2) { finsh = 1; } if (hr1 > hr2) { goto dod2; } mn1 = tim2.TimeOfDay.Minutes; mn2 = DateTime.Now.TimeOfDay.Minutes; if (mn1 <= mn2) { finsh = 1; } sc1 = tim2.TimeOfDay.Seconds; sc2 = DateTime.Now.TimeOfDay.Seconds; if ((sc1 < sc2) && (mn1 == mn2)) { finsh = 1; } dod2 :; } if (oDate2.Date < DateTime.Now.Date) { finsh = 1; } foreach (var aq in trends[i].Questions) { qus.Rows.Add(aq.QId, trends[i].Id); } if (finsh == 1) { stt = "Finish"; } dt_exam.Rows.Add(trends[i].Id, trends[i].Dat, trends[i].Tim, trends[i].Des, trends[i].Hor, trends[i].Mark, stt, trends[i].CoursesId); StackLayout frm1 = new StackLayout { Margin = new Thickness(10, 5, 10, 5), HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.White, }; RoundCornersEffect.SetCornerRadius(frm1, 7); var c1 = new Parm { Ctk = frm1, Qhour = Convert.ToInt32(trends[i].Hor), Qtyp = Convert.ToInt32(trends[i].Hor), Qmark = Convert.ToInt32(trends[i].Mark), Des = trends[i].Des, Qdat = trends[i].Dat, Qtim = trends[i].Tim, E_id = trends[i].Id, Stat = stt, }; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, new Binding("stackClick", 0)); tapGestureRecognizer.BindingContext = this; tapGestureRecognizer.CommandParameter = c1; frm1.GestureRecognizers.Add(tapGestureRecognizer); StackLayout stk1 = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; oDate = trends[i].Dat; mo = oDate.Date.Month.ToString(); da = oDate.Date.Day.ToString(); ye = oDate.Date.Year.ToString(); tim = trends[i].Tim; string cn = da + "/" + mo + "/" + ye + " " + tim.TimeOfDay; // Titel Label lb1 = new Label { Margin = 5, Text = cn, TextColor = Color.FromHex("#1941A2"), FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; //DEscription Label lb2 = new Label { Margin = 5, Text = trends[i].Des, TextColor = Color.FromHex("#393939"), FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), VerticalOptions = LayoutOptions.CenterAndExpand, }; //Footer Grid grd1 = new Grid { ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA") }; grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); StackLayout st1 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lbb1_g1 = new Label { Text = trends[i].Hor + " Minute", TextColor = Color.FromHex("#393939"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g1 = new Label { Text = "Duration", TextColor = Color.FromHex("#AAAAAA"), FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; st1.Children.Add(lbb1_g1); st1.Children.Add(lbb2_g1); StackLayout stk_g1 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g1.Children.Add(st1); BoxView bx = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g1.Children.Add(bx); StackLayout st2 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lbb1_g2 = new Label { Text = trends[i].Mark.ToString(), TextColor = Color.FromHex("#393939"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g2 = new Label { Text = "Mark", TextColor = Color.FromHex("#AAAAAA"), FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; st2.Children.Add(lbb1_g2); st2.Children.Add(lbb2_g2); StackLayout stk_g2 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g2.Children.Add(st2); BoxView bx2 = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g2.Children.Add(bx2); Label lbb1_g3 = new Label { Text = trends[i].Stat, TextColor = Color.FromHex("#EF880F"), FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, }; if (trends[i].Stat == "Finish") { lbb1_g3.TextColor = Color.FromHex("#1ECE2C"); } if (finsh == 1) { lbb1_g3.Text = "Finish"; lbb1_g3.TextColor = Color.FromHex("#1ECE2C"); } StackLayout stk_g3 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g3.Children.Add(lbb1_g3); grd1.Children.Add(stk_g1, 0, 0); grd1.Children.Add(stk_g2, 1, 0); grd1.Children.Add(stk_g3, 2, 0); stk1.Children.Add(lb1); stk1.Children.Add(lb2); stk1.Children.Add(grd1); frm1.Children.Add(stk1); stk.Children.Add(frm1); } if (trends.Count == 0) { examjson.Animation = "examjson2.json"; } else { examjson.IsVisible = false; } } catch (Exception eb) { } } else { DependencyService.Get <IMessage>().ShortAlert("تأكد من الاتصال بالانترنت"); } } else { DependencyService.Get <IMessage>().ShortAlert("تأكد من الاتصال بالانترنت"); } //DataRow[] fr = Login.dt_exam.Select("courses_id=" + Course.course_id); //CourseName.Text = Course.course_name; //if (fr.Length == 0) { examjson.IsVisible = true; DependencyService.Get<IMessage>().ShortAlert("There Are No Exams For This Course"); return; } //fr = Login.dt_exam.Select("courses_id=" + Course.course_id); //stk.Children.Clear(); //CultureInfo us = new CultureInfo("en-US"); //System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("en-US"); //for (int i = 0; i < fr.Length; i++) //{ // StackLayout frm1 = new StackLayout // { // Margin = new Thickness(10, 5, 10, 5), // HorizontalOptions = LayoutOptions.FillAndExpand, // BackgroundColor = Color.White, // }; // RoundCornersEffect.SetCornerRadius(frm1, 7); // var c1 = new Parm { // Ctk = frm1, // Qhour = Convert.ToInt32(fr[i]["hor"]), // Qtyp = Convert.ToInt32(fr[i]["hor"]), // Qmark = Convert.ToInt32(fr[i]["mark"]), // Des = fr[i]["des"].ToString(), // Qdat = DateTime.Parse(fr[i]["dat"].ToString()), // Qtim = DateTime.Parse(fr[i]["tim"].ToString()), // }; // var tapGestureRecognizer = new TapGestureRecognizer(); // tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, new Binding("stackClick", 0)); // tapGestureRecognizer.BindingContext = this; // tapGestureRecognizer.CommandParameter = c1; // frm1.GestureRecognizers.Add(tapGestureRecognizer); // StackLayout stk1 = new StackLayout // { // HorizontalOptions = LayoutOptions.FillAndExpand, // VerticalOptions = LayoutOptions.FillAndExpand, // }; // DateTime oDate = DateTime.Parse(fr[i]["dat"].ToString()); // string mo = oDate.Date.Month.ToString(); // string da = oDate.Date.Day.ToString(); // string ye = oDate.Date.Year.ToString(); // DateTime tim = DateTime.Parse(fr[i]["tim"].ToString()); // string cn = da + "/" + mo + "/" + ye + " " + tim.TimeOfDay; // // Titel // Label lb1 = new Label // { // Margin = 5, // Text = cn, // TextColor = Color.FromHex("#1941A2"), // FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) // }; // //DEscription // Label lb2 = new Label // { // Margin = 5, // Text = fr[i]["des"].ToString(), // TextColor = Color.FromHex("#393939"), // FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), // VerticalOptions = LayoutOptions.CenterAndExpand, // }; // //Footer // Grid grd1 = new Grid { ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA") }; // grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); // grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); // grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); // StackLayout st1 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; // Label lbb1_g1 = new Label // { // Text = fr[i]["hor"].ToString() + " Hour", // TextColor = Color.FromHex("#393939"), // FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), // HorizontalOptions = LayoutOptions.CenterAndExpand, // }; // Label lbb2_g1 = new Label // { // Text = "Duration", // TextColor = Color.FromHex("#AAAAAA"), // FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), // HorizontalOptions = LayoutOptions.CenterAndExpand, // }; // st1.Children.Add(lbb1_g1); // st1.Children.Add(lbb2_g1); // StackLayout stk_g1 = new StackLayout { Orientation = StackOrientation.Horizontal }; // stk_g1.Children.Add(st1); // BoxView bx = new BoxView // { // WidthRequest = 1, // BackgroundColor = Color.FromHex("#DBDBDB"), // Margin = 5, // }; // stk_g1.Children.Add(bx); // StackLayout st2 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; // Label lbb1_g2 = new Label // { // Text = fr[i]["mark"].ToString(), // TextColor = Color.FromHex("#393939"), // FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), // HorizontalOptions = LayoutOptions.CenterAndExpand, // }; // Label lbb2_g2 = new Label // { // Text = "Mark", // TextColor = Color.FromHex("#AAAAAA"), // FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), // HorizontalOptions = LayoutOptions.CenterAndExpand, // }; // st2.Children.Add(lbb1_g2); // st2.Children.Add(lbb2_g2); // StackLayout stk_g2 = new StackLayout { Orientation = StackOrientation.Horizontal }; // stk_g2.Children.Add(st2); // BoxView bx2 = new BoxView // { // WidthRequest = 1, // BackgroundColor = Color.FromHex("#DBDBDB"), // Margin = 5, // }; // stk_g2.Children.Add(bx2); // Label lbb1_g3 = new Label // { // Text = fr[i]["stat"].ToString(), // TextColor = Color.FromHex("#EF880F"), // FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), // HorizontalOptions = LayoutOptions.CenterAndExpand, // VerticalOptions = LayoutOptions.Center, // }; // if (fr[i]["stat"].ToString() == "Finish") // { // lbb1_g3.TextColor = Color.FromHex("#1ECE2C"); // } // StackLayout stk_g3 = new StackLayout { Orientation = StackOrientation.Horizontal }; // stk_g3.Children.Add(lbb1_g3); // grd1.Children.Add(stk_g1, 0, 0); // grd1.Children.Add(stk_g2, 1, 0); // grd1.Children.Add(stk_g3, 2, 0); // stk1.Children.Add(lb1); // stk1.Children.Add(lb2); // stk1.Children.Add(grd1); // frm1.Children.Add(stk1); // stk.Children.Add(frm1); //} }
async void Refsh() { examjson.IsVisible = true; examjson.IsEnabled = true; examjson.IsRunning = true; var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { if (CrossConnectivity.Current.IsConnected) { try { string tt = "https://onlineexamination.a2hosted.com/OnlineExamination/get_AllUser.php"; var content = await App.con.GetStringAsync(tt); var tr = JsonConvert.DeserializeObject <IList <AllUsers> >(content); if (tr is null) { examjson.IsVisible = false; examjson.IsEnabled = false; examjson.IsRunning = false; return; } ObservableCollection <AllUsers> trends = new ObservableCollection <AllUsers>(tr); dt_AllUser.Rows.Clear(); stk.Children.Clear(); string knd = ""; int tech = 0; for (int i = 0; i < trends.Count; i++) { if (trends[i].UserKind == 0) { knd = "Student"; tech = 0; } if (trends[i].UserKind == 1) { knd = "Teacher"; tech = 1; } if (trends[i].UserKind == 2) { knd = "Admin"; tech = 0; } dt_AllUser.Rows.Add(trends[i].Id, trends[i].UserName, trends[i].UserPass, trends[i].UserKind, trends[i].Fin, trends[i].UserNickname); StackLayout frm1 = new StackLayout { Margin = new Thickness(10, 5, 10, 5), HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.White, }; RoundCornersEffect.SetCornerRadius(frm1, 7); var c1 = new Parm { Nickname = trends[i].UserName, Ctk = frm1, Tech = tech, Idd = trends[i].Id, }; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, new Binding("stackClick", 0)); tapGestureRecognizer.BindingContext = this; tapGestureRecognizer.CommandParameter = c1; frm1.GestureRecognizers.Add(tapGestureRecognizer); StackLayout stk1 = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = 5, }; Label lb1 = new Label { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Text = trends[i].UserNickname, TextColor = Color.FromHex("#4D4D4D"), }; //DEscription Label lb2 = new Label { Margin = 5, Text = knd, VerticalOptions = LayoutOptions.Center, TextColor = Color.FromHex("#4D4D4D"), FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), }; if (trends[i].UserKind == 0) { lb1.TextColor = Color.FromHex("#4D4D4D"); lb2.TextColor = Color.FromHex("#4D4D4D"); } if (trends[i].UserKind == 1) { lb1.TextColor = Color.FromHex("#1E48A6"); lb2.TextColor = Color.FromHex("#1E48A6"); } if (trends[i].UserKind == 2) { lb1.TextColor = Color.Green; lb2.TextColor = Color.Green; } stk1.Children.Add(lb1); stk1.Children.Add(lb2); frm1.Children.Add(stk1); stk.Children.Add(frm1); } } catch (Exception eb) { } examjson.IsVisible = false; examjson.IsEnabled = false; examjson.IsRunning = false; } else { DependencyService.Get <IMessage>().ShortAlert("تأكد من الاتصال بالانترنت"); } } else { DependencyService.Get <IMessage>().ShortAlert("تأكد من الاتصال بالانترنت"); } }
protected override async void OnAppearing() { var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { if (CrossConnectivity.Current.IsConnected) { try { string tt = "https://onlineexamination.a2hosted.com/OnlineExamination/Ref_Exam.php?stud=1"; var content = await App.con.GetStringAsync(tt); var tr = JsonConvert.DeserializeObject <IList <ExamClass2> >(content); if (tr is null) { examjson.Animation = "examjson2.json"; return; } ObservableCollection <ExamClass2> trends = new ObservableCollection <ExamClass2>(tr); dt_exam.Rows.Clear(); qus.Rows.Clear(); Answ.Rows.Clear(); stk.Children.Clear(); CultureInfo us = new CultureInfo("en-US"); System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("en-US"); string time = DateTime.Now.ToString("h:mm:ss tt"); double hr1, hr2, mn1, mn2, sc1, sc2; for (int i = 0; i < trends.Count; i++) { DateTime oDate = trends[i].Dat; string mo = oDate.Date.Month.ToString(); string da = oDate.Date.Day.ToString(); string ye = oDate.Date.Year.ToString(); DateTime tim = trends[i].Tim; if (oDate.Date == DateTime.Now.Date) { hr1 = tim.TimeOfDay.Hours; hr2 = DateTime.Now.TimeOfDay.Hours; if (hr1 < hr2) { goto dod; } if (hr1 > hr2) { goto dod2; } mn1 = tim.TimeOfDay.Minutes; mn2 = DateTime.Now.TimeOfDay.Minutes; if (mn1 <= mn2) { goto dod; } sc1 = tim.TimeOfDay.Seconds; sc2 = DateTime.Now.TimeOfDay.Seconds; if ((sc1 < sc2) && (mn1 == mn2)) { goto dod; } dod2 :; } dt_exam.Rows.Add(trends[i].Id, trends[i].Dat, trends[i].Tim, trends[i].Des, trends[i].Hor, trends[i].Mark, trends[i].Stat, trends[i].CoursesId, trends[i].QType, trends[i].CourseName); foreach (var aq in trends[i].Questions) { qus.Rows.Add(trends[i].Id, aq.QId, aq.QName, aq.QText, aq.QType, aq.QMark, aq.CourseId); foreach (var an in aq.Answers) { Answ.Rows.Add(trends[i].Id, an.Id, an.AText, an.ACorrect, an.QId); } } StackLayout frm1 = new StackLayout { Margin = new Thickness(10, 5, 10, 5), HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.White, }; RoundCornersEffect.SetCornerRadius(frm1, 7); var c1 = new Parm { Ctk = frm1, Hor = trends[i].Hor, Idd = trends[i].Id, }; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, new Binding("stackClick", 0)); tapGestureRecognizer.BindingContext = this; tapGestureRecognizer.CommandParameter = c1; frm1.GestureRecognizers.Add(tapGestureRecognizer); StackLayout stk1 = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; string cn = da + "/" + mo + "/" + ye; // " " + tim.TimeOfDay; // Titel StackLayout stk_dat = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, }; Label lbd1 = new Label { Margin = 5, Text = cn, VerticalOptions = LayoutOptions.Center, TextColor = Color.FromHex("#1941A2"), HorizontalOptions = LayoutOptions.StartAndExpand, FontSize = 17,// Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; Label lbd2 = new Label { Margin = 5, VerticalOptions = LayoutOptions.Center, Text = tim.TimeOfDay.ToString(), TextColor = Color.FromHex("#1941A2"), HorizontalOptions = LayoutOptions.Center, FontSize = 17,// Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; stk_dat.Children.Add(lbd1); stk_dat.Children.Add(lbd2); //DEscription Label lb2 = new Label { Margin = 5, Text = trends[i].Des, TextColor = Color.FromHex("#393939"), FontSize = 14,// Device.GetNamedSize(NamedSize.Small, typeof(Label)), VerticalOptions = LayoutOptions.CenterAndExpand, }; //Footer Grid grd1 = new Grid { ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA") }; grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); StackLayout st1 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lbb1_g1 = new Label { Text = trends[i].Hor + " Minute", TextColor = Color.FromHex("#393939"), FontSize = 17,// Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g1 = new Label { Text = "Duration", TextColor = Color.FromHex("#AAAAAA"), FontSize = 14,// Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; st1.Children.Add(lbb1_g1); st1.Children.Add(lbb2_g1); StackLayout stk_g1 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g1.Children.Add(st1); BoxView bx = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g1.Children.Add(bx); StackLayout st2 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lbb1_g2 = new Label { Text = trends[i].Mark.ToString(), TextColor = Color.FromHex("#393939"), FontSize = 17,// Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g2 = new Label { Text = "Mark", TextColor = Color.FromHex("#AAAAAA"), FontSize = 14,// Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, }; st2.Children.Add(lbb1_g2); st2.Children.Add(lbb2_g2); StackLayout stk_g2 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g2.Children.Add(st2); BoxView bx2 = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g2.Children.Add(bx2); Label lbb1_g3 = new Label { Text = trends[i].CourseName, TextColor = Color.FromHex("#1941A2"), FontSize = 16,// Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, }; StackLayout stk_g3 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g3.Children.Add(lbb1_g3); grd1.Children.Add(stk_g1, 0, 0); grd1.Children.Add(stk_g2, 1, 0); grd1.Children.Add(stk_g3, 2, 0); stk1.Children.Add(stk_dat); stk1.Children.Add(lb2); stk1.Children.Add(grd1); frm1.Children.Add(stk1); stk.Children.Add(frm1); dod :; } if (trends.Count == 0) { examjson.Animation = "examjson2.json"; } else { examjson.IsVisible = false; } } catch (Exception eb) { await DisplayAlert("", eb.Message, "ok"); } } else { DependencyService.Get <IMessage>().ShortAlert("تأكد من الاتصال بالانترنت"); } } else { DependencyService.Get <IMessage>().ShortAlert("تأكد من الاتصال بالانترنت"); } }
void refrsh(int ty) { stk.Children.Clear(); DataRow[] fr; if (ty >= 0) { fr = dt_Question.Select("q_type=" + ty); } else { fr = dt_Question.Select(); } string typ = ""; DataRow[] fr2; int ctm = 0; for (int i = 0; i < fr.Length; i++) { //Frame frm1 = new Frame //{ // Margin = new Thickness(10, 5, 10, 5), // Padding = 0, // CornerRadius = 7, // HasShadow = true, // Visual = VisualMarker.Default, // HeightRequest = 180, // HorizontalOptions = LayoutOptions.FillAndExpand, // BackgroundColor = Color.White, // BorderColor = Color.FromHex("#D6D6D6"), //}; fr2 = AddExam.dt_selectQ.Select("q_id=" + fr[i]["q_id"].ToString()); if (fr2.Length == 1) { ctm = 1; } else { ctm = 0; } StackLayout frm1 = new StackLayout { Margin = new Thickness(10, 5, 10, 5), HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.White, }; if (ctm == 0) { frm1.BackgroundColor = Color.White; } else { frm1.BackgroundColor = Color.FromHex("#EBFFF3"); } RoundCornersEffect.SetCornerRadius(frm1, 7); StackLayout stk1 = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; StackLayout stkk1 = new StackLayout { VerticalOptions = LayoutOptions.StartAndExpand, Orientation = StackOrientation.Vertical }; //DEscription Label lb2 = new Label { Margin = 5, Text = fr[i]["q_text"].ToString(), TextColor = Color.FromHex("#393939"), FontSize = 16, VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; ImageButton img = new ImageButton { HeightRequest = 30, WidthRequest = 30, Margin = new Thickness(5, 3, 5, 0), Aspect = Aspect.AspectFit, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.End, }; if (ctm == 0) { img.Source = "choseno.png"; } else { img.Source = "choseok.png"; } img.BindingContext = this; img.SetBinding(ImageButton.CommandProperty, new Binding("SelectQ", 0)); var c1 = new Parm { Q_mark = Convert.ToInt32(fr[i]["q_mark"].ToString()), Q_id = Convert.ToInt32(fr[i]["q_id"].ToString()), Ctk = img, Stk_main = frm1 }; img.CommandParameter = c1; stkk1.Children.Add(img); stkk1.Children.Add(lb2); //Footer Grid grd1 = new Grid { ColumnSpacing = 5, BackgroundColor = Color.FromHex("#FAFAFA") }; grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); grd1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); StackLayout st1 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; typ = ExamType.Items[AddExam.pic_index]; Label lbb1_g1 = new Label { Text = typ, TextColor = Color.FromHex("#393939"), FontSize = 16, HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g1 = new Label { Text = "Type", TextColor = Color.FromHex("#AAAAAA"), FontSize = 13, HorizontalOptions = LayoutOptions.CenterAndExpand, }; st1.Children.Add(lbb1_g1); st1.Children.Add(lbb2_g1); StackLayout stk_g1 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g1.Children.Add(st1); BoxView bx = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g1.Children.Add(bx); StackLayout st2 = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lbb1_g2 = new Label { Text = fr[i]["q_mark"].ToString(), TextColor = Color.FromHex("#393939"), FontSize = 16, HorizontalOptions = LayoutOptions.CenterAndExpand, }; Label lbb2_g2 = new Label { Text = "Mark", TextColor = Color.FromHex("#AAAAAA"), FontSize = 13, HorizontalOptions = LayoutOptions.CenterAndExpand, }; st2.Children.Add(lbb1_g2); st2.Children.Add(lbb2_g2); StackLayout stk_g2 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g2.Children.Add(st2); BoxView bx2 = new BoxView { WidthRequest = 1, BackgroundColor = Color.FromHex("#DBDBDB"), Margin = 5, }; stk_g2.Children.Add(bx2); Label lbb1_g3 = new Label { Text = fr[i]["q_name"].ToString(), TextColor = Color.FromHex("#1941A2"), FontSize = 16, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, }; StackLayout stk_g3 = new StackLayout { Orientation = StackOrientation.Horizontal }; stk_g3.Children.Add(lbb1_g3); grd1.Children.Add(stk_g1, 0, 0); grd1.Children.Add(stk_g2, 1, 0); grd1.Children.Add(stk_g3, 2, 0); stk1.Children.Add(stkk1); stk1.Children.Add(grd1); frm1.Children.Add(stk1); stk.Children.Add(frm1); } if (fr.Length == 0) { AnimationView nose = new AnimationView { Animation = "examjson2.json", AutoPlay = true, IsVisible = true, Loop = true, WidthRequest = 300, HeightRequest = 300, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; stk.Children.Add(nose); } }