private void GenerateGridContent(StackLayout addElement, HtmlNode htmlNode, string textHeader) { try { //Check if node contains childs if (!htmlNode.ChildNodes.Any()) { Debug.WriteLine("No child nodes found to add to grid content."); return; } //Grid stacklayout StackLayout stackPanelGrid = new StackLayout(); //Grid Header if (!string.IsNullOrWhiteSpace(textHeader)) { Label LabelHeader = new Label(); LabelHeader.Text = textHeader + ":"; LabelHeader.HorizontalOptions = LayoutOptions.Start; LabelHeader.SetDynamicResource(Label.StyleProperty, "LabelAccent"); LabelHeader.SetDynamicResource(Label.FontSizeProperty, "TextSizeMedium"); //Fix ////Enable or disable text selection //if ((bool)AppSettingLoad("ItemTextSelection"]) //{ // LabelHeader.IsTextSelectionEnabled = true; //} //else //{ // LabelHeader.IsTextSelectionEnabled = false; //} //Add to stackpanel stackPanelGrid.Children.Add(LabelHeader); } //Add other child node elements StackLayout spanContent = new StackLayout(); spanContent.SetDynamicResource(StackLayout.BackgroundColorProperty, "ApplicationLightGrayColor"); AddNodes(spanContent, htmlNode, false); stackPanelGrid.Children.Add(spanContent); //Fix ////Enable or disable text selection //if ((bool)AppSettingLoad("ItemTextSelection"]) //{ // richLabel.IsTextSelectionEnabled = true; //} //else //{ // richLabel.IsTextSelectionEnabled = false; //} //Add to stackpanel grid addElement.Children.Add(stackPanelGrid); } catch { } }
public LeadingTablePage() { InitializeComponent(); gc = GameController.getInstance(); if (CrossMultilingual.Current.CurrentCultureInfo.Equals(gc.hebrew)) { leadingTable.FlowDirection = FlowDirection.RightToLeft; userPlace.FlowDirection = FlowDirection.RightToLeft; } //scoreLabel.Text = AppResources.score + ": " + gc.GetScore(); List <UserGroupScore> leadingTableData = gc.GetLeadingTable(); int userPlaceIndex = -1; for (int i = 0; i < leadingTableData.Count; i++) { Color c = Color.White; if (leadingTableData[i].groupName.Equals(gc.currentTrip.groupName) && leadingTableData[i].score == gc.GetScore()) { c = Color.Orange; userPlaceIndex = i; } leadingTable.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star }); Label lblPosition = new Label { Text = (i + 1) + "", HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = c, Margin = 0 }; lblPosition.SetDynamicResource(VisualElement.StyleProperty, "labelStyle"); StackLayout sPosition = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = c }; sPosition.SetDynamicResource(VisualElement.StyleProperty, "mainStackLayout"); sPosition.Children.Add(lblPosition); leadingTable.Children.Add(sPosition, 0, i + 1); Label lblGroupName = new Label { Text = leadingTableData[i].groupName, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = c, Margin = 0 }; lblGroupName.SetDynamicResource(VisualElement.StyleProperty, "labelStyle"); StackLayout sGroupName = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = c }; sGroupName.SetDynamicResource(VisualElement.StyleProperty, "mainStackLayout"); sGroupName.Children.Add(lblGroupName); leadingTable.Children.Add(sGroupName, 1, i + 1); Label lblScore = new Label { Text = "" + leadingTableData[i].score, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = c, Margin = 0 }; lblScore.SetDynamicResource(VisualElement.StyleProperty, "labelStyle"); StackLayout sScore = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = c }; sScore.SetDynamicResource(VisualElement.StyleProperty, "mainStackLayout"); sScore.Children.Add(lblScore); leadingTable.Children.Add(sScore, 2, i + 1); } if (userPlaceIndex != -1) { userPlace.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star }); Label lblPosition = new Label { Text = (userPlaceIndex + 1) + "", HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Orange, Margin = 0 }; lblPosition.SetDynamicResource(VisualElement.StyleProperty, "labelStyle"); StackLayout sPosition = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Orange }; sPosition.SetDynamicResource(VisualElement.StyleProperty, "mainStackLayout"); sPosition.Children.Add(lblPosition); userPlace.Children.Add(sPosition, 0, 0); Label lblGroupName = new Label { Text = leadingTableData[userPlaceIndex].groupName, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Orange, Margin = 0 }; lblGroupName.SetDynamicResource(VisualElement.StyleProperty, "labelStyle"); StackLayout sGroupName = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Orange }; sGroupName.SetDynamicResource(VisualElement.StyleProperty, "mainStackLayout"); sGroupName.Children.Add(lblGroupName); userPlace.Children.Add(sGroupName, 1, 0); Label lblScore = new Label { Text = "" + leadingTableData[userPlaceIndex].score, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Orange, Margin = 0 }; lblScore.SetDynamicResource(VisualElement.StyleProperty, "labelStyle"); StackLayout sScore = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Orange }; sScore.SetDynamicResource(VisualElement.StyleProperty, "mainStackLayout"); sScore.Children.Add(lblScore); userPlace.Children.Add(sScore, 2, 0); userPlace.BackgroundColor = Color.Orange; userPlace.IsVisible = true; } }
private void GenerateTable(StackLayout addElement, HtmlNode htmlNode, string textHeader) { try { //Check if node contains childs if (!htmlNode.ChildNodes.Any()) { Debug.WriteLine("No child nodes found to add to grid content."); return; } //Set image settings vImageShowAlt = false; //Grid Stackpanel StackLayout stackPanelGrid = new StackLayout(); //Grid Header if (!string.IsNullOrWhiteSpace(textHeader)) { Label LabelHeader = new Label(); LabelHeader.Text = textHeader + ":"; LabelHeader.HorizontalOptions = LayoutOptions.Start; LabelHeader.SetDynamicResource(Label.StyleProperty, "LabelAccent"); LabelHeader.SetDynamicResource(Label.FontSizeProperty, "TextSizeMedium"); //Fix ////Enable or disable text selection //if ((bool)AppSettingLoad("ItemTextSelection"]) //{ // LabelHeader.IsTextSelectionEnabled = true; //} //else //{ // LabelHeader.IsTextSelectionEnabled = false; //} //Add to stackpanel stackPanelGrid.Children.Add(LabelHeader); } int RowTotalCount = htmlNode.Descendants("tr").Count(); if (RowTotalCount > 0) { //Add table child node elements Grid gridContent = new Grid(); gridContent.SetDynamicResource(Grid.BackgroundColorProperty, "ApplicationLightGrayColor"); //Table Row int RowCurrentCount = 0; foreach (HtmlNode TableRow in htmlNode.Descendants("tr")) { //Create and add row RowDefinition gridRowDefinition = new RowDefinition(); gridRowDefinition.Height = GridLength.Auto; gridContent.RowDefinitions.Add(gridRowDefinition); Grid gridRow = new Grid(); gridContent.Children.Add(gridRow); Grid.SetRow(gridRow, RowCurrentCount); RowCurrentCount++; //Fix ////Set grid row style //if (RowCurrentCount != RowTotalCount) //{ // gridRow.BorderBrush = new SolidColorBrush((Color)ApplicationLightGrayColor); // gridRow.BorderThickness = new Thickness(0, 0, 0, 2); //} //Table Header int ColumnCurrentCount = 0; foreach (HtmlNode TableHeader in TableRow.Descendants("th")) { ColumnDefinition gridColDefinition = new ColumnDefinition(); gridColDefinition.Width = GridLength.Star; gridRow.ColumnDefinitions.Add(gridColDefinition); Label Label = new Label(); Label.Text = TableHeader.InnerText; Label.SetDynamicResource(Label.StyleProperty, "LabelAccent"); Label.SetDynamicResource(Label.FontSizeProperty, "TextSizeMedium"); //Fix ////Enable or disable text selection //if ((bool)AppSettingLoad("ItemTextSelection"]) //{ // Label.IsTextSelectionEnabled = true; //} //else //{ // Label.IsTextSelectionEnabled = false; //} gridRow.Children.Add(Label); Grid.SetColumn(Label, ColumnCurrentCount); ColumnCurrentCount++; } //Table Column foreach (HtmlNode TableColumn in TableRow.Descendants("td")) { ColumnDefinition gridColDefinition = new ColumnDefinition(); gridColDefinition.Width = GridLength.Star; gridRow.ColumnDefinitions.Add(gridColDefinition); //Add other child node elements StackLayout spanContent = new StackLayout(); AddNodes(spanContent, TableColumn, false); ////Enable or disable text selection //if ((bool)AppSettingLoad("ItemTextSelection"]) //{ // richLabel.IsTextSelectionEnabled = true; //} //else //{ // richLabel.IsTextSelectionEnabled = false; //} gridRow.Children.Add(spanContent); Grid.SetColumn(spanContent, ColumnCurrentCount); ColumnCurrentCount++; } } //Add to stackpanel grid stackPanelGrid.Children.Add(gridContent); } else { Debug.WriteLine("No row found in the table."); //Add other child node elements StackLayout spanContent = new StackLayout(); spanContent.SetDynamicResource(StackLayout.BackgroundColorProperty, "ApplicationLightGrayColor"); AddNodes(spanContent, htmlNode, false); ////Enable or disable text selection //if ((bool)AppSettingLoad("ItemTextSelection"]) //{ // richLabel.IsTextSelectionEnabled = true; //} //else //{ // richLabel.IsTextSelectionEnabled = false; //} //Add to stackpanel grid stackPanelGrid.Children.Add(spanContent); } addElement.Children.Add(stackPanelGrid); //Set image settings vImageShowAlt = true; } catch { } }
public View UpdateAttributesUI(ComosWebSDK.UI.UIQuery ui) { int rowIndex = 0; int columnIndex = 0; if (ui.Result == null || ui.Result.Rows == null || ui.Result.Rows.Length == 0) { return(null); } var table = new Grid(); foreach (var column in ui.Result.Columns) { table.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); } foreach (var row in ui.Result.Rows) { table.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); } if (ui.Result.Columns.Length > 1) { table.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); foreach (var column in ui.Result.Columns) { UIGrid.AddChild(table, new Label() { Text = column.DisplayDescription, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, }, rowIndex, columnIndex); columnIndex++; } rowIndex++; columnIndex = 0; } foreach (var row in ui.Result.Rows) { if (row.Items[0].Text != "") { var viewcell = new StackLayout() { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.Fill, //Padding = new Thickness(10, 5), //BackgroundColor = (Color)Application.Current.Resources["ComosColorModuleCard"], }; viewcell.SetDynamicResource(StackLayout.StyleProperty, "ComosQueryResult"); FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage() { HeightRequest = 20, WidthRequest = 20, Source = converter.GetAsUrl("?keyid=" + row.Items[0].Picture), }; Label lbl = new Label() { Text = row.Items[0].Text, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; viewcell.Children.Add(img); viewcell.Children.Add(lbl); viewcell.BindingContext = row; TapGestureRecognizer gesture = new TapGestureRecognizer(); gesture.Tapped += ViewCell_DocumentTapped; viewcell.GestureRecognizers.Add(gesture); UIGrid.AddChild(table, viewcell, rowIndex, columnIndex); columnIndex++; for (int i = 1; i < row.Items.Length; i++) { UIGrid.AddChild(table, new Label() { Text = row.Items[i].Text, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }, rowIndex, columnIndex); columnIndex++; } } rowIndex++; columnIndex = 0; } table.SetDynamicResource(StackLayout.StyleProperty, "ComosQueryResult"); table.ColumnSpacing = 20; table.BackgroundColor = (Color)Application.Current.Resources["ComosColorNavBarText"]; ScrollView scroll = new ScrollView { Orientation = ScrollOrientation.Horizontal, }; scroll.BackgroundColor = (Color)Application.Current.Resources["ComosColorNavBarText"]; scroll.Content = table; /*var table = new StackLayout() { * HorizontalOptions =LayoutOptions.Fill, * VerticalOptions =LayoutOptions.StartAndExpand, * BackgroundColor = (Color)Application.Current.Resources["ComosColorNavBar"], * Spacing = 1, * }; * * if (ui.Result == null || ui.Result.Rows == null || ui.Result.Rows.Length == 0) * return null; * * foreach (var row in ui.Result.Rows) * { * if (row.Items[0].Text != "") * { * var viewcell = new StackLayout() * { * Orientation = StackOrientation.Horizontal, * VerticalOptions = LayoutOptions.FillAndExpand, * HorizontalOptions = LayoutOptions.Fill, * Padding = new Thickness(10,5), * //BackgroundColor = (Color)Application.Current.Resources["ComosColorModuleCard"], * }; * viewcell.SetDynamicResource(StackLayout.StyleProperty, "ComosQueryResult"); * * FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage() * { * HeightRequest = 20, * WidthRequest = 20, * Source = converter.GetAsUrl("?keyid=" + row.Items[0].Picture), * }; * viewcell.Children.Add(img); * * for(int i=0; i < row.Items.Length;i++) * { * viewcell.Children.Add(new Label() * { * Text = row.Items[i].Text, * HorizontalOptions = LayoutOptions.FillAndExpand, * VerticalOptions = LayoutOptions.FillAndExpand, * }); * } * * viewcell.BindingContext = row; * TapGestureRecognizer gesture = new TapGestureRecognizer(); * gesture.Tapped += ViewCell_DocumentTapped; * viewcell.GestureRecognizers.Add(gesture); * * table.Children.Add(viewcell); * } * }*/ //table.SizeChanged += Table_SizeChanged; return(scroll); }