private void LabelGrid_MouseEnter(object sender, MouseEventArgs e) { MyGrid mg = sender as MyGrid; mg.Background = getDarkDailyColor(); }
public async void loadBookmarkAPI() { Bookmark bookmark = new Bookmark(); foreach (BookmarkData bd in bookmark.getHistory()) { MyGrid LabelGrid = new MyGrid(); LabelGrid.CityName = bd.CityName; LabelGrid.Background = getLightDailyColor(); LabelGrid.PreviewMouseDown += LabelGrid_PreviewMouseDown; LabelGrid.MouseEnter += LabelGrid_MouseEnter; LabelGrid.MouseLeave += LabelGrid_MouseLeave; LabelGrid.Margin = new Thickness(20, 20, 20, 20); LabelGrid.Height = 130; LabelGrid.Width = 200; LabelGrid.ColumnDefinitions.Clear(); LabelGrid.RowDefinitions.Clear(); LabelGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) }); LabelGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(4, GridUnitType.Star) }); LabelGrid.RowDefinitions.Clear(); BasicWeatherRecord bwr = await WeatherProcess.LoadBasicWeatherRecord(bd.CityName); LabelGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(4, GridUnitType.Star) }); LabelGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(4, GridUnitType.Star) }); LabelGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(2.5, GridUnitType.Star) }); LabelGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(2.5, GridUnitType.Star) }); Label cityName = new Label(); cityName.Content = bd.CityName; cityName.FontSize = 22; cityName.HorizontalAlignment = HorizontalAlignment.Center; cityName.Foreground = new SolidColorBrush(Colors.White); MyGrid.SetRow(cityName, 0); MyGrid.SetColumnSpan(cityName, 2); LabelGrid.Children.Add(cityName); Label currTemp = new Label(); currTemp.Content = Convert.ToInt32(bwr.Main.Temp) + "°C"; currTemp.FontSize = 22; currTemp.Foreground = new SolidColorBrush(Colors.White); MyGrid.SetRow(currTemp, 1); MyGrid.SetColumnSpan(currTemp, 2); currTemp.HorizontalAlignment = HorizontalAlignment.Center; LabelGrid.Children.Add(currTemp); Label maxTemp = new Label(); maxTemp.Content = "Max: " + Convert.ToInt32(bwr.Main.Temp_max) + "°C"; //maxTemp.FontSize = 15; maxTemp.Foreground = new SolidColorBrush(Colors.White); MyGrid.SetRow(maxTemp, 2); MyGrid.SetColumn(maxTemp, 1); maxTemp.HorizontalAlignment = HorizontalAlignment.Right; LabelGrid.Children.Add(maxTemp); Label minTemp = new Label(); minTemp.Content = "Min: " + Convert.ToInt32(bwr.Main.Temp_min) + "°C"; //minTemp.FontSize = 15; minTemp.HorizontalAlignment = HorizontalAlignment.Right; minTemp.Foreground = new SolidColorBrush(Colors.White); MyGrid.SetRow(minTemp, 3); MyGrid.SetColumn(minTemp, 1); LabelGrid.Children.Add(minTemp); Label description = new Label(); description.Content = bwr.Weathers[0].Main; description.Foreground = new SolidColorBrush(Colors.White); MyGrid.SetRow(description, 3); MyGrid.SetColumn(description, 0); LabelGrid.Children.Add(description); Image image = new Image(); image.Source = getImage(bwr.Weathers[0].Icon); image.HorizontalAlignment = HorizontalAlignment.Left; MyGrid.SetColumn(image, 0); MyGrid.SetRow(image, 2); LabelGrid.Children.Add(image); //I want to creatre the Seperate coloum and row to display KEY // VALUE Pair distinctly bookmarkList.Children.Add(LabelGrid); } }
private void LabelGrid_MouseLeave(object sender, MouseEventArgs e) { MyGrid mg = sender as MyGrid; mg.Background = getLightDailyColor(); }