Esempio n. 1
0
        public void SetProgress(float progress, bool animated)
        {
            if (progress < 0.0f)
            {
                progress = 0.0f;
            }
            else if (progress > 1.0f)
            {
                progress = 1.0f;
            }
            var rl = this.Layer as RoundProgressLayer;

            if (animated)
            {
                CABasicAnimation animation = new CABasicAnimation();
                animation.KeyPath  = "progress";
                animation.Duration = 0.25;
                animation.From     = NSNumber.FromFloat(rl.Progress);
                animation.To       = NSNumber.FromFloat(progress);
                rl.AddAnimation(animation, "progressAnimation");
                rl.Progress = progress;
            }
            else
            {
                rl.Progress = progress;
                rl.SetNeedsDisplay();
            }
        }
        private void Animate()
        {
            if (stopAnim)
            {
                return;
            }

            if (locationAnimations != null)
            {
                AnimationImage.Layer.RemoveAnimation("locAnim");
            }

            var locationAnimation = CABasicAnimation.FromKeyPath("opacity");

            locationAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            locationAnimation.From           = NSNumber.FromFloat(GetAlpha());
            locationAnimation.To             = NSNumber.FromFloat(0.05f);

            var scaleAnimation = CABasicAnimation.FromKeyPath("transform.scale");

            scaleAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            scaleAnimation.From           = NSNumber.FromFloat(1.1f);
            scaleAnimation.To             = NSNumber.FromFloat(1);;

            locationAnimations                   = CAAnimationGroup.CreateAnimation();
            locationAnimations.Duration          = GetAnimationDuration();
            locationAnimations.AutoReverses      = true;
            locationAnimations.Animations        = new CAAnimation[] { scaleAnimation, locationAnimation };
            locationAnimations.AnimationStopped += (sender, e) => {
                Animate();
            };

            AnimationImage.Layer.AddAnimation(locationAnimations, "locAnim");
            systemSound.PlaySystemSound();
        }
        public void FromObjectsAndKeysGenericTest()
        {
            var keys = new [] {
                new NSString("Key1"),
                new NSString("Key2"),
                new NSString("Key3"),
                new NSString("Key4"),
                new NSString("Key5"),
            };
            var values = new [] {
                NSNumber.FromByte(0x1),
                NSNumber.FromFloat(8.5f),
                NSNumber.FromDouble(10.5),
                NSNumber.FromInt32(42),
                NSNumber.FromBoolean(true),
            };

            var dict = NSMutableDictionary <NSString, NSNumber> .FromObjectsAndKeys(values, keys, values.Length);

            Assert.AreEqual(dict.Count, 5, "count");
            for (int i = 0; i < values.Length; i++)
            {
                Assert.AreEqual(dict [keys [i]], values [i], $"key lookup, Iteration: {i}");
            }
        }
        public void Shake(double duration = 0.5)
        {
            var animation = CAKeyFrameAnimation.GetFromKeyPath("transform.translation.x");

            animation.Delegate = this;
            animation.Duration = duration;
            animation.Values   = new NSObject[]
            {
                NSNumber.FromFloat(0),
                NSNumber.FromFloat(10),
                NSNumber.FromFloat(-8),
                NSNumber.FromFloat(8),
                NSNumber.FromFloat(-5),
                NSNumber.FromFloat(5),
                NSNumber.FromFloat(0)
            };
            animation.KeyTimes = new NSNumber[]
            {
                new NSNumber(0),
                new NSNumber(0.225),
                new NSNumber(0.425),
                new NSNumber(0.6),
                new NSNumber(0.75),
                new NSNumber(0.875),
                new NSNumber(1)
            };
            animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);

            foreach (var view in this.views)
            {
                view.Layer.AddAnimation(animation, ANIMATION_KEY);
            }
        }
Esempio n. 5
0
        internal NSDictionary ToDictionary()
        {
            var ret = new NSMutableDictionary();

            if (AffineMatrix.HasValue)
            {
                var a      = AffineMatrix.Value;
                var affine = new NSNumber [6];
                affine [0] = NSNumber.FromFloat(a.xx);
                affine [1] = NSNumber.FromFloat(a.yx);
                affine [2] = NSNumber.FromFloat(a.xy);
                affine [3] = NSNumber.FromFloat(a.yy);
                affine [4] = NSNumber.FromFloat(a.x0);
                affine [5] = NSNumber.FromFloat(a.y0);
                ret.SetObject(NSArray.FromNSObjects(affine), CISampler.AffineMatrix);
            }
            if (WrapMode.HasValue)
            {
                var k = WrapMode.Value == CIWrapMode.Black ? CISampler.WrapBlack : CISampler.FilterNearest;
                ret.SetObject(k, CISampler.WrapMode);
            }
            if (FilterMode.HasValue)
            {
                var k = FilterMode.Value == CIFilterMode.Nearest ? CISampler.FilterNearest : CISampler.FilterLinear;
                ret.SetObject(k, CISampler.FilterMode);
            }
            return(ret);
        }
Esempio n. 6
0
        private void RefreshImage(object state)
        {
            try {
                object[]    on         = state as object[];
                UIImageView controller = on [0] as UIImageView;

                //Console.WriteLine("<<<<<<  Actualiza Imagen >>>>>>>>>");
                var animation = CABasicAnimation.FromKeyPath("opacity");
                animation.From     = NSNumber.FromFloat(0);
                animation.To       = NSNumber.FromFloat(1);
                animation.Duration = .2;
                //animation.Delegate = new MyAnimationDelegate (controller, true);
                //AppDes.PropertyName = hotel.Hotel_HOD_RS.Property.GeneralInformation.Name;

                controller.Layer.MasksToBounds = false;
                controller.Layer.CornerRadius  = 7;

                controller.Layer.AddAnimation(animation, "moveToHeader");

                /*
                 * tableView.BeginUpdates();
                 * tableView.ReloadRows(new[] { indexPath }, UITableViewRowAnimation.Fade);
                 * //tableView.EndUpdates();
                 */
            } catch {
            }

            /*
             * UIView.BeginAnimations ("imageThumbnailTransitionIn");
             * imageView2.Alpha =  1.0f;
             * UIView.SetAnimationDuration (0.5f);
             * UIView.CommitAnimations ();
             */
        }
Esempio n. 7
0
        public AnimationBuilder FadeTo(float?fromOpacity, float toOpacity, double delaySeconds, double durationSeconds)
        {
            var alphaAnimation = CABasicAnimation.FromKeyPath("opacity");

            alphaAnimation.TimingFunction = this.EasingFunction;
            if (durationSeconds > 0)
            {
                alphaAnimation.Duration = durationSeconds;
            }
            if (delaySeconds > 0)
            {
                alphaAnimation.BeginTime = delaySeconds;
            }
            alphaAnimation.FillMode            = CAFillMode.Forwards;
            alphaAnimation.RemovedOnCompletion = false;
            if (fromOpacity.HasValue)
            {
                alphaAnimation.From = NSNumber.FromFloat(fromOpacity.Value);
            }
            alphaAnimation.To = NSNumber.FromFloat(toOpacity);

            this.Animations.Add(alphaAnimation);
            this.EnsureTotalDuration(delaySeconds, durationSeconds);

            return(this);
        }
Esempio n. 8
0
        static CTFont CTFontWithFamilyName(string family, CTFontSymbolicTraits straits, float size, float weight)
        {
            var bold   = Math.Abs(weight - CTFontWeight.Bold) < 0.01f;
            var traits = new NSMutableDictionary();

            if (Math.Abs(weight) > 0.01 && !bold)
            {
                traits[CTFontTraitKey.Weight] = NSNumber.FromFloat(weight);
            }

            if (bold)
            {
                straits |= CTFontSymbolicTraits.Bold;
            }

            if (0 != (straits & (CTFontSymbolicTraits.Bold | CTFontSymbolicTraits.Italic)))
            {
                traits[CTFontTraitKey.Symbolic] = NSNumber.FromUInt32((UInt32)straits);
            }

            var attrs = new NSMutableDictionary();

            attrs[CTFontDescriptorAttributeKey.FamilyName] = (NSString)family;
            attrs[CTFontDescriptorAttributeKey.Traits]     = traits;

            var desc = new CTFontDescriptor(new CTFontDescriptorAttributes(attrs));
            var font = new CTFont(desc, size);

            return(font);
        }
Esempio n. 9
0
        private void AddShakeAnimation(UIView view, NSAction onAnimationStopped)
        {
            var curve = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);

            var shakeAnimation = CAKeyFrameAnimation.GetFromKeyPath("transform.translation.x");

            shakeAnimation.RemovedOnCompletion = false;
            shakeAnimation.TimingFunction      = curve;
            shakeAnimation.Duration            = Duration;
            shakeAnimation.Values = new NSNumber[] {
                NSNumber.FromFloat(0),
                NSNumber.FromFloat(10),
                NSNumber.FromFloat(-8),
                NSNumber.FromFloat(8),
                NSNumber.FromFloat(-5),
                NSNumber.FromFloat(5),
                NSNumber.FromFloat(0)
            };
            shakeAnimation.KeyTimes = new NSNumber[] {
                NSNumber.FromFloat(0f),
                NSNumber.FromFloat(0.225f),
                NSNumber.FromFloat(0.425f),
                NSNumber.FromFloat(0.6f),
                NSNumber.FromFloat(0.75f),
                NSNumber.FromFloat(0.875f),
                NSNumber.FromFloat(1f),
            };

            if (onAnimationStopped != null)
            {
                shakeAnimation.AnimationStopped += (o, e) => onAnimationStopped();
            }

            view.Layer.AddAnimation(shakeAnimation, "shake");
        }
        void SetProgress(float fromProgress, float toProgress, bool animate)
        {
            Layer.RemoveAnimation(indeterminateAnimation);
            Layer.RemoveAnimation(CircularProgressLayer.ProgressKey);

            var progressPct    = Progress / StartAngle;
            var pinnedProgress = Math.Min(Math.Max(progressPct, 0.0f), 1.0f);

            if (toProgress > fromProgress) //Don't want to animate between 360 to 0
            {
                if (animate)
                {
                    var animation = CABasicAnimation.FromKeyPath(CircularProgressLayer.ProgressKey);
                    animation.Duration       = Math.Abs(progressPct - pinnedProgress);
                    animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
                    animation.From           = NSNumber.FromFloat(fromProgress);
                    animation.To             = NSNumber.FromFloat(toProgress);
                    CircularProgressLayer.AddAnimation(animation, CircularProgressLayer.ProgressKey);
                }
                else
                {
                    CircularProgressLayer.SetNeedsDisplay();
                }
            }

            CircularProgressLayer.Progress = toProgress;
        }
Esempio n. 11
0
        public static void Pop(this UIView view, double duration, int repeatCount, float force, double delay = 0)
        {
            CAKeyFrameAnimation animation = CAKeyFrameAnimation.FromKeyPath("transform.scale");

            animation.BeginTime      = CAAnimation.CurrentMediaTime() + delay;
            animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            animation.KeyTimes       = new[]
            {
                NSNumber.FromFloat(0),
                NSNumber.FromFloat(0.2f),
                NSNumber.FromFloat(0.4f),
                NSNumber.FromFloat(0.6f),
                NSNumber.FromFloat(0.8f),
                NSNumber.FromFloat(1)
            };
            animation.Duration    = duration;
            animation.Additive    = true;
            animation.RepeatCount = repeatCount;
            animation.Values      = new NSObject[]
            {
                NSNumber.FromFloat(0),
                NSNumber.FromFloat(0.2f * force),
                NSNumber.FromFloat(-0.2f * force),
                NSNumber.FromFloat(0.2f * force),
                NSNumber.FromFloat(0)
            };
            if (view.Hidden)
            {
                view.Hidden = false;
            }
            view.Layer.AddAnimation(animation, "pop");
        }
Esempio n. 12
0
            public ProjectCell(IntPtr handle) : base(handle)
            {
                this.Apply(Style.Screen);
                BackgroundView = new UIView();

                ContentView.Add(textContentView  = new UIView());
                ContentView.Add(tasksButton      = new UIButton().Apply(Style.ProjectList.TasksButtons));
                textContentView.Add(projectLabel = new UILabel().Apply(Style.ProjectList.ProjectLabel));
                textContentView.Add(clientLabel  = new UILabel().Apply(Style.ProjectList.ClientLabel));

                var maskLayer = new CAGradientLayer()
                {
                    AnchorPoint = CGPoint.Empty,
                    StartPoint  = new CGPoint(0.0f, 0.0f),
                    EndPoint    = new CGPoint(1.0f, 0.0f),
                    Colors      = new [] {
                        UIColor.FromWhiteAlpha(1, 1).CGColor,
                        UIColor.FromWhiteAlpha(1, 1).CGColor,
                        UIColor.FromWhiteAlpha(1, 0).CGColor,
                    },
                    Locations = new [] {
                        NSNumber.FromFloat(0f),
                        NSNumber.FromFloat(0.9f),
                        NSNumber.FromFloat(1f),
                    },
                };

                textContentView.Layer.Mask = maskLayer;
                tasksButton.TouchUpInside += OnTasksButtonTouchUpInside;
            }
Esempio n. 13
0
        void SetupRecorder()
        {
            // An extension is required otherwise the file does not save to a format that browsers support (mp4)
            // Note: output the file rather than the path as the path is calculated via PrivatePath interface in the PCL
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            filename = Path.Combine(documents, DateTimeOffset.Now.ToUnixTimeSeconds().ToString() + ".3gp");

            var audioSession = AVAudioSession.SharedInstance();
            var err          = audioSession.SetCategory(AVAudioSessionCategory.PlayAndRecord);

            err = audioSession.SetActive(true);

            NSObject[] values =
            {
                NSNumber.FromFloat(8000.0f),
                NSNumber.FromInt32((int)AudioToolbox.AudioFormatType.MPEG4AAC),
                NSNumber.FromInt32(1)
            };

            NSObject[] keys =
            {
                AVAudioSettings.AVSampleRateKey,
                AVAudioSettings.AVFormatIDKey,
                AVAudioSettings.AVNumberOfChannelsKey
            };

            recorder = AVAudioRecorder.Create(
                NSUrl.FromFilename(filename),
                new AudioSettings(NSDictionary.FromObjectsAndKeys(values, keys)),
                out var error
                );
        }
Esempio n. 14
0
        public UserLocationMarker() : base(new CoreGraphics.CGRect(0, 0, 30, 30))
        {
            var innerCircle = new UIView(new CoreGraphics.CGRect(10, 10, 10, 10));

            innerCircle.Layer.CornerRadius    = 5;
            innerCircle.Layer.BackgroundColor = OSAppConstants.USER_MARKER_CGCOLOR;
            AddSubview(innerCircle);

            var outerDisk = new UIView(new CoreGraphics.CGRect(0, 0, 30, 30));

            outerDisk.Layer.CornerRadius    = 15;
            outerDisk.Layer.BackgroundColor = OSAppConstants.USER_MARKER_LIGHT_CGCOLOR;

            var scalingAnimation = new CoreAnimation.CABasicAnimation();

            scalingAnimation.KeyPath      = "transform.scale";
            scalingAnimation.Duration     = 1.5;
            scalingAnimation.RepeatCount  = float.MaxValue;
            scalingAnimation.AutoReverses = true;
            scalingAnimation.From         = NSNumber.FromFloat(0.5f);
            scalingAnimation.To           = NSNumber.FromFloat(1.0f);
            outerDisk.Layer.AddAnimation(scalingAnimation, "scale");
            AddSubview(outerDisk);

            //BackgroundColor = UIColor.FromRGBA(1, 1, 1, 0.5f);
        }
Esempio n. 15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Warning.Layer.BorderColor = UIColor.White.CGColor;
            Warning.Layer.BorderWidth = 5;
            Warning.Layer.AddAnimation(new CABasicAnimation
            {
                KeyPath        = "transform.scale",
                Duration       = 0.75,
                From           = NSNumber.FromFloat(0.9f),
                To             = NSNumber.FromFloat(1),
                TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut),
                AutoReverses   = true,
                RepeatCount    = float.PositiveInfinity
            }, null);

            const float radius = 80;

            RootView.Layer.InsertSublayer(new PulseCALayer(radius, RootView.Center)
            {
                BackgroundColor = UIColor.Red.CGColor
            }, 0);
            RootView.Layer.InsertSublayer(new PulseCALayer(radius, RootView.Center, delay: 0.2f)
            {
                BackgroundColor = UIColor.Red.CGColor
            }, 1);
            RootView.Layer.InsertSublayer(new PulseCALayer(radius, RootView.Center, delay: 0.4f)
            {
                BackgroundColor = UIColor.Red.CGColor
            }, 1);
        }
        public void animation2(Button button)
        {
            var scaleAnimation = CABasicAnimation.FromKeyPath("transform");

            scaleAnimation.From = NSValue.FromCATransform3D(CATransform3D.MakeScale(1, 1, 1));
            scaleAnimation.To   = NSValue.FromCATransform3D(CATransform3D.MakeScale(2, 2, 1));


            var opacityAnimation = CABasicAnimation.FromKeyPath("opacity");

            opacityAnimation.From = NSNumber.FromFloat(0.25f);
            opacityAnimation.To   = NSNumber.FromFloat(0.0f);

            var rippleAnimationGroup = new CAAnimationGroup
            {
                Duration            = 2.0f,
                TimeOffset          = -0.25f,
                RemovedOnCompletion = true,
                FillMode            = CAFillMode.Both,
                TimingFunction      = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut),
                Animations          = new CAAnimation[] { scaleAnimation, opacityAnimation }
            };


            rippleCircleLayer.AddAnimation(rippleAnimationGroup, "rippleMyAnimations");
        }
Esempio n. 17
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            //Creates basic moving animation
            var pt = layer.Position;

            layer.Position = new CGPoint(100, 300);
            var basicAnimation = CABasicAnimation.FromKeyPath("position");

            basicAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            basicAnimation.From           = NSValue.FromCGPoint(pt);
            basicAnimation.To             = NSValue.FromCGPoint(new CGPoint(100, 300));


            //Creates transformation animation
            layer.Transform = CATransform3D.MakeRotation((float)Math.PI * 2, 0, 0, 1);
            var animRotate = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("transform");

            animRotate.Values = new NSObject[] {
                NSNumber.FromFloat(0f),
                NSNumber.FromFloat((float)Math.PI / 2f),
                NSNumber.FromFloat((float)Math.PI),
                NSNumber.FromFloat((float)Math.PI * 2)
            };
            animRotate.ValueFunction = CAValueFunction.FromName(CAValueFunction.RotateX);

            //Adds the animations to a group, and adds the group to the layer
            var animationGroup = CAAnimationGroup.CreateAnimation();

            animationGroup.Duration   = 2;
            animationGroup.Animations = new CAAnimation[] { basicAnimation, animRotate };
            layer.AddAnimation(animationGroup, null);
        }
        private void Expand(Action completion)
        {
            var expandAnim = CABasicAnimation.FromKeyPath("transform.scale");

            expandAnim.From                = NSNumber.FromFloat(1.0f);
            expandAnim.To                  = NSNumber.FromFloat(26.0f);
            expandAnim.TimingFunction      = expandCurve;
            expandAnim.Duration            = 0.3;
            expandAnim.FillMode            = CAFillMode.Forwards;
            expandAnim.RemovedOnCompletion = false;
            expandAnim.AnimationStopped   += delegate
            {
                OnAnimationComplete();
                if (completion != null)
                {
                    completion();
                }
                CreateScheduledTimer(1.0, () =>
                {
                    ReturnToOriginalState();

                    isAnimating = false;
                });
            };

            Layer.AddAnimation(expandAnim, expandAnim.KeyPath);
        }
Esempio n. 19
0
        // Helper method to animate the sub view
        private void animateView(NSView subView, RectangleF toFrame)
        {
#if true
            // Simple animation: assign the new value, and let CoreAnimation
            // take it from here

            ((NSView)subView.Animator).Frame = toFrame;
#else
            //
            // Performing the animation by hand, every step of the way
            //
            var animationY = CABasicAnimation.FromKeyPath("position.y");
            animationY.To = NSNumber.FromFloat(toFrame.Y);
            animationY.AnimationStopped += delegate {
                //Console.WriteLine("animation stopped");
                subView.Layer.Frame = toFrame;
            };

            var animationX = CABasicAnimation.FromKeyPath("position.x");
            animationX.To = NSNumber.FromFloat(toFrame.X);

            animationY.AutoReverses = false;
            animationX.AutoReverses = false;

            animationY.RemovedOnCompletion = false;
            animationX.RemovedOnCompletion = false;

            animationY.FillMode = CAFillMode.Forwards;
            animationX.FillMode = CAFillMode.Forwards;

            subView.Layer.AddAnimation(animationX, "moveX");
            subView.Layer.AddAnimation(animationY, "moveY");
#endif
        }
Esempio n. 20
0
        public void QueryForRecords(CLLocation location, Action <List <CKRecord> > completionHandler)
        {
            var radiusInKilometers = NSNumber.FromFloat(5f);
            var predicate          = NSPredicate.FromFormat("distanceToLocation:fromLocation:(location, %@) < %f",
                                                            new NSObject[] { location, radiusInKilometers });

            var query = new CKQuery(ItemRecordType, predicate)
            {
                SortDescriptors = new [] { new NSSortDescriptor("creationDate", false) }
            };

            var queryOperation = new CKQueryOperation(query)
            {
                DesiredKeys = new [] { NameField }
            };

            var results = new List <CKRecord> ();

            queryOperation.RecordFetched = (record) => results.Add(record);

            queryOperation.Completed = (cursor, error) => {
                if (error != null)
                {
                    Console.WriteLine("An error occured: {0}", error.Description);
                    return;
                }

                DispatchQueue.MainQueue.DispatchAsync(() => completionHandler(results));
            };

            publicDatabase.AddOperation(queryOperation);
        }
        /// <summary>
        /// Touchs up animation.
        /// </summary>
        public void TouchUpAnimation()
        {
            foreach (UIImageView Icon in IconArray)
            {
                UIView.AnimateNotify(0.1f, 0.0f, UIViewAnimationOptions.BeginFromCurrentState, () =>
                {
                    Icon.Alpha = 0.0f;
                }
                                     , (finished) =>
                {
                    Icon.Hidden = true;
                });
            }

            var ButtonScaleSmallCABasicAnimation = CABasicAnimation.FromKeyPath(@"transform.scale");

            ButtonScaleSmallCABasicAnimation.Duration            = 0.2f;
            ButtonScaleSmallCABasicAnimation.AutoReverses        = false;
            ButtonScaleSmallCABasicAnimation.To                  = NSNumber.FromFloat(1.0f);
            ButtonScaleSmallCABasicAnimation.From                = NSNumber.FromFloat(BigRadius / SmallRadius);
            ButtonScaleSmallCABasicAnimation.FillMode            = CAFillMode.Forwards;
            ButtonScaleSmallCABasicAnimation.RemovedOnCompletion = false;

            SmallButton.Layer.AddAnimation(ButtonScaleSmallCABasicAnimation, @"ButtonScaleSmallCABasicAnimation");


            var BackgroundViewScaleSmallCABasicAnimation = CABasicAnimation.FromKeyPath(@"transform.scale");

            BackgroundViewScaleSmallCABasicAnimation.Duration            = 0.1f;
            BackgroundViewScaleSmallCABasicAnimation.AutoReverses        = false;
            BackgroundViewScaleSmallCABasicAnimation.To                  = NSNumber.FromFloat(1.0f);
            BackgroundViewScaleSmallCABasicAnimation.From                = NSNumber.FromNFloat(this.Frame.Size.Height / SmallRadius);
            BackgroundViewScaleSmallCABasicAnimation.FillMode            = CAFillMode.Forwards;
            BackgroundViewScaleSmallCABasicAnimation.RemovedOnCompletion = false;


            BackgroundView.Layer.AddAnimation(BackgroundViewScaleSmallCABasicAnimation, @"BackgroundViewScaleSmallCABasicAnimation");

            var Rotate = CATransform3D.MakeRotation(0, 0, 1, 0).Concat(CATransform3D.MakeRotation(0, 1, 0, 0));

            if (Parallex)
            {
                SmallButton.Layer.Transform = CATransform3DPerspect(Rotate, new CGPoint(0, 0), BigRadius + ParallexParameter);
            }
            else
            {
                //Do nothing ^_^
            }

            SmallButton.SetImage(IconImage, UIControlState.Normal);

            UIView.AnimateNotify(0.1f, 0.0f, UIViewAnimationOptions.BeginFromCurrentState, () =>
            {
                SmallButton.ImageView.Alpha = 1.0f;
            }
                                 , (finished) =>
            {
            });
        }
 public override void SendOutcomeWithValue(string name, float value, SendOutcomeEventSuccess sendOutcomeEventSuccess)
 {
    NSNumber weight = NSNumber.FromFloat(value);
    iOS.OneSignal.SendOutcomeWithValue(name, weight, (outcomeEvent) =>
    {
       SendOutcomeEventSuccess(outcomeEvent, sendOutcomeEventSuccess);
    });
 }
Esempio n. 23
0
 void DefineAnimation()
 {
     animation             = CABasicAnimation.FromKeyPath("transform.rotation.z");
     animation.From        = NSNumber.FromFloat(0.0f);
     animation.To          = NSNumber.FromFloat(2f * (float)System.Math.PI);
     animation.Duration    = 1.0f;
     animation.RepeatCount = int.MaxValue;
 }
Esempio n. 24
0
        private CABasicAnimation rotationAnimation()
        {
            CABasicAnimation rotation = new CABasicAnimation();

            rotation.KeyPath = "frameRotation";
            rotation.From    = NSNumber.FromFloat(0);
            rotation.To      = NSNumber.FromFloat(45);
            return(rotation);
        }
Esempio n. 25
0
        public void NSFormatter_ShouldGetAttributedString()
        {
            var str = formatter.GetAttributedString(NSNumber.FromFloat(3.21f), new NSStringAttributes()
            {
                Font = NSFont.SystemFontOfSize(8)
            });

            Assert.AreEqual(str.Value, "$3.21");
        }
Esempio n. 26
0
        public void PrepareRecorder()
        {
            if (Recorder != null)
            {
                Recorder.Dispose();
            }
            var audioSession = AVAudioSession.SharedInstance();
            var err          = audioSession.SetCategory(AVAudioSessionCategory.PlayAndRecord);

            if (err != null)
            {
                Console.WriteLine("audioSession: {0}", err);
            }
            err = audioSession.SetActive(true);
            if (err != null)
            {
                Console.WriteLine("audioSession: {0}", err);
            }

            Console.WriteLine("Audio File Path: " + AudioFilePath + AudioFileName);
            Url = NSUrl.FromFilename(AudioFilePath + AudioFileName + ".mp4");

            if (File.Exists(AudioFilePath + "/" + AudioFileName + ".mp4"))
            {
                File.Delete(AudioFilePath + "/" + AudioFileName + ".mp4");
            }

            //set up the NSObject Array of values that will be combined with the keys to make the NSDictionary
            NSObject[] values = new NSObject[] {
                NSNumber.FromFloat(44100.0f),
                //Sample Rate
                NSNumber.FromInt32((int)AudioToolbox.AudioFormatType.LinearPCM),
                //AVFormat
                NSNumber.FromInt32(2),
                //Channels
                NSNumber.FromInt32(16),
                //PCMBitDepth
                NSNumber.FromBoolean(false),
                //IsBigEndianKey
                NSNumber.FromBoolean(false)
                //IsFloatKey
            };
            //Set up the NSObject Array of keys that will be combined with the values to make the NSDictionary
            NSObject[] keys = new NSObject[] {
                AVAudioSettings.AVSampleRateKey,
                AVAudioSettings.AVFormatIDKey,
                AVAudioSettings.AVNumberOfChannelsKey,
                AVAudioSettings.AVLinearPCMBitDepthKey,
                AVAudioSettings.AVLinearPCMIsBigEndianKey,
                AVAudioSettings.AVLinearPCMIsFloatKey
            };

            Settings = NSDictionary.FromObjectsAndKeys(values, keys);
            Recorder = AVAudioRecorder.Create(Url, new AudioSettings(Settings), out Error);
            Recorder.PrepareToRecord();
        }
        // Render image to display.
        public void DrawInRect(GLKView view, CGRect rect)
        {
            var context = ciContext;

            if (context == null)
            {
                return;
            }

            var filter = ciRawFilter;

            if (filter == null)
            {
                return;
            }

            var nativeSize = imageNativeSize;

            if (!nativeSize.HasValue)
            {
                return;
            }

            // OpenGLES drawing setup.
            ClearColor(0, 0, 0, 1);
            Clear(ClearBufferMask.ColorBufferBit);

            // Set the blend mode to "source over" so that CI will use that.
            Enable(EnableCap.Blend);
            BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);

            // Calculate scale to show the image at.
            var scaleTransform    = MakeScale(view.ContentScaleFactor, view.ContentScaleFactor);
            var contentScaledRect = CGRectApplyAffineTransform(rect, scaleTransform);
            var scale             = (float)Math.Min(contentScaledRect.Width / nativeSize.Value.Width, contentScaledRect.Height / nativeSize.Value.Height);

            // Set scale factor of the CIRawFilter to size it correctly for display.
            filter.SetValueForKey(NSNumber.FromFloat(scale), Keys.kCIInputScaleFactorKey);

            // Calculate rectangle to display image in.
            var displayRect = CGRectApplyAffineTransform(new CGRect(0, 0, nativeSize.Value.Width, nativeSize.Value.Height), MakeScale(scale, scale));

            // Ensure the image is centered.
            displayRect.X = (contentScaledRect.Width - displayRect.Width) / 2;
            displayRect.Y = (contentScaledRect.Height - displayRect.Height) / 2;

            var image = ciRawFilter.OutputImage;

            if (image == null)
            {
                return;
            }

            // Display the image scaled to fit.
            context.DrawImage(image, displayRect, image.Extent);
        }
Esempio n. 28
0
        private bool PrepareVariables()
        {
            var audioSession = AVAudioSession.SharedInstance();
            var err          = audioSession.SetCategory(AVAudioSessionCategory.PlayAndRecord);

            if (err != null)
            {
                Console.WriteLine($"audioSession: {err}");
                return(false);
            }
            err = audioSession.SetActive(true);
            if (err != null)
            {
                Console.WriteLine($"audioSession: {err}");
                return(false);
            }
            //Declare string for application temp path and tack on the file extension
            string fileName = $"Myfile{DateTime.Now.ToString("yyyyMMddHHmmss")}.wav";

            audioFilePath = Path.Combine(Path.GetTempPath(), fileName);

            Console.WriteLine("Audio File Path: " + audioFilePath);

            url = NSUrl.FromFilename(audioFilePath);
            //set up the NSObject Array of values that will be combined with the keys to make the NSDictionary
            NSObject[] values =
            {
                NSNumber.FromFloat(44100.0f),                                    //Sample Rate
                NSNumber.FromInt32((int)AudioToolbox.AudioFormatType.LinearPCM), //AVFormat
                NSNumber.FromInt32(2),                                           //Channels
                NSNumber.FromInt32(16),                                          //PCMBitDepth
                NSNumber.FromBoolean(false),                                     //IsBigEndianKey
                NSNumber.FromBoolean(false)                                      //IsFloatKey
            };

            //Set up the NSObject Array of keys that will be combined with the values to make the NSDictionary
            NSObject[] keys =
            {
                AVAudioSettings.AVSampleRateKey,
                AVAudioSettings.AVFormatIDKey,
                AVAudioSettings.AVNumberOfChannelsKey,
                AVAudioSettings.AVLinearPCMBitDepthKey,
                AVAudioSettings.AVLinearPCMIsBigEndianKey,
                AVAudioSettings.AVLinearPCMIsFloatKey
            };

            //Set Settings with the Values and Keys to create the NSDictionary
            settings = NSDictionary.FromObjectsAndKeys(values, keys);

            //Set recorder parameters
            recorder = AVAudioRecorder.Create(url, new AudioSettings(settings), out error);

            //Set Recorder to Prepare To Record
            recorder.PrepareToRecord();
            return(true);
        }
Esempio n. 29
0
 private static CABasicAnimation CreateScaleAnimation(float animationDuration, float initialPulseScale)
 {
     return(new CABasicAnimation
     {
         KeyPath = "transform.scale.xy",
         From = NSNumber.FromFloat(initialPulseScale),
         To = NSNumber.FromFloat(1),
         Duration = animationDuration,
     });
 }
        private CGSize CalculatePopUpViewSize()
        {
            // negative values need more width than positive values
            var    minStr     = new NSString(NumberFormatter.StringFromNumber(NSNumber.FromFloat(MinValue)));
            CGSize minValSize = PopUpView.PopUpSizeForString(minStr);
            var    maxStr     = new NSString(NumberFormatter.StringFromNumber(NSNumber.FromFloat(MaxValue)));
            CGSize maxValSize = PopUpView.PopUpSizeForString(maxStr);

            return(minValSize.Width >= maxValSize.Width ? minValSize : maxValSize);
        }