public void ButtonFinished(ButtonView button, UIView trackingView, UITouch location) { double delayInSeconds; buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; CGPoint point = location.LocationInView(miniPadView); if (miniPadView.PointInside(point, null)) { UpdateScoreForDroppedButton(button); UIView.Animate(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(10f * (float)Math.PI / 180), async() => { await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(-10f * (float)Math.PI / 180)); await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(10f * (float)Math.PI / 180)); await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(-10f * (float)Math.PI / 180)); await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(0)); }); } delayInSeconds = 0.5; var popTime = new DispatchTime(DispatchTime.Now, (long)(delayInSeconds * NSEC_PER_SEC)); DispatchQueue.MainQueue.DispatchAfter(popTime, async() => { await UIView.AnimateAsync(0.35f, () => { CGRect bounds = trackingView.Bounds; bounds.Size = new CGSize(10, 10); trackingView.Bounds = bounds; }); trackingView.RemoveFromSuperview(); }); }
public void ButtonSelected(ButtonView button) { if (!isVoiceOverSpeaking) { UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"Memory Selected, drag to zombies to play"); } }
public void TrackingStarted(ButtonView button) { UIGraphics.BeginImageContext(button.Bounds.Size); button.Layer.RenderInContext(UIGraphics.GetCurrentContext()); UIImage image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); if (trackingImageView == null) { trackingImageView = new UIImageView(RectangleF.Empty); Superview.AddSubview(trackingImageView); trackingImageView.Alpha = 0.5f; } trackingImageView.Image = image; trackingImageView.SizeToFit(); RectangleF frame = trackingImageView.Frame; var newFrame = new RectangleF(Superview.ConvertPointFromView(button.Frame.Location, this), frame.Size); trackingImageView.Frame = newFrame; if (ButtonSelectedEvent != null) { ButtonSelectedEvent(button); } }
public void TrackingEnded(ButtonView button, UITouch location) { if (ButtonFinishedEvent != null) { ButtonFinishedEvent(button, trackingImageView, location); } trackingImageView = null; }
public void TrackingContinued(ButtonView button, UITouch location) { PointF point = location.LocationInView(Superview); RectangleF frame = trackingImageView.Frame; var newPoint = new PointF(point.X - button.Frame.Size.Width / 2, point.Y - button.Frame.Size.Height / 2); var newFrame = new RectangleF(newPoint, frame.Size); trackingImageView.Frame = newFrame; if (ButtonDraggedEvent != null) { ButtonDraggedEvent(button, location); } }
public ButtonCollectionView(CGRect frame) : base(frame) { Layer.BorderColor = UIColor.Black.CGColor; Layer.BorderWidth = 1; Layer.CornerRadius = 8; BackgroundColor = UIColor.White.ColorWithAlpha(0.75f); for (int k = 0; k < (int)ButtonType.Count; k++) { var button = new ButtonView(CGRect.Empty); AddSubview(button); button.TrackingStartedEvent += TrackingStarted; button.TrackingContinuedEvent += TrackingContinued; button.TrackingEndedEvent += TrackingEnded; button.Tag = k; button.SetLabel(ButtonLabelForType((ButtonType)k)); } }
public ButtonCollectionView (RectangleF frame) : base(frame) { Layer.BorderColor = UIColor.Black.CGColor; Layer.BorderWidth = 1; Layer.CornerRadius = 8; BackgroundColor = UIColor.White.ColorWithAlpha (0.75f); for (int k = 0; k < (int) ButtonType.Count; k++) { var button = new ButtonView (RectangleF.Empty); AddSubview (button); button.TrackingStartedEvent += TrackingStarted; button.TrackingContinuedEvent += TrackingContinued; button.TrackingEndedEvent += TrackingEnded; button.Tag = k; button.SetLabel (ButtonLabelForType ((ButtonType)k)); } }
public void TrackingStarted (ButtonView button) { UIGraphics.BeginImageContext (button.Bounds.Size); button.Layer.RenderInContext (UIGraphics.GetCurrentContext ()); UIImage image = UIGraphics.GetImageFromCurrentImageContext (); UIGraphics.EndImageContext (); if (trackingImageView == null) { trackingImageView = new UIImageView (RectangleF.Empty); Superview.AddSubview (trackingImageView); trackingImageView.Alpha = 0.5f; } trackingImageView.Image = image; trackingImageView.SizeToFit (); RectangleF frame = trackingImageView.Frame; var newFrame = new RectangleF (Superview.ConvertPointFromView (button.Frame.Location, this), frame.Size); trackingImageView.Frame = newFrame; if (ButtonSelectedEvent != null) ButtonSelectedEvent (button); }
void updateScoreForDroppedButton(ButtonView button) { ButtonType buttonType = (ButtonType)(int)button.Tag; float change = 0; switch (buttonType) { case ButtonType.Free: change = -.02f; break; case ButtonType.DeAlloc: change = -.03f; break; case ButtonType.Release: change = -0.1f; break; case ButtonType.AutoRelease: change = -0.5f; break; case ButtonType.GC: change = .1f; break; case ButtonType.ARC: change = -.1f; break; default: break; } meterView.ZombieLevel = meterView.ZombieLevel + change; monitorZombiePressure(); manageVisibleZombies(); }
public void ButtonDragged(ButtonView button, UITouch location) { CGPoint point = location.LocationInView(miniPadView); if (miniPadView.PointInside(point, null)) { if (!buttonDraggedToPad) { CATransaction.Begin(); CATransaction.AnimationDuration = 1; miniPadView.Layer.BorderColor = UIColor.Yellow.CGColor; miniPadView.Layer.BorderWidth = 2; CATransaction.Commit(); buttonDraggedToPad = true; if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"Memory object near the zombies, Lift to deploy"); } } } else { if (buttonDraggedToPad) { if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification(UIAccessibilityPostNotification.Announcement, (NSString)"Memory object outside iPad. Lift to Cancel"); } } buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; } }
public void ButtonFinished (ButtonView button, UIView trackingView, UITouch location) { double delayInSeconds = 0; buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; CGPoint point = location.LocationInView (miniPadView); if (miniPadView.PointInside (point, null)) { updateScoreForDroppedButton (button); UIView.Animate (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (10f * (float)Math.PI / 180), async () => { await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (-10f * (float)Math.PI / 180)); await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (10f * (float)Math.PI / 180)); await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (-10f * (float)Math.PI / 180)); await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (0)); }); } delayInSeconds = 0.5; var popTime = new DispatchTime (DispatchTime.Now, (long)(delayInSeconds * NSEC_PER_SEC)); DispatchQueue.MainQueue.DispatchAfter (popTime, async () => { await UIView.AnimateAsync (0.35f, () => { CGRect bounds = trackingView.Bounds; bounds.Size = new CGSize (10, 10); trackingView.Bounds = bounds; }); trackingView.RemoveFromSuperview (); }); }
public void ButtonDragged (ButtonView button, UITouch location) { CGPoint point = location.LocationInView (miniPadView); if (miniPadView.PointInside (point, null)) { if (!buttonDraggedToPad) { CATransaction.Begin (); CATransaction.AnimationDuration = 1; miniPadView.Layer.BorderColor = UIColor.Yellow.CGColor; miniPadView.Layer.BorderWidth = 2; CATransaction.Commit (); buttonDraggedToPad = true; if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification (UIAccessibilityPostNotification.Announcement, (NSString)"Memory object near the zombies, Lift to deploy"); } } } else { if (buttonDraggedToPad) { if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification (UIAccessibilityPostNotification.Announcement, (NSString)"Memory object outside iPad. Lift to Cancel"); } } buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; } }
public void ButtonSelected (ButtonView button) { if (!isVoiceOverSpeaking) UIAccessibility.PostNotification (UIAccessibilityPostNotification.Announcement, (NSString)"Memory Selected, drag to zombies to play"); }
void updateScoreForDroppedButton (ButtonView button) { ButtonType buttonType = (ButtonType)(int)button.Tag; float change = 0; switch (buttonType) { case ButtonType.Free: change = -.02f; break; case ButtonType.DeAlloc: change = -.03f; break; case ButtonType.Release: change = -0.1f; break; case ButtonType.AutoRelease: change = -0.5f; break; case ButtonType.GC: change = .1f; break; case ButtonType.ARC: change = -.1f; break; default: break; } meterView.ZombieLevel = meterView.ZombieLevel + change; monitorZombiePressure (); manageVisibleZombies (); }
public void TrackingEnded (ButtonView button, UITouch location) { if (ButtonFinishedEvent != null) ButtonFinishedEvent (button, trackingImageView, location); trackingImageView = null; }
public void TrackingContinued (ButtonView button, UITouch location) { PointF point = location.LocationInView (Superview); RectangleF frame = trackingImageView.Frame; var newPoint = new PointF (point.X - button.Frame.Size.Width / 2, point.Y - button.Frame.Size.Height / 2); var newFrame = new RectangleF (newPoint, frame.Size); trackingImageView.Frame = newFrame; if (ButtonDraggedEvent != null) ButtonDraggedEvent (button, location); }