コード例 #1
0
ファイル: ViewHandler.cs プロジェクト: mohachouch/Comet
        public static void MapAnimationProperty(IViewHandler handler, View virtualView)
        {
            var nativeView = (UIView)handler.NativeView;
            var animation  = virtualView.GetAnimation();

            if (animation != null)
            {
                System.Diagnostics.Debug.WriteLine($"Starting animation [{animation}] on [{virtualView.GetType().Name}/{nativeView.GetType().Name}]");

                var duration = (animation.Duration ?? 1000.0) / 1000.0;
                var delay    = (animation.Delay ?? 0.0) / 1000.0;
                var options  = animation.Options.ToAnimationOptions();

                UIView.Animate(
                    duration,
                    delay,
                    options,
                    () =>
                {
                    System.Diagnostics.Debug.WriteLine($"Animation [{animation}] has been started");

                    var transform = CGAffineTransform.MakeIdentity();

                    if (animation.TranslateTo != null)
                    {
                        var translateTransform = CGAffineTransform.MakeTranslation(animation.TranslateTo.Value.X, animation.TranslateTo.Value.Y);
                        transform = CGAffineTransform.Multiply(transform, translateTransform);
                    }
                    if (animation.RotateTo != null)
                    {
                        var angle           = Convert.ToSingle(animation.RotateTo.Value * Math.PI / 180);
                        var rotateTransform = CGAffineTransform.MakeRotation(angle);
                        transform           = CGAffineTransform.Multiply(transform, rotateTransform);
                    }
                    if (animation.ScaleTo != null)
                    {
                        var scaleTransform = CGAffineTransform.MakeScale(animation.ScaleTo.Value.X, animation.ScaleTo.Value.Y);
                        transform          = CGAffineTransform.Multiply(transform, scaleTransform);
                    }
                    // TODO: implement other animations

                    nativeView.Transform = transform;
                },
                    () =>
                {
                    System.Diagnostics.Debug.WriteLine($"Animation [{animation}] has been completed");
                    // Do nothing
                });
            }
        }
コード例 #2
0
 void SignalTimeChanged(DateTime time)
 {
     InvokeOnMainThread(() =>
                        UIView.Animate(0.5, () =>
     {
         TimeLabel.Text       = time.ToLongTimeString();
         nfloat secondDegrees = ((360 / 60) * time.Second);
         //the value in degrees
         secondHand.Transform = CGAffineTransform.MakeRotation(secondDegrees * (nfloat)Math.PI / 180f);
         nfloat minuteDegrees = ((360 / 60) * time.Minute);
         //the value in degrees
         minuteHand.Transform = CGAffineTransform.MakeRotation(minuteDegrees * (nfloat)Math.PI / 180f);
     }));
 }
コード例 #3
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     webView.LoadHtmlString(html, null);
     View.AddSubview(webView);
     View.BackgroundColor = UIColor.LightGray;
     webView.Transform    = CGAffineTransform.MakeRotation(1.57f);
     webView.Frame        = new CoreGraphics.CGRect(0, 50, 42, 171);
     originalFrame        = webView.Frame;
     View.AddSubview(button);
     View.AddSubview(button1);
     button.Frame  = new CoreGraphics.CGRect(View.Frame.Width / 2, 0, View.Frame.Width / 2, 50);
     button1.Frame = new CGRect(0, 0, View.Frame.Width / 2, 50);
 }
コード例 #4
0
        public UISingleDayView()
        {
            _title = new UILabel()
            {
                Font = UIFont.PreferredBody
            };
            this.Add(_title);

            _buttonExpand = new UIButton(UIButtonType.System);
            _buttonExpand.SetImage(UIImage.FromBundle("ToolbarDown").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);
            nfloat radians180 = unchecked ((nfloat)Math.PI); // 180 degrees is exactly PI in radians

            _buttonExpand.Transform      = CGAffineTransform.MakeRotation(radians180);
            _buttonExpand.TouchUpInside += _buttonExpand_TouchUpInside;
            this.Add(_buttonExpand);

            _nothingDueText = new UILabel()
            {
                Font          = UIFont.PreferredBody,
                Text          = PowerPlannerResources.GetString("String_NothingDue"),
                TextAlignment = UITextAlignment.Center,
                TextColor     = UIColor.LightGray
            };
            this.Add(_nothingDueText);

            _line = new CAShapeLayer()
            {
                FillColor = UIColor.LightGray.CGColor
            };
            this.Layer.AddSublayer(_line);

            _items = new UITableView()
            {
                SeparatorInset = UIEdgeInsets.Zero
            };
            if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
            {
                // Stretch to full width even on iPad
                _items.CellLayoutMarginsFollowReadableWidth = false;
            }
            _scheduleSnapshot = new UIDayScheduleSnapshot();
            _scheduleSnapshot.OnRequestViewClass += new WeakEventHandler <ViewItemClass>(_scheduleSnapshot_OnRequestViewClass).Handler;
            _items.TableFooterView = _scheduleSnapshot;
            this.Add(_items);

            MainScreenViewController.ListenToTabBarHeightChanged(ref _tabBarHeightListener, delegate
            {
                _items.ContentInset = new UIEdgeInsets(0, 0, MainScreenViewController.TAB_BAR_HEIGHT, 0);
            });
        }
コード例 #5
0
        void HandleUpdatedHeading(object sender, CLHeadingUpdatedEventArgs e)
        {
            double oldRad = -_iPhoneLocationManager.Heading.TrueHeading * Math.PI / 180D;
            double newRad = -e.NewHeading.TrueHeading * Math.PI / 180D;

            CABasicAnimation theAnimation;

            theAnimation          = CABasicAnimation.FromKeyPath("transform.rotation");
            theAnimation.From     = NSNumber.FromDouble(oldRad);
            theAnimation.To       = NSNumber.FromDouble(newRad);
            theAnimation.Duration = 0.5;
            compassImage.Layer.AddAnimation(theAnimation, "rotationAnimation");
            compassImage.Transform = CGAffineTransform.MakeRotation((float)newRad);
        }
コード例 #6
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);
            var touch = (UITouch)touches.AnyObject;
            var point = touch.LocationInView(this);

            var dx        = point.X - _container.Center.X;
            var dy        = point.Y - _container.Center.Y;
            var angle     = Math.Atan2(dy, dx);
            var angleDiff = (float)(_deltaAngle - angle);

            _startTransform.Rotate(-angleDiff);
            _container.Transform = CGAffineTransform.MakeRotation(-angleDiff);
        }
コード例 #7
0
        /// <summary>
        /// Toucheses the moved.
        /// </summary>
        /// <param name="touches">Touches.</param>
        /// <param name="evt">Evt.</param>
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);

            var touch = evt.AllTouches.AnyObject as UITouch;

            if (touch.View is UIImageView)
            {
                var mustReturnToOldRotation = false;

                var degrees = GetRotationValueOfView(touch.View);
                if (Math.Abs(degrees / 45) % 2 == 1)
                {
                    mustReturnToOldRotation = true;

                    degrees += 45.0f;
                    var radians = Math.PI / 180 * degrees;
                    touch.View.Transform = CGAffineTransform.MakeRotation((float)radians);
                }

                int rawX = (int)touch.LocationInView(View).X;
                int rawY = (int)touch.LocationInView(View).Y;

                var xDelta = rawX - _oldX;
                var yDelta = rawY - _oldY;

                var touchLocation = touch.LocationInView(View);
                var frame         = touch.View.Frame;
                frame.X          = View.Window.Frame.X + touchLocation.X - _oldX;
                frame.Y          = View.Window.Frame.Y + touchLocation.Y - _oldY;
                touch.View.Frame = frame;

                _viewModel.MoveKite((int)touch.View.Tag, new Position
                {
                    X = (float)touch.View.Frame.X,
                    Y = (float)touch.View.Frame.Y
                });

                if (mustReturnToOldRotation)
                {
                    degrees -= 45.0f;
                    var radians = Math.PI / 180 * degrees;
                    touch.View.Transform = CGAffineTransform.MakeRotation((float)radians);
                }

                _drawView.UpdateTeam(_viewModel.Team);
                View.SetNeedsDisplay();
                _drawView.SetNeedsDisplay();
            }
        }
コード例 #8
0
ファイル: DraggableView.cs プロジェクト: libin85/Bait-News
        void DetermineSwipeAction(nfloat xTranslation)
        {
            if (xTranslation <= -SwipeThreshold)
            {
                if (xTranslation < -220)
                {
                    Dragged = DraggableDirection.Left;
                    UIView.Animate(RotationAnimationDuration, () =>
                    {
                        Center = new CGPoint(Frame.Width - 700, startingPoint.Y);
                        // The translation of the pan gesture in the coordinate system of the specified UIView.
                        Transform = CGAffineTransform.MakeRotation(0);
                    });
                }
                else
                {
                    ResetView();
                }
            }
            else if (xTranslation >= SwipeThreshold)
            {
                if (xTranslation > 220)
                {
                    Dragged = DraggableDirection.Right;
                    UIView.Animate(RotationAnimationDuration, () =>
                    {
                        Center = new CGPoint(Frame.Width + 700, startingPoint.Y);
                        // The translation of the pan gesture in the coordinate system of the specified UIView.
                        Transform = CGAffineTransform.MakeRotation(0);
                    });
                }
                else
                {
                    ResetView();
                }
            }
            else
            {
                Dragged = DraggableDirection.None;
                ResetView();
            }

            var evt = OnSwipe;

            if (evt != null)
            {
                OnSwipe(this, new DraggableEventArgs(Dragged));
            }
        }
コード例 #9
0
        static CALayer CreateNeedle(CGRect bounds)
        {
            UIImage needleImage     = UIImage.FromBundle("VUMeterNeedle");
            CGSize  needleImageSize = needleImage.Size;

            var needleLayer = CALayer.Create();

            needleLayer.AffineTransform = CGAffineTransform.MakeRotation(ConvertValueToNeedleAngle(nfloat.NegativeInfinity));
            needleLayer.AnchorPoint     = new CGPoint(0.5f, 1);
            needleLayer.Bounds          = new CGRect(0, 0, needleImageSize.Width, needleImageSize.Height);
            needleLayer.Contents        = needleImage.CGImage;
            needleLayer.Position        = new CGPoint(0.5f * bounds.Width, needleImageSize.Height);

            return(needleLayer);
        }
コード例 #10
0
ファイル: ViewController.cs プロジェクト: MIliev11/Samples
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            image     = UIImage.FromBundle("dino-sml.jpeg");
            imageView = new UIImageView(new CGRect(50, 50, 100, 100))
            {
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = image,
                Transform   = CGAffineTransform.MakeRotation((float)Math.PI / 4)
            };

            View.AddSubview(imageView);
        }
コード例 #11
0
        /// <summary>
        /// Creates a Transform to apply to the OpenGL view to display the Video at the proper orientation
        /// </summary>
        /// <returns>
        /// A transform to correct the orientation
        /// </returns>
        /// <param name='orientation'>
        /// Current Orientation
        /// </param>
        public CGAffineTransform TransformFromCurrentVideoOrientationToOrientation(AVCaptureVideoOrientation orientation)
        {
            CGAffineTransform transform = CGAffineTransform.MakeIdentity();

            // Calculate offsets from an arbitrary reference orientation (portrait)
            float orientationAngleOffset      = AngleOffsetFromPortraitOrientationToOrientation(orientation);
            float videoOrientationAngleOffset = AngleOffsetFromPortraitOrientationToOrientation(videoOrientation);

            // Find the difference in angle between the passed in orientation and the current video orientation
            float angleOffset = orientationAngleOffset - videoOrientationAngleOffset;

            transform = CGAffineTransform.MakeRotation(angleOffset);

            return(transform);
        }
コード例 #12
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell(cellIdentifier) as LogTableViewCell;

            if (cell == null)
            {
                var views = NSBundle.MainBundle.LoadNib("LogTableViewCell", tableView, null);
                cell = Runtime.GetNSObject(views.ValueAt(0)) as LogTableViewCell;
            }

            cell.Transform = CGAffineTransform.MakeRotation((float)Math.PI);
            cell.UpdateCell(data[indexPath.Row]);

            return(cell);
        }
コード例 #13
0
ファイル: Matrix.cs プロジェクト: migueldeicaza/DrawingSkia
        public void Rotate(float angle, MatrixOrder order)
        {
            angle *= (float)(Math.PI / 180.0);               // degrees to radians
            var affine = CGAffineTransform.MakeRotation(angle);

            if (order == MatrixOrder.Append)
            {
                transform.Multiply(affine);
            }
            else
            {
                affine.Multiply(transform);
                transform = affine;
            }
        }
コード例 #14
0
 private void CreateRotationGestureRecognizer()
 {
     rotateGesture = new UIRotationGestureRecognizer(() =>
     {
         if ((rotateGesture.State == UIGestureRecognizerState.Began ||
              rotateGesture.State == UIGestureRecognizerState.Changed) && (rotateGesture.NumberOfTouches == 2))
         {
             Transform = CGAffineTransform.MakeRotation(rotateGesture.Rotation + r);
         }
         else if (rotateGesture.State == UIGestureRecognizerState.Ended)
         {
             r += rotateGesture.Rotation;
         }
     });
 }
コード例 #15
0
        private CALayer createMinuteSegment(CGRect rect, CGColor color, nfloat distanceFromcenter, nfloat angle)
        {
            var layer = new CAShapeLayer();

            var rotation    = CGAffineTransform.MakeRotation(angle);
            var translation = CreateTranslationTransform(distanceFromcenter, angle);
            var transform   = rotation * translation;

            var path = CGPath.FromRect(rect, transform);

            layer.Path      = path;
            layer.FillColor = color;

            return(layer);
        }
コード例 #16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            slider.MinValue  = 1;
            slider.MaxValue  = 10;
            slider.Value     = 1;
            slider.Transform = CGAffineTransform.MakeRotation((float)PI / 2);

            slider.ValueChanged += (object sender, EventArgs e) => { lblValue.Text = slider.Value.ToString(); };


            // Perform any additional setup after loading the view, typically from a nib.
        }
コード例 #17
0
ファイル: MediaService.cs プロジェクト: tvvister91/Arena
        public byte[] RotateImage(byte[] imageData, int degrees)
        {
            //  get the original image from data
            UIImage originalImage = ImageFromByteArray(imageData);

            if (originalImage == null)
            {
                return(imageData);
            }


            // calculate the size of the rotated view's containing box for our drawing space
            var rotated         = new UIView(new CGRect(0, 0, originalImage.Size.Width, originalImage.Size.Height));
            CGAffineTransform t = CGAffineTransform.MakeRotation(DegreesToRadians(degrees));

            rotated.Transform = t;
            CGSize rotatedSize = rotated.Frame.Size;

            //  create the graphics context
            try
            {
                UIGraphics.BeginImageContext(rotatedSize);
                CGContext context = UIGraphics.GetCurrentContext();

                // Move the origin to the middle of the image so we will rotate and scale around the center.
                context.TranslateCTM(rotatedSize.Width / 2, rotatedSize.Height / 2);

                //   // Rotate the image context
                context.RotateCTM(DegreesToRadians(degrees));

                // Now, draw the rotated/scaled image into the context
                context.ScaleCTM(1.0f, -1.0f);
                context.DrawImage(new CGRect(-originalImage.Size.Width / 2, -originalImage.Size.Height / 2, originalImage.Size.Width, originalImage.Size.Height), originalImage.CGImage);

                var newImage = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();
                return(newImage.AsPNG().ToArray());
                //}
            }
            catch
            {
                return(null);
            }
            finally
            {
                UIGraphics.EndImageContext();
            }
        }
コード例 #18
0
 protected override void OnElementChanged(ElementChangedEventArgs <Image> e)
 {
     base.OnElementChanged(e);
     if (e.OldElement == null)
     {
         _image                 = UIImage.FromFile(e.NewElement.Source.ToString());
         _imageView             = new UIImageView(new CGRect(50, 50, 100, 100));
         _imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
         _imageView.Image       = _image;
         _imageView.Transform   = CGAffineTransform.MakeRotation((float)Math.PI / 4);
         AddSubview(_imageView);
         //FlipTransformation ft = new FlipTransformation(flipType);
         //var im = UIImage.FromFile(e.OldElement.Source.ToString());
         //ft.TransformFromUIImage(im);
     }
 }
コード例 #19
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();

            float y     = 0;
            float x     = 0;
            float width = (float)Bounds.Width;

            foreach (GradientButton b in _Buttons)
            {
                b.Bounds    = new CGSize(TabHeight, width).OriginRect();
                b.Center    = b.Bounds.Center().Add(new CGPoint(x, y));
                b.Transform = CGAffineTransform.MakeRotation((float)-Math.PI / 2.0f);
                y          += TabHeight;
            }
        }
コード例 #20
0
ファイル: ViewController.cs プロジェクト: bertdd/ocr-concept
        public void SetupUI()
        {
            // Live Camera Feed
            var layer = new AVCaptureVideoPreviewLayer(CaptureSession);

            layer.VideoGravity = AVLayerVideoGravity.ResizeAspectFill;

            layer.Frame = CameraView.Bounds;
            CameraView.Layer.AddSublayer(layer);

            // Selection Bar Options
            SelectionBarView.Layer.BorderWidth = 3.5f;
            SelectionBarView.Layer.BorderColor = new CGColor(246, 137, 27, 0.35f);

            SelectionBarSlider.Transform = CGAffineTransform.MakeRotation((float)PI / 2);
        }
コード例 #21
0
        void StartAnim()
        {
            int derece = 0;

            new System.Threading.Thread(new System.Threading.ThreadStart(delegate
            {
                InvokeOnMainThread(delegate()
                {
                    Timerr = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(0.004), delegate
                    {
                        derece += 1;
                        LoadingimView.Transform = CGAffineTransform.MakeRotation(3.14159f * derece / 180f);
                    });
                });
            })).Start();
        }
コード例 #22
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            RotationImage image = (RotationImage)sender;

            newRotation = (float)image.NextRotation;

            if (Control != null)
            {
                Animate(0.5, () =>
                {
                    nfloat angle = (nfloat)((newRotation * Math.PI) / 180);
                    Transform    = CGAffineTransform.MakeRotation(angle);
                });
            }
        }
コード例 #23
0
        void RotateAccordingToStatusBarOrientationAndSupportedOrientations()
        {
            var angle     = UIInterfaceOrientationAngleOfOrientation(UIApplication.SharedApplication.StatusBarOrientation);
            var transform = CGAffineTransform.MakeRotation(angle);

            if (!Transform.Equals(transform))
            {
                Transform = transform;
            }

            var frame = WindowBounds;

            if (!Frame.Equals(frame))
            {
                Frame = frame;
            }
        }
コード例 #24
0
            public override void DidOutputSampleBuffer(AVCaptureOutput captureOutput, CMSampleBuffer sampleBuffer, AVCaptureConnection connection)
            {
                try {
                    var image = ImageFromSampleBuffer(sampleBuffer);

                    // Do something with the image, we just stuff it in our main view.
                    AppDelegate.ImageView.BeginInvokeOnMainThread(() => {
                        TryDispose(AppDelegate.ImageView.Image);
                        AppDelegate.ImageView.Image     = image;
                        AppDelegate.ImageView.Transform = CGAffineTransform.MakeRotation((float)Math.PI / 2);
                    });
                } catch (Exception e) {
                    Console.WriteLine(e);
                } finally {
                    sampleBuffer.Dispose();
                }
            }
コード例 #25
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var collisionBehavior = new UICollisionBehavior(square)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };

            var pushBehavior = new UIPushBehavior(UIPushBehaviorMode.Instantaneous, square)
            {
                Angle     = 0.0f,
                Magnitude = 0.0f
            };

            Animator = new UIDynamicAnimator(View);
            Animator.AddBehaviors(collisionBehavior, pushBehavior);

            redSquare.Center            = new CGPoint(View.Bounds.GetMidX(), View.Bounds.GetMidY());
            redSquare.Layer.AnchorPoint = new CGPoint(0.0f, 0.5f);

            View.AddGestureRecognizer(new UITapGestureRecognizer((gesture) => {
                /*
                 * Tapping will change the angle and magnitude of the impulse.
                 * To visually show the impulse vector on screen, a red line representing
                 * the angle and magnitude of this vector is briefly drawn.
                 */
                CGPoint p      = gesture.LocationInView(View);
                CGPoint o      = new CGPoint(View.Bounds.GetMidX(), View.Bounds.GetMidY());
                float distance = (float)Math.Sqrt((p.X - o.X) * (p.X - o.X) + (p.Y - o.Y) * (p.Y - o.Y));
                float angle    = (float)Math.Atan2(p.Y - o.Y, p.X - o.X);
                distance       = Math.Min(distance, 100.0f);

                redSquare.Bounds    = new CGRect(0.0f, 0.0f, distance, 5.0f);
                redSquare.Transform = CGAffineTransform.MakeRotation(angle);
                redSquare.Alpha     = 1.0f;

                UIView.Animate(1.0f, () => {
                    redSquare.Alpha = 0.0f;
                });

                pushBehavior.Magnitude = distance / 100.0f;
                pushBehavior.Angle     = angle;
                pushBehavior.Active    = true;
            }));
        }
コード例 #26
0
        public static void Rotate(UIView view, bool isIn, bool fromLeft = true, double duration = 0.3, Action onFinished = null)
        {
            var minAlpha     = (nfloat)0.0f;
            var maxAlpha     = (nfloat)1.0f;
            var minTransform = CGAffineTransform.MakeRotation((nfloat)((fromLeft ? -1 : 1) * 720));
            var maxTransform = CGAffineTransform.MakeRotation((nfloat)0.0);

            view.Alpha     = isIn ? minAlpha : maxAlpha;
            view.Transform = isIn ? minTransform : maxTransform;
            UIView.Animate(duration, 0, UIViewAnimationOptions.CurveEaseInOut,
                           () => {
                view.Alpha     = isIn ? maxAlpha : minAlpha;
                view.Transform = isIn ? maxTransform : minTransform;
            },
                           onFinished
                           );
        }
コード例 #27
0
        public static UIImage Rotate(UIImage src, UIImageOrientation orientation)
        {
            if (orientation == UIImageOrientation.Up || orientation == UIImageOrientation.UpMirrored)
            {
                return(src);
            }

            nfloat angle = 0;

            if (orientation == UIImageOrientation.Right || orientation == UIImageOrientation.RightMirrored)
            {
                angle = 90;
            }

            if (orientation == UIImageOrientation.Down || orientation == UIImageOrientation.DownMirrored)
            {
                angle = 180;
            }

            if (orientation == UIImageOrientation.Left || orientation == UIImageOrientation.LeftMirrored)
            {
                angle = 270;
            }

            var radians         = GetRadians(angle);
            CGAffineTransform t = CGAffineTransform.MakeRotation(radians);
            UIView            rotatedViewBox = new UIView(new CGRect(0, 0, src.Size.Width, src.Size.Height));

            rotatedViewBox.Transform = t;
            CGSize rotatedSize = rotatedViewBox.Frame.Size;

            UIGraphics.BeginImageContext(src.Size);
            var context = UIGraphics.GetCurrentContext();

            context.TranslateCTM(src.Size.Width / 2.0f, src.Size.Height / 2.0f);
            context.RotateCTM(radians);
            context.ScaleCTM(1.0f, -1.0f);
            context.TranslateCTM(-rotatedSize.Width / 2.0f, -rotatedSize.Height / 2.0f);
            context.DrawImage(new CGRect(0, 0, rotatedSize.Width, rotatedSize.Height), src.CGImage);
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(image);
        }
コード例 #28
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Imagen.UserInteractionEnabled = true;
            var GestoToque = new UITapGestureRecognizer(Tocando);

            Gestomover = new UIPanGestureRecognizer(() =>
            {
                if ((Gestomover.State == UIGestureRecognizerState.Began || Gestomover.State == UIGestureRecognizerState.Changed) &&
                    (Gestomover.NumberOfTouches == 1))
                {
                    var p0 = Gestomover.LocationInView(View);
                    if (CoordenadaX == 0)
                    {
                        CoordenadaX = p0.X - Imagen.Center.X;
                    }
                    if (CoordenadaY == 0)
                    {
                        CoordenadaY = p0.Y - Imagen.Center.Y;
                    }
                    var p1        = new CGPoint(p0.X - CoordenadaX, p0.Y - CoordenadaY);
                    Imagen.Center = p1;
                }
                else
                {
                    CoordenadaX = 0;
                    CoordenadaY = 0;
                }
            });
            GestoRotar = new UIRotationGestureRecognizer(() =>
            {
                if ((GestoRotar.State == UIGestureRecognizerState.Began || GestoRotar.State == UIGestureRecognizerState.Changed) &&
                    (GestoRotar.NumberOfTouches == 2))
                {
                    Imagen.Transform = CGAffineTransform.MakeRotation(GestoRotar.Rotation + Rotation);
                }
                else if (GestoRotar.State == UIGestureRecognizerState.Ended)
                {
                    Rotation = GestoRotar.Rotation;
                }
            });
            Imagen.AddGestureRecognizer(Gestomover);
            Imagen.AddGestureRecognizer(GestoRotar);
            Imagen.AddGestureRecognizer(GestoToque);
        }
コード例 #29
0
 private void ZoomTap()
 {
     UIView.Animate(0.15, () =>
     {
         if (topArrow.Transform.xx == 1)
         {
             topArrow.Transform    = CGAffineTransform.MakeRotation((float)(Math.PI));
             bottomArrow.Transform = CGAffineTransform.MakeRotation(0);
         }
         else
         {
             topArrow.Transform    = CGAffineTransform.MakeRotation(0);
             bottomArrow.Transform = CGAffineTransform.MakeRotation((float)(Math.PI));
         }
     });
     _toSquareMode = !_toSquareMode;
     _cropView.ZoomTap(false);
 }
コード例 #30
0
        CGAffineTransform TransformForOrientation(UIInterfaceOrientation orientation)
        {
            switch (orientation)
            {
            case UIInterfaceOrientation.LandscapeLeft:
                return(CGAffineTransform.MakeRotation(-(float)Math.PI / 2));

            case UIInterfaceOrientation.LandscapeRight:
                return(CGAffineTransform.MakeRotation((float)Math.PI / 2));

            case UIInterfaceOrientation.PortraitUpsideDown:
                return(CGAffineTransform.MakeRotation((float)Math.PI));

            case UIInterfaceOrientation.Portrait:
            default:
                return(CGAffineTransform.MakeRotation(0));
            }
        }