Beispiel #1
0
        public CLMenu(string title, float x, float y, float width, float height, Action <float[], bool> drawContent)
        {
            this.titleLabel = new CLFormsLabel()
            {
                Text      = title,
                TextScale = 1.337f
            };
            this.x           = x;
            this.y           = y;
            this.width       = width;
            this.height      = height;
            this.drawContent = drawContent;
            this.inTap       = new BoxView()
            {
                BackgroundColor = Color.Transparent
            };
            this.outTap = new BoxView()
            {
                BackgroundColor = Color.Transparent
            };
            bool actionDelayed = false;
            var  tapped        = new TapGestureRecognizer();

            tapped.Tapped += (sender, ev) => {
                if (actionDelayed)
                {
                    return;
                }
                actionDelayed = true;
                Task.Run(async() => {
                    await Task.Delay(500);
                    actionDelayed = false;
                });
                //sync pop with game render loop
                this.popping = true;
            };
            this.outTap.GestureRecognizers.Add(tapped);
        }
Beispiel #2
0
        public CLCheckBox(bool check, string text, float x, float y, float width, float height, Color textColour, TextAlignment align, float textScale = 1.337f)
        {
            this.x          = x;
            this.y          = y;
            this.width      = width;
            this.height     = height;
            this.align      = align;
            this.textColour = textColour;
            this.label      = new CLFormsLabel()
            {
                Text      = text,
                TextColor = this.textColour,
                HorizontalTextAlignment = this.align,
                TextScale = textScale
            };
            var tapped = new TapGestureRecognizer();

            tapped.Tapped += (sender, ev) => {
                if (this.IsEnabled)
                {
                    CLField.PlaySound("MenuNav.mp3");
                    this.Check = !this.Check;
                }
            };
            this.label.GestureRecognizers.Add(tapped);
            this.yn = new CLFormsLabel()
            {
                TextColor = this.textColour,
                HorizontalTextAlignment = (this.align == TextAlignment.End) ? TextAlignment.Start : TextAlignment.End,
                TextScale = textScale
            };
            this.yn.GestureRecognizers.Add(tapped);
            this.added     = false;
            this.Check     = check;
            this.IsEnabled = true;
        }
Beispiel #3
0
        public CLLabel(string text, float x, float y, float width, float height, Color textColour, TextAlignment align, float textScale = 1.0f, View hackyView = null)
        {
            this.x      = x;
            this.y      = y;
            this.width  = width;
            this.height = height;
            this.align  = align;
            if (hackyView == null || !(hackyView is CLFormsLabel))
            {
                this.added = false;
                this.label = new CLFormsLabel()
                {
                    Text      = text,
                    TextColor = textColour,
                    HorizontalTextAlignment = this.align,
                    TextScale = textScale
                };
            }
            else
            {
                this.added = true;
                this.label = (CLFormsLabel)hackyView;
                Device.BeginInvokeOnMainThread(() => {
                    this.label.Text      = text;
                    this.label.TextColor = textColour;
                    this.label.HorizontalTextAlignment = this.align;
                    this.label.TextScale = textScale;
                });
            }
            bool actionDelayed = false;
            var  tapped        = new TapGestureRecognizer();

            tapped.Tapped += (sender, ev) => {
                if (actionDelayed)
                {
                    return;
                }
                actionDelayed = true;
                Task.Run(async() => {
                    await Task.Delay(500);
                    actionDelayed = false;
                });
                if (this != null && this.Action != null)
                {
                    CLField.PlaySound("MenuNav.mp3");
                    this.Action();
                }
            };
            this.label.GestureRecognizers.Add(tapped);
            this.outTap = new BoxView()
            {
                BackgroundColor = Color.Transparent
            };
//			bool outActionDelayed = false;
            tapped         = new TapGestureRecognizer();
            tapped.Tapped += (sender, ev) => {
                if (actionDelayed)
                {
                    return;
                }
                actionDelayed = true;
                Task.Run(async() => {
                    await Task.Delay(500);
                    actionDelayed = false;
                });
                if (this != null && this.OutAction != null)
                {
                    CLField.PlaySound("MenuNav.mp3");
                    this.OutAction();
                }
            };
            this.outTap.GestureRecognizers.Add(tapped);
        }