Advertisement
OfficialHelm88

Untitled

Jun 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System.Windows;
  2. using System.Windows.Input;
  3. using System.Windows.Media;
  4.  
  5. namespace Klassenarbeit_19_06_2018
  6. {
  7.     public partial class MainWindow : Window
  8.     {
  9.         public MainWindow()
  10.         {
  11.             InitializeComponent();
  12.  
  13.             window.Background = Brushes.Yellow;
  14.         }
  15.  
  16.         private void Rect_MouseEnter(object sender, MouseEventArgs e)
  17.         {
  18.             if (e.LeftButton == MouseButtonState.Pressed)
  19.             {
  20.                 rect.Fill = Brushes.IndianRed;
  21.             }
  22.         }
  23.  
  24.         private void Rect_MouseLeave(object sender, MouseEventArgs e)
  25.         {
  26.             if (e.LeftButton == MouseButtonState.Pressed)
  27.             {
  28.                 rect.Fill = Brushes.ForestGreen;
  29.             }
  30.         }
  31.  
  32.         private void Rect_MouseWheel(object sender, MouseWheelEventArgs e)
  33.         {
  34.             if (rect.IsMouseOver)
  35.             {
  36.                 // falls das rechteck zu klein wird
  37.                 if (rect.Width + e.Delta < 100 && rect.Height + e.Delta < 100)
  38.                     return;
  39.  
  40.                 rect.Width += e.Delta;
  41.                 rect.Height += e.Delta;
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement