Advertisement
isotonicq

Untitled

Jul 4th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. using View.Annotations;
  19.  
  20. namespace View.Menu
  21. {
  22.     /// <summary>
  23.     /// Interaction logic for Menu.xaml
  24.     /// </summary>
  25.     public partial class Menu : INotifyPropertyChanged
  26.     {
  27.         private double _height;
  28.         private double _width;    
  29.         public string Version { get; set; }
  30.  
  31.         public double HeightValue { get => _height;
  32.             set { _height = value; OnPropertyChanged(); } }
  33.  
  34.         public double WidthValue { get => _width;
  35.             set { _width = value; OnPropertyChanged(); } }
  36.  
  37.         public Menu()
  38.         {
  39.             InitializeComponent();
  40.             Version = $"Version: {FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion}";
  41.             DataContext = this;
  42.         }
  43.  
  44.         public event PropertyChangedEventHandler PropertyChanged;
  45.  
  46.         [NotifyPropertyChangedInvocator]
  47.         protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
  48.         {
  49.             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  50.         }
  51.  
  52.         private void FrameworkElement_OnSizeChanged(object sender, SizeChangedEventArgs e)
  53.         {
  54.             var temp = (Grid)sender;
  55.  
  56.             //Properties
  57.             HeightValue = temp.ActualHeight;
  58.             WidthValue = temp.ActualWidth;
  59.  
  60.             //Top logo
  61.             Logo.Width = WidthValue / 2;
  62.             Logo.Height = HeightValue / 3;
  63.  
  64.             //Button Panel
  65.             MenuPanel.Width = WidthValue / 2;
  66.             MenuPanel.Height = HeightValue;
  67.  
  68.             //Right Label
  69.             RightLabel.FontSize = WidthValue / 22;
  70.  
  71.             //News Panel
  72.             NewsPanel.Height = HeightValue;
  73.         }
  74.  
  75.         private void ExitButton_OnClick(object sender, RoutedEventArgs e)
  76.         {
  77.             Process.GetCurrentProcess().Kill();
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement