public MainPage() { this.InitializeComponent(); initLedMatrixDevice(); for (int i = 0; i < MATRIX_SIZE; i++) { TextBlock tb = new TextBlock(); tb.Text = "0x00"; tb.HorizontalAlignment = HorizontalAlignment.Center; tb.VerticalAlignment = VerticalAlignment.Center; tb.SetValue(Grid.RowProperty, i); tb.SetValue(Grid.ColumnProperty, MATRIX_SIZE); _matrix.Children.Add(tb); _matrixRowValue[i] = tb; for (int j = 0; j < MATRIX_SIZE; j++) { Ellipse led = new Ellipse(); led.Width = 40; led.Height = 40; led.HorizontalAlignment = HorizontalAlignment.Center; led.VerticalAlignment = VerticalAlignment.Center; led.Fill = _off; led.SetValue(Grid.RowProperty, i); led.SetValue(Grid.ColumnProperty, j); led.PointerPressed += Led_PointerPressed; _matrix.Children.Add(led); setMatrixData(i, j, 0); } } }
private TextBlock CreateLabel(string text, double top, double left) { TextBlock txt = new TextBlock(); txt.Text = text; txt.FontSize = 5*Convert.ToInt32(text); //txt.SetValue(Canvas.TopProperty, top); //txt.SetValue(Canvas.LeftProperty, left - txt.ActualWidth / 2); txt.SetValue(Canvas.TopProperty, top - txt.ActualHeight/2); txt.SetValue(Canvas.LeftProperty, left); return txt; }
public Snow(int x, int y, int size) { this.tb = new TextBlock(); tb.Text = "❆"; tb.FontFamily = new FontFamily("Segoe UI Symbol"); tb.FontSize = size; tb.Foreground = new SolidColorBrush(Windows.UI.Colors.White); this.x = x; this.y = y; tb.SetValue(Canvas.LeftProperty, this.x); tb.SetValue(Canvas.TopProperty, this.y); }
public MainPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Required; foreach (var month in _monthsList) { var textBlock = new TextBlock { Text = month }; textBlock.SetValue(AutomationProperties.NameProperty, month); // ReSharper disable once PossibleNullReferenceException this.ListBox.Items.Add(textBlock); } }
public static void SetText(TextBlock element, string value) { element.SetValue(TextProperty, value); }
private void InitializeDayLabelBoxes() { int column = 0; CalendarGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); foreach (var day in Enum.GetValues(typeof(DayOfWeek))) { //Runtime generate controls and setting style Rectangle box = new Rectangle(); box.Style = Application.Current.Resources["CalendarLabelBox"] as Style; box.SetValue(Grid.RowProperty, 0); box.SetValue(Grid.ColumnProperty, column); TextBlock textBlock = new TextBlock(); textBlock.Style = Application.Current.Resources["CalendarLabel"] as Style; textBlock.Text = day.ToString(); //Runtime setting the control Grid.Row and Grid.Column XAML property value textBlock.SetValue(Grid.RowProperty, 0); textBlock.SetValue(Grid.ColumnProperty, column); //Adding the box and the textblock control to the Grid during runtime CalendarGrid.Children.Add(box); CalendarGrid.Children.Add(textBlock); column++; } }
/// <summary> /// Cette méthode permet de créer le TextBlock composé du nom de l'équipement/de la pièce, et qui apparaît en dessous de l'icône de l'équipement/de la pièce. /// </summary> /// <param name="nom">Nom de l'équipement/de la pièce.</param> /// <returns>TextBlock composé du nom.</returns> public TextBlock creerLabel(String nom) { // création label : nom de l'icône TextBlock labelIcone = new TextBlock(); labelIcone.SetValue(TextBlock.TextProperty, nom); // police du label labelIcone.FontFamily = new FontFamily("Segoe UI"); labelIcone.Foreground = new SolidColorBrush(Colors.Black); labelIcone.FontSize = 24; // positionnement du label labelIcone.TextAlignment = TextAlignment.Center; labelIcone.VerticalAlignment = VerticalAlignment.Center; labelIcone.HorizontalAlignment = HorizontalAlignment.Center; labelIcone.TextWrapping = TextWrapping.Wrap; return labelIcone; }
private void MySquare_Tapped(object sender, TappedRoutedEventArgs e) { Rectangle curr = (Rectangle)sender; //tblSquare.Text = curr.Name.ToString(); //create a new textblock //set the grid row and col properties(same as the sender) //set the text = X or O depending //set the font //set the alignment TextBlock myTblLetter = new TextBlock(); myTblLetter.Name = "tbl" + curr.Name.ToString(); //set the grid.row of the textblock equal //to grid.row of the sender (getvalue) //double x = (double) curr.GetValue(Grid.RowProperty); //double y = (double)curr.GetValue(Grid.ColumnProperty); #region add X or O textblock to the grid tapped myTblLetter.SetValue(Grid.RowProperty, curr.GetValue(Grid.RowProperty)); myTblLetter.SetValue(Grid.ColumnProperty, curr.GetValue(Grid.ColumnProperty)); //set alignment myTblLetter.HorizontalAlignment = HorizontalAlignment.Center; myTblLetter.VerticalAlignment = VerticalAlignment.Center; //set the font size to large myTblLetter.FontSize = 42; //myTblLetter.Name = "tbl" + curr.Name.ToString(); //add it to the grid grdGame.Children.Add(myTblLetter); // show it on the screen #endregion #region switch statement to make moves switch (currColour) { case "X": curr.Fill = new SolidColorBrush(Colors.Yellow); // set the text to X myTblLetter.Text = "X"; currColour = "O"; break; case "O": curr.Fill = new SolidColorBrush(Colors.Green); // set the text to O myTblLetter.Text = "O"; currColour = "X"; break; } // switch #endregion curr.Tapped -= MySquare_Tapped; #region check for winning conditions //get the sender object and find the row and column //rectangles named RxCy //parse the name // //get the string value of X // curr.Name.Substring(1, curr.Name.IndexOf("C") - 1); string xValue = curr.Name.Substring(1, curr.Name.IndexOf("C") - 1); int iRow = Convert.ToInt32(xValue); int iCol = Convert.ToInt32(curr.Name.Substring(curr.Name.IndexOf("C") + 1)); //got row and column //figure out the if statement to check a row //create a method to check rows and collumns //checkRow(); /* for (int i = 0; i <= 2; i++) { if (grdGame.FindName("tblR" + iRow.ToString() + "C" + i.ToString) != null) { // found a textblock, so compare } }*/ /* if(rowArray[iRow] == 3) { //winner } */ #endregion }
private async void PopulateData() { if (DataSource == null) return; ChartCanvas.Children.Clear(); await Task.Delay(50); // raceeee... wrooom! var margin = 10; var values = DataSource; if (values.Count == 0) return; var nonZeroValuesCount = values.Count(i => i != 0); var maxWidth = ChartCanvas.ActualWidth - _lineThickness*3/4*nonZeroValuesCount - margin*2; var height = 0; //(ChartCanvas.ActualHeight / 2) ; var all = values.Aggregate(0.0f, (current, value) => current + value); double currX = _lineThickness/2 + margin/2, offset; var currColor = 0; var labels = new Dictionary<double, float>(); float totalPercentage = 0; float percentage; ChartCanvas.Children.Add(new Line { X1 = currX, X2 = ChartCanvas.ActualWidth - margin*2, Y1 = height, Y2 = height, Stroke = B2, Fill = B2, StrokeThickness = 40, StrokeDashCap = PenLineCap.Round, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round }); foreach (var value in values) { if (value == 0) { currColor++; continue; } percentage = value*100/all; totalPercentage += percentage; offset = percentage*maxWidth/100; labels.Add(currX + offset, totalPercentage); var line = new Line { X1 = currX, X2 = currX + offset, Y1 = height, Y2 = height, Stroke = new SolidColorBrush(ColorsOrder[currColor]), Fill = B2, StrokeThickness = _lineThickness, StrokeDashCap = PenLineCap.Round, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round }; line.PointerEntered += LineOnPointerEntered; line.PointerExited += LineOnPointerExited; ChartCanvas.Children.Add(line); currX += offset + _lineThickness*3/4; currColor++; } int? prevLabel = null; foreach (var label in labels) { if ((int) Math.Ceiling(label.Value) == 100) break; var txt = new TextBlock { Text = Math.Floor(label.Value) + "%", TextAlignment = TextAlignment.Center }; var lblHeight = height + 30; if (prevLabel == null || Math.Abs((int) label.Key - (int) prevLabel) > 30) prevLabel = (int) label.Key; else lblHeight -= 80; txt.SetValue(Canvas.TopProperty, lblHeight); txt.SetValue(Canvas.LeftProperty, label.Key); ChartCanvas.Children.Add(txt); } }
void InitializeFeaturePage(Grid grid, DependencyProperty chooserProperty, TypographyFeaturePage page) { if (page == null) { grid.Children.Clear(); grid.RowDefinitions.Clear(); } else { // Get the property value and metadata. object value = GetValue(chooserProperty); var metadata = (TypographicPropertyMetadata)chooserProperty.GetMetadata(typeof(FontChooser)); // Look up the sample text. string sampleText = (metadata.SampleTextTag != null) ? LookupString(metadata.SampleTextTag) : _defaultSampleText; if (page == _currentFeaturePage) { // Update the state of the controls. for (int i = 0; i < page.Items.Length; ++i) { // Check the radio button if it matches the current property value. if (page.Items[i].Value.Equals(value)) { var radioButton = (RadioButton)grid.Children[i * 2]; radioButton.IsChecked = true; } // Apply properties to the sample text block. var sample = (TextBlock)grid.Children[i * 2 + 1]; sample.Text = sampleText; ApplyPropertiesToObjectExcept(sample, chooserProperty); sample.SetValue(metadata.TargetProperty, page.Items[i].Value); } } else { grid.Children.Clear(); grid.RowDefinitions.Clear(); // Add row definitions. for (int i = 0; i < page.Items.Length; ++i) { var row = new RowDefinition(); row.Height = GridLength.Auto; grid.RowDefinitions.Add(row); } // Add the controls. for (int i = 0; i < page.Items.Length; ++i) { string tag = page.Items[i].Tag; var radioContent = new TextBlock(new Run(LookupString(tag))); radioContent.TextWrapping = TextWrapping.Wrap; // Add the radio button. var radioButton = new RadioButton(); radioButton.Name = tag; radioButton.Content = radioContent; radioButton.Margin = new Thickness(5.0, 0.0, 0.0, 0.0); radioButton.VerticalAlignment = VerticalAlignment.Center; Grid.SetRow(radioButton, i); grid.Children.Add(radioButton); // Check the radio button if it matches the current property value. if (page.Items[i].Value.Equals(value)) { radioButton.IsChecked = true; } // Hook up the event. radioButton.Checked += featureRadioButton_Checked; // Add the block with sample text. var sample = new TextBlock(new Run(sampleText)); sample.Margin = new Thickness(5.0, 5.0, 5.0, 0.0); sample.TextWrapping = TextWrapping.WrapWithOverflow; ApplyPropertiesToObjectExcept(sample, chooserProperty); sample.SetValue(metadata.TargetProperty, page.Items[i].Value); Grid.SetRow(sample, i); Grid.SetColumn(sample, 1); grid.Children.Add(sample); } // Add borders between rows. for (int i = 0; i < page.Items.Length; ++i) { var border = new Border(); border.BorderThickness = new Thickness(0.0, 0.0, 0.0, 1.0); border.BorderBrush = SystemColors.ControlLightBrush; Grid.SetRow(border, i); Grid.SetColumnSpan(border, 2); grid.Children.Add(border); } } } _currentFeature = chooserProperty; _currentFeaturePage = page; }
private void _OnIsEditingChanged(bool isEditing, Item item) { UpdateGlyph(); if (_leftSide != null) MainGrid.Children.Remove(_leftSide); if (isEditing) { TextBox box = new TextBox() {HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center }; box.SetValue(Grid.ColumnProperty, 0); box.FontSize = FontSize; box.SetBinding(TextBox.TextProperty, new Binding() { Source = this, Path = new PropertyPath(ItemMode ? "Item.Name" : "EditableText"), Mode = BindingMode.TwoWay }); _leftSide = box; } else { TextBlock block = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center }; block.SetValue(Grid.ColumnProperty, 0); block.SetBinding(TextBlock.TextProperty, new Binding() { Source = this, Path = new PropertyPath(ItemMode ? "Item.Name" : "EditableText"), Mode = BindingMode.OneWay }); _leftSide = block; } MainGrid.Children.Add(_leftSide); }
public async void LcdPrint(ScreenMessage lcdt) { var isText = lcdt.Service.Equals("LCDT"); FrameworkElement element = null; var expandToEdge = false; SolidColorBrush backgroundBrush = null; if (lcdt.Action != null) { if (!string.IsNullOrWhiteSpace(lcdt.ARGB)) { if (lcdt.ARGB[0] == '#') { var hex = lcdt.ARGB.ToByteArray(); if (hex.Length > 3) { backgroundBrush = new SolidColorBrush(Color.FromArgb((hex[0] == 0 ? (byte) 255 : hex[0]), hex[1], hex[2], hex[3])); } } else { UInt32 color; if (UInt32.TryParse(lcdt.ARGB, out color)) { var argb = new ArgbUnion {Value = color}; backgroundBrush = new SolidColorBrush(Color.FromArgb(argb.A == 0 ? (byte) 255 : argb.A, argb.R, argb.G, argb.B)); } } } var action = lcdt.Action.ToUpperInvariant(); switch (action) { case "ORIENTATION": { var current = DisplayInformation.AutoRotationPreferences; if (lcdt.Value.HasValue) { DisplayInformation.AutoRotationPreferences = (DisplayOrientations)lcdt.Value.Value; } await mainPage.SendResult(new ScreenResultMessage(lcdt) { ResultId = (int)current }); break; } case "ENABLE": { mainPage.sensors[lcdt.Service + ":" + lcdt.Message] = 1; return; } case "DISABLE": { if (mainPage.sensors.ContainsKey(lcdt.Service + ":" + lcdt.Message)) { mainPage.sensors.Remove(lcdt.Service + ":" + lcdt.Message); } return; } case "CLEAR": { if (lcdt.Y.HasValue) { RemoveLine(lcdt.Y.Value); } else if (lcdt.Pid.HasValue) { RemoveId(lcdt.Pid.Value); } else { mainPage.canvas.Children.Clear(); if (backgroundBrush != null) { mainPage.canvas.Background = backgroundBrush; } lastY = -1; mainPage.player.Stop(); mainPage.player.Source = null; } break; } case "BUTTON": { element = new Button { Content = lcdt.Message, FontSize = lcdt.Size ?? DefaultFontSize, Tag = lcdt.Tag, Foreground = textForgroundBrush, Background = new SolidColorBrush(Colors.Gray) }; element.Tapped += async (s, a) => await mainPage.SendEvent(s, a, "tapped"); ((Button)element).Click += async (s, a) => await mainPage.SendEvent(s, a, "click"); element.PointerPressed += async (s, a) => await mainPage.SendEvent(s, a, "pressed"); element.PointerReleased += async (s, a) => await mainPage.SendEvent(s, a, "released"); break; } case "IMAGE": { var imageBitmap = new BitmapImage(new Uri(lcdt.Path, UriKind.Absolute)); //imageBitmap.CreateOptions = Windows.UI.Xaml.Media.Imaging.BitmapCreateOptions.IgnoreImageCache; if (lcdt.Width.HasValue) { imageBitmap.DecodePixelWidth = lcdt.Width.Value; } if (lcdt.Height.HasValue) { imageBitmap.DecodePixelHeight = lcdt.Height.Value; } element = new Image { Tag = lcdt.Tag }; ((Image)element).Source = imageBitmap; element.Tapped += async (s, a) => await mainPage.SendEvent(s, a, "tapped"); break; } case "LINE": { var line = new Line { X1 = lcdt.X.Value, Y1 = lcdt.Y.Value, X2 = lcdt.X2.Value, Y2 = lcdt.Y2.Value, StrokeThickness = lcdt.Width ?? 1, Stroke = foreground }; element = line; break; } case "INPUT": { element = new TextBox { Text = lcdt.Message, FontSize = lcdt.Size ?? DefaultFontSize, TextWrapping = TextWrapping.Wrap, Foreground = textForgroundBrush, AcceptsReturn = lcdt.Multi ?? false }; expandToEdge = true; element.SetValue(Canvas.LeftProperty, lcdt.X); element.SetValue(Canvas.TopProperty, lcdt.Y); element.LostFocus += async (s, a) => await mainPage.SendEvent(s, a, "lostfocus", lcdt, ((TextBox)s).Text); ((TextBox)element).TextChanged += async (s, a) => await mainPage.SendEvent(s, a, "changed", lcdt, ((TextBox)s).Text); break; } case "CHANGE": { var retrievedElement = GetId(lcdt.Pid.Value); if (retrievedElement != null) { if (lcdt.ARGB != null) { var i = 0; } } break; } case "RECTANGLE": { var rect = new Rectangle { Tag = lcdt.Tag, Fill = backgroundBrush ?? gray }; if (lcdt.Width.HasValue) { rect.Width = lcdt.Width.Value; } if (lcdt.Height.HasValue) { rect.Height = lcdt.Height.Value; } element = rect; element.Tapped += async (s, a) => await mainPage.SendEvent(s, a, "tapped", lcdt); rect.PointerEntered += async (s, a) => await mainPage.SendEvent(s, a, "entered", lcdt); rect.PointerExited += async (s, a) => await mainPage.SendEvent(s, a, "exited", lcdt); break; } case "TEXT": { TextBlock textBlock = new TextBlock { Text = lcdt.Message, FontSize = lcdt.Size ?? DefaultFontSize, TextWrapping = TextWrapping.Wrap, Tag = lcdt.Tag, Foreground = textForgroundBrush }; expandToEdge = true; element = textBlock; element.SetValue(Canvas.LeftProperty, lcdt.X); element.SetValue(Canvas.TopProperty, lcdt.Y); break; } default: break; } } if (element == null && isText && lcdt.Message != null) { var x = lcdt.X ?? 0; var y = lcdt.Y ?? lastY + 1; expandToEdge = true; element = new TextBlock { Text = lcdt.Message, FontSize = lcdt.Size ?? DefaultFontSize, TextWrapping = TextWrapping.Wrap, Tag = y.ToString(), Foreground = textForgroundBrush }; var textblock = (TextBlock)element; textblock.FontFamily = fixedFont; if (lcdt.Foreground != null) { textblock.Foreground = HexColorToBrush(lcdt.Foreground); } if (lcdt.HorizontalAlignment != null) { if (lcdt.HorizontalAlignment.Equals("Center")) { textblock.TextAlignment = TextAlignment.Center; } } element.SetValue(Canvas.LeftProperty, isText ? x * textblock.FontSize : x); element.SetValue(Canvas.TopProperty, isText ? y * textblock.FontSize : y); } else if (element != null && element.GetType() != typeof(Line)) { element.SetValue(Canvas.LeftProperty, lcdt.X); element.SetValue(Canvas.TopProperty, lcdt.Y); } if (element != null) { var x = lcdt.X ?? 0; var y = lcdt.Y ?? lastY + 1; if (lcdt.HorizontalAlignment != null) { if (lcdt.HorizontalAlignment.Equals("Center")) { element.HorizontalAlignment = HorizontalAlignment.Center; element.Width = mainPage.canvas.Width; } } if (lcdt.FlowDirection != null) { if (lcdt.FlowDirection.Equals("RightToLeft")) { element.FlowDirection = FlowDirection.RightToLeft; } else if (lcdt.FlowDirection.Equals("LeftToRight")) { element.FlowDirection = FlowDirection.LeftToRight; } } if (lcdt.Width.HasValue) { element.Width = lcdt.Width.Value; } else if (expandToEdge) { element.Width = mainPage.canvas.ActualWidth; } if (lcdt.Height.HasValue) { element.Height = lcdt.Height.Value; } //TODO: add optional/extra properties in a later version here. if (isText && x == 0) { RemoveLine(y); } element.SetValue(RemoteIdProperty, lcdt.Id); mainPage.canvas.Children.Add(element); if (isText) { lastY = y; } } }
private void populateRecipes() { // PivotItem pvt; int i = 0; if (listRecipes.Count == 0) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = "No Results"; TextBlock txtTitle = new TextBlock(); txtTitle.Text = "No Results Found"; txtTitle.Margin = new Thickness(10, 10, 10, 10); pivotItem.Content = txtTitle; pvtRecipes.Items.Add(pivotItem); } foreach (Model.ResponseYummly recipe in listRecipes) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = recipe.RecipeName; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol"+i.ToString(); BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("https://image.freepik.com/free-icon/favorites-star-outlined-symbol_318-69168.png"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; favorite.SetValue(Grid.ColumnProperty, 1); i++; //grid.Children.Add(favorite); StackPanel stk = new StackPanel(); stk.Name = "recipeStk"; stk.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(favorite); TextBlock txtTitle = new TextBlock(); txtTitle.Text = "Title: " + recipe.RecipeName; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.Id; txtRecipeId.Margin = new Thickness(10, 10, 10, 10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.Ingredients.Replace("\",","\n"); txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.Rating.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.SourceDisplayName; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtTotalTime = new TextBlock(); txtTotalTime.Text = "Total Time (seconds): " + recipe.TotalTime.ToString(); txtTotalTime.Margin = new Thickness(10, 10, 10, 10); txtTotalTime.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTotalTime); TextBlock txtCourse = new TextBlock(); txtCourse.Text = "Courses: " + recipe.Course; txtCourse.Margin = new Thickness(10, 10, 10, 10); txtCourse.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCourse); TextBlock txtCusine = new TextBlock(); txtCusine.Text = "Cuisine: " + recipe.Cuisine; txtCusine.Margin = new Thickness(10, 10, 10, 10); txtCusine.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCusine); TextBlock txtFlavors = new TextBlock(); txtFlavors.Text = "Flavors: " + recipe.Flavors.Replace(",\"", "\n"); txtFlavors.Margin = new Thickness(10, 10, 10, 10); txtFlavors.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtFlavors); grid.Children.Add(stk); pivotItem.Content = grid; pvtRecipes.Items.Add(pivotItem); } }
public static void SetText(TextBlock element, string value) { if(element != null) { element.SetValue(ArticleContentProperty, value); } }
private void ReceivedMessageCallbackWhenSubscribed(string result) { if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim())) { List<object> deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToListOfObject(result); if (deserializedMessage != null && deserializedMessage.Count > 0) { object subscribedObject = (object)deserializedMessage[0]; if (subscribedObject != null) { string serializedResultMessage = pubnub.JsonPluggableLibrary.SerializeToJsonString(subscribedObject); RTPMServer rtpmServer = JsonConvert.DeserializeObject<RTPMServer>(serializedResultMessage); Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ctd = grid.RowDefinitions.Count; grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(columnHeight) }); TextBlock t = new TextBlock(); t.HorizontalAlignment = HorizontalAlignment.Left; t.FontSize = 11; t.Text = rtpmServer.Date.ToLocalTime().ToString(); t.SetValue(Grid.ColumnProperty, 0); t.SetValue(Grid.RowProperty, ctd); grid.Children.Add(t); TextBlock tS = new TextBlock(); tS.HorizontalAlignment = HorizontalAlignment.Left; tS.FontSize = 12; tS.Text = rtpmServer.ServerName; tS.SetValue(Grid.ColumnProperty, 1); tS.SetValue(Grid.RowProperty, ctd); grid.Children.Add(tS); TextBlock tC = new TextBlock(); tC.HorizontalAlignment = HorizontalAlignment.Center; tC.FontSize = 14; tC.Text = rtpmServer.CPUUsage.ToString("###.##") + " %"; tC.SetValue(Grid.ColumnProperty, 2); tC.SetValue(Grid.RowProperty, ctd); grid.Children.Add(tC); TextBlock tR = new TextBlock(); tR.HorizontalAlignment = HorizontalAlignment.Center; tR.FontSize = 14; tR.Text = rtpmServer.RAMUsage.ToString() + " Mb"; tR.SetValue(Grid.ColumnProperty, 3); tR.SetValue(Grid.RowProperty, ctd); grid.Children.Add(tR); ctd++; }).GetResults(); } } } mrePubNub.Set(); }
public static void SetWikiText(TextBlock wb, string html) { wb.SetValue(WikiTextProperty, html); }
void UpdateGrid() { if (_root == null || ItemsSource == null) { return; } _root.Children.Clear(); _root.ColumnDefinitions.Clear(); _independentValues.Clear(); _dependentValues.Clear(); BindingEvaluator independentBinding = new BindingEvaluator(IndependentValuePath); BindingEvaluator dependentBinding = new BindingEvaluator(DependentValuePath); int column = 0; foreach (var item in ItemsSource) { var independentValue = independentBinding.Eval(item).ToString(); var dependentValue = (long)dependentBinding.Eval(item); _dependentValues.Add(dependentValue); _root.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); TextBlock independentTB = new TextBlock(); independentTB.Text = independentValue; independentTB.FontSize = IndependentValueFontSize; independentTB.Foreground = IndependentValueBrush; independentTB.VerticalAlignment = VerticalAlignment.Center; independentTB.HorizontalAlignment = HorizontalAlignment.Center; independentTB.SetValue(Grid.RowProperty, 3); independentTB.SetValue(Grid.ColumnProperty, column++); _root.Children.Add(independentTB); } Rectangle rc = new Rectangle(); rc.Fill = GridLineBrush; rc.Height = 1; rc.SetValue(Grid.RowProperty, 1); rc.SetValue(Grid.ColumnSpanProperty, column); _root.Children.Add(rc); var min = _dependentValues.Min(); var max = _dependentValues.Max(); long temp = 0; if (min >= 0 && max >= 0) { temp = max; } else if (min < 0 && max >= 0) { temp = max - min; } else if (max < 0) { temp = -min; } var height = (this.ActualHeight - 1 - 30) / temp; for (int i = 0; i < _dependentValues.Count; i++) { var dependentValue = _dependentValues[i]; TextBlock dependentTB = new TextBlock(); dependentTB.Text = dependentValue.ToString(); dependentTB.FontSize = DependentValueFontSize; dependentTB.Foreground = dependentValue >= 0 ? PositiveValueBrush : NegativeValueBrush; dependentTB.VerticalAlignment = dependentValue > 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom; dependentTB.HorizontalAlignment = HorizontalAlignment.Center; dependentTB.SetValue(Grid.RowProperty, dependentValue > 0 ? 2 : 0); dependentTB.SetValue(Grid.ColumnProperty, i); Rectangle dependentRC = new Rectangle(); dependentRC.Fill = dependentValue >= 0 ? PositiveValueBrush : NegativeValueBrush; dependentRC.Height = Math.Abs(height * dependentValue); dependentRC.Margin = new Thickness(20, 0, 20, 0); dependentRC.VerticalAlignment = dependentValue <= 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom; dependentRC.SetValue(Grid.RowProperty, dependentValue <= 0 ? 2 : 0); dependentRC.SetValue(Grid.ColumnProperty, i); _root.Children.Add(dependentRC); _root.Children.Add(dependentTB); } }
// Show score public void DisplayScore(Hexagon hex, int value) { // Create new textElement TextBlock score = new TextBlock(); score.FontSize = 35; score.Text = string.Format("+{0}", value); // Center Textblock score.SetValue(Canvas.LeftProperty, hex.Left - 25); score.SetValue(Canvas.TopProperty, hex.Top - 10); // Add to Canvas _canvas.Children.Add(score); // Animate score AnimateScore(hex, score); }
private void SetKebiaoGridBorder(int week) { //边框 //for (int i = 0; i < kebiaoGrid.RowDefinitions.Count; i++) //{ // for (int j = 0; j < kebiaoGrid.ColumnDefinitions.Count; j++) // { // var border = new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(0.5) }; // Grid.SetRow(border, i); // Grid.SetColumn(border, j); // kebiaoGrid.Children.Add(border); // } //} //星期背景色 if (week == 0) { Grid backgrid = new Grid(); backgrid.Background = new SolidColorBrush(Color.FromArgb(255, 254, 245, 207)); backgrid.SetValue(Grid.RowProperty, 0); backgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) + 6) % 7); backgrid.SetValue(Grid.RowSpanProperty, 12); kebiaoGrid.Children.Add(backgrid); backweekgrid.Background = new SolidColorBrush(Color.FromArgb(255, 254, 245, 207)); backweekgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 6 : Int16.Parse(Utils.GetWeek()) - 1)); backweekgrid.SetValue(Grid.RowSpanProperty, 2); KebiaoWeekTitleGrid.Children.Remove(backweekgrid); KebiaoWeekTitleGrid.Children.Add(backweekgrid); } else { backweekgrid.Background = new SolidColorBrush(Color.FromArgb(255, 248, 248, 248)); backweekgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 6 : Int16.Parse(Utils.GetWeek()) - 1)); backweekgrid.SetValue(Grid.RowSpanProperty, 2); KebiaoWeekTitleGrid.Children.Remove(backweekgrid); KebiaoWeekTitleGrid.Children.Add(backweekgrid); } TextBlock KebiaoWeek = new TextBlock(); KebiaoWeek.Text = Utils.GetWeek(2); KebiaoWeek.FontSize = 20; KebiaoWeek.Foreground = new SolidColorBrush(Color.FromArgb(255, 33, 33, 33)); KebiaoWeek.FontWeight = FontWeights.Light; KebiaoWeek.VerticalAlignment = VerticalAlignment.Center; KebiaoWeek.HorizontalAlignment = HorizontalAlignment.Center; KebiaoWeek.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 6 : Int16.Parse(Utils.GetWeek()) - 1)); KebiaoWeek.SetValue(Grid.RowProperty, 1); KebiaoWeekTitleGrid.Children.Add(KebiaoWeek); }
private static string HtmlTableXaml(HtmlNode cntnt) { if (IsFirstRun) { return ("<Paragraph TextAlignment=\"Left\"><Span FontFamily=\"rp_tb" + TbCount.ToString() + "\" /></Paragraph>"); } else { Grid tableGrid = null; //var grdWidth = CalulateItemWidth(cntnt, RTB.ActualWidth); IList<HtmlNode> rows = (from tblNode in cntnt.ChildNodes where (tblNode.Name.ToLower().Equals("tr")) select tblNode).ToList(); //CREATE Grid rows and cols var trNode = rows[0]; int colCount = (from tdNode in trNode.ChildNodes where (tdNode.Name.ToLower().Equals("td")) select tdNode).Count<HtmlNode>(); if (rows.Count > 0 && colCount > 0) { tableGrid = new Grid(); //if (grdWidth > 0) // tableGrid.Width = grdWidth; //set up rows for (int ictr = 0; ictr < rows.Count; ictr++) { tableGrid.RowDefinitions.Add(new RowDefinition()); } //setup cols for (int jctr = 0; jctr < colCount; jctr++) { Double wdth = CalulateItemWidth(trNode.ChildNodes[jctr], tableGrid.Width); if (wdth > 0) tableGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(wdth) }); else tableGrid.ColumnDefinitions.Add(new ColumnDefinition()); } } if (rows.Count > 0 && colCount > 0) { for (int trCtr = 0; trCtr < rows.Count; trCtr++) { IList<HtmlNode> cols = (from tdNode in rows[trCtr].ChildNodes where (tdNode.Name.ToLower().Equals("td")) select tdNode).ToList(); for (int tdCtr = 0; tdCtr < cols.Count; tdCtr++) { var tbcnt = new TextBlock {Text = cols[tdCtr].InnerText}; tbcnt.SetValue(Grid.RowProperty, trCtr); tbcnt.SetValue(Grid.ColumnProperty, tdCtr); tableGrid.Children.Add(tbcnt); } cols = null; } } var ilContainer = new InlineUIContainer {Child = tableGrid}; //fire the event OnContainerCreated("rp_tb" + TbCount.ToString(), ilContainer); return string.Empty; } }
private void Draw(object sender, object e) { SetTime(DateTime.Now); ClockLayout.Children.Clear(); double ClockWidth = ClockLayout.Width; var step = 360 / 60; var innerRadiusX = (ClockWidth * 0.8) / 2; var innerRadiusY = (Height * 0.8) / 2; var outerRadiusX = (ClockWidth * 0.9) / 2; var outerRadiusY = (Height * 0.9) / 2; var textRadiusX = (ClockWidth * 0.7) / 2; var textRadiusY = (Height * 0.7) / 2; outerCasing.Visibility = Visibility.Visible; ClockLayout.Children.Add(outerCasing); for (var i = 0; i < 60; i++) { Line line = new Line(); if (i % 5 == 0) { line.Stroke = new SolidColorBrush(Colors.Black); line.X1 = (ClockWidth / 2) + Math.Sin((step * i) * (Math.PI / 180)) * innerRadiusX; line.Y1 = (Height / 2) + Math.Cos((step * i) * (Math.PI / 180)) * innerRadiusY; line.X2 = (ClockWidth / 2) + Math.Sin((step * i) * (Math.PI / 180)) * outerRadiusX; line.Y2 = (Height / 2) + Math.Cos((step * i) * (Math.PI / 180)) * outerRadiusY; var textblock = new TextBlock(); textblock.FontFamily = new FontFamily("verdana"); textblock.FontSize = 10; SolidColorBrush mytextBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); textblock.Foreground = mytextBrush; if (i % 15 == 0) textblock.Text = i == 0 ? "12" : ((double)(i / 60D) * 12D).ToString(); else textblock.Text = ""; var textX = (ClockWidth / 2) + Math.Sin(-((step * i + 180) % 360) * (Math.PI / 180)) * textRadiusX; var textY = (Height / 2) + Math.Cos(-((step * i + 180) % 360) * (Math.PI / 180)) * textRadiusY; textblock.SetValue(Canvas.LeftProperty, textX - textblock.ActualWidth / 2); textblock.SetValue(Canvas.TopProperty, textY - textblock.ActualHeight / 2); ClockLayout.Children.Add(textblock); } line.StrokeThickness = 4; ClockLayout.Children.Add(line); } DrawHourHand(); DrawMinuteHand(); DrawSecondHand(); }
public void UpdateText() { if (!_updating) { _updating = true; CAXamlDebugCounters._singleton.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () => { if (textOutput == null) { textOutput = new TextBlock(); textOutput.FontSize = 14; textOutput.Text = name; textOutput.SetValue(Canvas.LeftProperty, 0); textOutput.SetValue(Canvas.TopProperty, 30 + idx * 17.0); CAXamlDebugCounters._singleton.Children.Add(textOutput); CAXamlDebugCounters._singleton.InvalidateArrange(); CAXamlDebugCounters._singleton.InvalidateMeasure(); } _updating = false; textOutput.Text = String.Format("{0}: {1}", name, count); }); } }
private void InsertOrders(OrderType type) { orderGrid.Children.Clear(); orderGrid.RowDefinitions.Clear(); orderGrid.ColumnDefinitions.Clear(); List<OrderInfo> orders = null; switch(type) { case OrderType.NOT_PAY: orders = notPayOrders; break; case OrderType.PAYED: orders = payedOrders; break; case OrderType.COMPLETED: orders = completedOrders; break; default: break; } if(null == orders) { return; } int count = orders.Count; for(int i=0; i<count; i++) { RowDefinition row = new RowDefinition(); //row.Height = new GridLength(orderGridSizeInfo.orderGridHeight); orderGrid.RowDefinitions.Add(row); } int nRow = 0; foreach(var item in orders) { Grid oneOrderGrid = new Grid(); oneOrderGrid.Background = new SolidColorBrush(Color.FromArgb(255,235,235,235)); //Init four panels RelativePanel topPanel = new RelativePanel(); topPanel.Background = new SolidColorBrush(Color.FromArgb(255,241,241,241)); topPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin; topPanel.Width = infoPanel.Width; Grid.SetColumn(topPanel, 0); Grid.SetRow(topPanel, 0); oneOrderGrid.Children.Add(topPanel); RelativePanel addressPanel = new RelativePanel(); addressPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin; addressPanel.Width = infoPanel.Width; addressPanel.Background = new SolidColorBrush(Color.FromArgb(255, 241, 241, 241)); Grid.SetColumn(addressPanel, 0); Grid.SetRow(addressPanel, 2); oneOrderGrid.Children.Add(addressPanel); //goods panel RelativePanel goodsGridPanel = new RelativePanel(); goodsGridPanel.Background = new SolidColorBrush(Color.FromArgb(255, 235, 235, 235)); //goodsGridPanel.Width = infoPanel.Width; goodsGridPanel.Height = orderGridSizeInfo.goodsPicHeight + 4 * orderGridSizeInfo.margin + orderGridSizeInfo.infoPanelHeight*2; //SlidePanel slidePanel = new SlidePanel(infoPanel.Width); //slidePanel.Add(goodsGridPanel,orderGridSizeInfo.goodsPicWidth); //Grid.SetColumn(slidePanel, 0); //Grid.SetRow(slidePanel, 1); //oneOrderGrid.Children.Add(slidePanel); //Grid.SetColumn(goodsGridPanel, 0); //Grid.SetRow(goodsGridPanel, 1); //oneOrderGrid.Children.Add(goodsGridPanel); RelativePanel buttonPanel = new RelativePanel(); buttonPanel.Background = new SolidColorBrush(Color.FromArgb(255, 241, 241, 241)); buttonPanel.Width = infoPanel.Width; buttonPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin*2; Grid.SetColumn(buttonPanel, 0); Grid.SetRow(buttonPanel, 3); buttonPanel.VerticalAlignment = VerticalAlignment.Top; oneOrderGrid.Children.Add(buttonPanel); RowDefinition topRow = new RowDefinition(); topRow.Height = new GridLength(topPanel.Height); oneOrderGrid.RowDefinitions.Add(topRow); RowDefinition goodsGridRow = new RowDefinition(); goodsGridRow.Height = new GridLength(goodsGridPanel.Height); oneOrderGrid.RowDefinitions.Add(goodsGridRow); RowDefinition addressRow = new RowDefinition(); addressRow.Height = new GridLength(addressPanel.Height); oneOrderGrid.RowDefinitions.Add(addressRow); RowDefinition buttonRow = new RowDefinition(); buttonRow.Height = new GridLength(buttonPanel.Height + orderGridSizeInfo.margin); oneOrderGrid.RowDefinitions.Add(buttonRow); #region order info panel items TextBlock topLeft = new TextBlock(); topLeft.Width = 80; topLeft.Height = orderGridSizeInfo.infoPanelHeight; topLeft.Text = "订单号"; topLeft.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51)); topLeft.Margin = new Thickness(20, 0, 0, 0); topLeft.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); topLeft.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); topPanel.Children.Add(topLeft); TextBlock topRight = new TextBlock(); topRight.Width = 150; topRight.Height = orderGridSizeInfo.infoPanelHeight; topRight.Text = item.id; topRight.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); topRight.Margin = new Thickness(0, 0, 20, 0); topRight.SetValue(RelativePanel.AlignRightWithPanelProperty, true); topRight.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); topRight.TextAlignment = TextAlignment.Right; topPanel.Children.Add(topRight); #endregion #region address panel item TextBlock addressLeft = new TextBlock(); addressLeft.Width = topPanel.Width / 2; addressLeft.Height = orderGridSizeInfo.infoPanelHeight; addressLeft.Margin = new Thickness(20,0,0,0); addressLeft.Text = "配送地址"; addressLeft.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); addressLeft.SetValue(RelativePanel.AlignLeftWithPanelProperty, true); addressLeft.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); addressPanel.Children.Add(addressLeft); TextBlock addressRight = new TextBlock(); addressRight.Width = 150; addressRight.Height = orderGridSizeInfo.infoPanelHeight; addressRight.Text = item.address; addressRight.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); addressRight.Margin = new Thickness(0,0,20,0); addressRight.TextAlignment = TextAlignment.Right; addressRight.SetValue(RelativePanel.AlignRightWithPanelProperty, true); addressRight.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); addressPanel.Children.Add(addressRight); #endregion #region button panel item TextBlock priceText = new TextBlock(); priceText.Width = 12; priceText.Height = 20; priceText.Text = "¥"; priceText.Name = "priceText"; priceText.Foreground = new SolidColorBrush(Color.FromArgb(255,253,40,3)); priceText.TextAlignment = TextAlignment.Left; priceText.SetValue(RelativePanel.AlignLeftWithPanelProperty, true); priceText.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); priceText.Margin = new Thickness(17, 0, 0, -32); buttonPanel.Children.Add(priceText); TextBlock priceNumberText = new TextBlock(); priceNumberText.Width = 70; priceNumberText.Height = orderGridSizeInfo.infoPanelHeight; priceNumberText.Text = item.price; priceNumberText.Foreground = new SolidColorBrush(Colors.Red); priceNumberText.FontSize = 20; priceNumberText.TextAlignment = TextAlignment.Left; priceNumberText.SetValue(RelativePanel.RightOfProperty, "priceText"); priceNumberText.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); priceNumberText.Margin = new Thickness(3, 0, 0, 0); buttonPanel.Children.Add(priceNumberText); Button btnPay = new Button(); if (item.payed.Equals("true")) { btnPay.Visibility = Visibility.Collapsed; } btnPay.Width = 100; btnPay.Height = orderGridSizeInfo.infoPanelHeight; btnPay.VerticalContentAlignment = VerticalAlignment.Center; btnPay.HorizontalContentAlignment = HorizontalAlignment.Center; btnPay.BorderThickness = new Thickness(0); btnPay.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 78, 0)); btnPay.Name = "btnPay"; TextBlock btnPayText = new TextBlock(); btnPayText.Text = "进行付款"; btnPayText.Foreground = new SolidColorBrush(Colors.White); btnPay.Content = btnPayText; //btnPay.Foreground = new SolidColorBrush(Colors.White); btnPay.Background = new SolidColorBrush(Color.FromArgb(255,255,78,0)); btnPay.SetValue(RelativePanel.AlignRightWithPanelProperty,true); btnPay.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); btnPay.Margin = new Thickness(0, 0, 20, 0); buttonPanel.Children.Add(btnPay); Button btnCancel = new Button(); btnCancel.Width = 100; btnCancel.Height = orderGridSizeInfo.infoPanelHeight; btnCancel.VerticalContentAlignment = VerticalAlignment.Center; btnCancel.HorizontalContentAlignment = HorizontalAlignment.Center; //btnCancel.Content = "取消订单"; TextBlock btnCancelText = new TextBlock(); btnCancelText.Text = "取消订单"; btnCancelText.Foreground = new SolidColorBrush(Colors.White); btnCancel.Content = btnCancelText; btnCancel.BorderThickness = new Thickness(0); btnCancel.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 148, 148, 148)); //btnCancel.Foreground = new SolidColorBrush(Colors.White); btnCancel.Background = new SolidColorBrush(Color.FromArgb(255,148,148,148)); btnCancel.Margin = new Thickness(0, 0, 5, 0); btnCancel.SetValue(RelativePanel.LeftOfProperty, "btnPay"); btnCancel.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); buttonPanel.Children.Add(btnCancel); #endregion #region goods detail panel item int goodsCount = item.goodsList.Count; double goodsGridPanelWidth = 0; for(int i=0; i< goodsCount; i++) { RelativePanel goodsItemPanel = new RelativePanel(); goodsItemPanel.Background = new SolidColorBrush(Color.FromArgb(255,224,224,224)); goodsItemPanel.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); goodsItemPanel.Margin = new Thickness(goodsGridPanelWidth + orderGridSizeInfo.margin,0,0,0); //goods name TextBlock goodsNameText = new TextBlock(); goodsNameText.Width = 60; goodsNameText.Height = orderGridSizeInfo.infoPanelHeight - 5; goodsNameText.Text = item.goodsList[i].name; goodsNameText.TextAlignment = TextAlignment.Left; goodsNameText.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51)); goodsNameText.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); goodsNameText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); goodsNameText.Margin = new Thickness(orderGridSizeInfo.margin,0,0,orderGridSizeInfo.margin); goodsItemPanel.Children.Add(goodsNameText); //goods number TextBlock numberText = new TextBlock(); numberText.Height = orderGridSizeInfo.infoPanelHeight - 5; numberText.Width = 25; numberText.Name = "number"; numberText.TextAlignment = TextAlignment.Right; numberText.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51)); numberText.Text = "x" + Convert.ToString(item.goodsList[i].count); numberText.SetValue(RelativePanel.AlignRightWithPanelProperty,true); numberText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); numberText.Margin = new Thickness(0,0, orderGridSizeInfo.margin, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(numberText); //goods price TextBlock singlePriceText = new TextBlock(); singlePriceText.Height = orderGridSizeInfo.infoPanelHeight; singlePriceText.Width = 30; singlePriceText.Name = "singlePriceText"; singlePriceText.TextAlignment = TextAlignment.Left; singlePriceText.FontSize = 20; singlePriceText.Foreground = new SolidColorBrush(Color.FromArgb(255, 253, 40, 3)); singlePriceText.Text = item.goodsList[i].price; singlePriceText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); singlePriceText.SetValue(RelativePanel.LeftOfProperty, "number"); singlePriceText.Margin = new Thickness(0,0,0, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(singlePriceText); TextBlock priceSymbol = new TextBlock(); priceSymbol.Height = orderGridSizeInfo.infoPanelHeight - 5; priceSymbol.Width = 20; priceSymbol.TextAlignment = TextAlignment.Right; priceSymbol.FontSize = 16; priceSymbol.Foreground = new SolidColorBrush(Color.FromArgb(255, 253, 40, 3)); priceSymbol.Text = "¥"; priceSymbol.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); priceSymbol.SetValue(RelativePanel.LeftOfProperty, "singlePriceText"); priceSymbol.Margin = new Thickness(0, 0, 0, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(priceSymbol); //pictrue name TextBlock picNameText = new TextBlock(); picNameText.Name = "picNameText"; picNameText.Height = orderGridSizeInfo.infoPanelHeight; picNameText.Width = orderGridSizeInfo.goodsPicWidth; picNameText.Text = item.goodsList[i].imageName; picNameText.TextAlignment = TextAlignment.Left; picNameText.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); picNameText.FontSize = 18; picNameText.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); picNameText.SetValue(RelativePanel.AboveProperty, "singlePriceText"); picNameText.Margin = new Thickness(orderGridSizeInfo.margin, 0, 0, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(picNameText); //goods picture Grid picGrid = new Grid(); RowDefinition row = new RowDefinition(); row.Height = new GridLength(orderGridSizeInfo.goodsPicHeight); ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(orderGridSizeInfo.goodsPicWidth); picGrid.RowDefinitions.Add(row); picGrid.ColumnDefinitions.Add(col); Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.White); border.BorderThickness = new Thickness(1); border.CornerRadius = new CornerRadius(3, 3, 3, 3); border.Background = item.goodsList[i].brush; picGrid.Children.Add(border); picGrid.SetValue(RelativePanel.AlignLeftWithPanelProperty, true); picGrid.SetValue(RelativePanel.AlignRightWithPanelProperty,true); picGrid.SetValue(RelativePanel.AlignTopWithPanelProperty,true); picGrid.SetValue(RelativePanel.AboveProperty, "picNameText"); picGrid.Margin = new Thickness(orderGridSizeInfo.margin, orderGridSizeInfo.margin, orderGridSizeInfo.margin, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(picGrid); goodsGridPanelWidth += (orderGridSizeInfo.goodsPicWidth + 3*orderGridSizeInfo.margin); goodsGridPanel.Children.Add(goodsItemPanel); } SlidePanel slidePanel = new SlidePanel(infoPanel.Width); goodsGridPanel.Width = goodsGridPanelWidth; slidePanel.Add(goodsGridPanel, orderGridSizeInfo.goodsPicWidth + orderGridSizeInfo.margin); Grid.SetColumn(slidePanel, 0); Grid.SetRow(slidePanel, 1); oneOrderGrid.Children.Add(slidePanel); #endregion Grid.SetColumn(oneOrderGrid, 0); Grid.SetRow(oneOrderGrid, nRow); orderGrid.Children.Add(oneOrderGrid); nRow++; } }
/// <summary> /// Setzt den Wert des DependencyProperty EmailText. /// </summary> /// <param name="attachedTextBlock">Der TextBlock, der als Email-TextBlock dient.</param> /// <param name="value">Der neue Wert.</param> public static void SetEmailText(TextBlock attachedTextBlock, string value) { if (attachedTextBlock != null) { attachedTextBlock.SetValue(EmailTextProperty, value); } }
// Associe au bouton passé en paramètre: une image (icône de l'équipement) et le nom de l'équipement /// <summary> /// Cette méthode associe à un bouton, un TextBlock (nom de la pièce ou de l'équipement) et une Image (icône de la pièce ou de l'équipement). /// </summary> /// <param name="image">Image (icône de la pièce ou de l'équipement).</param> /// <param name="nomIcone">TextBlock (nom de la pièce ou de l'équipement).</param> /// <param name="bouton">Bouton qui sera associé à une pièce ou un équipement</param> public void ajouterImageEtLabelAuBouton(Image image, TextBlock nomIcone, Button bouton) { Grid grilleBouton = new Grid(); grilleBouton.RowDefinitions.Add(new RowDefinition()); grilleBouton.RowDefinitions.Add(new RowDefinition()); image.SetValue(Grid.RowProperty, 0); //image sur la partie supérieure du bouton nomIcone.SetValue(Grid.RowProperty, 1); //textblock sur la partie inférieure du bouton grilleBouton.Children.Add(image); grilleBouton.Children.Add(nomIcone); bouton.Content = grilleBouton; }
private void populateRecipes() { // PivotItem pvt; int i = 0; if(recipeFinalList.Count == 0) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = "No Results"; TextBlock txtTitle = new TextBlock(); txtTitle.Text = "No Results Found"; txtTitle.Margin = new Thickness(10, 10, 10, 10); pivotItem.Content = txtTitle; pvtRecipes.Items.Add(pivotItem); } foreach(Model.Recipef2f recipe in recipeFinalList) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = recipe.Title; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol" + i.ToString(); BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("https://image.freepik.com/free-icon/favorites-star-outlined-symbol_318-69168.png"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; ; favorite.SetValue(Grid.ColumnProperty, 1); i++; StackPanel stk = new StackPanel(); stk.SetValue(Grid.ColumnProperty, 1); stk.Name = "recipeStk"; stk.Children.Add(favorite); TextBlock txtTitle= new TextBlock(); txtTitle.Text = "Title: " + recipe.Title; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.RecipeId; txtRecipeId.Margin = new Thickness(10,10,10,10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.IngredientsList; txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.SocialRank.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.Publisher; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtPublisherUrl = new TextBlock(); txtPublisherUrl.Text = "Publisher URL: " + recipe.PublisherUrl; txtPublisherUrl.Margin = new Thickness(10, 10, 10, 10); txtPublisherUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisherUrl); TextBlock txtSourceUrl = new TextBlock(); txtSourceUrl.Text = "Source URL: " + recipe.SourceUrl; txtSourceUrl.Margin = new Thickness(10, 10, 10, 10); txtSourceUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSourceUrl); TextBlock txtF2fUrl = new TextBlock(); txtF2fUrl.Text = "F2F URL: " + recipe.F2fUrl; txtF2fUrl.Margin = new Thickness(10, 10, 10, 10); txtF2fUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtF2fUrl); grid.Children.Add(stk); pivotItem.Content = grid; pvtRecipes.Items.Add(pivotItem); } }
private void populateRecipes() { // PivotItem pvt; if(listRecipes.Count == 0 && listf2fRecipe.Count == 0) { PivotItem pivotItem = new PivotItem(); pivotItem.Header ="Favorites"; TextBlock txtTitle = new TextBlock(); txtTitle.Text = "No Favorites at this Point"; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); pivotItem.Content = txtTitle; pvtFavorites.Items.Add(pivotItem); } int yummly = 0; int i = 0; foreach (Model.ResponseYummly recipe in listRecipes) { PivotItem pivotItem = new PivotItem(); pivotItem.Name = "yummly" + yummly.ToString(); yummly++; pivotItem.Header = recipe.RecipeName; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol" + i.ToString(); i++; BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("http://images.all-free-download.com/images/graphiclarge/favorite_icon_55521.jpg"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; favorite.SetValue(Grid.ColumnProperty, 1); StackPanel stk = new StackPanel(); stk.Name = "recipeStk"; stk.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(favorite); TextBlock txtTitle = new TextBlock(); txtTitle.Text = "Title: " + recipe.RecipeName; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.Id; txtRecipeId.Margin = new Thickness(10, 10, 10, 10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.Ingredients.Replace("\",", "\n"); txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.Rating.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.SourceDisplayName; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtTotalTime = new TextBlock(); txtTotalTime.Text = "Total Time (seconds): " + recipe.TotalTime.ToString(); txtTotalTime.Margin = new Thickness(10, 10, 10, 10); txtTotalTime.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTotalTime); TextBlock txtCourse = new TextBlock(); txtCourse.Text = "Courses: " + recipe.Course; txtCourse.Margin = new Thickness(10, 10, 10, 10); txtCourse.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCourse); TextBlock txtCusine = new TextBlock(); txtCusine.Text = "Cuisine: " + recipe.Cuisine; txtCusine.Margin = new Thickness(10, 10, 10, 10); txtCusine.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCusine); TextBlock txtFlavors = new TextBlock(); txtFlavors.Text = "Flavors: " + recipe.Flavors.Replace(",\"", "\n"); txtFlavors.Margin = new Thickness(10, 10, 10, 10); txtFlavors.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtFlavors); grid.Children.Add(stk); pivotItem.Content = grid; pvtFavorites.Items.Add(pivotItem); } int f2f = 0; foreach (Model.Recipef2f recipe in listf2fRecipe) { PivotItem pivotItem = new PivotItem(); pivotItem.Name = "f2f" + f2f.ToString(); f2f++; pivotItem.Header = recipe.Title; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol" + i.ToString(); i++; BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("http://images.all-free-download.com/images/graphiclarge/favorite_icon_55521.jpg"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; favorite.SetValue(Grid.ColumnProperty, 1); StackPanel stk = new StackPanel(); stk.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(favorite); TextBlock txtTitle = new TextBlock(); txtTitle.Text = "Title: " + recipe.Title; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.RecipeId; txtRecipeId.Margin = new Thickness(10, 10, 10, 10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.IngredientsList; txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.SocialRank.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.Publisher; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtPublisherUrl = new TextBlock(); txtPublisherUrl.Text = "Publisher URL: " + recipe.PublisherUrl; txtPublisherUrl.Margin = new Thickness(10, 10, 10, 10); txtPublisherUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisherUrl); TextBlock txtSourceUrl = new TextBlock(); txtSourceUrl.Text = "Source URL: " + recipe.SourceUrl; txtSourceUrl.Margin = new Thickness(10, 10, 10, 10); txtSourceUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSourceUrl); TextBlock txtF2fUrl = new TextBlock(); txtF2fUrl.Text = "F2F URL: " + recipe.F2fUrl; txtF2fUrl.Margin = new Thickness(10, 10, 10, 10); txtF2fUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtF2fUrl); grid.Children.Add(stk); pivotItem.Content = grid; pvtFavorites.Items.Add(pivotItem); } }
public void postXMLData1(GetAvailableService Get) { try { var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { string uri = AppStatic.WebServiceBaseURL; Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute); GetSeatlayoutRequest _objSLR = new GetSeatlayoutRequest(); _objSLR.franchUserID = AppStatic.franchUserID; _objSLR.password = AppStatic.password; _objSLR.userID = AppStatic.userID; _objSLR.userKey = AppStatic.userKey; _objSLR.userName = AppStatic.userName; _objSLR.userRole = AppStatic.userRole; _objSLR.userStatus = AppStatic.userStatus; _objSLR.userType = AppStatic.userType; _objSLR.placeIDFrom = Get.placeIDFrom; _objSLR.placeCodeFrom = Get.placeCodeFrom; _objSLR.placeNameFrom = Get.placeNameFrom; _objSLR.placeIDto = Get.placeIDto; _objSLR.placeCodeTo = Get.placeCodeTo; _objSLR.placeNameTo = Get.placeNameTo; _objSLR.journeyDate = Get.journeyDate; _objSLR.classID = Get.classID; _objSLR.classLayoutID = Get.classLayoutID; _objSLR.serviceID = Get.serviceID; _objSLR.placeCodestuFromPlace = txthplaceCodeStatusFrm.Text; _objSLR.placeCodestuToPlace = txthplaceCodeStatusTo.Text; _objSLR.placeIDstuFromPlace = txthplaceIDStatusFrm.Text; _objSLR.placeIDstuToPlace = txthplaceIDStatusTo.Text; _objSLR.placeNamestuFromPlace = txthplaceNameStatusFrm.Text; _objSLR.placeNamestuToPlace = txthplaceNameStatusTo.Text; _objSLR.studID = Get.studID; _objSLR.totalPassengers = "?"; xmlUtility listings = new xmlUtility(); XDocument element = listings.getlayout(_objSLR); string stringXml = element.ToString(); var httpClient = new Windows.Web.Http.HttpClient(); var info = AppStatic.WebServiceAuthentication; var token = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info)); httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token); httpClient.DefaultRequestHeaders.Add("SOAPAction", ""); Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url); httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0"); IHttpContent content = new HttpStringContent(stringXml, Windows.Storage.Streams.UnicodeEncoding.Utf8); httpRequestMessage.Content = content; Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage); string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync(); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(strXmlReturned); XDocument loadedData = XDocument.Parse(strXmlReturned); List<XElement> _listResponse = (from t1 in loadedData.Descendants("wsResponse") select t1).ToList(); List<getSeatlayout> responsList = new List<getSeatlayout>(); string _msg = ""; if (_listResponse != null) { foreach (XElement _elemet in _listResponse) { getSeatlayout _obj = new getSeatlayout(); _obj.message = _elemet.Element("message").Value.ToString(); responsList.Add(_obj); } _msg = responsList.FirstOrDefault().message.ToString(); } if (_msg != "FAILURE") { var sdata = loadedData.Descendants("Seatlayout"). Select(x => new getSeatlayout { availableSeatNos = x.Element("availableSeatNos").Value, bookedSeatNos = x.Element("bookedSeatNos").Value, conductorSeatNo = x.Element("conductorSeatNo").Value, ladiesAvailableSeatNos = x.Element("ladiesAvailableSeatNos").Value, ladiesBookedSeatNos = x.Element("ladiesBookedSeatNos").Value, maxColCount = x.Element("maxColCount").Value, maxRowCount = x.Element("maxRowCount").Value, column = x.Element("seatDetails").Element("seats").Element("column").Value, quota = x.Element("seatDetails").Element("seats").Element("quota").Value, row = x.Element("seatDetails").Element("seats").Element("row").Value, seatNo = x.Element("seatDetails").Element("seats").Element("seatNo").Value, seatStatus = x.Element("seatDetails").Element("seats").Element("seatStatus").Value, type = x.Element("seatDetails").Element("seats").Element("type").Value, busID = x.Element("service").Element("busID").Value, distance = x.Element("service").Element("distance").Value, endPoint = x.Element("service").Element("endPoint").Value, startPoint = x.Element("service").Element("startPoint").Value, placeCodestuFromPlace = x.Element("stuFromPlace").Element("placeCode").Value, placeIDstuFromPlace = x.Element("stuFromPlace").Element("placeID").Value, placeNamestuFromPlace = x.Element("stuFromPlace").Element("placeName").Value, placeCodestuToPlace = x.Element("stuToPlace").Element("placeCode").Value, placeIDstuToPlace = x.Element("stuToPlace").Element("placeID").Value, placeNamestuToPlace = x.Element("stuToPlace").Element("placeName").Value, totalSeats = x.Element("totalSeats").Value, message = x.Element("wsResponse").Element("message").Value, statusCode = x.Element("wsResponse").Element("statusCode").Value }); foreach (var item in sdata) { _objS.placeCodestuFromPlace = item.placeCodestuFromPlace; _objS.placeIDstuFromPlace = item.placeIDstuFromPlace; _objS.placeNamestuFromPlace = item.placeNamestuFromPlace; _objS.placeCodestuToPlace = item.placeCodestuToPlace; _objS.placeIDstuToPlace = item.placeIDstuToPlace; _objS.placeNamestuToPlace = item.placeNamestuToPlace; _getStudDetails.Add(_objS); break; } int maxrowCount; int maxcolcount; var _listCol = (from t1 in loadedData.Descendants("maxColCount") select t1).FirstOrDefault(); var _listRow = (from t1 in loadedData.Descendants("maxRowCount") select t1).FirstOrDefault(); maxcolcount = Convert.ToInt32(_listCol.Value.ToString()); maxrowCount = Convert.ToInt32(_listRow.Value.ToString()); int b = maxrowCount; int a = maxcolcount; for (int r = 0; r <= a; r++) { Mygrid.RowDefinitions.Add(new RowDefinition()); } for (int c = 0; c < b; c++) { Mygrid.ColumnDefinitions.Add(new ColumnDefinition()); } List<XElement> _srow = (from t1 in loadedData.Descendants("seats") select t1).ToList(); List<getSeatlayout> srow = new List<getSeatlayout>(); foreach (XElement _elemetsr in _srow) { Image img = new Image(); TextBlock txtSeatnumber = new TextBlock(); TextBlock txtType = new TextBlock(); txtSeatnumber.Visibility = Visibility.Visible; getSeatlayout _objsr = new getSeatlayout(); _objsr.row = _elemetsr.Element("row").Value.ToString(); _objsr.column = _elemetsr.Element("column").Value.ToString(); _objsr.seatNo = _elemetsr.Element("seatNo").Value.ToString(); _objsr.type = _elemetsr.Element("type").Value.ToString(); _objsr.quota = _elemetsr.Element("quota").Value.ToString(); _objsr.seatStatus = _elemetsr.Element("seatStatus").Value.ToString(); srow.Add(_objsr); c = Convert.ToInt32(srow.LastOrDefault().row.ToString()); r = Convert.ToInt32(srow.LastOrDefault().column.ToString()); s = Convert.ToInt32(srow.LastOrDefault().seatNo.ToString()); t = srow.LastOrDefault().type.ToString(); q = srow.LastOrDefault().quota.ToString(); SeatS = srow.LastOrDefault().seatStatus.ToString(); int nn = -(r - (a + 1)); img.SetValue(Grid.ColumnProperty, c - 1); img.SetValue(Grid.RowProperty, nn - 1); txtSeatnumber.SetValue(Grid.ColumnProperty, c - 1); txtSeatnumber.SetValue(Grid.RowProperty, nn - 1); txtType.SetValue(Grid.ColumnProperty, c - 1); txtType.SetValue(Grid.RowProperty, nn - 1); txtType.FontSize = 12; txtType.Text = t.ToString(); txtType.Foreground = new SolidColorBrush(Colors.Black); txtType.Margin = new Thickness { Left = 20, Top = 95, Right = 0, Bottom = 0 }; txtSeatnumber.FontSize = 12; txtSeatnumber.Text = s.ToString(); txtSeatnumber.Foreground = new SolidColorBrush(Colors.Black); txtSeatnumber.Margin = new Thickness { Left = 5, Top = 95, Right = 0, Bottom = 0 }; img.Height = 40; img.Width = 40; img.Margin = new Thickness { Left = 0, Top = 40, Right = 0, Bottom = 0 }; if (SeatS == "AVAILABLE") { img.Name = txtSeatnumber.Text + txtType.Text; img.Source = new BitmapImage(new System.Uri("ms-appx:///Assets/Seats/ss_empty_seat.png")); img.Tapped += img_Tapped; } else { img.Source = new BitmapImage(new System.Uri("ms-appx:///Assets/Seats/ss_booked_seat.png")); } for (int row = 0; row < Mygrid.RowDefinitions.Count; row++) { for (int column = 0; column < Mygrid.ColumnDefinitions.Count; column++) { if (nn == row && c == column) { txtSeatnumber.Visibility = Visibility.Visible; txtType.Visibility = Visibility.Visible; img.Visibility = Visibility.Visible; Mygrid.Children.Add(txtSeatnumber); Mygrid.Children.Add(img); Mygrid.Children.Add(txtType); } } } } LoderPopup.Visibility = Visibility.Collapsed; } else { LoderPopup.Visibility = Visibility.Collapsed; } }).AsTask(); } catch (Exception e) { var messagedialog = new Windows.UI.Popups.MessageDialog("There is service not available"); } }
private DependencyObject createPin() { //Creating a Grid element. var myGrid = new Grid(); myGrid.Height = 140; myGrid.Width = 210; myGrid.Background = new ImageBrush() { ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/box.png")) }; //adding stackpanel var mystack = new StackPanel(); var img = new Image(); img.Height = 25; img.Width = 35; img.Stretch = Stretch.UniformToFill; img.Source = new BitmapImage(new Uri("ms-appx:///Assets/plane1.png")); img.HorizontalAlignment = HorizontalAlignment.Center; mystack.Children.Add(img); var flightcs = new TextBlock() { FontSize = 15, Foreground = new SolidColorBrush(Colors.Red), HorizontalAlignment = HorizontalAlignment.Center, Text = "G9-345" }; mystack.Children.Add(flightcs); var ngrid = new Grid(); ngrid.Margin = new Thickness(5, 0, 5, 0); ngrid.RowDefinitions.Add(new RowDefinition()); ngrid.RowDefinitions.Add(new RowDefinition()); ngrid.ColumnDefinitions.Add(new ColumnDefinition()); ngrid.ColumnDefinitions.Add(new ColumnDefinition()); var alttb = new TextBlock() { FontSize = 15, Foreground = new SolidColorBrush(Colors.Black), Text = "Altitude" }; alttb.SetValue(Grid.RowProperty, 0); alttb.SetValue(Grid.ColumnProperty, 0); ngrid.Children.Add(alttb); var alttb1 = new TextBlock() { FontSize = 15, Foreground = new SolidColorBrush(Colors.Black), Text="15000 ft" }; alttb1.SetValue(Grid.RowProperty, 0); alttb1.SetValue(Grid.ColumnProperty, 1); ngrid.Children.Add(alttb1); var sptb = new TextBlock() { FontSize = 15, Foreground = new SolidColorBrush(Colors.Black), Text = "Speed" }; sptb.SetValue(Grid.RowProperty, 1); sptb.SetValue(Grid.ColumnProperty, 0); ngrid.Children.Add(sptb); var sptb1 = new TextBlock() { FontSize = 15, Foreground = new SolidColorBrush(Colors.Black), Text="500 Knt" }; sptb1.SetValue(Grid.RowProperty, 1); sptb1.SetValue(Grid.ColumnProperty, 1); ngrid.Children.Add(sptb1); mystack.Children.Add(ngrid); var nstack = new StackPanel() { Orientation = Orientation.Horizontal, Margin = new Thickness(5, 5, 5, 0) }; var ntb = new TextBlock() { FontSize = 15, Foreground = new SolidColorBrush(Colors.Black), Text = "2017-07-07" }; nstack.Children.Add(ntb); var ntb1 = new TextBlock() { FontSize = 15, Foreground = new SolidColorBrush(Colors.Black), Margin = new Thickness(20, 0, 0, 0), Text = "9:00:00 AM" }; nstack.Children.Add(ntb1); mystack.Children.Add(nstack); myGrid.Children.Add(mystack); return myGrid; }
public static void SetHighlightBrush(TextBlock element, Brush value) { element.SetValue(HighlightBrushProperty, value); }