Inheritance: ScriptWithController
Exemplo n.º 1
0
        private void load(LargeTextureStore textures)
        {
            if (textures == null)
            {
                throw new ArgumentNullException(nameof(textures));
            }

            Texture texture = null;

            if (user != null && user.Id > 1)
            {
                texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
            }
            texture ??= textures.Get(@"Online/avatar-guest");

            ClickableArea clickableArea;

            Add(clickableArea = new ClickableArea
            {
                RelativeSizeAxes = Axes.Both,
                Child            = new Sprite
                {
                    RelativeSizeAxes = Axes.Both,
                    Texture          = texture,
                    FillMode         = FillMode.Fit,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre
                },
                Action = openProfile
            });

            clickableArea.Enabled.BindTo(OpenOnClick);
        }
Exemplo n.º 2
0
        private void load(LargeTextureStore textures)
        {
            if (textures == null)
            {
                throw new ArgumentNullException(nameof(textures));
            }

            Texture texture = null;

            if (user != null && user.Id > 1)
            {
                if (!File.Exists($"User Avatar\\{user.Id}.png"))
                {
                    try
                    {
                        if (!Directory.Exists("User Avatar"))
                        {
                            Directory.CreateDirectory("User Avatar");
                        }

                        var fileWebRequest = new Framework.IO.Network.WebRequest($@"https://a.ppy.sh/{user.Id}")
                        {
                            Method = System.Net.Http.HttpMethod.Get
                        };
                        fileWebRequest.Perform();

                        File.WriteAllBytes($"User Avatar\\{user.Id}.png", fileWebRequest.GetResponseData());
                    }
                    catch (Exception) { }
                }
                if (File.Exists($"User Avatar\\{user.Id}.png"))
                {
                    texture = Texture.FromStream(File.OpenRead($"User Avatar\\{user.Id}.png"));
                }
            }
            if (texture == null)
            {
                texture = textures.Get(@"Online/avatar-guest");
            }

            ClickableArea clickableArea;

            Add(clickableArea = new ClickableArea
            {
                RelativeSizeAxes = Axes.Both,
                Child            = new Sprite
                {
                    RelativeSizeAxes = Axes.Both,
                    Texture          = texture,
                    FillMode         = FillMode.Fit,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre
                },
                Action = openProfile
            });

            clickableArea.Enabled.BindTo(OpenOnClick);
        }
Exemplo n.º 3
0
        private void load(LargeTextureStore textures)
        {
            ClickableArea clickableArea;

            Add(clickableArea = new ClickableArea
            {
                RelativeSizeAxes = Axes.Both,
                Action           = openProfile
            });

            LoadComponentAsync(new DrawableAvatar(user), clickableArea.Add);

            clickableArea.Enabled.BindTo(OpenOnClick);
        }
Exemplo n.º 4
0
 void Awake()
 {
     Instance = this;
 }
Exemplo n.º 5
0
 public void Open()
 {
     ClickableArea.Click();
 }