Ejemplo n.º 1
0
        public TimeEntry()
        {
            InitializeComponent();

            CustomEntry.SetBinding(Entry.TextProperty, new Binding(nameof(Time), source: this));
            CustomEntry.SetBinding(Entry.IsEnabledProperty, new Binding(nameof(IsEnabled), source: this));
            CustomEntry.SetBinding(Entry.IsReadOnlyProperty, new Binding(nameof(IsReadOnly), source: this));
            CustomEntry.TextChanged += OnTextChanged;
            CustomEntry.Unfocused   += OnUnfocused;
        }
        public BarcodeEntry()
        {
            InitializeComponent();

            _viewModel = (BarcodeEntryViewModel)BindingContext;

            CustomEntry.SetBinding(Entry.TextProperty, new Binding(nameof(Text), source: this));
            CustomEntry.SetBinding(Entry.IsEnabledProperty, new Binding(nameof(IsEnabled), source: this));
            CustomEntry.SetBinding(Entry.IsReadOnlyProperty, new Binding(nameof(IsReadOnly), source: this));
            CustomEntry.TextChanged += OnTextChanged;
            CustomEntry.Unfocused   += OnUnfocused;
        }
Ejemplo n.º 3
0
        public CustomEntry entry(string ID, string bind)
        {
            CustomEntry txt = new CustomEntry(new CustomEntryParams {
                MaxLength = 3
            });

            txt.ClassId  = ID;
            txt.Keyboard = Keyboard.Numeric;
            txt.SetBinding(Entry.TextProperty, bind);
            txt.WidthRequest  = w / 10;
            txt.HeightRequest = w / 10;

            return(txt);
        }
Ejemplo n.º 4
0
        private CustomEntry GenerateEntryDefault(string placeHolder, string fieldName, FontType fontType, Keyboard keyboard)
        {
            var result = new CustomEntry
            {
                Placeholder             = placeHolder,
                PlaceholderColor        = Palette.Green,
                Keyboard                = keyboard,
                HorizontalTextAlignment = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.Center,
                FontSize                = PaletteText.FontSizeM,
                MaxLength               = 200,
                FontType                = fontType,
                HeightRequest           = 45
            };

            result.SetBinding(Entry.TextProperty, fieldName, BindingMode.TwoWay);

            return(result);
        }
Ejemplo n.º 5
0
        public ColorConverterPage()
        {
            BindingContext       = new ColorConverterViewModel(this.Navigation);
            this.BackgroundImage = "Bg.png";
            btnHtoR = new Button
            {
                Text            = "Convert Hexa to RGB",
                TextColor       = Colors.CCBtn.ToFormsColor(),
                BackgroundColor = Color.White,
                Command         = ViewModel.HEXtoRGB
            };
            btnRtoH = new Button
            {
                Text            = "Convert RGB to Hexa",
                TextColor       = Colors.CCBtn.ToFormsColor(),
                BackgroundColor = Color.White,
                Command         = ViewModel.RGBtoHEX
            };

            lblHexa = new Label
            {
                Text      = "Hexa Color",
                FontSize  = h / 22,
                TextColor = Colors.CCBtn.ToFormsColor(),
                YAlign    = TextAlignment.Start
            };
            CustomEntry txt =

                txtHexa = new CustomEntry(new CustomEntryParams
            {
                MaxLength = 6
            })
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            txtHexa.SetBinding(Entry.TextProperty, "Hexa");
            boxColor = new BoxView
            {
                BackgroundColor = Color.Black,
                WidthRequest    = w / 3,
                HeightRequest   = w / 3
            };
            boxColor.SetBinding(BoxView.ColorProperty, "BoxColor");
            var boxColortap = new TapGestureRecognizer(OnboxColorTapped);

            boxColortap.NumberOfTapsRequired = 1;
            boxColor.IsEnabled = true;
            boxColor.GestureRecognizers.Clear();
            boxColor.GestureRecognizers.Add(boxColortap);

            Content = new StackLayout
            {
                Padding           = new Thickness(w / 10, w / 10, w / 10, w / 10),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Spacing           = w / 10,
                Children          =
                {
                    GenEventTablelGrid(),
                    btnRtoH,
                    new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            lblHexa, txtHexa
                        }
                    },
                    btnHtoR,
                    boxColor
                }
            };
        }
Ejemplo n.º 6
0
        private void CreateFiltro()
        {
            PainelFiltro = new AbsoluteLayout()
            {
                BackgroundColor = Color.FromHex("#2E2F3A"),
                Margin          = 0,
                Padding         = 0
            };

            PainelFiltro.SetBinding(
                VisualElement.WidthRequestProperty
                , new Binding(
                    "DefaultWidth"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );

            PainelFiltro.SetBinding(
                VisualElement.IsVisibleProperty
                , new Binding(
                    "ListPainelTop_IsVisible"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );

            Grid filtroGrid = new Grid()
            {
                RowSpacing    = 0,
                ColumnSpacing = 0,
                Margin        = 0,
                Padding       = 0
            };

            filtroGrid.SetBinding(
                VisualElement.WidthRequestProperty
                , new Binding(
                    "DefaultWidth"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );

            filtroGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Star
            });

            filtroGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });

            filtroGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Star
            });

            #region Filtro Texto
            Grid filtroTexto = new Grid()
            {
                RowSpacing      = 0,
                ColumnSpacing   = 0,
                Margin          = 10,
                Padding         = 0,
                BackgroundColor = Color.White
            };

            filtroTexto.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Star
            });

            filtroTexto.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = 30
            });

            CustomEntry TxtBuscar = new CustomEntry()
            {
                Margin          = new Thickness(5, 0),
                BackgroundColor = Color.Transparent,
                BorderStyle     = "Hide"
            };

            TxtBuscar.SetBinding(
                Entry.TextProperty
                , new Binding(
                    "TxtBuscar"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );
            filtroTexto.Children.Add(TxtBuscar, 0, 0);

            Button imageBuscar = new Button()
            {
                Image           = "ic_busca.png",
                BackgroundColor = Color.Transparent,
                Margin          = 0
            };

            imageBuscar.SetBinding(
                Button.CommandProperty
                , new Binding(
                    "BuscarCommand"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );
            filtroTexto.Children.Add(imageBuscar, 1, 0);

            StackLayout panelFiltroText = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#d2d8e2"),
                Margin          = 0,
                Padding         = 0,
                Spacing         = 0,
            };

            panelFiltroText.SetBinding(
                VisualElement.HeightRequestProperty
                , new Binding(
                    "PainelFiltroTextHeight"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );
            panelFiltroText.Children.Add(filtroTexto);

            filtroGrid.Children.Add(panelFiltroText, 0, 0);
            #endregion

            #region Filtro Status
            ListViewPanelTop = new Grid()
            {
                BackgroundColor = Color.FromHex("#2E2F3A"),
                RowSpacing      = 0,
                ColumnSpacing   = 0,
                Margin          = 0
            };

            ListViewPanelTop.BindingContextChanged += Handle_BindingContextChanged;

            #region ListViewPanelTop Binding
            ListViewPanelTop.SetBinding(
                VisualElement.WidthRequestProperty
                , new Binding(
                    "DefaultWidth"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );

            ListViewPanelTop.SetBinding(
                VisualElement.HeightRequestProperty
                , new Binding(
                    "ListPainelTop_Height"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );

            ListViewPanelTop.SetBinding(
                BindableObject.BindingContextProperty
                , new Binding(
                    "ListPainelTop_Source"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );

            ListViewPanelTop.SetBinding(
                VisualElement.IsEnabledProperty
                , new Binding(
                    "ListEndRefresh"
                    , BindingMode.Default
                    , null
                    , null
                    , null
                    , this.BindingContext
                    )
                );
            #endregion


            filtroGrid.Children.Add(ListViewPanelTop, 0, 1);
            #endregion

            PainelFiltro.Children.Add(filtroGrid);
            PageContent.Children.Add(PainelFiltro);
        }
Ejemplo n.º 7
0
 public MyCustomControl()
 {
     InitializeComponent();
     CustomEntry.SetBinding(Entry.TextProperty, new Binding(nameof(EntryText), source: this));
 }
Ejemplo n.º 8
0
        // Generate Crossword Grid and Style
        private Grid GenerateCrosswordGrid(ObservableCollection <ObservableCollection <LetterCell> > board)
        {
            var crossWordGrid = new Grid()
            {
                ColumnSpacing = 1,
                RowSpacing    = 1,
                Padding       = 0
            };

            crossWordGrid.SetDynamicResource(Grid.BackgroundColorProperty, "backgroundGridColour");
            for (var i = 0; i < board.Count; i++)
            {
                crossWordGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }

            for (var i = 0; i < board[0].Count; i++)
            {
                crossWordGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }

            for (var i = 0; i < board.Count; i++)
            {
                for (var j = 0; j < board[i].Count; j++)
                {
                    var boxView = new BoxView()
                    {
                        CornerRadius = 2
                    };
                    boxView.BindingContext = board[i][j];
                    boxView.SetBinding(BoxView.BackgroundColorProperty, new Binding("BackgroundCellColour", BindingMode.OneWay));

                    var labelDefinitionLocation = new Label()
                    {
                        //Style = _resources["horizontalLabelStyle"] as Style
                    };
                    labelDefinitionLocation.BindingContext = board[i][j];
                    labelDefinitionLocation.SetBinding(Label.TextProperty, new Binding("DefinitionLocation", BindingMode.OneWay));
                    labelDefinitionLocation.SetDynamicResource(Label.StyleProperty, "orientationLabelStyle");
                    labelDefinitionLocation.SetDynamicResource(Label.TextColorProperty, "fontColour");

                    var entry = new CustomEntry()
                    {
                        MaxLength = 1,
                        HorizontalTextAlignment = TextAlignment.Center,
                    };
                    entry.Keyboard = Keyboard.Create(KeyboardFlags.CapitalizeCharacter);
                    //entry.Effects.Add(Effect.Resolve("FormsCommunityToolkit.Effects.EntryCapitalizeKeyboard"));

                    entry.BindingContext = board[i][j];
                    entry.SetBinding(CustomEntry.IsEnabledProperty, new Binding("IsEnabled", BindingMode.OneWay));
                    entry.SetBinding(CustomEntry.TextProperty, new Binding("LetterIn", BindingMode.TwoWay, new StringToCharConverter()));
                    entry.SetBinding(CustomEntry.TextColorProperty, new Binding("FontColour", BindingMode.OneWay));
                    entry.SetBinding(CustomEntry.FontAttributesProperty, new Binding("FontWeight", BindingMode.OneWay));
                    entry.SetDynamicResource(CustomEntry.StyleProperty, "orientationEntryStyle");
                    entry.TextChanged += (s, e) =>
                    {
                        if (IsCharUpper(e.NewTextValue) == null)
                        {
                            return;
                        }
                        if ((bool)IsCharUpper(e.NewTextValue))
                        {
                            LetterCell_TextChanged(entry, e);
                        }
                        else
                        {
                            entry.Text = e.NewTextValue.ToUpper();
                        }
                    };

                    entry.Focused += (s, e) =>
                    {
                        EntryFocused((LetterCell)e.VisualElement.BindingContext);
                    };


                    board[i][j].CellEntry = entry;
                    board[i][j].Pos       = new Tuple <int, int>(j, i);

                    var button = new Button()
                    {
                        BorderColor     = Color.Transparent,
                        BackgroundColor = Color.Transparent
                    };
                    button.BindingContext = board[i][j];
                    button.SetBinding(Button.IsEnabledProperty, new Binding("IsEnabled", BindingMode.OneWay));
                    button.Pressed += (s, e) =>
                    {
                        var letterCell = (LetterCell)button.BindingContext;

                        if (_buttonCount < 1)
                        {
                            Device.StartTimer(TimeSpan.FromMilliseconds(500), () => DoubleClick(letterCell));
                        }
                        _buttonCount++;
                    };

                    crossWordGrid.Children.Add(boxView, j, i);
                    crossWordGrid.Children.Add(labelDefinitionLocation, j, i);
                    crossWordGrid.Children.Add(entry, j, i);
                    crossWordGrid.Children.Add(button, j, i);
                }
            }

            return(crossWordGrid);
        }