Exemplo n.º 1
0
        private StackLayout CreateItem(string title, string binding, object context, Keyboard key = null, bool isLabel = false)
        {
            var titleStack = new StackLayout()
            {
                Orientation = StackOrientation.Vertical
            };

            titleStack.BindingContext = context;
            titleStack.Children.Add(new Label()
            {
                Text = title
            });
            if (isLabel)
            {
                var lblTitle = new Label();
                lblTitle.SetBinding(Label.TextProperty, new Binding(binding));
                titleStack.Children.Add(lblTitle);
            }
            else
            {
                var txtName = new CustomTextBox()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand
                };
                txtName.SetBinding(Entry.TextProperty, binding, BindingMode.TwoWay);
                if (key != null)
                {
                    txtName.Keyboard = key;
                }
                titleStack.Children.Add(txtName);
            }
            return(titleStack);
        }
Exemplo n.º 2
0
        public static Entry AddTextField(this Grid contentGrid, string binding, int row, Keyboard key = null)
        {
            var entry = new CustomTextBox
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center
            };

            if (key != null)
            {
                entry.Keyboard = key;
            }
            entry.SetBinding(Entry.TextProperty, binding, BindingMode.TwoWay);
            contentGrid.Children.Add(entry, 1, row);
            return(entry);
        }
Exemplo n.º 3
0
        /// <summary>Generates the cell for the given item. </summary>
        /// <param name="dataGrid"></param>
        /// <param name="dataItem">The item to generate the cell for. </param>
        /// <returns>The <see cref="DataGridCellBase"/>. </returns>
        public override DataGridCellBase CreateCell(DataGrid dataGrid, object dataItem)
        {
            var block = new CustomTextBox();

            block.VerticalAlignment          = VerticalAlignment.Center;
            block.Background                 = new SolidColorBrush(Colors.Transparent);
            block.Foreground                 = Foreground;
            block.BorderBrush                = new SolidColorBrush(Colors.Transparent);
            block.BorderThickness            = new Thickness(0);
            block.Margin                     = new Thickness(2, 0, 2, 0);
            block.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            block.VerticalContentAlignment   = VerticalAlignment.Stretch;
            block.IsEnabled                  = false;
            block.UpdateOnlyOnEnter          = dataGrid.UpdateOnlyOnEnter;
            block.NumericKeyType             = NumericKeyType;

            if (MaxCharacterLength != 0)
            {
                block.MaxLength = MaxCharacterLength;
            }
            if (FontSize <= 0)
            {
                FontSize = dataGrid.FontSize;
            }

            CreateBinding(StyleProperty, "Style", block, CustomTextBox.StyleProperty);
            CreateBinding(FontStyleProperty, "FontStyle", block, CustomTextBox.FontStyleProperty);
            CreateBinding(FontSizeProperty, "FontSize", block, CustomTextBox.FontSizeProperty);
            CreateBinding(ForegroundProperty, "Foreground", block, CustomTextBox.ForegroundProperty);
            CreateBinding(TextAlignmentProperty, "TextAlignment", block, CustomTextBox.TextAlignmentProperty);

            if (Binding != null)
            {
                block.SetBinding(CustomTextBox.TextProperty, Binding);
            }

            return(new DefaultDataGridCell(block));
        }
Exemplo n.º 4
0
        public override DataGridCellBase CreateEditableCell(DataGrid dataGrid, object dataItem, bool setFocus)
        {
            var block = new CustomTextBox();

            block.VerticalAlignment          = VerticalAlignment.Center;
            block.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            block.VerticalContentAlignment   = VerticalAlignment.Stretch;
            block.Background        = new SolidColorBrush(Colors.Transparent);
            block.Foreground        = Foreground;
            block.BorderBrush       = new SolidColorBrush(Colors.Transparent);
            block.Padding           = new Thickness(0);
            block.Margin            = new Thickness(0);
            block.BorderThickness   = new Thickness(0);
            block.UpdateOnlyOnEnter = dataGrid.UpdateOnlyOnEnter;
            block.PreventKeyboardDisplayOnProgrammaticFocus = true;
            block.NumericKeyType = NumericKeyType;

            block.InputScope = new InputScope
            {
                Names =
                {
                    new InputScopeName()
                    {
                        NameValue = InputScope
                    }
                }
            };

            if (MaxCharacterLength != 0)
            {
                block.MaxLength = MaxCharacterLength;
            }
            if (FontSize <= 0)
            {
                FontSize = dataGrid.FontSize;
            }

            CreateBinding(StyleProperty, "Style", block, CustomTextBox.StyleProperty);
            CreateBinding(FontStyleProperty, "FontStyle", block, CustomTextBox.FontStyleProperty);
            CreateBinding(FontSizeProperty, "FontSize", block, CustomTextBox.FontSizeProperty);
            CreateBinding(ForegroundProperty, "Foreground", block, CustomTextBox.ForegroundProperty);
            CreateBinding(TextAlignmentProperty, "TextAlignment", block, CustomTextBox.TextAlignmentProperty);

            if (Binding != null)
            {
                block.SetBinding(CustomTextBox.TextProperty, Binding);
            }

            if (Edit != null)
            {
                block.SetBinding(CustomTextBox.IsEnabledProperty, Edit);
            }

            KeyEventHandler keyeventHandler = new KeyEventHandler(Block_KeyDown);

            block.RemoveHandler(TextBox.KeyDownEvent, keyeventHandler);
            block.AddHandler(TextBox.KeyDownEvent, keyeventHandler, false);

            block.GotFocus -= BlockGotFocus;
            block.GotFocus += BlockGotFocus;

            return(new DefaultDataGridCell(block));
        }
Exemplo n.º 5
0
        protected override void RenderContentView(StackLayout parent)
        {
            ScrollView scrollview = new ScrollView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
            };
            var stlayout = new StackLayout()
            {
                Spacing = 0, Padding = new Thickness(0, 0, 0, 15), Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            contentGrid = new Grid
            {
                Padding         = new Thickness(5, 10, 15, 5),
                ColumnSpacing   = 7,
                RowSpacing      = 15,
                VerticalOptions = LayoutOptions.Start,
                RowDefinitions  =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(80, GridUnitType.Absolute)
                    },                                                                        //GridLength.Auto },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            contentGrid.AddLabel("Note:", 0);
            contentGrid.AddLabel(string.Empty, 0, 1);
            contentGrid.AddLabel("Name", 1);
            contentGrid.AddTextField("Name", 1);
            contentGrid.AddLabel("Emirates ID", 2);
            contentGrid.AddTextField("EmirateID", 2, Keyboard.Numeric);
            contentGrid.AddLabel("Thiqa", 3);
            contentGrid.AddTextField("Thiqa", 3);
            contentGrid.AddLabel("Attach", 4);

            var txtUpload = new CustomTextBox
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                IsEnabled         = false
            };

            txtUpload.SetBinding(Entry.TextProperty, "Path", BindingMode.TwoWay);
            btnUpload = new Button()
            {
                BackgroundColor = Color.FromHex("FF54A6D3"),
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 75,
                HeightRequest   = Device.OnPlatform(30, 35, 35),
                TextColor       = Color.Black,
                Text            = "Upload"
            };

            var uploadStack = new StackLayout()
            {
                Spacing = 2, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
            };

            uploadStack.Children.Add(txtUpload);
            uploadStack.Children.Add(btnUpload);
            contentGrid.Children.Add(uploadStack, 1, 4);

            btnSubmit = new Button()
            {
                BackgroundColor   = Color.FromHex("FF54A6D3"),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start,
                WidthRequest      = 200,
                HeightRequest     = 40,
                TextColor         = Color.Black,
                Text = "Submit"
            };

            stlayout.Children.Add(contentGrid);
            stlayout.Children.Add(btnSubmit);

            scrollview.Content = stlayout;
            if (Device.OS == TargetPlatform.Android)
            {
                btnSubmit.Font = Font.SystemFontOfSize(16);
                btnUpload.Font = Font.SystemFontOfSize(14);
                scrollview.IsClippedToBounds = true;
            }
            parent.Children.Add(scrollview);
        }
Exemplo n.º 6
0
        protected override void RenderContentView(StackLayout parent)
        {
            var content = new StackLayout()
            {
                Padding           = 40,
                Orientation       = StackOrientation.Vertical,
                Spacing           = 15,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            var doctorLayout = new StackLayout()
            {
                Spacing = 5, Orientation = StackOrientation.Vertical
            };

            doctorLayout.Children.Add(new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand, TextColor = Color.Black, Text = "Find Doctor"
            });
            var txt = new CustomTextBox()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand, TextColor = Color.Black
            };

            txt.SetBinding(CustomTextBox.TextProperty, "SearchText", BindingMode.TwoWay);
            doctorLayout.Children.Add(txt);

            var specLayout = new StackLayout()
            {
                Spacing = 5, Orientation = StackOrientation.Vertical
            };

            specLayout.Children.Add(new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand, TextColor = Color.Black, Text = "Speicalties"
            });
            specLayout.Children.Add(this.CreateComboBox(ref btnCombo));

            btnSearch = new Button()
            {
                BackgroundColor   = Color.FromHex("FF54A6D3"),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                TextColor         = Color.Black,
                Text = "Search"
            };
            if (Device.OS == TargetPlatform.Android)
            {
                btnSearch.Font = Font.SystemFontOfSize(16);
            }
            var searchStack = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal, HeightRequest = 40,
                Children    = { btnSearch }, Padding = new Thickness(10, 15, 10, 0)
            };

            content.Children.Add(doctorLayout);
            content.Children.Add(specLayout);
            content.Children.Add(searchStack);

            parent.Children.Add(content);

            lblTitle.Text = HeaderTitle;
        }