-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageChanger.cs
34 lines (31 loc) · 1.04 KB
/
ImageChanger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Android.Widget;
using System;
namespace Radiation
{
static class ImageChanger
{
private static int minImageNumber = 1;
private static int maxImageNumber = 14;
/// <summary>
/// Generates random number for image name.
/// </summary>
/// <returns>Image name.</returns>
private static string GetRandomImageName()
{
Random rnd = new Random();
return "img" + rnd.Next(minImageNumber, maxImageNumber);
}
/// <summary>
/// Sets random image to ImageView control.
/// </summary>
/// <param name="view">ImageView to set image to.</param>
/// <param name="mn">Current Activity</param>
public static void SetRandomImage(ImageView view, MainActivity mn)
{
string imgName = GetRandomImageName();
Console.WriteLine(imgName);
int id = mn.Application.Resources.GetIdentifier(imgName, "drawable", mn.PackageName);
view.SetImageResource(id);
}
}
}