Advertisement
EnZDarkSide

Untitled

Feb 14th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Input;
  4.  
  5. namespace CPU_Control
  6. {
  7.     /// <summary>
  8.     /// Логика взаимодействия для MainWindow.xaml
  9.     /// </summary>
  10.     public partial class PcControl : Window
  11.     {
  12.         public bool Pinned { get; set; } = false;
  13.         public PcControl()
  14.         {
  15.             InitializeComponent();
  16.             WindowStartupLocation = WindowStartupLocation.Manual;
  17.             var margin = 10;
  18.             Top = margin;
  19.             Left = SystemParameters.PrimaryScreenWidth - Width - margin;
  20.         }
  21.  
  22.         private void Window_MouseDown(object sender, MouseButtonEventArgs e)
  23.         {
  24.             if (e.ChangedButton == MouseButton.Left && !Pinned)
  25.                 this.DragMove();
  26.         }
  27.  
  28.         private void Window_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
  29.         {
  30.             ContextMenu cm = this.FindResource("cmButton") as ContextMenu;
  31.             cm.PlacementTarget = sender as Button;
  32.             cm.IsOpen = true;
  33.         }
  34.  
  35.         private void CmCloseApp(object sender, RoutedEventArgs e)
  36.         {
  37.             Close();
  38.         }
  39.        
  40.         private void TogglePin(object sender, RoutedEventArgs e)
  41.         {
  42.             Pinned = !Pinned;
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement