public ProjectVM(ITrimbleConnectClient client, Project entity)
            {
                this.Entity      = entity;
                this.Name        = entity.Name;
                this.Description = entity.Description;

                if (this.Entity.ThumbnailUrl != null && this.Entity.ThumbnailUrl.StartsWith("http"))
                {
                    this.ImageSource = ImageSource.FromStream(() => new ThumbnailImageSource(client.GetProjectClientAsync(this.Entity).Result).GetStream(this.Entity.ThumbnailUrl).Result);
                }
            }
        public ProjectListPage(ITrimbleConnectClient client)
        {
            this.client = client;

            this.Title = "Projects";

            this.RefreshAsync();

            var listView = new ListView
            {
                ItemsSource = this.items,

                ItemTemplate = new DataTemplate(() =>
                {
                    var cell = new ImageCell();
                    cell.SetBinding <ProjectVM>(TextCell.TextProperty, _ => _.Name);
                    cell.SetBinding <ProjectVM>(TextCell.DetailProperty, _ => _.Description);
                    cell.SetBinding <ProjectVM>(ImageCell.ImageSourceProperty, _ => _.ImageSource);

                    cell.Tapped += async delegate
                    {
                        var project = (ProjectVM)cell.BindingContext;
                        await this.Navigation.PushAsync(new ProjectPage(await this.client.GetProjectClientAsync(project.Entity), project.Entity));
                    };

                    return(cell);
                }),
                IsPullToRefreshEnabled = true,
            };

            listView.RefreshCommand = new Command(async() =>
            {
                try
                {
                    await this.RefreshAsync();
                }
                finally
                {
                    listView.IsRefreshing = false;
                }
            });
            this.Content = listView;
        }
Exemple #3
0
        public MainPage(ITrimbleConnectClient client)
        {
            this.client = client;

            this.Title = "Trimble Connect";

            this.Master = new ContentPage
            {
                Title           = "E",
                BackgroundColor = Color.FromHex(Constants.MENU_PAGE_ITEM_BG_SEL),
                Content         = new StackLayout
                {
                    Padding = 20,
                    Spacing = 20,

                    Children =
                    {
                        new Image()
                        {
                            Source = ImageSource.FromFile("ic_user_account.png"),
                            Aspect = Aspect.AspectFit,
                        },

                        new Label
                        {
                            Text              = AppState.CurrentUser.UserInfo.FamilyName + " " + AppState.CurrentUser.UserInfo.GivenName,
                            TextColor         = Color.White,
                            HorizontalOptions = LayoutOptions.Center,
                        },

                        new Label
                        {
                            Text              = AppState.CurrentUser.UserInfo.DisplayableId,
                            TextColor         = Color.White,
                            HorizontalOptions = LayoutOptions.Center,
                        },

                        new Button
                        {
                            Text            = "NetStats",
                            TextColor       = Color.White,
                            BackgroundColor = Color.FromHex(Constants.LOGIN_BUTTON_ENABLED_COLOR),
                            Command         = new Command(
                                async() =>
                            {
                                await this.Detail.Navigation.PushAsync(new StatsPage());
                                this.IsPresented = false;
                            })
                        },

                        new Button
                        {
                            Text            = "Log out",
                            TextColor       = Color.White,
                            BackgroundColor = Color.FromHex(Constants.LOGIN_BUTTON_ENABLED_COLOR),
                            Command         = new Command(
                                () =>
                            {
                                ((TrimbleConnectClient)AppState.Client).Dispose();
                                AppState.Client      = null;
                                App.Current.MainPage = new LoginPage();
                            })
                        },
                    }
                }
            };

            // Create the detail page using NamedColorPage and wrap it in a
            // navigation page to provide a NavigationBar and Toggle button
            this.Detail = new NavigationPage(new ProjectListPage(this.client))
            {
                BarBackgroundColor = Color.FromHex(Constants.NAV_BAR_COLOR),
                BarTextColor       = Color.FromHex(Constants.NAV_BAR_TEXT_COLOR),
            };

            // For Android & Windows Phone, provide a way to get back to the master page.
            if (Device.OS != TargetPlatform.iOS)
            {
                TapGestureRecognizer tap = new TapGestureRecognizer();
                tap.Tapped += (sender, args) => {
                    this.IsPresented = true;
                };
            }
        }