public override void Perform() { if (isPerforming) { ErrorLog.AddError(ErrorType.Failure, "Waiting for last snapshot to save"); return; } if (!selectedCameraConnected) { ErrorLog.AddError(ErrorType.Failure, "Waiting for webcam to become available"); return; } if (selectedCameraIndex != -1 && selectedCameraConnected && webcambuffer != null) { isPerforming = true; Bitmap image = webcambuffer.GetLastBufferedItem(); try { if (image != null) { string savedPath = SaveImage(ref image); //save image if (playShutterSound) { SoundPlayer shutterSound = new SoundPlayer(Properties.Resources.shutterSound); shutterSound.Play(); } if (showPreview) { ImagePopup popup = new ImagePopup(); popup.ShowPopup(1000, savedPath); popup = null; } } } catch { Logger.WriteLine("Exception while saving picture"); ErrorLog.AddError(ErrorType.Failure, "Could not save picture"); } finally { if (image != null) { image.Dispose(); } image = null; } isPerforming = false; } else { ReleasePreviousBuffers(); ErrorLog.AddError(ErrorType.Failure, "Webcam snapshot is disabled because selected camera was not found"); } }
public MapPage() { InitializeComponent(); ViewModel = (MapPageViewModel)BindingContext; ViewModel.SetView(this); Material.PlatformConfiguration.ChangeStatusBarColor(new Color(1, 1, 1, 0.5)); NavigationPage.SetHasNavigationBar(this, false); PlotPins = new List <Pin>(); PlotDelineations = new List <Polygon>(); DelineationPins = new List <Pin>(); DelineationPositions = new List <Position>(); HubContactPins = new List <Pin>(); InvestigationPlatformPins = new List <Pin>(); MachineryPointPins = new List <Pin>(); ImagePopup = new ImagePopup(); }
private void Image_Tapped(object sender, TappedRoutedEventArgs e) { var originalSender = (Image)sender; var comment = (Comment)originalSender.DataContext; var bounds = Window.Current.Bounds; var popup = new Popup(); var imagePopup = new ImagePopup(); imagePopup.DataContext = comment.ImagePath; imagePopup.Width = bounds.Width; imagePopup.Height = bounds.Height; popup.Child = imagePopup; popup.IsLightDismissEnabled = true; popup.IsOpen = true; }
private void onImagePrefabLoaded(string path, GameObject prefab) { DImagePopup dImagePopup = new DImagePopup(); dImagePopup.ImageContentKey = item.DataModel.PopupImageContentKey; dImagePopup.Text = ""; GameObject gameObject = Object.Instantiate(prefab); ImagePopup component = gameObject.GetComponent <ImagePopup>(); if (component != null) { if (item.DataModel.PopupImageContentKey != null && !string.IsNullOrEmpty(item.DataModel.PopupImageContentKey.Key)) { component.SetData(dImagePopup); } component.EnableCloseButtons(closeButtonEnabled: false, fullScreenButtonEnabled: true); component.ShowBackground = true; } Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(gameObject, destroyPopupOnBackPressed: false, scaleToFit: true, "Accessibility.Popup.Title.QuestItem")); }
private void onPrefabLoaded(string path, GameObject prefab) { DImagePopup dImagePopup = new DImagePopup(); dImagePopup.ImageContentKey = new SpriteContentKey(ImageAssetPath); dImagePopup.ImageOffset = ImageOffset; dImagePopup.ImageScale = ImageScale; if (!HasText) { dImagePopup.Text = ""; } else if (string.IsNullOrEmpty(i18nText)) { dImagePopup.Text = Text; } else { dImagePopup.Text = i18nText; } dImagePopup.TextStyle = TextStyle; dImagePopup.TextAlignment = TextAlignment; dImagePopup.TextOffset = TextOffset; popup = Object.Instantiate(prefab); imagePopup = popup.GetComponent <ImagePopup>(); if (imagePopup != null) { imagePopup.SetData(dImagePopup); imagePopup.EnableCloseButtons(ShowCloseButton, FullScreenClose); imagePopup.ShowBackground = ShowBackground; imagePopup.OpenDelay = OpenDelay; imagePopup.DoneClose += onPopupClosed; } Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(popup)); if (!WaitForPopupComplete) { Finish(); } }
public async Task UpdateImages() { using (await MaterialDialog.Instance.LoadingSnackbarAsync("UpdatingImages")) { AllImages.Children.Clear(); if (ViewModel.SelectedPlot?.MediaItems != null && (bool)ViewModel.SelectedPlot?.MediaItems.Any()) { foreach (var img in ViewModel.SelectedPlot.MediaItems) { var layout = new AbsoluteLayout { Margin = 10 }; var imageSource = img.IsVideo ? "video_icon.png" : ImageSource.FromFile(img.Path); var closeImage = new CachedImage { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start, HeightRequest = 20, WidthRequest = 20, DownsampleToViewSize = true, Source = "close_cross.png" }; var cachedImage = new CachedImage { HeightRequest = 150, WidthRequest = 150, IsVisible = true, Source = imageSource, ClassId = img.Id.ToString(), CacheType = CacheType.Disk, DownsampleToViewSize = true, }; cachedImage.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => { if (!img.IsVideo) { ImagePopup.Show(img.Path); } else { //Device.OpenUri(new Uri(img.Path)); ViewModel.DocumentViewer.ShowDocumentFile(img.Path, MimeTypes.Mp4); } }) }); layout.HeightRequest = 150; layout.WidthRequest = 150; AbsoluteLayout.SetLayoutBounds(closeImage, new Rectangle(1, 0, 30, 30)); AbsoluteLayout.SetLayoutFlags(closeImage, AbsoluteLayoutFlags.All); layout.Children.Add(cachedImage); layout.Children.Add(closeImage); layout.RaiseChild(closeImage); closeImage.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async o => { ViewModel.SelectedPlot?.MediaItems.Remove(img); await UpdateImages(); }), NumberOfTapsRequired = 1 }); AllImages.Children.Add(layout); } } } }