Facebook
From Cobalt Penguin, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 229
  1. public void InitializeInterface()
  2.         {
  3.             try
  4.             {
  5.                 var layout = new StackLayout() { Spacing = 0 };
  6.  
  7.                 ScrollView clientscroll = new ScrollView
  8.                 {
  9.                     Padding = new Thickness(0, 10, 15, 10),
  10.                     HeightRequest = 50,
  11.                     WidthRequest = 50,
  12.                     Orientation = ScrollOrientation.Vertical,
  13.                     VerticalOptions = LayoutOptions.Fill,
  14.                     HorizontalOptions = LayoutOptions.Fill,
  15.                     Content = new StackLayout
  16.                     {
  17.                         Orientation = StackOrientation.Vertical,
  18.                         Children = { layout }
  19.                     }
  20.                 };
  21.                 Content = clientscroll;
  22.  
  23.                 for (int i = 0; i < scheduleData.schedule.Count; i++)
  24.                 {
  25.                     var dayLabel = new Label
  26.                     {
  27.                         Text = DateHelper.GetDate(scheduleData.schedule[i].Day.Date),
  28.                         Font = Font.SystemFontOfSize(15, FontAttributes.Bold),
  29.                         HorizontalOptions = LayoutOptions.Center,
  30.                         WidthRequest = AppConfig.DayLabelWidth,
  31.                         HeightRequest = AppConfig.DayLabelHeight,
  32.                         TextColor = Color.Black,
  33.                         BackgroundColor = Color.FromHex(AppConfig.DayLabelBackgroundColorHex)
  34.                     };
  35.                     layout.Children.Add(dayLabel);
  36.  
  37.                     for (int j = 0; j < scheduleData.schedule[i].Events.Count; j++)
  38.                     {
  39.                         var EventRow = new StackLayout()
  40.                         {
  41.                             Spacing = 0,
  42.                             Orientation = StackOrientation.Horizontal
  43.                         };
  44.  
  45.                         var EventStatusImage = new Image()
  46.                         {
  47.                             HorizontalOptions = LayoutOptions.End,
  48.                             HeightRequest = AppConfig.EventStatusImageHeight,
  49.                             WidthRequest = AppConfig.EventStatusImageWidth,
  50.                             Source = EventStatusHelper.GetImageSource(scheduleData.schedule[i].Events[j])
  51.                         };
  52.  
  53.                         var button = new Button
  54.                         {
  55.                             Text = EventsMapper.GetName(scheduleData.schedule[i].Events[j].EventType) +
  56.                                    "\n" +
  57.                                    scheduleData.schedule[i].Events[j].EventStartTime + " - " +
  58.                                    scheduleData.schedule[i].Events[j].EventEndTime,
  59.                             //use string bilder?
  60.  
  61.                             HorizontalOptions = LayoutOptions.End,
  62.                             HeightRequest = AppConfig.EventButtonHeight,
  63.                             WidthRequest = AppConfig.EventButtonWidth,
  64.                             BackgroundColor = Color.FromHex(AppConfig.DomainColorHex),
  65.                             TextColor = Color.White,
  66.                         };
  67.                         var thisEvent = scheduleData.schedule[i].Events[j];
  68.  
  69.                         button.Clicked += async delegate
  70.                         {
  71.                             await Navigation.PushAsync(new EventDetailsPage(thisEvent, User));
  72.                         };
  73.  
  74.                     EventRow.Children.Add(EventStatusImage);
  75.                     EventRow.Children.Add(button);
  76.                     layout.Children.Add(EventRow);
  77.  
  78.                     eventsCount++;
  79.                     }
  80.                 }
  81.             }
  82.             catch(Exception e)
  83.             {
  84.                 // to do
  85.             }
  86.         }