Esempio n. 1
0
 public void animateToColor(UIColor c)
 {
     UIView.Animate(
         duration: 0.6f,
         animation: () =>
     {
         BackgroundColor     = c.ColorWithAlpha(0.7f);
         TempBackgroundColor = c.ColorWithAlpha(0.7f);
     },
         completion: () =>
     {
     }
         );
 }
Esempio n. 2
0
        private static UIImage drawToken(string projectName, UIColor projectColor, UIFont font)
        {
            var stringToDraw = new NSAttributedString(
                projectName, new UIStringAttributes {
                Font = font, ForegroundColor = projectColor
            });

            var size = CalculateSize(stringToDraw, circleWidth);

            UIGraphics.BeginImageContextWithOptions(size, false, 0.0f);
            using (var context = UIGraphics.GetCurrentContext())
            {
                var tokenPath = CalculateTokenPath(size);
                context.AddPath(tokenPath.CGPath);
                context.SetFillColor(projectColor.ColorWithAlpha(0.12f).CGColor);
                context.FillPath();

                var dot = UIBezierPath.FromRoundedRect(new CGRect(
                                                           x: dotPadding + TokenMargin,
                                                           y: dotYOffset,
                                                           width: dotDiameter,
                                                           height: dotDiameter
                                                           ), dotRadius);
                context.AddPath(dot.CGPath);
                context.SetFillColor(projectColor.CGColor);
                context.FillPath();

                var textOffset = (TokenHeight - font.LineHeight) / 2;
                stringToDraw.DrawString(new CGPoint(TokenMargin + TokenPadding + circleWidth, textOffset));

                var image = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();
                return(image);
            }
        }
Esempio n. 3
0
        public ProjectTextAttachment(NSAttributedString stringToDraw, UIColor projectColor, nfloat textVerticalOffset, nfloat fontDescender)
            : base(fontDescender)
        {
            var size = CalculateSize(stringToDraw, circleWidth);

            UIGraphics.BeginImageContextWithOptions(size, false, 0.0f);
            using (var context = UIGraphics.GetCurrentContext())
            {
                var tokenPath = CalculateTokenPath(size);
                context.AddPath(tokenPath.CGPath);
                context.SetFillColor(projectColor.ColorWithAlpha(0.12f).CGColor);
                context.FillPath();

                var dot = UIBezierPath.FromRoundedRect(new CGRect(
                                                           x: dotPadding + TokenMargin,
                                                           y: dotYOffset,
                                                           width: dotDiameter,
                                                           height: dotDiameter
                                                           ), dotRadius);
                context.AddPath(dot.CGPath);
                context.SetFillColor(projectColor.CGColor);
                context.FillPath();

                stringToDraw.DrawString(new CGPoint(circleWidth + TokenMargin + TokenPadding, textVerticalOffset));

                var image = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();
                Image = image;
            }
        }
Esempio n. 4
0
 public FAButton(FA icon, UIColor fontColor, float iconSize = 20) : base()
 {
     Icon     = icon;
     IconSize = iconSize;
     SetTitleColor(fontColor, UIControlState.Normal);
     SetTitleColor(fontColor.ColorWithAlpha(100), UIControlState.Highlighted);
 }
Esempio n. 5
0
        internal static CALayer CrateRippleAnimationLayer(this UIButton button, CGPoint tapLocation, UIColor color = null, double initialSize = 10)
        {
            var aLayer = new CALayer();

            if (color != null)
            {
                nfloat red   = 1;
                nfloat green = 0;
                nfloat blue  = 0;
                nfloat alpha = 0;
                color.GetRGBA(out red, out green, out blue, out alpha);
                aLayer.BackgroundColor = alpha == 1 ? color.ColorWithAlpha(0.10f).CGColor : color.CGColor;
            }
            else
            {
                aLayer.BackgroundColor = UIColor.White.ColorWithAlpha(0.10f).CGColor;
            }

            aLayer.Frame         = new CGRect(0, 0, initialSize, initialSize);
            aLayer.CornerRadius  = (nfloat)initialSize / 2;
            aLayer.MasksToBounds = true;
            aLayer.Position      = tapLocation;
            button.Layer.InsertSublayer(aLayer, button.Layer.Sublayers.Length);
            return(aLayer);
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FontAwesomeXamarin.FAButton"/> class.
 /// This class extends UIButton. It does not set a default Frame. You must do this yourself
 /// </summary>
 /// <param name="icon">Icon.</param>
 /// <param name="fontColor">Font color.</param>
 /// <param name="iconSize">Icon size.</param>
 public FAButton(string icon, UIColor fontColor, float iconSize = 20)
 {
     Icon     = icon;
     IconSize = iconSize;
     this.SetTitleColor(fontColor, UIControlState.Normal);
     this.SetTitleColor(fontColor.ColorWithAlpha(100), UIControlState.Highlighted);
 }
Esempio n. 7
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                string CellIdentifier = "cellId";
                UITableViewCell aCell = tableView.DequeueReusableCell(CellIdentifier);
                if (aCell == null)
                {
                    aCell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier);
                }
                String plainText = SuggestionsData[indexPath.Row];

                UIStringAttributes stringAttr_F17Reg = new UIStringAttributes();
                stringAttr_F17Reg.Font = UIFont.SystemFontOfSize(fSize);
                stringAttr_F17Reg.ForegroundColor = textColor;

                NSMutableAttributedString attributedSText = new NSMutableAttributedString(plainText, stringAttr_F17Reg);
                aCell.TextLabel.AttributedText = attributedSText;

                NSRange rangeInText = ((NSString)plainText.ToLower()).LocalizedStandardRangeOfString(((NSString)hightlightText.ToLower()));

                if (rangeInText.Location > -1)
                {
                    attributedSText.AddAttribute(UIStringAttributeKey.Font,
                                                 UIFont.BoldSystemFontOfSize(fSize), rangeInText);
                    aCell.TextLabel.AttributedText = attributedSText;
                }
                //aCell.TextLabel.TextColor = textColor;
                //aCell.TextLabel.AttributedText = ;
                //aCell.TextLabel.TextColor = UIColor.DarkGray;
                aCell.BackgroundColor = aCell.ContentView.BackgroundColor = bgColor.ColorWithAlpha(bgAlpha);
                return aCell;
            }
Esempio n. 8
0
        private UIImage ChangeImageColor(UIImage image, nfloat alpha, UIColor color)
        {
            var alphaColor = color.ColorWithAlpha(alpha);

            UIGraphics.BeginImageContextWithOptions(image.Size, false, UIScreen.MainScreen.Scale);

            var context = UIGraphics.GetCurrentContext();

            alphaColor.SetFill();

            context.TranslateCTM(0, image.Size.Height);
            context.ScaleCTM(new nfloat(1.0), new nfloat(-1.0));
            context.SetBlendMode(CGBlendMode.Lighten);

            var rect = new CGRect(0, 0, image.Size.Width, image.Size.Height);

            context.DrawImage(rect, image.CGImage);

            context.SetBlendMode(CGBlendMode.SourceAtop);
            context.AddRect(rect);
            context.DrawPath(CGPathDrawingMode.Fill);

            image = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();

            return(image);
        }
Esempio n. 9
0
        protected UIView Make_Box(UIColor bg_color, nfloat w, nfloat h)
        {
            var view = new UIView();

            view.Frame           = new CGRect(0, 0, w, h);
            view.BackgroundColor = bg_color.ColorWithAlpha(0.5f);
            return(view);
        }
Esempio n. 10
0
 /// <summary>
 /// <see cref="!:https://stackoverflow.com/a/48489506/1479638"/>
 /// </summary>
 public static TView WithSketchShadow <TView>(this TView view, UIColor shadowColor, float x = 0, float y = 0, float blur = 4) where TView : UIView
 {
     view.Layer.ShadowColor   = shadowColor.ColorWithAlpha(1).CGColor;
     view.Layer.ShadowOpacity = (float)shadowColor.CGColor.Alpha;
     view.Layer.ShadowOffset  = new CGSize(x, y);
     view.Layer.ShadowRadius  = blur / 2f;
     return(view);
 }
Esempio n. 11
0
 public static TView WithShadow <TView>(this TView view, UIColor shadowColor, float xOffset, float yOffset, float radius = 8f) where TView : UIView
 {
     view.Layer.ShadowColor   = shadowColor.ColorWithAlpha(1).CGColor;
     view.Layer.ShadowOpacity = (float)shadowColor.CGColor.Alpha;
     view.Layer.ShadowOffset  = new CGSize(xOffset, yOffset);
     view.Layer.ShadowRadius  = radius;
     return(view);
 }
Esempio n. 12
0
        private void DrawGrid()
        {
            var size = new CGRect()
            {
                Width  = ContentSize.Width > Frame.Width ? Frame.Width : ContentSize.Width,
                Height = ContentSize.Height > Frame.Width ? Frame.Width : ContentSize.Height,
                X      = ContentOffset.X < 0 ? 0 : ContentOffset.X,
                Y      = ContentOffset.Y < 0 ? 0 : ContentOffset.Y,
            };

            var gridHeight = size.Height / (_linesCount + 1);
            var gridWidth  = size.Width / (_linesCount + 1);

            _path           = UIBezierPath.Create();
            _path.LineWidth = 1;

            for (int i = 1; i < _linesCount + 1; i++)
            {
                var start = new CGPoint(x: i * gridWidth + size.X, y: size.Y);
                var end   = new CGPoint(x: i * gridWidth + size.X, y: size.Height + size.Y);
                _path.MoveTo(start);
                _path.AddLineTo(end);
            }

            for (int i = 1; i < _linesCount + 1; i++)
            {
                var start = new CGPoint(x: size.X, y: i * gridHeight + size.Y);
                var end   = new CGPoint(x: size.Width + size.X, y: i * gridHeight + size.Y);
                _path.MoveTo(start);
                _path.AddLineTo(end);
            }
            _shapeLayer.RemoveAllAnimations();
            _shapeLayer.StrokeColor = _strokeColor.ColorWithAlpha(0.15f).CGColor;

            var animation = CABasicAnimation.FromKeyPath("strokeColor");

            animation.BeginTime = CAAnimation.CurrentMediaTime() + 0.2; //delay
            animation.Duration  = 0.2;
            animation.SetTo(_strokeColor.ColorWithAlpha(0).CGColor);
            animation.RemovedOnCompletion = false;
            animation.FillMode            = CAFillMode.Forwards;

            _shapeLayer.AddAnimation(animation, "flashStrokeColor");
            _shapeLayer.Path = _path.CGPath;
            _path.ClosePath();
        }
Esempio n. 13
0
        private UIImage ChangeImageToColor(UIImage image, nfloat alpha, UIColor color)
        {
            var alphaColor = color.ColorWithAlpha(alpha);

            UIGraphics.BeginImageContextWithOptions(image.Size, false, UIScreen.MainScreen.Scale);
            alphaColor.SetFill();
            image = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();

            return(image);
        }
Esempio n. 14
0
 CAShapeLayer barcodeOverlayLayer(CGPath path, UIColor color)
 {
     return(new CAShapeLayer()
     {
         Path = path,
         LineJoin = CAShapeLayer.JoinRound,
         LineWidth = 2.0f,
         StrokeColor = color.CGColor,
         FillColor = color.ColorWithAlpha(0.2f).CGColor
     });
 }
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement != null)
            {
                if (Element.HeightRequest > 1)
                {
                    elementHeight = Element.HeightRequest;
                }
                else
                {
                    elementHeight = 125.00;
                }

                textColor       = Element.TextColor.ToUIColor();
                backgroundColor = textColor.ColorWithAlpha(0.5f);
            }

            var customButton = Element as CustomButton;

            if (customButton == null)
            {
                return;
            }

            customButton.FireAnimation += (sender, en) =>
            {
                if (Element == null)
                {
                    return;
                }

                // Create ripple 1 circle
                outerCircleLayer = createOuterCircle(Control.Layer.Frame, backgroundColor);

                Control.Layer.InsertSublayer(outerCircleLayer, 0);


                // Create ripple 2 circle
                rippleCircleLayer = createOuterCircle(Control.Layer.Frame, backgroundColor);

                Control.Layer.InsertSublayer(rippleCircleLayer, 0);

                animation1(Element);
                animation2(Element);
            };
        }
Esempio n. 16
0
        public TokenTextAttachment(
            NSAttributedString projectStringToDraw,
            nfloat textVerticalOffset,
            UIColor projectColor,
            nfloat fontDescender,
            int leftMargin,
            int rightMargin)
        {
            const int circleWidth = dotDiameter + dotPadding;
            var       totalWidth  = projectStringToDraw.Size.Width + circleWidth + leftMargin + rightMargin + (tokenPadding * 2);
            var       size        = new CGSize(totalWidth, lineHeight);

            UIGraphics.BeginImageContextWithOptions(size, false, 0.0f);
            using (var context = UIGraphics.GetCurrentContext())
            {
                var tokenPath = UIBezierPath.FromRoundedRect(new CGRect(
                                                                 x: leftMargin,
                                                                 y: tokenVerticallOffset,
                                                                 width: totalWidth - leftMargin - rightMargin,
                                                                 height: tokenHeight
                                                                 ), tokenCornerRadius);
                context.AddPath(tokenPath.CGPath);
                context.SetFillColor(projectColor.ColorWithAlpha(0.12f).CGColor);
                context.FillPath();

                var dot = UIBezierPath.FromRoundedRect(new CGRect(
                                                           x: dotPadding + leftMargin,
                                                           y: dotYOffset,
                                                           width: dotDiameter,
                                                           height: dotDiameter
                                                           ), dotRadius);
                context.AddPath(dot.CGPath);
                context.SetFillColor(projectColor.CGColor);
                context.FillPath();

                projectStringToDraw.DrawString(new CGPoint(circleWidth + leftMargin + tokenPadding, textVerticalOffset));

                var image = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();
                Image = image;
            }

            FontDescender = fontDescender;
        }
Esempio n. 17
0
        public static void MSStandardButton(this UIButton self, UIColor mainColor = null, UIColor disabledColor = null)
        {
            if (mainColor == null)
            {
                mainColor = UIColorMS.ThemePrimary;
            }
            if (disabledColor == null)
            {
                disabledColor = UIColorMS.NeutralTertiaryAlt;
            }
            self.SetBackgroundImage(UIImageMS.MSButtonBackground(mainColor, UIColor.Clear), self.State);
            self.SetBackgroundImage(UIImageMS.MSButtonBackground(mainColor, mainColor), UIControlState.Highlighted);
            self.SetBackgroundImage(UIImageMS.MSButtonBackground(mainColor, mainColor), UIControlState.Selected);
            self.SetBackgroundImage(UIImageMS.MSButtonBackground(disabledColor, disabledColor.ColorWithAlpha(0.1f)), UIControlState.Disabled);

            self.SetTitleColor(mainColor, self.State);
            self.SetTitleColor(UIColorMS.NeutralWhite, UIControlState.Highlighted);
            self.SetTitleColor(UIColorMS.NeutralWhite, UIControlState.Selected);
            self.SetTitleColor(disabledColor, UIControlState.Disabled);
        }
Esempio n. 18
0
            private void ChangeNavBarButtonColor(UIColor textColor)
            {
                var buttonFont = UIFont.FromName(FontName.HelveticaNeueLight, 34 / 2);

                // set back/left/right button color
                var buttonTextColor = new UITextAttributes
                {
                    Font             = buttonFont,
                    TextColor        = textColor,
                    TextShadowColor  = UIColor.Clear,
                    TextShadowOffset = new UIOffset(0, 0)
                };
                var selectedButtonTextColor = new UITextAttributes
                {
                    Font             = buttonFont,
                    TextColor        = textColor.ColorWithAlpha(0.5f),
                    TextShadowColor  = UIColor.Clear,
                    TextShadowOffset = new UIOffset(0, 0)
                };

                UIBarButtonItem.Appearance.SetTitleTextAttributes(buttonTextColor, UIControlState.Normal);
                UIBarButtonItem.Appearance.SetTitleTextAttributes(selectedButtonTextColor, UIControlState.Highlighted);
                UIBarButtonItem.Appearance.SetTitleTextAttributes(selectedButtonTextColor, UIControlState.Selected);
            }
Esempio n. 19
0
        MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlayWrapper)
        {
            MKOverlayRenderer renderer = null;

            var overlay = Runtime.GetNSObject(overlayWrapper.Handle) as IMKOverlay;

            Type overlayType = overlayWrapper.GetType();

            if (overlayType == typeof(MKCircle))
            {
                MKCircleRenderer circleRenderer = new MKCircleRenderer(overlay as MKCircle)
                {
                    FillColor = currentFillColor.ColorWithAlpha(0.1f),
                };

                if (currentLineWidth != 0)
                {
                    circleRenderer.StrokeColor = currentStrokeColor;
                    circleRenderer.LineWidth   = currentLineWidth;
                }

                renderer = circleRenderer;
            }

            else if (overlayType == typeof(MKPolyline))
            {
                renderer = new MKPolylineRenderer(overlay as MKPolyline)
                {
                    FillColor   = currentFillColor,
                    StrokeColor = currentStrokeColor,
                    LineWidth   = 3,
                    Alpha       = 0.4f
                };
            }
            return(renderer);
        }
Esempio n. 20
0
        ZMJCell ISpreadsheetViewDataSource.CellForItemAt(SpreadsheetView spreadsheetView, NSIndexPath indexPath)
        {
            nint column = indexPath.GetColumn();

            if (column >= 1 &&
                indexPath.Row <= _dates.Length + 1 &&
                indexPath.Row == 0)
            {
                DateCell cell = (DateCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(DateCell), indexPath);
                cell.Label.Text = _dates[column - 1];
                return(cell);
            }

            if (column >= 1 &&
                column <= _days.Length + 1 &&
                indexPath.Row == 1)
            {
                DayTitleCell cell = (DayTitleCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(DayTitleCell), indexPath);
                cell.Label.Text      = _days[column - 1];
                cell.Label.TextColor = _dayColors[column - 1];
                return(cell);
            }

            if (column == 0 &&
                indexPath.Row == 1)
            {
                TimeTitleCell cell = (TimeTitleCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(TimeTitleCell), indexPath);
                cell.Label.Text = "TIME";
                return(cell);
            }

            if (column == 0 &&
                indexPath.Row >= 2 &&
                indexPath.Row <= _hours.Length + 2)
            {
                TimeCell cell = (TimeCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(TimeCell), indexPath);

                cell.Label.Text      = _hours[indexPath.Row - 2];
                cell.BackgroundColor = indexPath.Row % 2 == 0
                    ? _evenRowColor
                    : _oddRowColor;
                return(cell);
            }

            if (column >= 1 &&
                column <= _days.Length + 1 &&
                indexPath.Row >= 2 &&
                indexPath.Row <= _hours.Length + 2)
            {
                ScheduleCell cell = (ScheduleCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(ScheduleCell), indexPath);

                String text = _data[column - 1][indexPath.Row - 2];
                if (!String.IsNullOrWhiteSpace(text))
                {
                    cell.Label.Text = text;
                    UIColor color = _dayColors[column - 1];
                    cell.Label.TextColor = color;
                    cell.Color           = color.ColorWithAlpha(0.2f);
                    cell.Borders.Top     = new BorderStyle(BorderStyleType.Solid, 2f, color);
                    cell.Borders.Bottom  = new BorderStyle(BorderStyleType.Solid, 2f, color);
                }
                else
                {
                    cell.Label.Text = null;
                    cell.Color      = indexPath.Row % 2 == 0
                        ? _evenRowColor
                        : _oddRowColor;
                    cell.Borders.Top    = BorderStyle.BorderStyleNone;
                    cell.Borders.Bottom = BorderStyle.BorderStyleNone;
                }
                return(cell);
            }

            return(null);
        }
Esempio n. 21
0
 public void setColor(UIColor c)
 {
     BackgroundColor     = c.ColorWithAlpha(0.7f);
     TempBackgroundColor = c.ColorWithAlpha(0.7f);
 }
		CAShapeLayer barcodeOverlayLayer (CGPath path, UIColor color)
		{
			return new CAShapeLayer () {
				Path = path,
				LineJoin = CAShapeLayer.JoinRound,
				LineWidth = 2.0f,
				StrokeColor = color.CGColor,
				FillColor = color.ColorWithAlpha (0.2f).CGColor
			};
		}
Esempio n. 23
0
        void Update()
        {
            foreach (var layer in dotLayers)
            {
                var offset = dotLayers.IndexOf(layer);
                layer.BackgroundColor = offset == _currentPage ? _currentPageTintColor.CGColor : _inactiveTintColor.ColorWithAlpha(_inactiveTransparency).CGColor;
            }

            if (Bounds.Size != _size)
            {
                UpdateDotLayersLayout();
                _size = Bounds.Size;
            }

            if (_numberOfPages > limit)
            {
                ChangeFullScaleIndexesIfNeeded();
                SetupDotLayersPosition();
                switch (_fadeType)
                {
                case FadeType.scale:
                    SetupDotLayersScale();
                    break;

                case FadeType.opacity:
                    SetupDotLayersOpacity();
                    break;
                }
            }
        }
        public override void Draw(CGRect rect)
        {
            if (_numberOfPages > 1 || !HidesForSinglePage)
            {
                using (var context = UIGraphics.GetCurrentContext()) {
                    CGSize size = SizeForNumbaerOfPager();
                    context.SetAllowsAntialiasing(true);
                    if (Vertical)
                    {
                        context.TranslateCTM(Frame.Size.Width / 2, (Frame.Size.Height - size.Height) / 2);
                    }
                    else
                    {
                        context.TranslateCTM((Frame.Size.Width - size.Width) / 2, Frame.Size.Height / 2);
                    }
                    for (int i = 0; i < _numberOfPages; i++)
                    {
                        UIImage     dotImage         = null;
                        UIColor     dotColor         = null;
                        TabDotShape dotShape         = TabDotShape.Circle;
                        UIColor     dotShadowColor   = null;
                        CGSize      dotShaddowOffset = CGSize.Empty;
                        nfloat      dotShalodwBlur   = 0;
                        nfloat      dotSize          = 0;

                        if (i == _currentPage)
                        {
//							_selectedDotColor.SetFill ();
                            dotImage         = _selectedDotImage;
                            dotShape         = _selectedDotShape;
                            dotColor         = _selectedDotColor;
                            dotShalodwBlur   = _selectedDotShadowBlur;
                            dotShadowColor   = _selectedDotShadowColor;
                            dotShaddowOffset = _selectedDotShadowOffset;
                            dotSize          = _selectedDotSize;
                        }
                        else
                        {
//							_dotColor.SetFill ();
                            dotImage         = _dotImage;
                            dotShape         = _dotShape;
                            dotColor         = _dotColor.ColorWithAlpha(0.25f);
                            dotShalodwBlur   = _dotShadowBlur;
                            dotShadowColor   = _dotShadowColor;
                            dotShaddowOffset = _dotShadowOffset;
                            dotSize          = _dotSize;
                        }
                        context.SaveState();
                        nfloat offset = (_dotSize + _dotSpacing) * i + _dotSize / 2;
                        context.TranslateCTM(Vertical ? 0 : offset, Vertical ? offset : 0);
                        if (dotShadowColor != null && dotShadowColor != UIColor.Clear)
                        {
                            context.SetShadow(dotShaddowOffset, dotShalodwBlur, dotShadowColor.CGColor);
                        }
                        if (dotImage != null)
                        {
                            dotImage.Draw(new CGRect(-dotImage.Size.Width / 2, -dotImage.Size.Height / 2, dotImage.Size.Width, dotImage.Size.Height));
                        }
                        else
                        {
                            dotColor.SetFill();
                            if (dotShape == TabDotShape.Circle)
                            {
                                context.FillEllipseInRect(new CGRect(-dotSize / 2, -dotSize / 2, dotSize, dotSize));
                            }
                            else if (dotShape == TabDotShape.Square)
                            {
                                context.FillRect(new CGRect(-dotSize / 2, -dotSize / 2, dotSize, dotSize));
                            }
                            else if (true)
                            {
                                context.BeginPath();
                                context.MoveTo(0, -dotSize / 2);
                                context.MoveTo(dotSize / 2, dotSize / 2);
                                context.MoveTo(-dotSize / 2, dotSize / 2);
                                context.MoveTo(0, -dotSize / 2);
                                context.FillPath();
                            }
                        }
                        context.RestoreState();
                    }
                }
            }
        }
Esempio n. 25
0
        void GraphicButtonClick(object sender, EventArgs e)
        {
            UIButton buttonSender = (UIButton)sender;

            if (_oSx == buttonSender.Frame.X && _oSy == buttonSender.Frame.Y)
            {
                if (view != null)
                {
                    DeleteTouchView();
                }
                else
                {
                    view            = new UIView(new CGRect(buttonSender.Frame.X - 10, buttonSender.Frame.Y - 22, 40, 25));
                    _labelText      = new UILabel(new CGRect(5, 0, 30, 20));
                    _labelText.Font = UIFont.FromName("Helvetica", 12f);
                    _labelText.Text = ((_mainFrameHeight - buttonSender.Frame.Y - 10) / _oSyStep).ToString();
                    _labelText.AdjustsFontSizeToFitWidth = false;
                    _labelText.TextColor     = UIColor.Gray;
                    _labelText.TextAlignment = UITextAlignment.Center;

                    UIImageView imageView = new UIImageView(new UIImage("buttongraph.png"));
                    imageView.Frame = new CGRect(0, 0, 40, 25);
                    ButtonViewGraph butNew = new ButtonViewGraph(_color, _rad);
                    butNew.Frame = new CGRect(16, 25, 20, 20);
                    view.AddSubview(butNew);
                    ButtonViewGraph butNewOval = new ButtonViewGraph(_color.ColorWithAlpha(0.5f), _rad + 6);
                    butNewOval.Frame = new CGRect(butNewOval.Frame.X - 3, butNewOval.Frame.Y - 3, 20, 20);
                    view.AddSubview(butNewOval);
                    view.AddSubview(imageView);
                    view.AddSubview(_labelText);
                    view.BackgroundColor = UIColor.Clear;
                    AddSubview(view);
                }
            }
            else
            {
                DeleteTouchView();
                view                 = new UIView(new CGRect(buttonSender.Frame.X - 10f, buttonSender.Frame.Y - 22, 40, 25));
                _labelText           = new UILabel(new CGRect(5, 0, 30, 20));
                _labelText.Font      = UIFont.FromName("HelveticaNeue-Bold", 12f);
                _labelText.TextColor = UIColor.FromRGB(152, 163, 163);
                _labelText.Text      = ((_mainFrameHeight - buttonSender.Frame.Y - 10) / _oSyStep).ToString();
                _labelText.AdjustsFontSizeToFitWidth = false;
                _labelText.TextColor     = UIColor.Gray;
                _labelText.TextAlignment = UITextAlignment.Center;


                UIImageView imageView = new UIImageView(new UIImage("buttongraph.png"));
                imageView.Frame = new CGRect(0, 0, 40, 25);
                view.AddSubview(imageView);
                ButtonViewGraph butNew = new ButtonViewGraph(_color, _rad);
                butNew.Frame = new CGRect(16, 28, 20, 20);
                view.AddSubview(butNew);
                ButtonViewGraph butNewOval = new ButtonViewGraph(_color.ColorWithAlpha(0.5f), _rad + 7);
                butNewOval.Frame = new CGRect(butNew.Frame.X - 3.5f, butNew.Frame.Y - 3.5f, 20, 20);
                view.AddSubview(butNewOval);
                view.AddSubview(_labelText);
                view.BackgroundColor = UIColor.Clear;
                parentView.Add(view);
            }
        }
Esempio n. 26
0
 private void AddTouchBackgroundColor(object sender, EventArgs e)
 {
     (sender as UIView).BackgroundColor = (Element.IsSelected) ? _activeBackgroundColor.ColorWithAlpha(.5f) : _backgroundColor.ColorWithAlpha(.5f);
 }
        protected void InitializeAndStartBarcodeScanning()
        {
            // Create data capture context using your license key.
            this.dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY);

            // Use the default camera and set it as the frame source of the context.
            // The camera is off by default and must be turned on to start streaming frames to the data
            // capture context for recognition.
            // See resumeFrameSource and pauseFrameSource below.
            this.camera = Camera.GetDefaultCamera();
            if (this.camera != null)
            {
                // Use the settings recommended by barcode capture.
                this.dataCaptureContext.SetFrameSourceAsync(this.camera);
            }

            // Use the recommended camera settings for the BarcodeTracking mode as default settings.
            // The preferred resolution is automatically chosen, which currently defaults to HD on all devices.
            CameraSettings cameraSettings = BarcodeTracking.RecommendedCameraSettings;

            // Setting the preferred resolution to full HD helps to get a better decode range.
            cameraSettings.PreferredResolution = VideoResolution.FullHd;
            camera?.ApplySettingsAsync(cameraSettings);
            BarcodeTrackingSettings barcodeTrackingSettings = BarcodeTrackingSettings.Create();

            // The settings instance initially has all types of barcodes (symbologies) disabled.
            // For the purpose of this sample we enable a very generous set of symbologies.
            // In your own app ensure that you only enable the symbologies that your app requires as
            // every additional enabled symbology has an impact on processing times.
            HashSet <Symbology> symbologies = new HashSet <Symbology>()
            {
                Symbology.Ean13Upca,
                Symbology.Ean8,
                Symbology.Upce,
                Symbology.Code39,
                Symbology.Code128
            };

            barcodeTrackingSettings.EnableSymbologies(symbologies);

            // Create new barcode tracking mode with the settings from above.
            this.barcodeTracking = BarcodeTracking.Create(this.dataCaptureContext, barcodeTrackingSettings);

            // Register self as a listener to get informed whenever a new barcode got recognized.
            this.barcodeTracking.AddListener(this);

            // To visualize the on-going barcode tracking process on screen, setup a data capture view
            // that renders the camera preview. The view must be connected to the data capture context.
            var dataCaptureView = DataCaptureView.Create(this.dataCaptureContext, this.View.Bounds);

            dataCaptureView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight |
                                               UIViewAutoresizing.FlexibleWidth;

            var overlay = BarcodeTrackingBasicOverlay.Create(this.barcodeTracking, dataCaptureView);

            overlay.Listener = this;

            this.defaultBrush = overlay.Brush;
            var rejectedColor = new UIColor(red: 255 / 255, green: 57 / 255, blue: 57 / 255, alpha: 1);

            this.rejectedBrush = new Brush(fillColor: rejectedColor.ColorWithAlpha((nfloat)0.3), strokeColor: rejectedColor, strokeWidth: 1);

            this.View.AddSubview(dataCaptureView);
            this.View.SendSubviewToBack(dataCaptureView);
        }
        private void InitializeUIElements()
        {
            _scrollView = new UIScrollView
            {
                AlwaysBounceVertical = true,
            };

            View.AddSubview(_scrollView);

            _imageView = new UIImageView()
            {
                Image           = UIImage.FromFile("Assets/test_image.png"),
                ContentMode     = UIViewContentMode.ScaleAspectFit,
                BackgroundColor = UIColor.Purple,
                ClipsToBounds   = true,
            };

            _scrollView.AddSubview(_imageView);

            _titleLabel = new UILabel
            {
                Text = "Testing the fake navigationbar translucency",
            };

            _nextButton = new UIButton(UIButtonType.System);
            _nextButton.SetTitle("Next", UIControlState.Normal);
            View.AddSubview(_nextButton);

            _valueLabel = new UILabel();
            View.AddSubview(_valueLabel);

            _changePlainViewAlphaSlider               = new UISlider();
            _changePlainViewAlphaSlider.MinValue      = 0.0f;
            _changePlainViewAlphaSlider.MaxValue      = 1.0f;
            _changePlainViewAlphaSlider.ValueChanged += (sender, e) =>
            {
                var color = ViewBackgroundColor.ColorWithAlpha(_changePlainViewAlphaSlider.Value);
                _valueLabel.Text = _changePlainViewAlphaSlider.Value.ToString();

                _plainView01.BackgroundColor = color;
                _plainView02.BackgroundColor = color;
            };

            View.AddSubview(_changePlainViewAlphaSlider);

            _changeBlurViewAlphaSlider               = new UISlider();
            _changeBlurViewAlphaSlider.MinValue      = 0.0f;
            _changeBlurViewAlphaSlider.MaxValue      = 1.0f;
            _changeBlurViewAlphaSlider.ValueChanged += (sender, e) =>
            {
                var color = ViewBackgroundColor.ColorWithAlpha(_changeBlurViewAlphaSlider.Value);
                _valueLabel.Text = _changeBlurViewAlphaSlider.Value.ToString();

                _blurView01.BackgroundColor = color;
                _blurView02.BackgroundColor = color;
            };

            View.AddSubview(_changeBlurViewAlphaSlider);

            _scrollView.AddSubview(_titleLabel);
        }
Esempio n. 29
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var scopes = string.Join(", ", OctokitClientFactory.Scopes);

            DescriptionLabel.Text      = string.Format("The provided Personal Access Token must allow access to the following scopes: {0}", scopes);
            DescriptionLabel.TextColor = ComponentTextColor;

            AuthenticationSelector.TintColor = ComponentTextColor.ColorWithAlpha(0.9f);

            View.BackgroundColor = EnterpriseBackgroundColor;
            Logo.Image           = Images.Logos.EnterpriseMascot;

            LoginButton.SetBackgroundImage(Images.Buttons.BlackButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);
            LoginButton.Enabled = true;

            //Set some generic shadowing
            LoginButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            LoginButton.Layer.ShadowOffset  = new CGSize(0, 1);
            LoginButton.Layer.ShadowOpacity = 0.2f;

            var attributes = new UIStringAttributes {
                ForegroundColor = UIColor.LightGray,
            };

            Domain.AttributedPlaceholder         = new NSAttributedString("Domain", attributes);
            User.AttributedPlaceholder           = new NSAttributedString("Username", attributes);
            Password.AttributedPlaceholder       = new NSAttributedString("Password", attributes);
            TokenTextField.AttributedPlaceholder = new NSAttributedString("Token", attributes);

            foreach (var i in new [] { Domain, User, Password, TokenTextField })
            {
                i.Layer.BorderColor  = UIColor.Black.CGColor;
                i.Layer.BorderWidth  = 1;
                i.Layer.CornerRadius = 4;
            }

            SelectAuthenticationScheme(0);

            Domain.ShouldReturn = delegate {
                User.BecomeFirstResponder();
                return(true);
            };

            User.ShouldReturn = delegate {
                Password.BecomeFirstResponder();
                return(true);
            };

            Password.ShouldReturn = delegate {
                Password.ResignFirstResponder();
                LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                return(true);
            };

            OnActivation(d =>
            {
                d(User.GetChangedObservable()
                  .Subscribe(x => ViewModel.Username = x));

                d(Password.GetChangedObservable()
                  .Subscribe(x => ViewModel.Password = x));

                d(Domain.GetChangedObservable()
                  .Subscribe(x => ViewModel.Domain = x));

                d(TokenTextField.GetChangedObservable()
                  .Subscribe(x => ViewModel.Token = x));

                d(LoginButton.GetClickedObservable()
                  .InvokeReactiveCommand(ViewModel.LoginCommand));

                d(AuthenticationSelector.GetChangedObservable()
                  .Do(x => ViewModel.TokenAuthentication = x == 1)
                  .Subscribe(SelectAuthenticationScheme));

                d(this.WhenAnyObservable(x => x.ViewModel.LoginCommand.CanExecute)
                  .Subscribe(x => LoginButton.Enabled = x));

                d(this.WhenAnyValue(x => x.ViewModel.TokenAuthentication)
                  .Subscribe(x => AuthenticationSelector.SelectedSegment = x ? 1 : 0));
            });
        }
Esempio n. 30
0
 public static UIColor BlurColor(UIColor color)
 {
     return(color.ColorWithAlpha((nfloat)0.7));
 }