コード例 #1
0
ファイル: RetroStyle.cs プロジェクト: Woprok/grcis
    public static void generate_colors(int color_count)
    {
        var color_set = new HashSet <RGB>();

        // Clearly this is dump way to generate colors, but it will work, through really big count is most likely going to take really long.
        while (color_set.Count < color_count)
        {
            color_set.Add(new RGB(ColorRandom.Next(0, 256), ColorRandom.Next(0, 256), ColorRandom.Next(0, 256)));
        }
        ColorData.ColorArray = color_set;
    }
コード例 #2
0
        public void Tint()
        {
            switch (Device.RuntimePlatform)
            {
            case Device.Android:
                ChronologyIcon.TintColor = Color.FromHex(Preferences.Get("Colore", "#000000"));
                break;

            default:
                ColorRandom r   = new ColorRandom();
                Color       app = Color.FromHex(Preferences.Get("Colore", "#000000"));
                //ChronologyIcon.TintColor = UIColor.FromRGB;
                break;
            }
            ChronologyIcon.TintColor = Color.FromHex(Preferences.Get("Colore", "#000000"));
        }
コード例 #3
0
        public void Bottone_ClickedAsync(object sender, EventArgs e)  // modifica i vari colori
        {
            ColorRandom c     = new ColorRandom();
            Color       color = c.GetRandomColorPreferences();

            Cerchio.BackgroundColor   = color;
            CerchioRc.FillColor       = color;
            CerchioRc.BackgroundColor = color;
            MessagingCenter.Send(new ChronologyViewCell()
            {
            }, "Refresh");

            MessagingCenter.Send(new FondoFondoMerendeViewCell()
            {
            }, "Refresh");


            MessagingCenter.Send(new EditUserInfoViewCell()
            {
            }, "Refresh");

            MessagingCenter.Send(new EditSnackViewCell()
            {
            }, "Refresh");

            MessagingCenter.Send(new ChangeColorViewCell()
            {
            }, "Refresh");


            MessagingCenter.Send(new AddSnackViewCell()
            {
            }, "Refresh");

            MessagingCenter.Send(new BuySnackViewCell()
            {
            }, "Refresh");

            MessagingCenter.Send(new LogoutViewCell()
            {
            }, "Refresh");
        }
コード例 #4
0
        public async Task GetSnacksMethod(bool Loaded, bool favourites)     //ottiene la lista degli snack e la applica alla ListView
        {
            result = await snackServiceManager.GetSnacksAsync();

            SnackFavarray        = new object[result.data.snacks.Count];
            ListView.ItemsSource = result.data.snacks;
            int FavIndex = 0;
            int index    = 0;

            if (!Loaded) //!WORKAROUND!   in questo modo si evita il crash ma la griglia non si aggiorna, urge investigazione sul vero problema
            {
                for (int i = 0; i <= result.data.snacks.Count; i++)
                {
                    bool addfav     = false; //variabile di appoggio
                    bool visibilità = true;
                    if (favourites && !Check_Favourites(result.data.snacks[i].id))
                    {
                        addfav = true;
                    }
                    else if (favourites && Check_Favourites(result.data.snacks[i].id))
                    {
                        visibilità = false;
                    }

                    ColorRandom c = new ColorRandom();
                    var         mainDisplayInfo = DeviceDisplay.MainDisplayInfo;



                    double latoCubo = App.Current.MainPage.Width / 2;

                    double box = 170;

                    var star19 = new Image
                    {
                        Aspect = Aspect.AspectFill,
                        Source = ImageSource.FromResource("fondomerende.image.Star19.png"),
                        Margin = new Thickness(5),
                    };

                    var imageSnack = new Image
                    {
                        Aspect = Aspect.AspectFill,
                        Margin = new Thickness(35),
                        Source = ImageSource.FromUri(new Uri("http://fondomerende.madeinapp.net/api/getphoto.php?name=" + result.data.snacks[i].friendly_name)),
                    };


                    var stackGrid = new StackLayout
                    {
                        WidthRequest  = box,
                        HeightRequest = box,

                        InputTransparent = true,
                    };

                    var griglia = new Grid()
                    {
                    };

                    var BordiSmussatiAndroid = new RoundedCornerView
                    {
                        HeightRequest       = box,
                        WidthRequest        = box,
                        RoundedCornerRadius = box / 2,
                        BorderColor         = c.GetRandomColor(),
                        BorderWidth         = 3,
                        InputTransparent    = true,
                        Margin = new Thickness(10, 10, 10, 0)
                    };

                    var BordiSmussatiiOS = new RoundedCornerView
                    {
                        HeightRequest       = box,
                        WidthRequest        = box,
                        RoundedCornerRadius = box / 4,
                        BorderColor         = c.GetRandomColor(),
                        BorderWidth         = 1,
                        InputTransparent    = true,
                        Margin = new Thickness(10, 10, 10, 0)
                    };

                    var label = new Label
                    {
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment   = TextAlignment.End,
                        Margin           = new Thickness(0, 0, 0, 5),
                        Text             = result.data.snacks[i].friendly_name,
                        FontAttributes   = FontAttributes.Bold,
                        FontSize         = 16,
                        InputTransparent = true,
                    };

                    string e;
                    if (Check_Favourites(result.data.snacks[i].id))
                    {
                        e = "fondomerende.image.star_empty.png";
                    }
                    else
                    {
                        e = "fondomerende.image.star_fill.png";
                    }

                    var star = new ImageButton
                    {
                        HeightRequest     = 20,
                        WidthRequest      = 20,
                        Margin            = new Thickness(0, 15, 15, 0),
                        Scale             = 1,
                        Aspect            = Aspect.Fill,
                        Source            = ImageSource.FromResource(e),
                        HorizontalOptions = LayoutOptions.EndAndExpand,
                        VerticalOptions   = LayoutOptions.StartAndExpand,
                        BackgroundColor   = Color.Transparent
                    };

                    var starAnimation = new AnimationView
                    {
                        Animation         = "star.json",
                        Scale             = 1,
                        Loop              = false,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        AutoPlay          = false,
                        InputTransparent  = true,
                        IsVisible         = false,
                    };

                    var eatAnimation = new AnimationView
                    {
                        Animation         = "LoadingEating.json",
                        Scale             = 1.2,
                        Rotation          = 180,
                        Loop              = false,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        AutoPlay          = false,
                        InputTransparent  = true,
                        IsVisible         = false,
                    };


                    var app = new StackLayout
                    {
                        Orientation = StackOrientation.Vertical,
                        IsVisible   = visibilità,
                    };

                    var sfondo = new StackLayout
                    {
                        BackgroundColor = Color.FromHex("#ece0ce"),
                        Opacity         = 0.99
                    };
                    starAnimation.OnFinish -= StopAnimation;
                    starAnimation.OnFinish += StopAnimation;

                    griglia.Children.Add(sfondo);
                    griglia.Children.Add(star19);
                    griglia.Children.Add(imageSnack);
                    if (!TabletManager.Instance.tablet)
                    {
                        griglia.Children.Add(star);
                    }
                    griglia.Children.Add(starAnimation);


                    stackGrid.Children.Add(griglia);
                    app.Children.Add(stackGrid);
                    app.Children.Add(label);


                    TapGestureRecognizer tg1 = new TapGestureRecognizer();
                    tg1.NumberOfTapsRequired = 1;
                    tg1.Tapped += Tgr_Tapped;
                    app.GestureRecognizers.Add(tg1);

                    if (!TabletManager.Instance.tablet)
                    {
                        TapGestureRecognizer tg2 = new TapGestureRecognizer();
                        tg2.NumberOfTapsRequired = 2;
                        tg2.Tapped += Tgr2_Tapped;
                        app.GestureRecognizers.Add(tg2);
                    }



                    if (addfav && favourites)
                    {
                        if (FavIndex % 2 == 0)
                        {
                            Column0Fav.Children.Add(app);
                        }
                        else
                        {
                            Column1Fav.Children.Add(app);
                        }


                        Snackarray[FavIndex] = app;
                        FavIndex++;
                    }
                    else
                    {
                        if (i % 2 == 0)
                        {
                            Column0.Children.Add(app);
                        }
                        else
                        {
                            Column1.Children.Add(app);
                        }

                        SnackFavarray[index] = app;
                        index++;
                    }
                }
            }
        }
コード例 #5
0
 private void Awake()
 {
     colorRandom = this;
 }