Exemplo n.º 1
0
        private UIElement CreateRadioButton(ISampleBase sample)
        {
            var radioButton = new RadioButton
            {
                FontSize = 16,
                Content  = sample.Name,
                Margin   = new Thickness(4)
            };

            radioButton.Click += (s, a) => {
                Catch.Exceptions(async() =>
                {
                    MapControl.Map?.Layers.Clear();

                    await sample.SetupAsync(MapControl);

                    MapControl.Info += MapControlOnInfo;
                    if (MapControl.Map != null)
                    {
                        LayerList.Initialize(MapControl.Map.Layers);
                    }
                });
            };
            return(radioButton);
        }
Exemplo n.º 2
0
    public static async Task SetupAsync(this ISampleBase sample, IMapControl mapControl)
    {
        if (sample is IAsyncSample asyncSample)
        {
            await asyncSample.SetupAsync(mapControl);

            return;
        }

        Setup(sample, mapControl);
    }
Exemplo n.º 3
0
    public static void Setup(this ISampleBase sample, IMapControl mapControl)
    {
        if (sample is ISample syncSample)
        {
            syncSample.Setup(mapControl);

            return;
        }

        throw new InvalidOperationException();
    }
Exemplo n.º 4
0
        public MapPage(ISampleBase sample, Func <MapView?, MapClickedEventArgs, bool>?c = null)
        {
            InitializeComponent();
            Refs.AddRef(this);
            Refs.AddRef(mapView);

            Title = sample.Name;

            mapView.RotationLock          = false;
            mapView.UnSnapRotationDegrees = 30;
            mapView.ReSnapRotationDegrees = 5;

            mapView.PinClicked += OnPinClicked;
            mapView.MapClicked += OnMapClicked;

            Compass.ReadingChanged += Compass_ReadingChanged;

            mapView.MyLocationLayer.UpdateMyLocation(new UI.Forms.Position());
            mapView.MyLocationLayer.CalloutText = "My location!\n";
            mapView.MyLocationLayer.Clicked    += MyLocationClicked;

            mapView.Renderer.WidgetRenders[typeof(CustomWidget.CustomWidget)] = new CustomWidgetSkiaRenderer();

            _ = Task.Run(() => StartGPSAsync());

            try
            {
                if (!Compass.IsMonitoring)
                {
                    Compass.Start(SensorSpeed.Default);
                }
            }
            catch (Exception) { }

            _ = Task.Run(async() =>
            {
                try
                {
                    await sample.SetupAsync(mapView);
                }
                catch (Exception e)
                {
                    Logger.Log(LogLevel.Error, e.Message, e);
                }
            });

            Clicker = c;
        }
Exemplo n.º 5
0
    public async Task TestSampleAsync(ISampleBase sample, bool compareImages)
    {
        try
        {
            var fileName   = sample.GetType().Name + ".Regression.png";
            var mapControl = await InitMapAsync(sample).ConfigureAwait(true);

            var map = mapControl.Map;
            await DisplayMapAsync(mapControl).ConfigureAwait(false);

            if (map != null)
            {
                // act
                using var bitmap = new MapRenderer().RenderToBitmapStream(mapControl.Viewport, map.Layers, map.BackColor, 2);

                // aside
                if (bitmap is { Length : > 0 })
                {
                    File.WriteToGeneratedRegressionFolder(fileName, bitmap);
                }
Exemplo n.º 6
0
        public MapPage(ISampleBase sample, Func <MapView?, MapClickedEventArgs, bool>?c = null)
        {
            InitializeComponent();

            // nullable warning workaround
            var test  = this.mapView ?? throw new InvalidOperationException();
            var test1 = this.info ?? throw new InvalidOperationException();

            mapView !.RotationLock        = false;
            mapView.UnSnapRotationDegrees = 30;
            mapView.ReSnapRotationDegrees = 5;

            mapView.PinClicked += OnPinClicked;
            mapView.MapClicked += OnMapClicked;

            Compass.ReadingChanged += Compass_ReadingChanged;

            mapView.MyLocationLayer.UpdateMyLocation(new Mapsui.UI.Maui.Position());

            mapView.Info += MapView_Info;
            mapView.Renderer.WidgetRenders[typeof(CustomWidget.CustomWidget)] = new CustomWidgetSkiaRenderer();

            _ = Task.Run(StartGPS);

            try
            {
                if (!Compass.IsMonitoring)
                {
                    Compass.Start(SensorSpeed.Default);
                }
            }
            catch (Exception) { }

            Catch.Exceptions(async() =>
            {
                await sample.SetupAsync(mapView);
            });

            Clicker = c;
        }
Exemplo n.º 7
0
        private UIElement CreateRadioButton(ISampleBase sample)
        {
            var radioButton = new RadioButton
            {
                FontSize = 16,
                Content  = sample.Name,
                Margin   = new Thickness(4)
            };

            radioButton.Click += (s, a) => {
                Catch.Exceptions(async() =>
                {
                    MapControl.Map !.Layers.Clear();
                    MapControl.Info -= MapOnInfo;
                    await sample.SetupAsync(MapControl);
                    MapControl.Info += MapOnInfo;
                    MapControl.Refresh();
                });
            };

            return(radioButton);
        }
Exemplo n.º 8
0
 public async Task TestSampleAsync(ISampleBase sample)
 {
     await TestSampleAsync(sample, true).ConfigureAwait(false);
 }