SHARE
TWEET

Untitled

EnZDarkSide Feb 14th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top