Generate a random image from a group of images in C# Windows Store App Development -


I am trying to generate a random image from a group of images with my pictures. I have not tried any code yet, because I'm not getting any suitable

More specifically, the name of my images is "orb1, orb2, orb3 ... orb18". Orb2-18 are set to invisible I want to show one of them randomly on my specified position when orb1 is pressed. I have solved the press function of an image so that there is no problem.

Here's my code:

  Public Start 1 () {this.InitializeComponent (); Orb2 Visibility = visibility Collapsed; Orb3 Visibility = visibility Collapsed; Orb4 Visibility = visibility Collapsed; Orb5 Visibility = visibility Collapsed; Orb6 Visibility = visibility Collapsed; Orb7 Visibility = visibility Collapsed; Orb8 Visibility = visibility Collapsed; Orb9 Visibility = visibility Collapsed; Orb10 Visibility = visibility Collapsed; Orb11 Visibility = visibility Collapsed; Orb12 Visibility = visibility Collapsed; Orb13 Visibility = visibility Collapsed; Orb14 Visibility = visibility Collapsed; Orb15 Visibility = visibility Collapsed; Orb16. Visibility = visibility Collapsed; Orb17 Visibility = visibility Collapsed; Orb18 Visibility = visibility Collapsed; } Private void O1 (object sender, PointerRoutedEventArgs e) {} private void O12 (object sender, PointerRoutedEventArgs e) {} private void O3 (object sender, PointerRoutedEventArgs e) {} private void O11 (object sender, PointerRoutedEventArgs e) {} private void O9 (object sender, PointerRoutedEventArgs e) {} private void O16 (object sender, PointerRoutedEventArgs e) {} private void o10 (object sender, PointerRoutedEventArgs e) {} private void o18 (object sender, PointerRoutedEventArgs e) {} private void O17 (Object Sender, PointerRoutedEventArgs E) {} Private Zero O15 (Object Sender, PointerRoutedEventA rgs e) {} private void o14 (object sender, PointerRoutedEventArgs e) {} private void o13 (object sender, PointerRoutedEventArgs e) {} private void O8 (object sender, Pointrrotedaventarj e) {} primary vate zero O7 (object sender, PointerRoutedEventArgs e) {} private void O6 (object sender, PointerRoutedEventArgs e) {} private void O5 (object sender, PointerRoutedEventArgs e) {} private void O4 (object sender, PointerRoutedEventArgs e) {} private void O2 (object sender, Pointrruted Iventarj E) {} Private Voices Scoreort Edded (object sender, text Chenjdeiventargs e) {}}  

There are no errors in the code to me, it's all right

In the original, I When wanting some help in making a random ORB visible from those 18 orbs is pressed orb1.

Thanks :)

You must define a random number provider and a To create a method, a random ORB appears:

  private random Rnd = new random (); Private zero show randomOrb () {switch (rnd.Next (2,19)) selects random integer for 2 to 18 {Case 2: orb2. Visibility = visibility View; break; Case 3: orb3. Visibility = visibility View; break; Case 4: orb4. Visibility = visibility Visible; break; // e.t.c. Case 18: orb18. Visibility = visibility Visible; break; }} Private Zero O1 (Object Sender, PointerUp Event Events E) {showRandomOrb (); }  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -