public async Task StartFlashingButtonAsync(ButtonFlash button, CancellationToken cancellationToken = default) { const int PHOTO_FLASH_DELAY = 500; Control buttonToFlash = button switch { ButtonFlash.InventorySearch => Target.SearchBtn, ButtonFlash.PublishToWeb => Target.PublishBtn, ButtonFlash.Purchase => Target.BuyBtn, ButtonFlash.NextPhoto => Target.NextBtn, ButtonFlash.PreviousPhoto => Target.PreviousBtn, _ => throw new ArgumentException(null, nameof(button)) }; bool flashToggle = false; while (!cancellationToken.IsCancellationRequested) { Resources.RenderButtonState(buttonToFlash, flashToggle = !flashToggle); await Task.Delay(PHOTO_FLASH_DELAY, cancellationToken).ConfigureAwait(false); } Resources.RenderButtonState(buttonToFlash, button == ButtonFlash.InventorySearch); //TODO: sets others to disabled state, is this fine? }
void BttFlash_TouchUpInside(object sender, EventArgs e) { var device = captureDeviceInput.Device; var error = new NSError(); if (device.HasFlash) { if (device.FlashMode == AVCaptureFlashMode.On) { device.LockForConfiguration(out error); device.FlashMode = AVCaptureFlashMode.Off; device.UnlockForConfiguration(); ButtonFlash.SetImage(UIImage.FromBundle("flash_off").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); } else { device.LockForConfiguration(out error); device.FlashMode = AVCaptureFlashMode.On; device.UnlockForConfiguration(); ButtonFlash.SetImage(UIImage.FromBundle("flash_on").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); } } }
private void Out_Click(object sender, EventArgs e) { if (AmpelNebenstraße.Zustand == 0) { bOutFlash = true; outPush = true; ButtonFlash.Start(); } }
private void Left_Click(object sender, EventArgs e) { if (AmpelLinks.Zustand == 0) { bLeftFlash = true; leftPush = true; ButtonFlash.Start(); } }
private void ButtonFlash_Tick(object sender, EventArgs e) { #region Left Button Flash if (bLeftFlash == true) { if (iBLF % 2 == 0) { Left.BackColor = Color.LightGreen; } else { Left.BackColor = Color.Ivory; } iBLF++; if (AmpelLinks.Zustand != 0) { bLeftFlash = false; Left.BackColor = Color.Ivory; iBLF = 0; } } #endregion Left Button Flash #region Out Button Flash if (bOutFlash == true) { if (iBOF % 2 == 0) { Out.BackColor = Color.LightGreen; } else { Out.BackColor = Color.Ivory; } iBOF++; if (AmpelNebenstraße.Zustand != 0) { bOutFlash = false; Out.BackColor = Color.Ivory; iBOF = 0; } } #endregion Out Button Flash #region Timer Stoppen, wenn nicht benötigt if (bOutFlash == false && bLeftFlash == false) { ButtonFlash.Stop(); } #endregion Timer Stoppen, wenn nicht benötigt }
public void SetupLiveCameraStream() { captureSession = new AVCaptureSession(); var viewLayer = CameraView.Layer; videoPreviewLayer = new AVCaptureVideoPreviewLayer(captureSession) { Frame = this.View.Bounds }; videoPreviewLayer.VideoGravity = AVLayerVideoGravity.ResizeAspectFill; CameraView.Layer.AddSublayer(videoPreviewLayer); var captureDevice = AVCaptureDevice.GetDefaultDevice(AVMediaType.Video); ConfigureCameraForDevice(captureDevice); captureDeviceInput = AVCaptureDeviceInput.FromDevice(captureDevice); captureSession.AddInput(captureDeviceInput); var dictionary = new NSMutableDictionary(); dictionary[AVVideo.CodecKey] = new NSNumber((int)AVVideoCodec.JPEG); stillImageOutput = new AVCaptureStillImageOutput() { OutputSettings = new NSDictionary() }; captureSession.AddOutput(stillImageOutput); captureSession.StartRunning(); ButtonBack.SetImage(UIImage.FromBundle("arrow_left").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); ButtonFlash.SetImage(UIImage.FromBundle("flash_off").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); ButtonSwitch.SetImage(UIImage.FromBundle("switch_camera").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); ButtonCapture.SetImage(UIImage.FromBundle("capture_camera").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); ButtonFlash.TouchUpInside += BttFlash_TouchUpInside; ButtonCapture.TouchUpInside += BttCapture_TouchUpInside; ButtonBack.TouchUpInside += BttBack_TouchUpInside; ButtonSwitch.TouchUpInside += BttSwitch_TouchUpInside; }
void ReleaseDesignerOutlets() { if (ButtonBack != null) { ButtonBack.Dispose(); ButtonBack = null; } if (ButtonCapture != null) { ButtonCapture.Dispose(); ButtonCapture = null; } if (ButtonFlash != null) { ButtonFlash.Dispose(); ButtonFlash = null; } if (ButtonSwitch != null) { ButtonSwitch.Dispose(); ButtonSwitch = null; } if (CameraView != null) { CameraView.Dispose(); CameraView = null; } if (ViewTop != null) { ViewTop.Dispose(); ViewTop = null; } }
private void CarMove_Tick(object sender, EventArgs e) { #region Car1 fährt gerade aus if (bCar1_enable == true) { #region Stop an Ampel if (iCar1X >= 789 && iCar1X <= 801 && AmpelGerade.Zustand != 5) { } #endregion Stop an Ampel #region Fahrbefehle else { //Zufall für Spurwechsel nach Ampel if (iCar1X <= 1100) { iSpurwechsel = rSpurwechsel.Next(0, 2); } //Spurwechsel if (iCar1X == 1100 && iSpurwechsel == 1) { iCar1Y -= iCarSpeedNormal / 2; iCar1X += iCarSpeedNormal; } //Gerade aus ohne Spurwechsel else { iCar1X += iCarSpeedNormal; } //Gerade mit Spurwechsel if (iCar1X >= 1100 && iCar1Y < 535) { if (iCar1Y >= 415) { iCar1Y -= iCarSpeedNormal - 3; } iCar1X += iCarSpeedFast; } } //Zurücksetzen if (iCar1X >= 1920) { iCar1X = -50; iCar1Y = 535; iCountCar1++; } this.Car1.Location = new Point(iCar1X, iCar1Y); #endregion Fahrbefehle } #endregion Car1 #region Car2 biegt links ab if (bCar2_enable == true) { #region Stop Bei Rot & Anforderung Kontaktschleife if (iCar2X >= 689 && iCar2X <= 701 && AmpelLinks.Zustand != 3) { ButtonFlash.Start(); if (bLeftFlash == false) { bLeftFlash = true; } if (bLeftFertig == true) { bLeftFertig = false; //leftPush = true; Left_Click(sender, e); } } #endregion #region Fahrbefehle else { //Gerade if (iCar2X < 850) { iCar2X += iCarSpeedNormal; } //Kurve if (iCar2X >= 850 && iCar2X <= 975) { iCar2X += iCarSpeedNormal / 2; iCar2Y -= iCarSpeedNormal / 2; } //Gerade auf Nebenstraße if (iCar2X >= 980) { iCar2Y -= iCarSpeedNormal; } //Rücksetzen if (iCar2Y <= -50) { iCar2Y = 415; iCar2X = -50; iCountCar2++; } } this.Car2.Location = new Point(iCar2X, iCar2Y); #endregion } #endregion Car2 biegt links ab #region Car3 fährt aus Nebenstraße if (bCar3_enable == true) { #region Stop bei Rot & Kontakschleife Anfordern if (iCar3Y >= 109 && iCar3Y <= 121 && AmpelNebenstraße.Zustand != 3) { ButtonFlash.Start(); if (bOutFlash == false) { bOutFlash = true; } #region Anforderung der Kontaktschleife if (bOutFertig == true) { Out_Click(sender, e); bOutFertig = false; //outPush = true; //Zufall für Abbiegen iCar3LR = Car3LR.Next(0, 100); } #endregion } #endregion #region Fahrbefehle else { //Gerade bis zur Ampel if (iCar3Y < 250) { iCar3Y += iCarSpeedNormal - 3; } //Rechts Abbiegen if (iCar3Y >= 250 && iCar3Y < 280 && (iCar3LR % 2) == 0 && bCar3L == false) { iCar3X -= 2; iCar3Y += 2; bCar3R = true; } if (iCar3Y >= 280 && bCar3R == true) { iCar3X -= iCarSpeedNormal; } //Zurücksetzen nach Rechts Abbiegen if (iCar3X <= -50 && bCar3R == true) { iCar3X = 890; iCar3Y = -50; bCar3R = false; iCountCar3++; } //Links abbiegen if (iCar3Y >= 250 && iCar3Y < 540 && (iCar3LR % 2) != 0 && bCar3R == false) { iCar3X += iCarSpeedNormal / 5; iCar3Y += (iCarSpeedNormal / 5) * 3; bCar3L = true; } if (iCar3Y >= 535 && bCar3L == true) { iCar3X += iCarSpeedNormal; } //Rücksetzen nach Links Abbiegen if (iCar3X >= 1920 && bCar3L == true) { iCar3X = 890; iCar3Y = -50; bCar3L = false; iCountCar3++; } this.Car3.Location = new Point(iCar3X, iCar3Y); } #endregion } #endregion Car3 fährt aus Nebenstraße #region Car4 Fährt von Rechts nach Links if (bCar4_enable == true) { #region Stop bei Rot & Zufall für Abbiegen if (iCar4X >= 1080 && iCar4X <= 1100 && AmpelGeradeRechts.Zustand != 5) { //Zufall für Abbiegen iCar4RG = Car4RG.Next(0, 100); } #endregion #region Fahrbefehle else { #region bis zur Ampel if (iCar4X > 1020) { iCar4X -= iCarSpeedNormal; } #endregion #region Rechts Abbiegen //Kurve if (iCar4X <= 1020 && iCar4X > 980 && (iCar4RG % 2) == 0 && bCar4G == false) { iCar4X -= iCarSpeedNormal / 2; iCar4Y -= iCarSpeedNormal / 2; bCar4R = true; } //Gerade auf Nebenstraße if (iCar4X <= 980 && bCar4R == true) { iCar4Y -= iCarSpeedNormal; } //Rücksetzen if (iCar4Y <= -50 && bCar4R == true) { iCar4X = 1920; iCar4Y = 300; bCar4R = false; iCountCar4++; } #endregion #region Gerade if (iCar4X <= 1020 && iCar4X > 980 && (iCar4RG % 2) != 0 && bCar4R == false) { iCar4X -= iCarSpeedNormal; bCar4G = true; } if (iCar4X <= 980 && bCar4G == true) { iCar4X -= iCarSpeedNormal; } //Rücksetzen if (iCar4X <= -50 && bCar4G == true) { iCar4X = 1920; iCar4Y = 300; bCar4G = false; iCountCar4++; } #endregion } this.Car4.Location = new Point(iCar4X, iCar4Y); #endregion } #endregion Car4 fährt von rechts nach links }