//https://stackoverflow.com/questions/37179815/displaying-a-background-image-on-a-uwp-ink-canvas private async void OpenMapCommandAction() { //Open the Map open dialog try { MapFile mapFile = await _fileService.GetFile(); MapSource = mapFile; //if(await _dialogService.ShowGeoDataQuestionDialog()) //{ // MapGeoData mapGeoData= await _dialogService.ShowGeoDataEntryDialog(); // mapFile.LatitudeTop = mapGeoData.LatitudeTop; // mapFile.LatitudeBottom = mapGeoData.LatitudeBottom; // mapFile.LongitudeLeft = mapGeoData.LongitudeLeft; // mapFile.LongitudeRight = mapGeoData.LongitudeRight; // mapFile.IsGeoReferenced = true; //} mapFile.IsGeoReferenced = false; BaumCollection.Clear(); CurrentBaum.BaumNr = 1; RaisePropertyChanged("CurrentBaum"); SelectedBaum = null; } catch (NullReferenceException) { } }
private void DeleteTree() { Baum baumToDelete = BaumCollection.Where(x => x.IsMarked == true).FirstOrDefault(); if (baumToDelete != null) { BaumCollection.Remove(baumToDelete); } else { } }
private async void RenderImage(NotificationMessageAction <SoftwareBitmap> notificationMessageAction) { if (BaumCollection != null && BaumCollection.Count > 0) { if (BaumCollection.Where(x => x.IsMarked == true).Count() > 0) { SelectTree(BaumCollection.Where(x => x.IsMarked == true).First()); } //_selectedBaum = _BaumCollection.Where(x => x.IsMarked = true).First(); //RaisePropertyChanged(() => SelectedBaum); } RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(mapGrid); if (renderTargetBitmap.PixelHeight != 0 && renderTargetBitmap.PixelWidth != 0) { SoftwareBitmap softwareBitmap = new SoftwareBitmap(BitmapPixelFormat.Bgra8, renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight); softwareBitmap.DpiX = 600; softwareBitmap.DpiY = 600; softwareBitmap.CopyFromBuffer(await renderTargetBitmap.GetPixelsAsync()); notificationMessageAction.Execute(softwareBitmap); } //BitmapDecoder imagedecoder; //using (var imagestream = await Map.OpenAsync(FileAccessMode.Read)) //{ // imagedecoder = await BitmapDecoder.CreateAsync(imagestream); // CanvasDevice device = CanvasDevice.GetSharedDevice(); // CanvasRenderTarget renderTarget = new CanvasRenderTarget(device, imagedecoder.PixelWidth, imagedecoder.PixelHeight, 96); // using (var ds = renderTarget.CreateDrawingSession()) // { // ds.Clear(Colors.White); // CanvasBitmap image = await CanvasBitmap.LoadAsync(device, imagestream); // ds.DrawImage(image); // //ds.DrawText(lblName.Text, new System.Numerics.Vector2(150, 150), Colors.Black); // } // await renderTarget.SaveAsync(imagestream, CanvasBitmapFileFormat.Jpeg); // BitmapImage bitmap = new BitmapImage(); // bitmap.SetSource(imagestream); // MapR = bitmap; //} }
private void MoveTree(PointerPoint imagePoint, PointerPoint canvasPoint) { if (BaumCollection != null) { Baum selectedTree = (Baum)BaumCollection.Where(x => x.IsMarked == true).FirstOrDefault(); if (selectedTree != null) { selectedTree.CanvasPosition = canvasPoint.Position; selectedTree.ImagePosition = imagePoint.Position; BaumCollection.Remove(selectedTree); BaumCollection.Add(selectedTree); } } }
private void SetTree(PointerPoint imagePoint, PointerPoint canvasPoint) { Baum neuerBaum = new Baum(); neuerBaum.CanvasPosition = canvasPoint.Position; neuerBaum.ImagePosition = imagePoint.Position; neuerBaum.BaumNr = CurrentBaum.BaumNr; BaumCollection.Add(neuerBaum); SelectTree(neuerBaum); double i = mapImage.DesiredSize.Height; Messenger.Default.Send <SetBaumMessage>(new SetBaumMessage()); }