/// <summary>
        /// Initializes a new instance of the <see cref="JZMultiChoice.JZMultiChoicesCircleButton"/> class.
        /// </summary>
        /// <param name="point">Center Point.</param>
        /// <param name="icon">Center Icon</param>
        /// <param name="sRadius">Small radius.</param>
        /// <param name="bRadius">Big radius.</param>
        /// <param name="mMenuItems">Choice items</param>
        /// <param name="isParallex">If set to <c>true</c> is parallex.</param>
        /// <param name="parallex">Parallex amount</param>
        /// <param name="vc">ViewContoller.</param>
        public JZMultiChoicesCircleButton(CGPoint point, UIImage icon
                                          , float sRadius, float bRadius, ChoiceItemCollection mMenuItems, bool isParallex
                                          , float parallex, UIViewController vc) : this(UIScreen.MainScreen.Bounds)
        {
            this.SmallRadius       = sRadius;
            this.BigRadius         = bRadius;
            this.isTouchDown       = false;
            this.CenterPoint       = point;
            this.IconImage         = icon;
            this.ParallexParameter = parallex;
            this.Parallex          = isParallex;
            this.ResponderUIVC     = vc;

            BackgroundView = new  UIView(new CGRect(point.X - sRadius, point.Y - sRadius, sRadius * 2, sRadius * 2));
            BackgroundView.BackgroundColor    = new UIColor(0f, 0f, 0f, 0.7f);
            BackgroundView.Layer.CornerRadius = sRadius;
            this.Add(BackgroundView);

            SmallButton = new UIButton(new CGRect(point.X - sRadius, point.Y - sRadius, sRadius * 2, sRadius * 2));
            SmallButton.Layer.CornerRadius    = sRadius;
            SmallButton.Layer.BackgroundColor = UIColor.FromRGBA(252.0f / 255.0f, 81.0f / 255.0f, 106.0f / 255.0f, 1.0f).CGColor;
            SmallButton.Layer.ShadowColor     = UIColor.Black.CGColor;
            SmallButton.Layer.ShadowOffset    = new CGSize(0.0f, 6.0f);
            SmallButton.Layer.ShadowOpacity   = 0.3f;
            SmallButton.Layer.ShadowRadius    = 4.0f;
            SmallButton.Layer.ZPosition       = bRadius;

            SmallButton.SetImage(IconImage, UIControlState.Normal);

            SmallButton.AddTarget(TouchDown, UIControlEvent.TouchDown);
            SmallButton.AddTarget(this, new Selector("TouchDrag:withEvent:"), UIControlEvent.TouchDragInside);
            SmallButton.AddTarget(this, new Selector("TouchDrag:withEvent:"), UIControlEvent.TouchDragOutside);
            SmallButton.AddTarget(this, new Selector("TouchUpInside:withEvent:"), UIControlEvent.TouchUpInside);
            SmallButton.AddTarget(TouchUpOutside, UIControlEvent.TouchUpOutside);

            this.Add(SmallButton);

            label          = new CATextLayer();
            label.FontSize = 9.0f;
            label.String   = @"Choose:";
            label.FontSize = 40;
            label.SetFont(@"ArialMT");
            label.AlignmentMode = CATextLayer.AlignmentCenter;

            label.ForegroundColor = UIColor.FromWhiteAlpha(1.0f, 0.0f).CGColor;
            label.Frame           = new CGRect(-SmallRadius * 3, -52, SmallRadius * 8, 100);

            var UnScaleFactor = SmallRadius / BigRadius;

            label.Transform = CATransform3D.MakeScale(UnScaleFactor, UnScaleFactor, 1.0f);
            SmallButton.Layer.AddSublayer(label);

            var TransformPara     = BigRadius / SmallRadius;
            var MultiChoiceRadius = (BigRadius + SmallRadius) / 8 / TransformPara;

            this.mItems = mMenuItems;

            IconArray = new List <UIImageView> ();

            var number = mMenuItems.Count;

            foreach (var aItem in this.mItems)
            {
                var i = mItems.IndexOf(aItem);

                var XOffest = 4 * MultiChoiceRadius * Math.Cos(2 * Math.PI * i / number);
                var YOffest = 4 * MultiChoiceRadius * Math.Sin(2 * Math.PI * i / number);


                var IconImageView = new UIImageView(new CGRect(sRadius + XOffest - MultiChoiceRadius, sRadius + YOffest - MultiChoiceRadius, MultiChoiceRadius * 2, MultiChoiceRadius * 2));

                IconImageView.Image  = aItem.Icon;
                IconImageView.Alpha  = 0.0f;
                IconImageView.Hidden = true;
                SmallButton.Add(IconImageView);

                SmallButton.BringSubviewToFront(IconImageView);

                IconImageView.Layer.ContentsScale = UIScreen.MainScreen.Scale * BigRadius / SmallRadius;

                IconArray.Add(IconImageView);
            }



            var UnFullFactor = SmallRadius / this.Frame.Size.Height;

            CallbackIcon = new UIImageView(new CGRect((SmallButton.Frame.Size.Width - BigRadius) / 2, (SmallButton.Frame.Size.Height - BigRadius) / 2, BigRadius, BigRadius));
            CallbackIcon.Layer.Transform = CATransform3D.MakeScale(UnFullFactor, UnFullFactor, 1.0f);
            CallbackIcon.Image           = UIImage.FromBundle("CallbackSuccess");
            CallbackIcon.Alpha           = 0.0f;
            SmallButton.Add(CallbackIcon);


            CallbackMessage                 = new UILabel();
            CallbackMessage.Text            = @"";
            CallbackMessage.Alpha           = 0.0f;
            CallbackMessage.Font            = UIFont.SystemFontOfSize(20.0f);
            CallbackMessage.Layer.Transform = CATransform3D.MakeScale(UnFullFactor, UnFullFactor, 1.0f);
            CallbackMessage.TextColor       = UIColor.White;      //[UIColor whiteColor];
            CallbackMessage.TextAlignment   = UITextAlignment.Center;
            CallbackMessage.Frame           = new CGRect((SmallButton.Frame.Size.Width - SmallRadius / 2) / 2, (SmallButton.Frame.Size.Height - SmallRadius / 4) / 2 + 6, SmallRadius / 2, SmallRadius / 4);
            SmallButton.Add(CallbackMessage);
//
            FullPara = this.Frame.Size.Height / SmallRadius;

            var thning = SmallButton.Layer.ValueForKey(new NSString(@"transform.scale"));

            if (thning != null)
            {
                var val = (NSNumber)NSNumber.FromObject(thning);
                MidiumPara = val.DoubleValue;
            }
            else
            {
                MidiumPara = 1.0f;
            }

            SmallPara = 1.0f;
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			// Perform any additional setup after loading the view, typically from a nib.


			var menuItems = new ChoiceItemCollection () {

				new ChoiceItem()
				{
					Title = "Send",
					Icon = UIImage.FromBundle (@"SendRound"),
					Action = ()=>
					{
						Console.WriteLine("Button 1 Selected"); 
						ShowSimple();
					},
					DisableActionAnimation = true,
				},
				new ChoiceItem()
				{
					Title = "Complete",
					Icon = UIImage.FromBundle (@"CompleteRound"),
					Action = ()=>
					{
						Console.WriteLine("Button 2 Selected"); 
						ShowSuccess(true, "YES!!");
					},
				},
				new ChoiceItem()
				{
					Title = "Calender",
					Icon = UIImage.FromBundle (@"CalenderRound"),
					Action = ()=>
					{
						Console.WriteLine("Button 3 Selected"); 
						ShowSuccess(false, "NO!!");
					},
				},
				new ChoiceItem()
				{
					Title = "Mark",
					Icon = UIImage.FromBundle (@"MarkRound"),
					Action = ()=>
					{
						Console.WriteLine("Button 4 Selected"); 
						ShowSuccess(false, "NO!!");
					},
				},
			};

			mCircleButton = new JZMultiChoicesCircleButton (new CGPoint (this.View.Frame.Size.Width / 2, this.View.Frame.Size.Height / 2)
				, UIImage.FromBundle (@"send")
				, 30.0f
				, 120.0f
				, menuItems
				, true
				, 100
				,this
			);

			this.View.Add (mCircleButton);
		}
Exemple #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.


            var menuItems = new ChoiceItemCollection()
            {
                new ChoiceItem()
                {
                    Title  = "Send",
                    Icon   = UIImage.FromBundle(@"SendRound"),
                    Action = () =>
                    {
                        Console.WriteLine("Button 1 Selected");
                        ShowSimple();
                    },
                    DisableActionAnimation = true,
                },
                new ChoiceItem()
                {
                    Title  = "Complete",
                    Icon   = UIImage.FromBundle(@"CompleteRound"),
                    Action = () =>
                    {
                        Console.WriteLine("Button 2 Selected");
                        ShowSuccess(true, "YES!!");
                    },
                },
                new ChoiceItem()
                {
                    Title  = "Calender",
                    Icon   = UIImage.FromBundle(@"CalenderRound"),
                    Action = () =>
                    {
                        Console.WriteLine("Button 3 Selected");
                        ShowSuccess(false, "NO!!");
                    },
                },
                new ChoiceItem()
                {
                    Title  = "Mark",
                    Icon   = UIImage.FromBundle(@"MarkRound"),
                    Action = () =>
                    {
                        Console.WriteLine("Button 4 Selected");
                        ShowSuccess(false, "NO!!");
                    },
                },
            };

            mCircleButton = new JZMultiChoicesCircleButton(new CGPoint(this.View.Frame.Size.Width / 2, this.View.Frame.Size.Height / 2)
                                                           , UIImage.FromBundle(@"send")
                                                           , 30.0f
                                                           , 120.0f
                                                           , menuItems
                                                           , true
                                                           , 100
                                                           , this
                                                           );

            this.View.Add(mCircleButton);
        }