Advertisement
Guest User

esf

a guest
Oct 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using System.Windows.Threading;
  16.  
  17. namespace WpfAppOefentoets
  18. {
  19. /// <summary>
  20. /// Interaction logic for MainWindow.xaml
  21. /// </summary>
  22. public partial class MainWindow : Window
  23. {
  24. DispatcherTimer tmMove = new DispatcherTimer();
  25. bool bMoveToRight = true;
  26.  
  27. public MainWindow()
  28. {
  29.  
  30. InitializeComponent();
  31. tbSwap1.IsReadOnly = true;
  32. tbSwap2.IsReadOnly = true;
  33.  
  34.  
  35.  
  36. tmMove.Interval = TimeSpan.FromMilliseconds(0.5);
  37. tmMove.Tick += TmMove_Tick;
  38.  
  39. }
  40.  
  41. private void TmMove_Tick(object sender, EventArgs e)
  42. {
  43.  
  44. double xpos = btn3.Margin.Left;
  45. double ypos = btn3.Margin.Top;
  46. if (bMoveToRight == true)
  47. {
  48. xpos++;
  49. }
  50. else
  51. {
  52. xpos--;
  53. }
  54. if ( btn3.Margin.Left + btn3.ActualWidth > cC0R4.ActualWidth)
  55. {
  56. bMoveToRight = false;
  57. }
  58. if (btn3.Margin.Left < 0)
  59. {
  60. bMoveToRight = true;
  61. }
  62. btn3.Margin = new Thickness(xpos, ypos, 0, 0);
  63.  
  64.  
  65.  
  66. }
  67.  
  68. private void btnColorswap_Click(object sender, RoutedEventArgs e)
  69. {
  70. if (btnColorswap.Background == Brushes.Red)
  71. {
  72.  
  73. btnColorswap.Background = Brushes.Orange;
  74. }
  75. else if (btnColorswap.Background == Brushes.Orange)
  76. {
  77.  
  78. btnColorswap.Background = Brushes.Green;
  79. }
  80. else
  81. {
  82. btnColorswap.Background = Brushes.Red;
  83. }
  84. }
  85.  
  86. private void btnSwap_Click(object sender, RoutedEventArgs e)
  87. {
  88.  
  89.  
  90. string sSwap = tbSwap1.Text;
  91. tbSwap1.Text = tbSwap2.Text;
  92. tbSwap2.Text = sSwap;
  93. }
  94.  
  95. private void btnVerander_Click(object sender, RoutedEventArgs e)
  96. {
  97. btnVerander.Content = "zoek";
  98. btnVerander.IsEnabled = false;
  99. Random rnd = new Random();
  100.  
  101. int iMaxWidth = Convert.ToInt32(cC0R1.ActualWidth);
  102. int iRandomWidthButton = rnd.Next(0, iMaxWidth);
  103.  
  104. int iMaxHeight = Convert.ToInt32(cC0R1.ActualHeight);
  105. int iRandomHeightButton = rnd.Next(0, iMaxHeight);
  106. btnRandom.Width = iRandomWidthButton;
  107. btnRandom.Height = iRandomHeightButton;
  108.  
  109. double dblX = cC0R1.ActualWidth - btnVerander.Width;
  110. int iX = Convert.ToInt32(dblX);
  111. int marginX = rnd.Next(0, iX);
  112.  
  113. double dblY = cC0R1.ActualHeight - btnVerander.Height;
  114. int iY = Convert.ToInt32(dblY);
  115. int marginY = rnd.Next(0, iY);
  116.  
  117. btnRandom.Margin = new Thickness(marginX, marginY, 0, 0);
  118. btnRandom.Visibility = Visibility.Visible;
  119.  
  120.  
  121. }
  122.  
  123.  
  124.  
  125. private int a = 0;
  126. private void btn3_Click(object sender, RoutedEventArgs e)
  127. {
  128. a++;
  129.  
  130. btn3.Content = a.ToString();
  131. btn3.Content = ("U heeft " + a + " keer geklikt.");
  132. }
  133.  
  134. private void btnRandom_Click(object sender, RoutedEventArgs e)
  135. {
  136.  
  137. btnVerander.Content = "Start";
  138. btnVerander.IsEnabled = true;
  139. btnRandom.Visibility = Visibility.Hidden;
  140.  
  141. }
  142.  
  143. private void btn3_MouseEnter(object sender, MouseEventArgs e)
  144. {
  145. tmMove.Start();
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement