Esempio n. 1
0
        protected async override void OnElementChanged(ElementChangedEventArgs <ImageButton> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                if (Control == null)
                {
                    _image = new AImage
                    {
                        VerticalAlignment   = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Stretch             = Stretch.Uniform
                    };

                    //_image.ImageFailed += OnImageFailed;

                    _button = new AButton
                    {
                        Padding         = new AThickness(0),
                        BorderThickness = new AThickness(0),
                        Background      = null,

                        Content = _image
                    };

                    //_button.Click += OnButtonClick;

                    SetNativeControl(_button);
                }

                if (Element.BorderColor != Color.Default)
                {
                    UpdateBorderColor();
                }

                if (Element.BorderWidth != 0)
                {
                    UpdateBorderWidth();
                }

                await TryUpdateSource().ConfigureAwait(false);

                UpdateAspect();

                if (Element.IsSet(Button.PaddingProperty))
                {
                    UpdatePadding();
                }
            }
        }
Esempio n. 2
0
        private void AddBrick(FoxDraw foxDraw, string brick, double x, double y)
        {
            string wallBrickPath  = @"C:\Users\bajer\Documents\wanderer-cs\img\wall.png";
            string floorBrickPath = @"C:\Users\bajer\Documents\wanderer-cs\img\floor.png";

            bool isFloor = (brick == "1") ? true : false;

            if (isFloor)
            {
                var image = new Avalonia.Controls.Image();
                image.Source = new Avalonia.Media.Imaging.Bitmap(floorBrickPath);
                foxDraw.AddImage(image, x, y);
            }
            else
            {
                var image = new Avalonia.Controls.Image();
                image.Source = new Avalonia.Media.Imaging.Bitmap(wallBrickPath);
                foxDraw.AddImage(image, x, y);
            }
        }