예제 #1
0
        public override void Run(ElmSharp.Box parent)
        {
            var container = new Canvas(parent)
            {
                AlignmentX    = -1,
                AlignmentY    = -1,
                WeightX       = 1,
                WeightY       = 1,
                MinimumHeight = 300,
            };

            container.Show();
            parent.PackEnd(container);

            container.LayoutUpdated += (s, e) =>
            {
                foreach (var child in container.Children)
                {
                    child.Geometry = container.Geometry;
                    if (child is SKClipperView clip)
                    {
                        clip.Invalidate();
                    }
                }
            };

            var img1 = new Image(parent);

            img1.Show();
            img1.Load(Application.Current.DirectoryInfo.Resource + "animated.gif");
            img1.SetIsAnimationPlaying(true);

            var clipper = new SKClipperView(parent);

            clipper.Show();
            clipper.PaintSurface += (s, e) =>
            {
                var canvas = e.Surface.Canvas;
                var width  = e.Info.Width;
                var height = e.Info.Height;

                using (var paint = new SKPaint
                {
                    IsAntialias = true,
                    Color = SKColors.White,
                    Style = SKPaintStyle.Fill,
                })
                {
                    canvas.Clear();
                    canvas.DrawCircle(width / 2.0f, height / 2.0f, Math.Min(width / 2.0f, height / 2.0f) / 2.0f, paint);
                }

                img1.SetClipperCanvas(clipper);
            };
            clipper.Lower();
            container.Children.Add(img1);
            container.Children.Add(clipper);
        }
예제 #2
0
        async Task <EvasObject> GetImageIconAsync(EvasObject parent)
        {
            var image    = new TImage(parent);
            var mImage   = s_currentDragStateData.DataPackage.Image;
            var services = Handler.MauiContext?.Services;
            var provider = services.GetService(typeof(IImageSourceServiceProvider)) as IImageSourceServiceProvider;
            var service  = provider?.GetImageSourceService(mImage);
            var result   = await service.GetImageAsync(mImage, image);

            if (result == null)
            {
                return(null);
            }
            return(image);
        }
        EvasObject CreateBackgroundImage(EvasObject parent)
        {
            var img = new Ext.Image(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            img.Show();
            img.Aspect = Common.Aspect.Fill;
            img.LoadAsync(Application.Current.DirectoryInfo.Resource + "animated2.gif");

            return(img);
        }
예제 #4
0
        public MauiImageButton(EvasObject parent) : base(parent)
        {
            _image  = new TImage(parent);
            _button = new TButton(parent);

            _button.Clicked  += OnClicked;
            _button.Pressed  += OnPressed;
            _button.Released += OnReleased;
            _button.SetTransparentStyle();

            Children.Add(_image);
            _image.RaiseTop();

            Children.Add(_button);
            _button.SetTransparentStyle();
            _button.RaiseTop();

            LayoutUpdated += OnLayout;
        }
예제 #5
0
파일: ShellView.cs 프로젝트: Glepooek/maui
        async void UpdateFlyoutBackgroundImage()
        {
            _ = Element ?? throw new InvalidOperationException($"{nameof(Element)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

            if (Element.FlyoutBackgroundImage != null)
            {
                var image       = new TImage(PlatformParent);
                var imageSource = Element.FlyoutBackgroundImage;
                var provider    = MauiContext.Services.GetRequiredService <IImageSourceServiceProvider>();
                var service     = provider.GetRequiredImageSourceService(imageSource);
                image.Aspect = Element.FlyoutBackgroundImageAspect.ToPlatform();
                _navigationView.BackgroundImage = image;

                await service.GetImageAsync(imageSource, image);
            }
            else
            {
                _navigationView.BackgroundImage = null;
            }
        }
예제 #6
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollview = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            scrollview.Show();
            scrollview.ScrollOrientation = ScrollOrientation.Vertical;
            parent.PackEnd(scrollview);

            var scrollCanvas = new ElmSharp.Box(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            scrollCanvas.Show();
            scrollview.SetScrollCanvas(scrollCanvas);


            var img1 = new Image(parent)
            {
                AlignmentX    = -1,
                AlignmentY    = -1,
                WeightX       = 1,
                WeightY       = 1,
                MinimumHeight = 300,
            };

            img1.Show();
            img1.LoadAsync(Application.Current.DirectoryInfo.Resource + "image.png");
            scrollCanvas.PackEnd(img1);

            {
                var label = new Label(parent)
                {
                    Text = "AspectFill"
                };
                label.Show();
                scrollCanvas.PackEnd(label);
                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.AspectFill;
                img2.LoadAsync("http://i.imgur.com/9f974SC.jpg");
                img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed");
                scrollCanvas.PackEnd(img2);
            }

            {
                var label = new Label(parent)
                {
                    Text = "AppectFit"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.AspectFit;
                img2.LoadAsync("http://i.imgur.com/9f974SC.jpg");
                img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed");
                scrollCanvas.PackEnd(img2);
            }

            {
                var label = new Label(parent)
                {
                    Text = "Fill"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.Fill;
                img2.LoadAsync("http://i.imgur.com/9f974SC.jpg");
                img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed");
                scrollCanvas.PackEnd(img2);
            }

            {
                var label = new Label(parent)
                {
                    Text = "Animated"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var animated = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                animated.Show();
                animated.Aspect = Aspect.AspectFit;
                animated.LoadAsync(Application.Current.DirectoryInfo.Resource + "animated.gif");

                animated.LoadingCompleted += (s, e) =>
                {
                    Console.WriteLine($"Loading completed");
                    animated.SetIsAnimationPlaying(true);
                };
                scrollCanvas.PackEnd(animated);
            }

            {
                var label = new Label(parent)
                {
                    Text = "IsAnimationPlaying = false"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.AspectFit;
                img2.LoadAsync(Application.Current.DirectoryInfo.Resource + "animated2.gif");
                img2.LoadingCompleted += (s, e) =>
                {
                    Console.WriteLine($"Loading completed");
                    (s as Image).SetIsAnimationPlaying(false);
                };
                scrollCanvas.PackEnd(img2);
            }

            scrollview.SetContentSize(720, 3000);
        }