Exemplo n.º 1
0
        public LoginPage()
        {
            ViewModel = new BaseViewModel{};
            BindingContext = ViewModel;
            DeviceDetail.UserKey = "";
			_database = new TokenDatabase();
            
            var layout = new StackLayout { Padding = 10};
           _message = new Label
            {
                Text = "",
                FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)),
                VerticalOptions = LayoutOptions.Center,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center,
                TextColor = Color.Red
            };
            
            var imgLogoImage = new Image {Source = "ecs.png"};
            layout.Children.Add(imgLogoImage);
            
			var spacer = new Label
			{
				Text = "",
				FontSize = 15,
				XAlign = TextAlignment.Center,
				YAlign = TextAlignment.Center,

			};


            var version = new Label
            {
                Text = "Version (0.0.0.2)",
				FontFamily = "HelveticaNeue-Medium",
                FontSize = 15,
				FontAttributes = FontAttributes.Bold,
                VerticalOptions = LayoutOptions.Center,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center,
                
            };
			layout.Children.Add (spacer);
            layout.Children.Add(version);

            _username = new Entry { Placeholder = "Username"};
            layout.Children.Add(_username);
            
            _password = new Entry { Placeholder = "Password", IsPassword = true };
            layout.Children.Add(_password);

            loginButton = new Button { Text = "Sign In" };
            loginButton.Clicked += async (sender, args) => await ValidateUser(_username.Text, _password.Text);
            layout.Children.Add(loginButton);
            layout.Children.Add(_message);

            
            // here's your activity indicator, it's bound to the IsBusy property of the BaseViewModel
            // those bindings are on both the visibility property as well as the IsRunning property
            var activityIndicator = new ActivityIndicator
            {
                Color = Color.Black
            };
            activityIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            layout.Children.Add(activityIndicator);

            var placeHolder = new Label
            {
                Text = "This software is proprietary and confidential to ECS and by using this software you agree that no part of the document that you would view may be disclosed in any manner to a third party without the prior written consent.",
                FontSize = Device.GetNamedSize(NamedSize.Default, typeof (Label)),
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.Black
            };
            layout.Children.Add(placeHolder);
            
            Content = new ScrollView()
            {
                Padding = 10,
                VerticalOptions = LayoutOptions.Start,
                Content = layout
                
            };
           

        }
Exemplo n.º 2
0
        public DocumentListPage(string search, string selectedFolderName, string parentName, string updatePath)
        {
            ViewModel = new BaseViewModel {};
            BindingContext = ViewModel;
            _updatePath = updatePath;
			_selectedFolderName = selectedFolderName;
            Title = string.IsNullOrEmpty(parentName) ? "" : parentName;
            _documentListView = new DocumentListView();
            
            _documentListView.ItemTapped += async (sender, e) =>
            {
                try
                {

                    if (CrossConnectivity.Current.IsConnected == false)
                    {
                        await DisplayAlert("Error", "Please check internet connectivity.", "OK");
                        return;
                    }

                    if (_documentListView.AcquireTapLock())
                    {
                        var selectedItem = (Document) e.Item;
                        if (!selectedItem.IsFolder)
                        {
                            int index = selectedItem.Name.LastIndexOf(".");

                            if (index > 0)
                            {
                                var fileExt = selectedItem.Name.Substring(index + 1);
                                if (ImageHelper.SuportedExtension.Contains(fileExt.ToLower()))
                                {
                                    await
                                        Navigation.PushAsync(new ContentPageXaml(selectedItem, _selectedFolderName,
                                            this.Navigation));
                                }
                                else
                                {
                                    await DisplayAlert("Error", "This file type is not suported for preview.", "OK");
                                }
                            }
                            else
                            {
                                await DisplayAlert("Error", "This file type is not suported for preview.", "OK");
                            }
                        }
                        else
                        {
                            string tempSelectedFolderName = selectedItem.Name;
                            string path = selectedItem.RelativePath + "/" + selectedItem.Name;

                            await
                                Navigation.PushAsync(
                                    new DocumentListPage(path, tempSelectedFolderName, _selectedFolderName, path), true);
                        }
                        _documentListView.ReleaseTapLock();
                        ((ListView) sender).SelectedItem = null;
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("Error", "An exception occurred.", "OK");
                }
                


            };

            _documentListView.Refreshing += async (sender, e) =>
            {
                try
                {
                    _documentListView.IsRefreshing = true;
                    lstDocuments = await Task.Run(() => GetUpdatedDocuments(search));
                    if (lstDocuments.Count > 0)
                    {
                        _documentListView.ItemsSource = null;
                        _documentListView.ItemsSource = lstDocuments;
                    }
                }
                catch (Exception ex)
                {
                   if (ex.Message.ToUpper().Equals(Constants.INVALID_TOKEN_MSG.ToUpper()))
                   {
                       DisplayAlert("Error","Your session has expired,please relogin.", "OK");
                       Application.Current.MainPage = new LoginPage();
                   }
                   else
                   {
                       DisplayAlert("Error","An exception occurred.", "OK");
                   }
                }
                finally
                {
                    _documentListView.EndRefresh();
                    _documentListView.IsRefreshing = false;
                }
            };
            
            Content = GetDocumentPage(_documentListView, "");
            Device.BeginInvokeOnMainThread(() => BindList(search));


        }