public void SetPageDisplay()
        {
            // Set the page title.
            //Title = "Expenses";
            Color asbestos = Color.FromHex("#7f8C8d");

            BackgroundColor = Color.White;
            //  Create a label for the expenses list
            _labelTitle            = new Xamarin.Forms.Label();
            _labelTitle.Text       = "EXPENSES";
            _labelTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null);
            _labelTitle.FontSize   = 22;
            _labelTitle.TextColor  = Color.White;
            _labelTitle.HorizontalTextAlignment = TextAlignment.Center;
            _labelTitle.VerticalTextAlignment   = TextAlignment.Center;

            Grid titleLayout = new Grid()
            {
                BackgroundColor   = Color.FromHex("#2980b9"),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 80
            };

            titleLayout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.Children.Add(_labelTitle, 0, 0);

            _pickerScheduledAppointment             = new BindablePicker();
            _pickerScheduledAppointment.Title       = "WORK TICKET";
            _pickerScheduledAppointment.ItemsSource = _vm.GetScheduledAppointments();
            _pickerScheduledAppointment.SetBinding(BindablePicker.DisplayPropertyProperty, "FormattedTicketNumber");
            _pickerScheduledAppointment.SelectedIndexChanged += PickerScheduledAppointmentt_SelectedIndexChanged;
            for (int i = 0; i < _pickerScheduledAppointment.Items.Count; i++)
            {
                if (_vm.WorkTicket != null && _pickerScheduledAppointment.Items[i] == _vm.WorkTicket.FormattedTicketNumber)
                {
                    _pickerScheduledAppointment.SelectedIndex = i;
                    break;
                }
            }

            // Create our screen objects
            //  Create a label for the technician list
            //         _labelTitle = new Xamarin.Forms.Label();
            //         _labelTitle.Text = "EXPENSES";
            //         _labelTitle.FontSize = 20;
            //_labelTitle.FontFamily = Device.OnPlatform("OpenSans-Bold","sans-serif-black", null);
            //_labelTitle.TextColor = asbestos;

            Button buttonAddExpense = new Button();

            buttonAddExpense.Text              = "ADD";
            buttonAddExpense.FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null);
            buttonAddExpense.TextColor         = Color.White;
            buttonAddExpense.BackgroundColor   = Color.FromHex("#2EcC71");
            buttonAddExpense.HorizontalOptions = LayoutOptions.FillAndExpand;
            buttonAddExpense.Clicked          += ButtonAddEditExpense_Clicked;

            // Create a template to display each technician in the list
            var dataTemplateExpense = new DataTemplate(typeof(ExpenseDataCell));

            // Create the actual list
            _listViewExpenses = new ListView()
            {
                HasUnevenRows       = true,
                ItemsSource         = _vm.ExpensesList,
                ItemTemplate        = dataTemplateExpense,
                SeparatorVisibility = SeparatorVisibility.None
            };
            _listViewExpenses.BindingContext = _vm.ExpensesList;
            _listViewExpenses.ItemTapped    += ListViewExpenses_ItemTapped;


            Content = new StackLayout
            {
                Padding  = 30,
                Children =
                {
                    //_labelTitle,
                    titleLayout,
                    _pickerScheduledAppointment,
                    _listViewExpenses,
                    buttonAddExpense
                }
            };
        }
Ejemplo n.º 2
0
        public void SetPageDisplay()
        {
            // Set the page title.
            //Title = "Expenses";
            SolidColorBrush asbestos = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7f8C8d"));

            //  Create a label for the expenses list
            _labelTitle                     = new Label();
            _labelTitle.Content             = "EXPENSES";
            _labelTitle.FontWeight          = FontWeights.Bold;
            _labelTitle.FontSize            = 18;
            _labelTitle.Foreground          = new SolidColorBrush(Colors.White);
            _labelTitle.HorizontalAlignment = HorizontalAlignment.Center;
            _labelTitle.VerticalAlignment   = VerticalAlignment.Center;

            Grid titleLayout = new Grid()
            {
                Background          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3498db")), //Color.FromHex("#2980b9"),
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Height = 80
            };

            titleLayout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.Children.Add(_labelTitle);
            Grid.SetColumn(_labelTitle, 0);
            Grid.SetRow(_labelTitle, 0);

            _pickerScheduledAppointment = new ComboBox();
            //_pickerScheduledAppointment.Title = "WORK TICKET";
            _pickerScheduledAppointment.ItemsSource = _vm.GetScheduledAppointments();
            //_pickerScheduledAppointment.SetBinding(BindablePicker.DisplayPropertyProperty, "FormattedTicketNumber");
            _pickerScheduledAppointment.DisplayMemberPath = "ServiceTicketNumber";
            _pickerScheduledAppointment.SelectionChanged += PickerScheduledAppointmentt_SelectedIndexChanged;
            for (int i = 0; i < _pickerScheduledAppointment.Items.Count; i++)
            {
                if (_vm.WorkTicket != null && (((App_ScheduledAppointment)_pickerScheduledAppointment.Items[i]).ServiceTicketNumber == _vm.WorkTicket.FormattedTicketNumber))
                {
                    _pickerScheduledAppointment.SelectedIndex = i;
                    break;
                }
            }

            // Create our screen objects

            Button buttonAddExpense = new Button();

            TextBlock addExpenseText = new TextBlock()
            {
                Text       = "ADD",
                Foreground = new SolidColorBrush(Colors.White),
                FontWeight = FontWeights.Bold
            };

            buttonAddExpense.Background          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2EcC71"));
            buttonAddExpense.HorizontalAlignment = HorizontalAlignment.Stretch;
            buttonAddExpense.Margin  = new Thickness(10);
            buttonAddExpense.Content = addExpenseText;
            buttonAddExpense.Click  += ButtonAddEditExpense_Clicked;

            // dch rkl 10/26/2016
            buttonAddExpense.Margin = new Thickness(30, 5, 30, 0);
            buttonAddExpense.Height = 40;

            // Create a template to display each technician in the list
            //var dataTemplateExpense = new DataTemplate(typeof(ExpenseDataCell));

            // Create the actual list
            _listViewExpenses = new ListView()
            {
                //HasUnevenRows = true,
                ItemsSource  = _vm.ExpensesList,
                ItemTemplate = (DataTemplate)this.Resources["ExpenseDataTemplate"]
            };
            _listViewExpenses.DataContext       = _vm.ExpensesList;
            _listViewExpenses.SelectionChanged += _listViewExpenses_SelectionChanged;

            _listViewExpenses.VerticalAlignment = VerticalAlignment.Stretch;

            gridMain.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(80, GridUnitType.Pixel), MaxHeight = 80
            });
            gridMain.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(40, GridUnitType.Pixel), MaxHeight = 40
            });
            gridMain.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            gridMain.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(50, GridUnitType.Pixel), MaxHeight = 50
            });

            gridMain.VerticalAlignment = VerticalAlignment.Top;

            Grid.SetRow(titleLayout, 0);
            gridMain.Children.Add(titleLayout);
            Grid.SetRow(_pickerScheduledAppointment, 1);
            gridMain.Children.Add(_pickerScheduledAppointment);
            Grid.SetRow(_listViewExpenses, 2);
            gridMain.Children.Add(_listViewExpenses);
            Grid.SetRow(buttonAddExpense, 3);
            gridMain.Children.Add(buttonAddExpense);

            /*gridMain.Children.Add(new StackPanel()
             * {
             *  CanVerticallyScroll = true,
             *  Margin = new Thickness(0),
             *  VerticalAlignment = VerticalAlignment.Stretch,
             *  Children = {
             *      titleLayout,
             *      _pickerScheduledAppointment,
             *     _listViewExpenses,
             *      buttonAddExpense
             *  }
             * });*/
        }