Пример #1
0
 public void Pop()
 {
     if (this.navigating)
     {
         return;
     }
     this.navigating = true;
     this.drawContent(null, false);
     CLField.PlaySound("MenuNav.mp3");
     this.drawContent = null;
     if (this.drawContentPrev == null)
     {
         this.Show = false;
         this.Dispose();
         this.navigating = false;
         return;
     }
     Device.BeginInvokeOnMainThread(() => {
         this.titleLabel.Text = this.titlePrev;
         this.titlePrev       = null;
     });
     this.drawContent     = this.drawContentPrev;
     this.drawContentPrev = null;
     this.navigating      = false;
 }
Пример #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;
        }
Пример #3
0
        private void Init(RelativeLayout mainLayout, View [] hackyViews = null)
        {
            float textureScale = this.Width * 0.00087f;

            this.SetScreenVirtualCoords(this.Width, this.Height);

            var textureIdsDouble = new int[embeddedTextures.Length][];
            int i = 0, size = 0;

            foreach (var texturesArray in embeddedTextures)
            {
                textureIdsDouble[i] = new int[texturesArray.Length];
                int j = 0;
                foreach (var texture in texturesArray)
                {
                    embeddedTextures[i][j].Name = string.Format("CLNG_{0}.png", texture.Name);
                    j++;
                    size++;
                }
                i++;
            }
            this.textureIds = new int[size];
            bool loadTexture =             /*!embeddedTextures[j][k].InitIgnore || */
                               Device.RuntimePlatform == Device.Android ||
                               Device.RuntimePlatform == Device.iOS ||
                               Device.Idiom == TargetIdiom.Desktop;

            //when the app is restarted (Android only for now)
            //then we cannot reload embedded resources
            //so we store them static and won't reload afterward
            if (ColorLinesNG.images == null)
            {
                ColorLinesNG.images = new SKImage[size];
            }
            else
            {
                loadTexture = false;
            }
            int [] specialBgTextureIds = new int[2];
            for (i = 0; i < size; i++)
            {
                int j = 0, sum = 0;
                foreach (var texturesArray in embeddedTextures)
                {
                    int k = 0;
                    foreach (var texture in texturesArray)
                    {
                        if (i == sum)
                        {
                            if (loadTexture)
                            {
                                ColorLinesNG.images[i] = LoadTexture(embeddedTextures[j][k], textureScale);
                            }
                            textureIdsDouble[j][k] = i;
                            if (embeddedTextures[j][k].Name.Equals("CLNG_Stars.png"))
                            {
                                specialBgTextureIds[0] = i;
                            }
                            else if (embeddedTextures[j][k].Name.Equals("CLNG_Nebula.png"))
                            {
                                specialBgTextureIds[1] = i;
                            }
                        }
                        else if (i < sum)
                        {
                            break;
                        }
                        k++;
                        sum++;
                    }
                    j++;
                }
            }
            this.field = new CLField(textureIdsDouble);
            this.field.InitVisuals(this.Left, this.Right, this.Bottom, this.Top, this.time.ElapsedMilliseconds, hackyViews);
            this.reQueue = new CLReQueue(mainLayout, ColorLinesNG.images, specialBgTextureIds);

            this.time.Start();

            this.Inited?.Invoke(this, new EventArgs());
        }
Пример #4
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);
        }