Guest User

Untitled

a guest
Apr 22nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Media;
  6. using System.IO;
  7. using Core;
  8. using System.Windows;
  9. using System.ComponentModel;
  10.  
  11. namespace UI
  12. {
  13.     class MainWindowViewModel : INotifyPropertyChanged
  14.     {
  15.         string _curDirectory = "";
  16.         SolidColorBrush _brushColor = new SolidColorBrush();
  17.         Core.MCProfile[] _profiles;
  18.         MCProfile _selectedProfile;
  19.  
  20.         public SolidColorBrush ColorName
  21.         {
  22.             get { return _brushColor; }
  23.         }
  24.  
  25.         public MCProfile[] Profiles
  26.         {
  27.             get { return _profiles; }
  28.             set
  29.             {
  30.                 _profiles = value;
  31.                 RaisePropertyChanged("Profiles");
  32.             }
  33.         }
  34.  
  35.         public MCProfile SelectedProfile
  36.         {
  37.             get { return _selectedProfile; }
  38.             set
  39.             {
  40.                 _selectedProfile = value;
  41.                 RaisePropertyChanged("SelectedProfiles");
  42.             }
  43.         }
  44.  
  45.         public MainWindowViewModel()
  46.         {
  47.             _brushColor.Color = Colors.LightCoral;
  48.             //_curDirectory = Directory.GetCurrentDirectory();
  49.             _curDirectory = "C:\\Games\\Minecraft";
  50.             LoadProfiles();
  51.         }
  52.  
  53.         public void LoadProfiles()
  54.         {
  55.             Profiles = FileMan.GetProfiles(Path.Combine(_curDirectory, "profiles"));
  56.             SelectedProfile = Profiles[0];
  57.         }
  58.  
  59.         public void LoadProfile()
  60.         {
  61.             ProcessMan.LaunchGame(SelectedProfile, _curDirectory);
  62.         }
  63.  
  64.         public void CopyProfile()
  65.         {
  66.             MessageBox.Show("Function not yet ready!", "Error", MessageBoxButton.OK);
  67.         }
  68.  
  69.         public void RenameProfile()
  70.         {
  71.             MessageBox.Show("Function not yet ready!", "Error", MessageBoxButton.OK);
  72.         }
  73.  
  74.         public void NewProfile()
  75.         {
  76.             Window newProfileWindow = new NewProfileWindow();
  77.             newProfileWindow.ShowDialog();
  78.             LoadProfiles();
  79.         }
  80.  
  81.         public void DeleteProfile()
  82.         {
  83.             MessageBoxResult results = MessageBox.Show("Are you sure you want to delete the profile \"" + SelectedProfile.Name + "\"?", "", MessageBoxButton.YesNo);
  84.             if (results == MessageBoxResult.Yes)
  85.             {
  86.                 FileMan.DeleteProfile(SelectedProfile);
  87.                 LoadProfiles();
  88.             }
  89.         }
  90.  
  91.         public event PropertyChangedEventHandler PropertyChanged;
  92.         public void RaisePropertyChanged(string propertyName)
  93.         {
  94.             PropertyChangedEventHandler handler = PropertyChanged;
  95.             if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
  96.         }
  97.  
  98.     }
  99. }
Add Comment
Please, Sign In to add comment