Esempio n. 1
0
            public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
            {
                #region Set animation when Display Data
                if (!Variables.ViewWillAppear)
                {
                    //1. Set the initial state of the cell
                    cell.Alpha = 0;
                    var transform = CATransform3D.MakeTranslation(-250, 20, 0);
                    cell.Layer.Transform = transform;


                    //2. UIView animation method to change to the final state of the cell
                    UIView.Animate(0.5, () =>
                    {
                        cell.Alpha           = 1;
                        cell.Layer.Transform = CATransform3D.Identity;
                    });
                }
                if (indexPath.Row == tableView.IndexPathsForVisibleRows[tableView.IndexPathsForVisibleRows.Length - 1].LongRow)
                {
                    var lastrow = tableView.IndexPathsForVisibleRows[tableView.IndexPathsForVisibleRows.Length - 1].LongRow;
                    Variables.ViewWillAppear = false;
                }
                #endregion
            }
Esempio n. 2
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     View.BackgroundColor = UIColor.Black;
     mainTabBar.Items.Each((UITabBarItem item, int index) =>
     {
         item.BadgeValue = "Normal";
         foreach (var badgeView in mainTabBar.Subviews[index].Subviews)
         {
             if (index > 0)
             {
                 if (badgeView.Class.Name.Contains("_UIBadgeView"))
                 {
                     badgeView.Layer.Transform = new CATransform3D();
                     badgeView.Layer.Transform = CATransform3D.MakeTranslation(-100, -20, 1);
                     item.BadgeValue           = "Custom";
                     item.BadgeColor           = UIColor.Green;
                     item.SetBadgeTextAttributes(new UIStringAttributes()
                     {
                         ForegroundColor = UIColor.Black
                     }, UIControlState.Normal);
                     return;
                 }
             }
         }
     });
 }
Esempio n. 3
0
        void animationLinear(int i, float offset)
        {
            var transform = CATransform3D.Identity;
            var mx        = (float)(1.0 - offset) * 100;

            transform = CATransform3D.MakeTranslation(mx * subsWeights[i].X, mx * subsWeights[i].Y, 0);
            applyTransform(i, transform);
        }
Esempio n. 4
0
        void animationCurve(int i, float offset)
        {
            var transform = CATransform3D.Identity;

            var x = (float)(1.0 - offset) * 10;

            transform = CATransform3D.MakeTranslation((System.nfloat)((Math.Pow(x, 3) - (x * 25)) * subsWeights[i].X), (System.nfloat)((Math.Pow(x, 3) - (x * 20)) * subsWeights[i].Y), 0);
            applyTransform(i, transform);
        }
        private CATransform3D CATransform3DMakePerspective(CGPoint center, float disZ)
        {
            CATransform3D transToCenter = CATransform3D.MakeTranslation(-center.X, -center.Y, 0);
            CATransform3D transBack     = CATransform3D.MakeTranslation(center.X, center.Y, 0);
            CATransform3D scale         = CATransform3D.Identity;

            scale.m34 = -1.0f / disZ;

            return(transToCenter.Concat(scale).Concat(transBack));
        }
Esempio n. 6
0
        public override async void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
        {
            cell.Alpha           = 0;
            cell.Layer.Transform = CATransform3D.MakeTranslation(-500, 0, 0);

            await UIView.AnimateAsync(0.5, () =>
            {
                cell.Alpha           = 1;
                cell.Layer.Transform = CATransform3D.Identity;
            });
        }
Esempio n. 7
0
        public void AddScannerLineAnimation()
        {
            animateLine.Layer.RemoveAllAnimations();

            scanNetAnimation             = CABasicAnimation.FromKeyPath("transform");
            scanNetAnimation.To          = NSValue.FromCATransform3D(CATransform3D.MakeTranslation(0, Scanner_Width - Scanner_LineHeight, 1));
            scanNetAnimation.Duration    = 4;
            scanNetAnimation.RepeatCount = float.MaxValue;
            animateLine.Layer.AddAnimation(scanNetAnimation, "ScannerLineAnmationKey");
            animateLine.Layer.Speed = 1.0f;
        }
Esempio n. 8
0
        private void AddTextField()
        {
            SelectGenderTextField.Placeholder             = "Select Gender";
            SelectGenderTextField.Layer.BorderWidth       = 1;
            SelectGenderTextField.Layer.BorderColor       = UIColor.Black.CGColor;
            SelectGenderTextField.Layer.MasksToBounds     = true;
            SelectGenderTextField.Layer.SublayerTransform = CATransform3D.MakeTranslation(5, 0, 0); //to Create a Space At The beginning of the text field


            SelectGenderTextField.InputView = GenderPicker; //To Start The UIPickerView from The bottom.
        }
        void SetInitialStyle()
        {
            if (!ExtendedEntry.HasBorder)
            {
                Control.BorderStyle = UITextBorderStyle.None;
            }

            if (ExtendedEntry.TextIndentation > 0)
            {
                Control.Layer.SublayerTransform = CATransform3D.MakeTranslation(ExtendedEntry.TextIndentation, 0, 0);
            }
        }
Esempio n. 10
0
        void animationInOut(int i, float offset)
        {
            var transform = CATransform3D.Identity;
            var tmpOffset = offset;

            if (tmpOffset > 1.0)
            {
                tmpOffset = (float)(1.0 + (1.0 - tmpOffset));
            }
            transform = CATransform3D.MakeTranslation((System.nfloat)((1.0 - tmpOffset) * subsWeights[i].X * 100), (System.nfloat)((1.0 - tmpOffset) * subsWeights[i].Y * 100), 0);
            applyTransform(i, transform);
        }
Esempio n. 11
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.BackgroundColor = UIColor.FromRGB(119, 171, 233);
                Control.BorderStyle     = UITextBorderStyle.None;
                Control.Font            = UIFont.FromName("HelveticaNeue-Thin", 20);
                Control.SetValueForKeyPath(UIColor.White, new NSString("_placeholderLabel.textColor"));
                Control.Layer.SublayerTransform = CATransform3D.MakeTranslation(10, 0, 0);
            }
        }
Esempio n. 12
0
        private void SetBorder(RoundEntry view)
        {
            Control.Layer.BorderWidth = view.BorderWidth;
            Control.BorderStyle       = (view.BorderWidth == 0) ? UITextBorderStyle.None : UITextBorderStyle.RoundedRect;

            Control.Layer.BorderColor = view.BorderColor.ToCGColor();
            if (view.BorderRadius > 0)
            {
                Control.Layer.CornerRadius      = view.BorderRadius;
                Control.Layer.MasksToBounds     = true;
                Control.Layer.SublayerTransform = CATransform3D.MakeTranslation(view.BorderRadius, 0, 0);
            }
        }
Esempio n. 13
0
        private void CenterPivot(SCNNode node)
        {
            var min = new SCNVector3();
            var max = new SCNVector3();

            if (node.GetBoundingBox(ref min, ref max))
            {
                node.Pivot = new SCNMatrix4(CATransform3D.MakeTranslation(
                                                min.X + (max.X - min.X) / 2,
                                                min.Y + (max.Y - min.Y) / 2,
                                                min.Z + (max.Z - min.Z) / 2));
            }
        }
Esempio n. 14
0
        private void UpdateTransform()
        {
            var matrix = CATransform3D.MakeTranslation((nfloat)_offset.X, (nfloat)_offset.Y, (nfloat)_offset.Z);

            matrix = matrix.Rotate((nfloat)ToRadians(RotationAngleInDegrees), _rotationAxis.X, _rotationAxis.Y, _rotationAxis.Z);

            CATransaction.Begin();
            CATransaction.DisableActions = true;

            NativeLayer.Transform = matrix;

            CATransaction.Commit();
        }
Esempio n. 15
0
        public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
        {
            if (_animatedRow < indexPath.Row)
            {
                cell.Alpha           = 0;
                cell.Layer.Transform = CATransform3D.MakeTranslation(-500, 0, 0);

                UIView.Animate(1, () =>
                {
                    cell.Alpha           = 1;
                    cell.Layer.Transform = CATransform3D.Identity;
                });
                _animatedRow++;
            }
        }
Esempio n. 16
0
        void SetupLayers()
        {
            if (view == null || view.Bounds.Size.IsEmpty)
            {
                return;
            }

            RemoveLayers();

            var width    = view.Bounds.Width;
            var distance = width / 5.0f / (float)shapeCount;

            // replicator layer
            replicatorLayer                   = new CAReplicatorLayer();
            replicatorLayer.Frame             = new CGRect(0, 0, view.Bounds.Width * 2, view.Bounds.Height);
            replicatorLayer.PreservesDepth    = false;
            replicatorLayer.InstanceCount     = (nint)shapeCount;
            replicatorLayer.InstanceTransform = CATransform3D.MakeTranslation(distance, 0, 0);
            replicatorLayer.InstanceDelay     = -0.06f;
            if (view.Layer == null)
            {
                view.Layer = new CALayer();
            }

            view.Layer.AddSublayer(replicatorLayer);
            view.WantsLayer = true;

            // instance layer
            var dotSize       = view.Bounds.Height;
            var instanceLayer = new CALayer();

            instanceLayer.Frame           = new CGRect(-(shapeCount * distance / 2.0f) - dotSize, 0, dotSize, dotSize);
            instanceLayer.BackgroundColor = shapeColor.CGColor;
            instanceLayer.Bounds          = new CGRect(0, 0, dotSize, dotSize);
            instanceLayer.CornerRadius    = dotSize / 2.0f;
            replicatorLayer.AddSublayer(instanceLayer);

            var runAnimation = CABasicAnimation.FromKeyPath("transform.translation.x");

            runAnimation.From           = NSNumber.FromDouble(-2f * width);
            runAnimation.To             = NSNumber.FromDouble(3f * width);
            runAnimation.Duration       = duration;
            runAnimation.RepeatCount    = float.PositiveInfinity;
            runAnimation.TimingFunction = CAMediaTimingFunction.FromControlPoints(0, 1.0f - easeFactor, 1, easeFactor);

            instanceLayer.AddAnimation(runAnimation, "RunAnimation");
        }
Esempio n. 17
0
        void SetupLayers()
        {
            if (view == null || view.Bounds.Size.IsEmpty)
            {
                return;
            }

            RemoveLayers();

            var shear = new CGAffineTransform(1.0f, 0, shearFactor, 1.0f, 0.0f, 0.0f);

            // replicator layer
            replicatorLayer = new CAReplicatorLayer();
            replicatorLayer.BackgroundColor   = trackColor.CGColor;
            replicatorLayer.Frame             = view.Bounds;
            replicatorLayer.InstanceCount     = (nint)(1 + view.Bounds.Width / hatchSize);
            replicatorLayer.PreservesDepth    = false;
            replicatorLayer.InstanceTransform = CATransform3D.MakeTranslation((nfloat)(hatchSize * 2.0), 0, 0);

            if (view.Layer == null)
            {
                view.Layer = new CALayer();
            }

            view.Layer.AddSublayer(replicatorLayer);
            view.WantsLayer = true;

            // instance layer
            var layerHeight   = view.Bounds.Height;
            var layerWidth    = hatchSize;
            var instanceLayer = new CALayer();

            instanceLayer.Frame           = new CGRect(0, 0, layerWidth, layerHeight);
            instanceLayer.BackgroundColor = hatchColor.CGColor;
            instanceLayer.Bounds          = new CGRect(0, 0, layerWidth, layerHeight);
            instanceLayer.Transform       = CATransform3D.MakeFromAffine(shear);
            replicatorLayer.AddSublayer(instanceLayer);

            var runAnimation = CABasicAnimation.FromKeyPath("transform.translation.x");

            runAnimation.From        = NSNumber.FromDouble(-hatchSize);
            runAnimation.To          = NSNumber.FromDouble(hatchSize);
            runAnimation.Duration    = 0.5;
            runAnimation.RepeatCount = float.PositiveInfinity;
            instanceLayer.AddAnimation(runAnimation, "RunAnimation");
        }
Esempio n. 18
0
        public void WalkThroughDidScroll(float position, float offset)
        {
            var tr = CATransform3D.Identity;

            tr.m34 = (System.nfloat)(-1 / 500.0);

            titleLabel.Layer.Transform = CATransform3D.MakeRotation((System.nfloat)(Math.PI * (1.0 - offset)), 1, 1, 1);
            textLabel.Layer.Transform  = CATransform3D.MakeRotation((System.nfloat)(Math.PI * (1.0 - offset)), 1, 1, 1);


            var tmpOffset = offset;

            if (tmpOffset > 1.0)
            {
                tmpOffset = (float)(1.0 + (1.0 - tmpOffset));
            }
            imageView.Layer.Transform = CATransform3D.MakeTranslation(0, (System.nfloat)((1.0 - tmpOffset) * 200), 0);
        }
Esempio n. 19
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                //Control.BackgroundColor = UIColor.FromRGB(119, 171, 233);
                Control.BorderStyle = UITextBorderStyle.None;
                //Control.Font = UIFont.FromName("HelveticaNeue-Thin", 20);
                //Control.SetValueForKeyPath(UIColor.White, new NSString("_placeholderLabel.textColor"));
                Control.Layer.SublayerTransform = CATransform3D.MakeTranslation(0, 0, 0);
                //Thêm chiều cao cho Entry iOS
                //Element.HeightRequest = 40;
            }
            if (e.OldElement != null || Element == null)
            {
                return;
            }

            Element.HeightRequest = 40;
        }
Esempio n. 20
0
        static CATransform3D GetLocalTransform(NSView view)
        {
            var flipped = view.Superview.IsFlipped;

            if (view.FrameRotation == 0)
            {
                return(CATransform3D.MakeTranslation(
                           view.Frame.X,
                           flipped ? view.Frame.Y : view.Superview.Bounds.Height - (view.Frame.Y + view.Frame.Height),
                           0));
            }

            return(CATransform3D.Identity
                   .Scale(1, -1, 1)
                   .Rotate((float)Math.PI * view.FrameRotation / 180f, 0, 0, 1)
                   .Translate(
                       view.Bounds.X,
                       flipped ? -view.Bounds.Y : view.Bounds.Y + view.Bounds.Height,
                       0)
                   .Scale(1, -1, 1)
                   .Translate(0, flipped ? 0 : view.Superview.Bounds.Height, 0));
        }
Esempio n. 21
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 0:
                // Set the slide's title and subtitle
                TextManager.SetTitle("Scene Graph");
                TextManager.SetSubtitle("Summary");
                break;

            case 1:
                // A node that will help visualize the position of the stars
                WireframeBoxNode          = SCNNode.Create();
                WireframeBoxNode.Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 4));
                WireframeBoxNode.Geometry = SCNBox.Create(1, 1, 1, 0);
                WireframeBoxNode.Geometry.FirstMaterial.Diffuse.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/box_wireframe", "png"));
                WireframeBoxNode.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; // no lighting
                WireframeBoxNode.Geometry.FirstMaterial.DoubleSided       = true;                      // double sided

                // Sun
                SunNode          = SCNNode.Create();
                SunNode.Position = new SCNVector3(0, 30, 0);
                ContentNode.AddChildNode(SunNode);
                SunNode.AddChildNode((SCNNode)WireframeBoxNode.Copy());

                // Earth-rotation (center of rotation of the Earth around the Sun)
                var earthRotationNode = SCNNode.Create();
                SunNode.AddChildNode(earthRotationNode);

                // Earth-group (will contain the Earth, and the Moon)
                EarthGroupNode          = SCNNode.Create();
                EarthGroupNode.Position = new SCNVector3(15, 0, 0);
                earthRotationNode.AddChildNode(EarthGroupNode);

                // Earth
                EarthNode          = (SCNNode)WireframeBoxNode.Copy();
                EarthNode.Position = new SCNVector3(0, 0, 0);
                EarthGroupNode.AddChildNode(EarthNode);

                // Rotate the Earth around the Sun
                var animation = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 10.0f;
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                earthRotationNode.AddAnimation(animation, new NSString("earth rotation around sun"));

                // Rotate the Earth
                animation             = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 1.0f;
                animation.From        = NSValue.FromVector(new SCNVector4(0, 1, 0, 0));
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                EarthNode.AddAnimation(animation, new NSString("earth rotation"));
                break;

            case 2:
                // Moon-rotation (center of rotation of the Moon around the Earth)
                var moonRotationNode = SCNNode.Create();
                EarthGroupNode.AddChildNode(moonRotationNode);

                // Moon
                MoonNode          = (SCNNode)WireframeBoxNode.Copy();
                MoonNode.Position = new SCNVector3(5, 0, 0);
                moonRotationNode.AddChildNode(MoonNode);

                // Rotate the moon around the Earth
                animation             = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 1.5f;
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                moonRotationNode.AddAnimation(animation, new NSString("moon rotation around earth"));

                // Rotate the moon
                animation             = CABasicAnimation.FromKeyPath("rotation");
                animation.Duration    = 1.5f;
                animation.To          = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2)));
                animation.RepeatCount = float.MaxValue;
                MoonNode.AddAnimation(animation, new NSString("moon rotation"));
                break;

            case 3:
                // Add geometries (spheres) to represent the stars
                SunNode.Geometry   = SCNSphere.Create(2.5f);
                EarthNode.Geometry = SCNSphere.Create(1.5f);
                MoonNode.Geometry  = SCNSphere.Create(0.75f);

                // Add a textured plane to represent Earth's orbit
                var earthOrbit = SCNNode.Create();
                earthOrbit.Opacity  = 0.4f;
                earthOrbit.Geometry = SCNPlane.Create(31, 31);
                earthOrbit.Geometry.FirstMaterial.Diffuse.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/orbit", "png"));
                earthOrbit.Geometry.FirstMaterial.Diffuse.MipFilter = SCNFilterMode.Linear;
                earthOrbit.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2));
                earthOrbit.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant;                 // no lighting
                SunNode.AddChildNode(earthOrbit);
                break;

            case 4:
                // Add a halo to the Sun (a simple textured plane that does not write to depth)
                SunHaloNode          = SCNNode.Create();
                SunHaloNode.Geometry = SCNPlane.Create(30, 30);
                SunHaloNode.Rotation = new SCNVector4(1, 0, 0, Pitch * (float)(Math.PI / 180.0f));
                SunHaloNode.Geometry.FirstMaterial.Diffuse.Contents    = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun-halo", "png"));
                SunHaloNode.Geometry.FirstMaterial.LightingModelName   = SCNLightingModel.Constant; // no lighting
                SunHaloNode.Geometry.FirstMaterial.WritesToDepthBuffer = false;                     // do not write to depth
                SunHaloNode.Opacity = 0.2f;
                SunNode.AddChildNode(SunHaloNode);

                // Add materials to the stars
                EarthNode.Geometry.FirstMaterial.Diffuse.Contents  = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-diffuse-mini", "jpg"));
                EarthNode.Geometry.FirstMaterial.Emission.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-emissive-mini", "jpg"));
                EarthNode.Geometry.FirstMaterial.Specular.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-specular-mini", "jpg"));
                MoonNode.Geometry.FirstMaterial.Diffuse.Contents   = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/moon", "jpg"));
                SunNode.Geometry.FirstMaterial.Multiply.Contents   = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun", "jpg"));
                SunNode.Geometry.FirstMaterial.Diffuse.Contents    = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun", "jpg"));
                SunNode.Geometry.FirstMaterial.Multiply.Intensity  = 0.5f;
                SunNode.Geometry.FirstMaterial.LightingModelName   = SCNLightingModel.Constant;

                SunNode.Geometry.FirstMaterial.Multiply.WrapS            =
                    SunNode.Geometry.FirstMaterial.Diffuse.WrapS         =
                        SunNode.Geometry.FirstMaterial.Multiply.WrapT    =
                            SunNode.Geometry.FirstMaterial.Diffuse.WrapT = SCNWrapMode.Repeat;

                EarthNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse       =
                    MoonNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse    =
                        SunNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse = true;

                EarthNode.Geometry.FirstMaterial.Shininess          = 0.1f;
                EarthNode.Geometry.FirstMaterial.Specular.Intensity = 0.5f;
                MoonNode.Geometry.FirstMaterial.Specular.Contents   = NSColor.Gray;

                // Achieve a lava effect by animating textures
                animation          = CABasicAnimation.FromKeyPath("contentsTransform");
                animation.Duration = 10.0f;

                var animationTransform1 = CATransform3D.MakeTranslation(0, 0, 0);
                animationTransform1 = animationTransform1.Concat(CATransform3D.MakeScale(3, 3, 3));
                var animationTransform2 = CATransform3D.MakeTranslation(1, 0, 0);
                animationTransform2 = animationTransform1.Concat(CATransform3D.MakeScale(3, 3, 3));

                animation.From        = NSValue.FromCATransform3D(animationTransform1);
                animation.To          = NSValue.FromCATransform3D(animationTransform2);
                animation.RepeatCount = float.MaxValue;
                SunNode.Geometry.FirstMaterial.Diffuse.AddAnimation(animation, new NSString("sun-texture"));

                animation          = CABasicAnimation.FromKeyPath("contentsTransform");
                animation.Duration = 30.0f;

                animationTransform1 = CATransform3D.MakeTranslation(0, 0, 0);
                animationTransform1 = animationTransform1.Concat(CATransform3D.MakeScale(5, 5, 5));
                animationTransform2 = CATransform3D.MakeTranslation(1, 0, 0);
                animationTransform2 = animationTransform1.Concat(CATransform3D.MakeScale(5, 5, 5));

                animation.From        = NSValue.FromCATransform3D(animationTransform1);
                animation.To          = NSValue.FromCATransform3D(animationTransform2);
                animation.RepeatCount = float.MaxValue;
                SunNode.Geometry.FirstMaterial.Multiply.AddAnimation(animation, new NSString("sun-texture2"));
                break;

            case 5:
                // We will turn off all the lights in the scene and add a new light
                // to give the impression that the Sun lights the scene
                var lightNode = SCNNode.Create();
                lightNode.Light           = SCNLight.Create();
                lightNode.Light.Color     = NSColor.Black;             // initially switched off
                lightNode.Light.LightType = SCNLightType.Omni;
                SunNode.AddChildNode(lightNode);

                // Configure attenuation distances because we don't want to light the floor
                lightNode.Light.SetAttribute(new NSNumber(20), SCNLightAttribute.AttenuationEndKey);
                lightNode.Light.SetAttribute(new NSNumber(19.5), SCNLightAttribute.AttenuationStartKey);

                // Animation
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                lightNode.Light.Color            = NSColor.White;                               // switch on
                presentationViewController.UpdateLightingWithIntensities(new float[] { 0.0f }); //switch off all the other lights
                SunHaloNode.Opacity = 0.5f;                                                     // make the halo stronger
                SCNTransaction.Commit();
                break;
            }
        }
Esempio n. 22
0
        private void MakeUI()
        {
            CreateAlertWindow();

            // Needs these parameters
            if (CRSAlertView.AlertWindow == null || Title == null || Actions == null || Actions.Length == 0)
            {
                throw new ModelNotImplementedException();
            }

            // Build Main View
            Alpha           = 0f;
            BackgroundColor = UIColor.Black.ColorWithAlpha(0.75f);
            Frame           = CRSAlertView.AlertWindow.Bounds;

            // Build Container
            nfloat imageWidth   = 40f;
            nfloat buttonWidth  = (CRSAlertView.AlertWindow.Frame.Width - 2 * pad) / Actions.Length;
            nfloat buttonHeight = 60f;

            _alertContainer = new UIView {
                Frame           = new CGRect(pad, 0, CRSAlertView.AlertWindow.Frame.Width - 2 * pad, pad),
                BackgroundColor = Background,
                Alpha           = 0f
            };
            _alertContainer.Layer.CornerRadius  = 10.0f;
            _alertContainer.Layer.MasksToBounds = true;

            _image = new UIImageView {
                Frame           = new CGRect(_alertContainer.Frame.Width / 2 - imageWidth / 2, pad, Image != null ? imageWidth : 0, Image != null ? imageWidth : 0),
                BackgroundColor = UIColor.Clear,
                TintColor       = TitleTextColor,
                Image           = Image ?? new UIImage(),
                ContentMode     = UIViewContentMode.ScaleAspectFit
            };

            _title = new UILabel {
                Frame     = new CGRect(pad / 2, _image.Frame.Width > 0 ? _image.Frame.Bottom + 5 : pad, _alertContainer.Frame.Width - pad, 24.0f),
                Text      = Title,
                TextColor = TitleTextColor,
                Font      = TitleFont,
                Lines     = 1,
                AdjustsFontSizeToFitWidth = true,
                MinimumScaleFactor        = 0.5f,
                TextAlignment             = UITextAlignment.Center
            };

            _message = new UILabel {
                Frame         = new CGRect(pad / 2, _title.Frame.Bottom + 2, _alertContainer.Frame.Width - pad, 20.0f),
                Text          = Message,
                TextColor     = MessageTextColor,
                Font          = MessageFont,
                Lines         = 0,
                TextAlignment = UITextAlignment.Center
            };
            _message.SizeToFit();
            _message.Center = new CGPoint(_title.Center.X, _message.Center.Y);

            if (Input != null)
            {
                _inputImage = new UIImageView {
                    Frame     = new CGRect(pad / 2, _message.Frame.Bottom + pad / 2, Input.Image != null ? 20 : 0, Input.Image != null ? 20 : 0),
                    Image     = Input.Image ?? new UIImage(),
                    TintColor = Input.TintColor != null ? Input.TintColor : Tint
                };

                var startX = Input.Image != null ? pad / 2 + 30 : pad / 2;
                _inputTextField = new UITextField {
                    Frame              = new CGRect(startX, _message.Frame.Bottom + pad / 2, _alertContainer.Frame.Width - _inputImage.Frame.Right - 20, 30),
                    BackgroundColor    = UIColor.White,
                    Placeholder        = Input.Placeholder != null ? Input.Placeholder : "",
                    Text               = Input.Text != null ? Input.Text : "",
                    TextColor          = InputTextColor,
                    Font               = InputFont,
                    BorderStyle        = UITextBorderStyle.None,
                    Alpha              = 0f,
                    Delegate           = new InputSource(),
                    ReturnKeyType      = UIReturnKeyType.Done,
                    KeyboardAppearance = UIKeyboardAppearance.Dark
                };
                _inputTextField.Layer.SublayerTransform = CATransform3D.MakeTranslation(5.0f, 0.0f, 0.0f);

                _inputLabel = new UILabel {
                    Frame     = new CGRect(startX, _message.Frame.Bottom + pad / 2, _alertContainer.Frame.Width - _inputImage.Frame.Right + 20, 30),
                    TextColor = Input.TintColor != null ? Input.TintColor : Tint,
                    Text      = Input.Placeholder != null ? Input.Placeholder : "",
                    Alpha     = 0,
                    Font      = InputFont
                };

                _inputButton = new UIButton {
                    BackgroundColor = UIColor.Clear
                };
                _inputButton.TouchUpInside += (sender, e) => {
                    ShowInputTextField();
                };

                _alertContainer.AddSubviews(new UIView[] { _inputImage, _inputLabel, _inputButton, _inputTextField });

                if (Input.OpenAutomatically)
                {
                    _inputButton.Hidden   = true;
                    _inputTextField.Alpha = 1f;
                    _inputImage.Center    = new CGPoint(_inputImage.Center.X, _inputTextField.Center.Y);
                }
                else
                {
                    _inputLabel.SizeToFit();
                    _inputLabel.Alpha = 1f;
                    nfloat width = _inputImage.Frame.Width + 10 + _inputLabel.Frame.Width;
                    _inputImage.Frame   = new CGRect(_alertContainer.Frame.Width / 2 - width / 2, _inputImage.Frame.Top, _inputImage.Frame.Width, _inputImage.Frame.Height);
                    _inputLabel.Frame   = new CGRect(_inputImage.Frame.Right + 10, _inputLabel.Frame.Top, _inputLabel.Frame.Width, _inputLabel.Frame.Height);
                    _inputImage.Center  = new CGPoint(_inputImage.Center.X, _inputLabel.Center.Y);
                    _inputButton.Frame  = new CGRect(_inputImage.Frame.Left, _inputLabel.Frame.Top, width, 44);
                    _inputButton.Center = new CGPoint(_inputButton.Center.X, _inputLabel.Center.Y);
                }
            }

            _bottomSeparator = new UIView {
                Frame           = new CGRect(0, Input == null ? _message.Frame.Bottom + pad : _inputLabel.Frame.Bottom + pad, _alertContainer.Frame.Width, 1),
                BackgroundColor = SeparatorColor
            };
            _alertContainer.AddSubviews(new UIView[] { _image, _title, _message, _bottomSeparator });

            for (int i = 0; i < Actions.Length; i++)
            {
                CRSAlertAction action = Actions [i];
                var            btn    = new UIButton {
                    Frame           = new CGRect(buttonWidth * i, _bottomSeparator.Frame.Bottom, buttonWidth, buttonHeight),
                    BackgroundColor = ButtonBackground,
                    Font            = action.Highlighted ? AlertButtonHighlightedFont : AlertButtonNormalFont
                };
                btn.ContentMode = UIViewContentMode.ScaleAspectFit;
                btn.SetTitle(string.IsNullOrEmpty(action.Text) ? "" : action.Text, UIControlState.Normal);
                btn.Tag        = i;
                btn.TouchDown += (sender, e) => {
                    btn.BackgroundColor = ButtonHighlighted;
                };
                btn.TouchUpOutside += (sender, e) => {
                    btn.BackgroundColor = ButtonBackground;
                };
                btn.TouchUpInside += (sender, e) => {
                    DidSelectAction((int)btn.Tag);
                };
                btn.SetTitleColor(action.Highlighted ? (action.TintColor ?? Tint) : TitleTextColor, UIControlState.Normal);
                _alertContainer.Add(btn);
                if (i < Actions.Length - 1)
                {
                    var s = new UIView {
                        Frame           = new CGRect(btn.Frame.Right - 1, btn.Frame.Top, 1, buttonHeight),
                        BackgroundColor = SeparatorColor
                    };
                    _alertContainer.Add(s);
                }
            }
            nfloat alertEnd = (_alertContainer.Subviews[_alertContainer.Subviews.Length - 1] as UIView).Frame.Bottom;

            _alertContainer.Frame  = new CGRect(_alertContainer.Frame.Left, _alertContainer.Frame.Top, _alertContainer.Frame.Width, alertEnd);
            _alertContainer.Center = new CGPoint(CRSAlertView.AlertWindow.Frame.Width / 2, CRSAlertView.AlertWindow.Frame.Height / 2);
            Add(_alertContainer);
        }
 public override MonoTouch.CoreAnimation.CATransform3D ItemTransformForOffset(iCarousel carousel, float offset, MonoTouch.CoreAnimation.CATransform3D transform)
 {
     // implement 'flip3D' style carousel
     transform = CATransform3D.MakeRotation(((float)Math.PI) / 8.0f, 0.0f, 1.0f, 0.0f);
     return(CATransform3D.MakeTranslation(0f, 0f, offset * carousel.ItemWidth));
 }