コード例 #1
0
        public UserNotificationHistoryPage(string username)
        {
            try
            {
                _client = new OMGITServiceClient(binding, EndPoint);
                _client.AddLogMessageMobileAsync("In User Notification History Page", "", 0, GlobalData.loginData);

                HistoryGrid.RowDefinitions.Add(new RowDefinition {
                    Height = 25
                });

                int i = 1;
                while (i <= PageSize + 1)
                {
                    HistoryGrid.RowDefinitions.Add(new RowDefinition {
                        Height = 35
                    });
                    i += 1;
                }
                HistoryGrid.RowDefinitions.Add(new RowDefinition {
                    Height = 35
                });

                HistoryGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                HistoryGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                HistoryGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                HistoryGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                HistoryGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });

                HistoryGrid.Children.Add(SenderLabel, 0, 0);
                HistoryGrid.Children.Add(SentToLabel, 1, 0);
                HistoryGrid.Children.Add(EmailLabel, 2, 4, 0, 1);
                HistoryGrid.Children.Add(TimeLabel, 4, 0);


                _client.Report_GetUserNotificationHistoryCompleted += ClientReport_GetUserNotificationHistoryCompleted;
                _client.Report_GetUserNotificationHistoryAsync(username, GlobalData.loginData);

                while (UserHistory.Count < 1)
                {
                    continue;
                }

                NumPages += UserHistory.Count / PageSize;

                i = 1;

                int remainder = UserHistory.Count % PageSize;

                while (i < NumPages)
                {
                    System.Collections.Generic.Dictionary <int, OMGITWebServices.OMGUserNotificationHistoryRow> temp = UserHistory.Skip((i - 1) * PageSize).Take(PageSize).ToDictionary(x => x.Key, x => x.Value);
                    UserHistoryList.Add(temp);
                    i += 1;
                }

                System.Collections.Generic.Dictionary <int, OMGITWebServices.OMGUserNotificationHistoryRow> lastPage = UserHistory.Skip((i - 1) * PageSize).Take(remainder).ToDictionary(x => x.Key, x => x.Value);
                UserHistoryList.Add(lastPage);



                i = 1;

                foreach (KeyValuePair <int, OMGITWebServices.OMGUserNotificationHistoryRow> kvp in UserHistoryList[0])
                {
                    var SenderName = new Label {
                        HorizontalTextAlignment = TextAlignment.Start, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)), Text = kvp.Value.SenderUserName, TextColor = Color.White, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Fill
                    };
                    var SentToName = new Label {
                        HorizontalTextAlignment = TextAlignment.Start, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)), Text = kvp.Value.SentToUserName, TextColor = Color.White, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Fill
                    };
                    var EmailAddress = new Label {
                        HorizontalTextAlignment = TextAlignment.Start, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = Color.White, Text = kvp.Value.EmailAddress
                    };
                    var SentTime = new Label {
                        HorizontalTextAlignment = TextAlignment.Start, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = Color.White, Text = kvp.Value.SendTime
                    };


                    HistoryGrid.Children.Add(SenderName, 0, i);
                    HistoryGrid.Children.Add(SentToName, 1, i);
                    HistoryGrid.Children.Add(EmailAddress, 2, 4, i, i + 1);
                    HistoryGrid.Children.Add(SentTime, 4, i);


                    i += 1;
                }


                var FirstPageButton = new Button();
                var PrevPageButton  = new Button();
                var CurPageButton   = new Button();
                var NextPageButton  = new Button();
                var LastPageButton  = new Button();

                if (Device.OS == TargetPlatform.Android)
                {
                    FirstPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "<<", IsEnabled = false
                    };
                    PrevPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "< Prev", IsEnabled = false
                    };
                    CurPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = CurrentPage.ToString() + "/" + NumPages.ToString()
                    };
                    if (NumPages == 1)
                    {
                        NextPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "Next >", IsEnabled = false
                        };
                        LastPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = ">>", IsEnabled = false
                        };
                    }
                    else
                    {
                        NextPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "Next >"
                        };
                        LastPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = ">>"
                        };
                    }
                }
                else
                {
                    FirstPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "<<", IsEnabled = false
                    };
                    PrevPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "< Prev", IsEnabled = false
                    };
                    CurPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = CurrentPage.ToString() + "/" + NumPages.ToString()
                    };
                    if (NumPages == 1)
                    {
                        NextPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "Next >", IsEnabled = false
                        };
                        LastPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = ">>", IsEnabled = false
                        };
                    }
                    else
                    {
                        NextPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "Next >"
                        };
                        LastPageButton = new Button {
                            FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = ">>"
                        };
                    }
                }

                FirstPageButton.Clicked += FirstPageButton_Clicked;
                PrevPageButton.Clicked  += PrevPageButton_Clicked;
                NextPageButton.Clicked  += NextPageButton_Clicked;
                LastPageButton.Clicked  += LastPageButton_Clicked;



                HistoryGrid.Children.Add(FirstPageButton, 0, PageSize + 2);
                HistoryGrid.Children.Add(PrevPageButton, 1, PageSize + 2);
                HistoryGrid.Children.Add(CurPageButton, 2, PageSize + 2);
                HistoryGrid.Children.Add(NextPageButton, 3, PageSize + 2);
                HistoryGrid.Children.Add(LastPageButton, 4, PageSize + 2);

                Logout.Clicked += Logout_Clicked;

                HistoryLayout.Children.Add(Logout);
                HistoryLayout.Children.Add(HistoryGrid);

                HistoryScrollView.Content = HistoryLayout;

                Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

                Content = HistoryScrollView;
            }
            catch (Exception ex) { string msg = ex.Message.ToString(); }
        }