コード例 #1
0
        public static void FillRoundedRect(CGContext ctx, CGRect rect, nfloat radius)
        {
            var p = GraphicsUtil.MakeRoundedRectPath(rect, radius);

            ctx.AddPath(p);
            ctx.FillPath();
        }
コード例 #2
0
        void DrawInnerGlow(CGContext context, CGPoint center, nfloat startRadius, nfloat endRadius, CGColor glowColor, nfloat glowRadius)
        {
            using (var innerGlowPath = BezierPathGenerator.Bagel(center, startRadius - glowRadius - GlowOffset, startRadius - GlowOffset, 0f, FullCircleAngle))
                using (var outerGlowPath = BezierPathGenerator.Bagel(center, endRadius + GlowOffset, endRadius + glowRadius + GlowOffset, 0f, FullCircleAngle)) {
                    context.SaveState();

#if __UNIFIED__
                    context.SetShadow(CGSize.Empty, glowRadius, glowColor);
#else
                    context.SetShadowWithColor(CGSize.Empty, glowRadius, glowColor);
#endif
                    context.SetFillColor(Color.CGColor);
                    context.AddPath(innerGlowPath.CGPath);
                    context.FillPath();
                    context.RestoreState();


                    context.SaveState();
#if __UNIFIED__
                    context.SetShadow(CGSize.Empty, glowRadius, glowColor);
#else
                    context.SetShadowWithColor(CGSize.Empty, glowRadius, glowColor);
#endif
                    context.SetFillColor(Color.CGColor);

                    context.SetFillColor(Color.CGColor);
                    context.AddPath(outerGlowPath.CGPath);
                    context.FillPath();
                    context.RestoreState();
                }
        }
コード例 #3
0
        public void Lab()
        {
            var whitepoint = new nfloat [] { 1, 2, 3 };
            var blackpoint = new nfloat [] { 3, 2, 1 };
            var range      = new nfloat [] { 1, 2, 3, 4 };

            Assert.Throws <ArgumentNullException> (() => CGColorSpace.CreateLab(null, blackpoint, range), "null whitepoint");
            Assert.Throws <ArgumentException> (() => CGColorSpace.CreateLab(new nfloat [0], blackpoint, range), "invalid whitepoint0");
            Assert.Throws <ArgumentException> (() => CGColorSpace.CreateLab(new nfloat [4], blackpoint, range), "invalid whitepoint4");

            Assert.Throws <ArgumentException> (() => CGColorSpace.CreateLab(whitepoint, new nfloat [0], range), "invalid blackpoint0");
            Assert.Throws <ArgumentException> (() => CGColorSpace.CreateLab(whitepoint, new nfloat [4], range), "invalid blackpoint4");

            Assert.Throws <ArgumentException> (() => CGColorSpace.CreateLab(whitepoint, blackpoint, new nfloat [0]), "invalid range0");
            Assert.Throws <ArgumentException> (() => CGColorSpace.CreateLab(whitepoint, blackpoint, new nfloat [3]), "invalid range3");

            using (var space = CGColorSpace.CreateLab(whitepoint, blackpoint, range)) {
                Assert.IsNotNull(space, "all non-null");
            }

            using (var space = CGColorSpace.CreateLab(whitepoint, null, range)) {
                Assert.IsNotNull(space, "null blackpoint");
            }

            using (var space = CGColorSpace.CreateLab(whitepoint, blackpoint, null)) {
                Assert.IsNotNull(space, "null gamma");
            }

            using (var space = CGColorSpace.CreateLab(whitepoint, null, null)) {
                Assert.IsNotNull(space, "all null");
            }
        }
コード例 #4
0
        public LoadingOverlay(CGRect frame, string text) : base(frame)
        {
            BackgroundColor  = UIColor.Black;
            Alpha            = 0.75f;
            AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

            nfloat labelHeight = 22;
            nfloat labelWidth  = Frame.Width - 20;

            nfloat centerX = Frame.Width / 2;
            nfloat centerY = Frame.Height / 2;

            activitySpinner       = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
            activitySpinner.Frame = new CGRect(
                centerX - (activitySpinner.Frame.Width / 2),
                centerY - activitySpinner.Frame.Height - 20,
                activitySpinner.Frame.Width,
                activitySpinner.Frame.Height);
            activitySpinner.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
            AddSubview(activitySpinner);
            activitySpinner.StartAnimating();

            loadingLabel = new UILabel(new CGRect(
                                           centerX - (labelWidth / 2),
                                           centerY + 20,
                                           labelWidth,
                                           labelHeight
                                           ));
            loadingLabel.BackgroundColor  = UIColor.Clear;
            loadingLabel.TextColor        = UIColor.White;
            loadingLabel.Text             = text;
            loadingLabel.TextAlignment    = UITextAlignment.Center;
            loadingLabel.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
            AddSubview(loadingLabel);
        }
コード例 #5
0
        nfloat getScaleFromSize(CGSize size, CGRect rectangle)
        {
            nfloat scaleX = size.Width / rectangle.Width;
            nfloat scaleY = size.Height / rectangle.Height;

            return((nfloat)Math.Min(scaleX, scaleY));
        }
コード例 #6
0
 //Set the bounds for the rectangle that will need to be redrawn to show the drawn path.
 void resetBounds(CGPoint point)
 {
     minX = point.X - 1;
     maxX = point.X + 1;
     minY = point.Y - 1;
     maxY = point.Y + 1;
 }
コード例 #7
0
        /// <summary>
        /// Draws a line on the target. The coordinates given are scene coordinates.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="color">Color.</param>
        /// <param name="width">Width.</param>
        /// <param name="lineJoin"></param>
        /// <param name="dashes"></param>
        protected override void DrawLine(Target2DWrapper <CGContextWrapper> target, double[] x, double[] y, int color, double width,
                                         LineJoin lineJoin, int[] dashes)
        {
            float widthInPixels = this.ToPixels(width) * _scaleFactor;

            SimpleColor simpleColor = SimpleColor.FromArgb(color);

            target.Target.CGContext.SetLineJoin(CGLineJoin.Round);
            target.Target.CGContext.SetLineWidth(widthInPixels);
            target.Target.CGContext.SetStrokeColor(simpleColor.R / 256.0f, simpleColor.G / 256.0f, simpleColor.B / 256.0f,
                                                   simpleColor.A / 256.0f);
            target.Target.CGContext.SetLineDash(0, new nfloat[0]);
            if (dashes != null && dashes.Length > 1)
            {
                nfloat[] intervals = new nfloat[dashes.Length];
                for (int idx = 0; idx < dashes.Length; idx++)
                {
                    intervals[idx] = dashes[idx];
                }
                target.Target.CGContext.SetLineDash(0.0f, intervals);
            }

            // transform the points all at once.
            double[][] transformed = this.TransformAll(x, y);

            // construct path.
            target.Target.CGContext.BeginPath();
            CGPoint[] points = new CGPoint[x.Length];
            for (int idx = 0; idx < x.Length; idx++)
            {
                points[idx] = new CGPoint((float)transformed[idx][0], (float)transformed[idx][1]);
            }
            target.Target.CGContext.AddLines(points);
            target.Target.CGContext.DrawPath(CGPathDrawingMode.Stroke);
        }
コード例 #8
0
ファイル: PDRatingView.cs プロジェクト: mohibsheth/PDRating
        public override void LayoutSubviews()
        {
            nfloat starAreaWidth      = Bounds.Width / StarRatingConfig.ScaleSize;
            nfloat starAreaHeight     = Bounds.Height - (2 * StarRatingConfig.ItemPadding);
            nfloat starImageMaxWidth  = starAreaWidth - (2 * StarRatingConfig.ItemPadding);
            nfloat starImageMaxHeight = starAreaHeight - (2 * StarRatingConfig.ItemPadding);
            CGSize starAreaScaled     = StarRatingConfig.EmptyImage.Size.ScaleProportional(starImageMaxWidth, starImageMaxHeight);
            nfloat top = (Bounds.Height / 2f) - (starAreaScaled.Height / 2f);
            int    i   = 0;

            StarViews.ForEach(v => {
                nfloat x = (i * starAreaWidth) + StarRatingConfig.ItemPadding;
                v.Frame  = new CGRect(new CGPoint(x, top), starAreaScaled);

                // Choose between showing a chosen rating and the average rating.
                if (ChosenRating != null)
                {
                    v.Chosen        = ChosenRating.Value > i;
                    v.PercentFilled = 0f;
                }
                else
                {
                    v.Chosen            = false;
                    float percentFilled = (AverageRating - 1) > i ? 1.0f : (float)(AverageRating - i);
                    v.PercentFilled     = percentFilled;
                }
                i += 1;
            });

            base.LayoutSubviews();
        }
コード例 #9
0
        private void PanOrTapValue(UIGestureRecognizer recognizer)
        {
            var center = new PointF(this.Bounds.Width / 2f, this.Bounds.Height / 2f);

            switch (recognizer.State)
            {
            case UIGestureRecognizerState.Began:
            case UIGestureRecognizerState.Changed:
            case UIGestureRecognizerState.Ended:
                var point = recognizer.LocationInView(this);
                var dx    = point.X - center.X;
                var dy    = point.Y - center.Y;
                //var distance = Math.Sqrt(dx * dx + dy * dy);

                var angle = (float)Math.Atan2(-dy, -dx);
                var h     = (angle + (float)Math.PI) / (2f * (float)Math.PI);

                this.Hue = h;
                break;

            case UIGestureRecognizerState.Failed:
            case UIGestureRecognizerState.Cancelled:
                break;

            default:
                break;
            }
        }
コード例 #10
0
ファイル: Json.cs プロジェクト: aalice072/CheckBox
        // Parses a font in the format:
        // Name[-SIZE]
        // if -SIZE is omitted, then the value is SystemFontSize
        //
        static UIFont ToFont(string kvalue)
        {
            int    q     = kvalue.LastIndexOf("-");
            string fname = kvalue;
            nfloat fsize = 0;

            if (q != -1)
            {
                nfloat.TryParse(kvalue.Substring(q + 1), out fsize);
                fname = kvalue.Substring(0, q);
            }
            if (fsize <= 0)
            {
#if __TVOS__
                fsize = UIFont.SystemFontOfSize(12).PointSize;
#else
                fsize = UIFont.SystemFontSize;
#endif // __TVOS__
            }

            var f = UIFont.FromName(fname, fsize);
            if (f == null)
            {
                return(UIFont.SystemFontOfSize(12));
            }
            return(f);
        }
コード例 #11
0
 private void Update_Restaurant_Rating(global::System.Single obj, int phase)
 {
     if ((phase & ((1 << 0) | NOT_PHASED)) != 0)
     {
         XamlBindingSetters.Set_Windows_UI_Xaml_Controls_TextBlock_Text(this.obj8, obj.ToString(), null);
     }
 }
コード例 #12
0
        CGSize getSizeFromScale(nfloat scale, CGRect rectangle)
        {
            nfloat width  = rectangle.Width * scale;
            nfloat height = rectangle.Height * scale;

            return(new CGSize(width, height));
        }
コード例 #13
0
ファイル: ElementBadge.cs プロジェクト: aalice072/CheckBox
        public nfloat GetHeight(UITableView tableView, NSIndexPath indexPath)
        {
            CGSize size   = new CGSize(tableView.Bounds.Width - 40, nfloat.MaxValue);
            nfloat height = Caption.StringSize(Font, size, LineBreakMode).Height + 10;

            // Image is 57 pixels tall, add some padding
            return((nfloat)Math.Max(height, 63));
        }
コード例 #14
0
ファイル: SizeFExtensions.cs プロジェクト: david-js/PDRating
        public static CGSize ScaleProportional(this CGSize original, nfloat maxWidth, nfloat maxHeight) {
            nfloat ratioX = (float)maxWidth / original.Width;
            nfloat ratioY = (float)maxHeight / original.Height;
            nfloat ratio = (nfloat)Math.Min(ratioX, ratioY);

            nfloat newWidth = (nfloat)(original.Width * ratio);
            nfloat newHeight = (nfloat)(original.Height * ratio);
            return new CGSize(newWidth, newHeight);
        }
コード例 #15
0
        public ColorPickerHSBView(RectangleF frame)
            : base(frame)
        {
            _hue        = 0f;
            _saturation = 1f;
            _brightness = 1f;

            SetCrosshairView();
            SetGestureRecognizer();
        }
コード例 #16
0
        private void CalculateHSB()
        {
            nfloat h, s, b, a;

            UIColor.FromRGBA(_red, _green, _blue, (byte)0xff).GetHSBA(out h, out s, out b, out a);

            _hue        = h;
            _saturation = s;
            _brightness = b;
        }
コード例 #17
0
ファイル: Quad.cs プロジェクト: ElWazy/Vehicle-Exercise
 public Quad(global::System.Boolean isElectric, global::System.Int32 aditionalCargo, global::System.String model, global::System.String color, global::System.Int32 price, global::System.Int32 passengerCapacity, global::System.Single fuel)
 {
     IsElectric        = isElectric;
     AditionalCargo    = aditionalCargo;
     Model             = model;
     Color             = color;
     Price             = price;
     PassengerCapacity = passengerCapacity;
     Fuel = fuel;
 }
コード例 #18
0
        /// <summary>
        /// Create a new ContactInfo object.
        /// </summary>
        /// <param name="homePhone">Initial value of the HomePhone property.</param>
        /// <param name="cellPhone">Initial value of the CellPhone property.</param>
        /// <param name="fax">Initial value of the Fax property.</param>
        /// <param name="emailAddress">Initial value of the EmailAddress property.</param>
        public static ContactInfo CreateContactInfo(global::System.Single homePhone, global::System.String cellPhone, global::System.String fax, global::System.String emailAddress)
        {
            ContactInfo contactInfo = new ContactInfo();

            contactInfo.HomePhone    = homePhone;
            contactInfo.CellPhone    = cellPhone;
            contactInfo.Fax          = fax;
            contactInfo.EmailAddress = emailAddress;
            return(contactInfo);
        }
コード例 #19
0
        static CGPoint RotatePoint(CGPoint center, nfloat radius, double phi)
        {
            var sinPhi = Math.Sin(phi);
            var cosPhi = Math.Cos(phi);

            var x = center.X + radius * cosPhi;
            var y = center.Y + radius * sinPhi;

            return(new CGPoint((nfloat)x, (nfloat)y));
        }
コード例 #20
0
 private void Update_BookChoice_price(global::System.Single obj, int phase)
 {
     if ((phase & ((1 << 0) | NOT_PHASED)) != 0)
     {
         // BookChoiceController.xaml line 42
         if (!isobj6TextDisabled)
         {
             XamlBindingSetters.Set_Windows_UI_Xaml_Controls_TextBlock_Text(this.obj6, obj.ToString(), null);
         }
     }
 }
コード例 #21
0
        /// <summary>
        /// Create a new treeObservation object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="lat">Initial value of the lat property.</param>
        /// <param name="longitude">Initial value of the longitude property.</param>
        /// <param name="radius">Initial value of the radius property.</param>
        /// <param name="date">Initial value of the date property.</param>
        public static treeObservation CreatetreeObservation(global::System.Int32 id, global::System.Single lat, global::System.Single longitude, global::System.Single radius, global::System.DateTime date)
        {
            treeObservation treeObservation = new treeObservation();

            treeObservation.Id        = id;
            treeObservation.lat       = lat;
            treeObservation.longitude = longitude;
            treeObservation.radius    = radius;
            treeObservation.date      = date;
            return(treeObservation);
        }
コード例 #22
0
 public Jetsky(global::System.Single tonnageCapacity, global::System.String propulsionType, global::System.String model, global::System.String color, global::System.Int32 price, global::System.Int32 passengerCapacity, global::System.Single fuel, global::System.Boolean isSitDown)
 {
     TonnageCapacity   = tonnageCapacity;
     PropulsionType    = propulsionType;
     Model             = model;
     Color             = color;
     Price             = price;
     PassengerCapacity = passengerCapacity;
     Fuel      = fuel;
     IsSitDown = isSitDown;
 }
コード例 #23
0
ファイル: Boat.cs プロジェクト: ElWazy/Vehicle-Exercise
 public Boat(global::System.Single tonnageCapacity, global::System.String propulsionType, global::System.String model, global::System.String color, global::System.Int32 price, global::System.Int32 passengerCapacity, global::System.Single fuel, String handleBarType)
 {
     TonnageCapacity   = tonnageCapacity;
     PropulsionType    = propulsionType;
     Model             = model;
     Color             = color;
     Price             = price;
     PassengerCapacity = passengerCapacity;
     Fuel          = fuel;
     HandleBarType = handleBarType;
 }
コード例 #24
0
        public static CGSize ScaleProportional(this CGSize original, nfloat maxWidth, nfloat maxHeight)
        {
            nfloat ratioX = (float)maxWidth / original.Width;
            nfloat ratioY = (float)maxHeight / original.Height;
            nfloat ratio  = (nfloat)Math.Min(ratioX, ratioY);

            nfloat newWidth  = (nfloat)(original.Width * ratio);
            nfloat newHeight = (nfloat)(original.Height * ratio);

            return(new CGSize(newWidth, newHeight));
        }
コード例 #25
0
 private void Update_emp_salary(global::System.Single obj, int phase)
 {
     if ((phase & ((1 << 0) | NOT_PHASED)) != 0)
     {
         // viewemployee.xaml line 20
         if (!isobj7TextDisabled)
         {
             XamlBindingSetters.Set_Windows_UI_Xaml_Controls_TextBlock_Text(this.obj7, obj.ToString(), null);
         }
     }
 }
コード例 #26
0
 private void Update_item_Blur(global::System.Single obj, int phase)
 {
     if ((phase & (NOT_PHASED | DATA_CHANGED | (1 << 0))) != 0)
     {
         this.Update_item_Blur_M_ToString3_2931822765(phase);
     }
     if ((phase & ((1 << 0) | NOT_PHASED | DATA_CHANGED)) != 0)
     {
         XamlBindingSetters.Set_Windows_UI_Xaml_Controls_Primitives_RangeBase_Value(this.obj23, obj);
     }
 }
コード例 #27
0
        public ColorPickerHueCircleView(RectangleF frame)
            : base(frame)
        {
            _hue = 0f;

            SetCrosshairView();

            var gestureRecognizer = new UIPanGestureRecognizer(PanOrTapValue);

            this.AddGestureRecognizer(gestureRecognizer);
        }
コード例 #28
0
        nfloat CalculatePercentage(nfloat currentValue)
        {
            var fullDistance    = MaxValue - MinValue;
            var currentDistance = MaxValue - currentValue;

            if (fullDistance == 0f)
            {
                return(0f);
            }

            return((1 - currentDistance / fullDistance) * 100f);
        }
コード例 #29
0
ファイル: DetailPage.g.cs プロジェクト: taylorbailey97/CIT365
 private void Update_item_Saturation(global::System.Single obj, int phase)
 {
     if ((phase & (NOT_PHASED | DATA_CHANGED | (1 << 0))) != 0)
     {
         this.Update_item_Saturation_M_ToString3_2931822765(phase);
     }
     if ((phase & ((1 << 0) | NOT_PHASED | DATA_CHANGED)) != 0)
     {
         // DetailPage.xaml line 516
         XamlBindingSetters.Set_Windows_UI_Xaml_Controls_Primitives_RangeBase_Value(this.obj25, obj);
     }
 }
コード例 #30
0
ファイル: Autobus.cs プロジェクト: ElWazy/Vehicle-Exercise
 public Autobus(global::System.Boolean isElectric, global::System.Int32 aditionalCargo, global::System.String model, global::System.String color, global::System.Int32 price, global::System.Int32 passengerCapacity, global::System.Single fuel, List <String> route, global::System.Boolean openBackDoor)
 {
     IsElectric        = isElectric;
     AditionalCargo    = aditionalCargo;
     Model             = model;
     Color             = color;
     Price             = price;
     PassengerCapacity = passengerCapacity;
     Fuel         = fuel;
     Route        = route;
     OpenBackDoor = openBackDoor;
 }
コード例 #31
0
        public static UIColor GetColour(int hex)
        {
            const int mask    = 0xFF;
            nfloat    divisor = 255.0f;

            nfloat r = (hex >> 24) & mask;
            nfloat g = (hex >> 16) & mask;
            nfloat b = (hex >> 8) & mask;
            nfloat a = hex & mask;

            return(UIColor.FromRGB(r / divisor, g / divisor, b / divisor));
        }
コード例 #32
0
		/// <summary>
		///    Creates a path for a rectangle with rounded corners
		/// </summary>
		/// <param name="rect">
		/// The <see cref="RectangleF"/> rectangle bounds
		/// </param>
		/// <param name="radius">
		/// The <see cref="System.Single"/> size of the rounded corners
		/// </param>
		/// <returns>
		/// A <see cref="CGPath"/> that can be used to stroke the rounded rectangle
		/// </returns>
		public static CGPath MakeRoundedRectPath (CGRect rect, nfloat radius)
		{
			nfloat minx = rect.Left;
			nfloat midx = rect.Left + (rect.Width)/2;
			nfloat maxx = rect.Right;
			nfloat miny = rect.Top;
			nfloat midy = rect.Y+rect.Size.Height/2;
			nfloat maxy = rect.Bottom;

			var path = new CGPath ();
			path.MoveToPoint (minx, midy);
			path.AddArcToPoint (minx, miny, midx, miny, radius);
			path.AddArcToPoint (maxx, miny, maxx, midy, radius);
			path.AddArcToPoint (maxx, maxy, midx, maxy, radius);
			path.AddArcToPoint (minx, maxy, minx, midy, radius);		
			path.CloseSubpath ();
			
			return path;
        }
コード例 #33
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            BTProgressHUD.Dismiss ();

            activeField = ActiveField.Player;
            Round = AppDelegate.Self.ApiClient.Get (new GetRound { Id = AppDelegate.Self.CurrentRoundId });
            Machines = AppDelegate.Self.ApiClient.Get (new GetMachinesInRound { Id = Round.Id });
            if (Machines.Count == 0)
                AppDelegate.Self.ShowModalAlertViewAsync ("No games found.");

            _backgroundViewHeight = UIScreen.MainScreen.Bounds.Height;
            _backgroundViewWidth = UIScreen.MainScreen.Bounds.Width;

            labelh = 50.0f;

            nfloat labelx = 70;
            nfloat labely = 120;

            playerLabel = new UILabel {
                Text = "Player",
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.White,
                Font = UIFont.FromName ("Arial", 16F),
                Frame = new CGRect(labelx, labely, _backgroundViewWidth - labelx, labelh),
                UserInteractionEnabled = true
            };
            playerLabel.AddGestureRecognizer (
                new UITapGestureRecognizer (() => {
                    setFocus(playerLabel);
                }));

            playerNumberLabel = new UILabel {
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(84, 164, 224),
                Font = UIFont.FromName ("Arial-BoldMT", 35F),
                Frame = new CGRect((_backgroundViewWidth / 2) - 130, labely, 100, labelh),
                Hidden = true
            };
            playerNameLabel = new UILabel {
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(84, 164, 224),
                Font = UIFont.FromName ("Arial", 16F),
                Frame = new CGRect((_backgroundViewWidth / 2) - 20, labely, 400, labelh),
                Hidden = true
            };

            inputField = new UITextField
            {
                Placeholder = "|",
                BackgroundColor = UIColor.FromRGB(41, 57, 69),
                TextColor = UIColor.White,
                Font = UIFont.FromName ("Arial", 30F),
                BorderStyle = UITextBorderStyle.RoundedRect,
                Frame = new CGRect((_backgroundViewWidth / 2) - 130, labely, 100, labelh),
                UserInteractionEnabled = false,
                TextAlignment = UITextAlignment.Center
            };

            labely += 140;
            gameLabel = new UILabel {
                Text = "Game",
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(84, 164, 224),
                Font = UIFont.FromName ("Arial", 16f),
                Frame = new CGRect(labelx, labely, _backgroundViewWidth - labelx, labelh),
                UserInteractionEnabled = true
            };
            gameLabel.AddGestureRecognizer (
                new UITapGestureRecognizer (() => {
                    setFocus(gameLabel);
                }));

            gameNumberLabel = new UILabel {
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(84, 164, 224),
                Font = UIFont.FromName ("Arial-BoldMT", 35F),
                Frame = new CGRect((_backgroundViewWidth / 2) - 130, labely, 100, labelh),
                Hidden = false
            };
            gameNameLabel = new UILabel {
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(84, 164, 224),
                Font = UIFont.FromName ("Arial", 16F),
                Frame = new CGRect((_backgroundViewWidth / 2) - 20, labely, 400, labelh),
                Hidden = false
            };

            labely += 140;
            scoreLabel = new UILabel {
                Text = "Score",
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(84, 164, 224),
                Font = UIFont.FromName ("Arial", 16f),
                Frame = new CGRect(labelx, labely, _backgroundViewWidth - labelx, labelh),
                UserInteractionEnabled = true
            };
            scoreLabel.AddGestureRecognizer (
                new UITapGestureRecognizer (() => {
                    setFocus(scoreLabel);
                }));

            scoreNumberLabel = new UILabel {
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(84, 164, 224),
                Font = UIFont.FromName ("Arial-BoldMT", 35F),
                Frame = new CGRect((_backgroundViewWidth / 2) - 130, labely, 300, labelh),
                Hidden = true
            };

            labely += 100;
            savedLabel = new UILabel {
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB(48, 202, 102),
                Text = "Score submitted successfully",
                Font = UIFont.FromName ("Arial", 16F),
                Frame = new CGRect((_backgroundViewWidth / 2) - 130, labely, 300, labelh),
                Hidden = true
            };

            View.AddSubview(playerLabel);
            View.AddSubview(playerNumberLabel);
            View.AddSubview(playerNameLabel);
            View.AddSubview(gameLabel);
            View.AddSubview(gameNumberLabel);
            View.AddSubview(gameNameLabel);
            View.AddSubview(scoreLabel);
            View.AddSubview(scoreNumberLabel);
            View.AddSubview(savedLabel);
            View.AddSubview(inputField);

            drawButtons ();

            if (InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || InterfaceOrientation == UIInterfaceOrientation.LandscapeRight)
            {
                _heightFix = View.Bounds.Width;
                DidRotate (UIInterfaceOrientation.Portrait);
            }
        }
コード例 #34
0
        void Scale(UIPinchGestureRecognizer gesture)
        {
            if (CurrentMonkey == null)
                return;
            if (gesture.State == UIGestureRecognizerState.Began)
                lastScale = 1f;
            var scale = 1f - (lastScale - gesture.Scale);

            var transform = CurrentMonkey.Transform;
            transform.Scale (scale, scale);
            CurrentMonkey.Transform = transform;

            lastScale = gesture.Scale;
            if(gesture.State == UIGestureRecognizerState.Ended)
            {
                CurrentMonkey.UpdateMonkey(Bounds);
                Parent.UpdateMonkey(CurrentMonkey.Monkey);
            }
        }
			public FieldCell (FormAuthenticatorField field, nfloat fieldXPosition, Action handleReturn)
				: base (UITableViewCellStyle.Default, "Field")
			{
				SelectionStyle = UITableViewCellSelectionStyle.None;

				TextLabel.Text = field.Title;

				var hang = 3;
				var h = FieldFont.PointSize + hang;

				var cellSize = Frame.Size;

				TextField = new UITextField (new CGRect (
					fieldXPosition, (cellSize.Height - h)/2, 
					cellSize.Width - fieldXPosition - 12, h)) {

					Font = FieldFont,
					Placeholder = field.Placeholder,
					Text = field.Value,
					TextColor = FieldColor,
					AutoresizingMask = UIViewAutoresizing.FlexibleWidth,

					SecureTextEntry = (field.FieldType == FormAuthenticatorFieldType.Password),

					KeyboardType = (field.FieldType == FormAuthenticatorFieldType.Email) ?
						UIKeyboardType.EmailAddress :
						UIKeyboardType.Default,

					AutocorrectionType = (field.FieldType == FormAuthenticatorFieldType.PlainText) ?
						UITextAutocorrectionType.Yes :
						UITextAutocorrectionType.No,
					
					AutocapitalizationType = UITextAutocapitalizationType.None,

					ShouldReturn = delegate {
						handleReturn ();
						return false;
					},
				};
				TextField.EditingDidEnd += delegate {
					field.Value = TextField.Text;
				};

				ContentView.AddSubview (TextField);
			}
コード例 #36
0
 public UIImage GetImage(UIColor strokeColor, UIColor fillColor, nfloat scale, bool shouldCrop = true, bool keepAspectRatio = true)
 {
     return GetImage (strokeColor, fillColor, getSizeFromScale(scale, Bounds), scale, shouldCrop, keepAspectRatio);
 }
コード例 #37
0
        UIImage GetImage(UIColor strokeColor, UIColor fillColor, CGSize size, nfloat scale, bool shouldCrop = true, bool keepAspectRatio = true)
        {
            if (size.Width == 0 || size.Height == 0 || scale <= 0 || strokeColor == null ||
                fillColor == null)
                return null;

            nfloat uncroppedScale;
            CGRect croppedRectangle = new CGRect ();

            CGPoint [] cachedPoints;

            if (shouldCrop && (cachedPoints = Points).Any ()) {
                croppedRectangle = getCroppedRectangle (cachedPoints);
                croppedRectangle.Width /= scale;
                croppedRectangle.Height /= scale;
                if (croppedRectangle.X >= 5) {
                    croppedRectangle.X -= 5;
                    croppedRectangle.Width += 5;
                }
                if (croppedRectangle.Y >= 5) {
                    croppedRectangle.Y -= 5;
                    croppedRectangle.Height += 5;
                }
                if (croppedRectangle.X + croppedRectangle.Width <= size.Width - 5)
               		croppedRectangle.Width += 5;
                if (croppedRectangle.Y + croppedRectangle.Height <= size.Height - 5)
               		croppedRectangle.Height += 5;

                nfloat scaleX = croppedRectangle.Width / Bounds.Width;
                nfloat scaleY = croppedRectangle.Height / Bounds.Height;
                uncroppedScale = 1 / (nfloat)Math.Max (scaleX, scaleY);
            } else {
                uncroppedScale = scale;
            }

            //Make sure the image is scaled to the screen resolution in case of Retina display.
            if (keepAspectRatio)
                UIGraphics.BeginImageContext (size);
            else
                UIGraphics.BeginImageContext (new CGSize (croppedRectangle.Width * uncroppedScale, croppedRectangle.Height * uncroppedScale));

            //Create context and set the desired options
            CGContext context = UIGraphics.GetCurrentContext ();
            context.SetFillColor (fillColor.CGColor);
            context.FillRect (new CGRect (0, 0, size.Width, size.Height));
            context.SetStrokeColor (strokeColor.CGColor);
            context.SetLineWidth (StrokeWidth);
            context.SetLineCap (CGLineCap.Round);
            context.SetLineJoin (CGLineJoin.Round);
            context.ScaleCTM (uncroppedScale, uncroppedScale);

            //Obtain all drawn paths from the array
            foreach (var bezierPath in paths) {
                var tempPath = (UIBezierPath)bezierPath.Copy ();
                if (shouldCrop)
                    tempPath.ApplyTransform (CGAffineTransform.MakeTranslation (-croppedRectangle.X, -croppedRectangle.Y));
                CGPath path = tempPath.CGPath;
                context.AddPath (path);
                tempPath = null;
            }
            context.StrokePath ();

            UIImage image = UIGraphics.GetImageFromCurrentImageContext ();

            UIGraphics.EndImageContext ();

            return image;
        }
コード例 #38
0
		private void PanBegan(UIPanGestureRecognizer panGesture, MenuLocations menuLocation, nfloat gestureActiveArea) {
			_panOriginX = ContentViewController.View.Frame.X;
			_ignorePan = PanGestureInActiveArea(panGesture, menuLocation, gestureActiveArea);
		}
コード例 #39
0
 //Set the bounds for the rectangle that will need to be redrawn to show the drawn path.
 void resetBounds(CGPoint point)
 {
     minX = point.X - 1;
     maxX = point.X + 1;
     minY = point.Y - 1;
     maxY = point.Y + 1;
 }
コード例 #40
0
		private bool PanGestureInActiveArea(UIPanGestureRecognizer panGesture, MenuLocations menuLocation, nfloat gestureActiveArea) {
			var position = panGesture.LocationInView(ContentViewController.View).X;
			if (menuLocation == MenuLocations.Left)
				return position > gestureActiveArea;
			else
				return position < ContentViewController.View.Bounds.Width - gestureActiveArea;
		}
コード例 #41
0
		/// <summary>
		/// Pan the specified view.
		/// </summary>
		private void Pan(UIView view)
		{
			if (_panGesture.State == UIGestureRecognizerState.Began) {
				_panOriginX = view.Frame.X;
				if (MenuLocation == MenuLocations.Left)
					_ignorePan = _panGesture.LocationInView(view).X > 50;
				else
					_ignorePan = _panGesture.LocationInView(view).X < view.Bounds.Width - 50;
			} else if (!_ignorePan && (_panGesture.State == UIGestureRecognizerState.Changed)) {
				var t = _panGesture.TranslationInView(view).X;

				if (MenuLocation == MenuLocations.Left) {
					if ((t > 0 && !IsOpen) || (t < 0 && IsOpen)) {
						if (t > MenuWidth)
							t = MenuWidth;
						else if (t < -MenuWidth && IsOpen)
							t = MenuWidth; 
						if (_panOriginX + t <= MenuWidth) {
							view.Frame = new RectangleF (_panOriginX + t, view.Frame.Y, view.Frame.Width, view.Frame.Height);
							MenuAreaController.View.Frame = new RectangleF (_panOriginX + t - MenuWidth, MenuAreaController.View.Frame.Y, MenuAreaController.View.Frame.Width, MenuAreaController.View.Frame.Height);
							//view.Alpha = 1.0f - ((_panOriginX + t) / MenuWidth)/2;
							_shadownOverlayContent.Alpha = ((_panOriginX + t) / MenuWidth)*0.7f;
							_shadownOverlayMenu.Alpha = 1.0f - ((_panOriginX + t) / MenuWidth);
						}
						ShowShadowWhileDragging();
					}
				} else if (MenuLocation == MenuLocations.Right) {
					if ((t < 0 && !IsOpen) || (t > 0 && IsOpen)) {
						if (t < -MenuWidth)
							t = -MenuWidth;
						else if (t > MenuWidth)
							t = MenuWidth; 
						if (_panOriginX + t <= 0)
							view.Frame = new RectangleF(_panOriginX + t, view.Frame.Y, view.Frame.Width, view.Frame.Height);
						ShowShadowWhileDragging();
					}
				}
			} else if (!_ignorePan && (_panGesture.State == UIGestureRecognizerState.Ended || _panGesture.State == UIGestureRecognizerState.Cancelled)) {
				var t = _panGesture.TranslationInView(view).X;
				var velocity = _panGesture.VelocityInView(view).X;
				if ((MenuLocation == MenuLocations.Left && IsOpen && t < 0) || (MenuLocation == MenuLocations.Right && IsOpen && t > 0)) {
					if (view.Frame.X > -view.Frame.Width / 2) {
						CloseMenu();
					} else {
						UIView.Animate(_slideSpeed, 0, UIViewAnimationOptions.CurveEaseInOut,
							() => {
								view.Frame = new RectangleF(-MenuWidth, view.Frame.Y, view.Frame.Width, view.Frame.Height);
							}, () => {
						});
					}
                } if ((MenuLocation == MenuLocations.Left && (velocity > FlingVelocity || view.Frame.X > (MenuWidth * FlingPercentage)))
                    || (MenuLocation == MenuLocations.Right && (velocity < -FlingVelocity || view.Frame.X < -(MenuWidth * FlingPercentage)))) {
                    OpenMenu();
                } else {
                    UIView.Animate(_slideSpeed, 0, UIViewAnimationOptions.CurveEaseInOut,
                        () =>
                        {
                            view.Frame = new RectangleF(0, 0, view.Frame.Width, view.Frame.Height);
                        }, () =>
                        {
                        });
                }
			}
		}
コード例 #42
0
		public static void FillRoundedRect (CGContext ctx, CGRect rect, nfloat radius)
		{
				var p = GraphicsUtil.MakeRoundedRectPath (rect, radius);
				ctx.AddPath (p);
				ctx.FillPath ();
		}
コード例 #43
0
        public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
        {
            base.DidRotate (fromInterfaceOrientation);

            if (fromInterfaceOrientation == _fromRotation)
                return;
            _fromRotation = fromInterfaceOrientation;

            int multipl = -1;
            int val = 100;
            if (fromInterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || fromInterfaceOrientation == UIInterfaceOrientation.LandscapeRight) {
                val = 100;
                multipl = 1;
            }
            _backgroundViewWidth = View.Bounds.Width;
            _backgroundViewHeight = _heightFix.HasValue ? _heightFix.Value : View.Bounds.Height;
            _heightFix = null;

            playerLabel.Frame = new CGRect (playerLabel.Frame.X, playerLabel.Frame.Y, playerLabel.Frame.Width, playerLabel.Frame.Height);
            playerNumberLabel.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, playerNumberLabel.Frame.Y, playerNumberLabel.Frame.Width, playerNumberLabel.Frame.Height);
            playerNameLabel.Frame = new CGRect ((_backgroundViewWidth / 2) - 20, playerNameLabel.Frame.Y, playerNameLabel.Frame.Width, playerNameLabel.Frame.Height);
            gameLabel.Frame = new CGRect (gameLabel.Frame.X, gameLabel.Frame.Y + (50 * multipl), gameLabel.Frame.Width, gameLabel.Frame.Height);
            gameNumberLabel.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, gameNumberLabel.Frame.Y + (50 * multipl), gameNumberLabel.Frame.Width, gameNumberLabel.Frame.Height);
            gameNameLabel.Frame = new CGRect ((_backgroundViewWidth / 2) - 20, gameNameLabel.Frame.Y + (50 * multipl), gameNameLabel.Frame.Width, gameNameLabel.Frame.Height);
            scoreLabel.Frame = new CGRect (scoreLabel.Frame.X, scoreLabel.Frame.Y + (100 * multipl), scoreLabel.Frame.Width, scoreLabel.Frame.Height);
            scoreNumberLabel.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, scoreNumberLabel.Frame.Y + (100 * multipl), scoreNumberLabel.Frame.Width, scoreNumberLabel.Frame.Height);
            savedLabel.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, savedLabel.Frame.Y + (150 * multipl), savedLabel.Frame.Width, savedLabel.Frame.Height);
            backgroundViewConfirm.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, (_backgroundViewHeight / 2) + (val * multipl), backgroundViewConfirm.Frame.Width, backgroundViewConfirm.Frame.Height);
            backgroundViewToken.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, (_backgroundViewHeight / 2) + (val * multipl), backgroundViewToken.Frame.Width, backgroundViewToken.Frame.Height);
            backgroundViewKeyPad.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, _backgroundViewHeight - 300 - val, backgroundViewKeyPad.Frame.Width, backgroundViewKeyPad.Frame.Height);
            switch (activeField) {
                case ActiveField.Player:
                    inputField.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, inputField.Frame.Y, inputField.Frame.Width, inputField.Frame.Height);
                    break;
                    case ActiveField.Game:
                inputField.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, inputField.Frame.Y + (50 * multipl), inputField.Frame.Width, inputField.Frame.Height);
                    break;
                case ActiveField.Score:
                inputField.Frame = new CGRect ((_backgroundViewWidth / 2) - 130, inputField.Frame.Y + (100 * multipl), inputField.Frame.Width, inputField.Frame.Height);
                    break;
                default:
                    break;
            }
        }
コード例 #44
0
 //Update the bounds for the rectangle to be redrawn if necessary for the given point.
 void updateBounds(CGPoint point)
 {
     if (point.X < minX + 1)
         minX = point.X - 1;
     if (point.X > maxX - 1)
         maxX = point.X + 1;
     if (point.Y < minY + 1)
         minY = point.Y - 1;
     if (point.Y > maxY - 1)
         maxY = point.Y + 1;
 }
コード例 #45
0
        void Rotate(UIRotationGestureRecognizer gesture)
        {
            if (CurrentMonkey == null)
                return;
            if (gesture.State == UIGestureRecognizerState.Ended) {
                lastRotation = 0;
                CurrentMonkey.UpdateMonkey(Bounds);
                Parent.UpdateMonkey(CurrentMonkey.Monkey);
                return;
            }
            var rotation = 0 - (lastRotation - gesture.Rotation);
            var transform = CurrentMonkey.Transform;
            transform.Rotate (rotation);
            CurrentMonkey.Transform = transform;

            lastRotation = gesture.Rotation;
        }
コード例 #46
0
		private void PanChangedMenuRight(int menuWidth, bool isOpen, nfloat xDelta) {
			if ((xDelta < 0 && !isOpen) || (xDelta > 0 && isOpen)) {
				if (xDelta < -menuWidth)
					xDelta = -menuWidth;
				else if (xDelta > menuWidth)
					xDelta = menuWidth; 
				if (_panOriginX + xDelta <= 0) 
					ContentViewController.View.Frame = 
						new RectangleF(_panOriginX + xDelta, ContentViewController.View.Frame.Y, ContentViewController.View.Frame.Width, ContentViewController.View.Frame.Height);
			}
		}
コード例 #47
0
        CGSize getSizeFromScale(nfloat scale, CGRect rectangle)
        {
            nfloat width = rectangle.Width * scale;
            nfloat height = rectangle.Height * scale;

            return new CGSize (width, height);
        }