public void ChangeProfile(DatabaseContext_Profile db)
 {
     _db = db;
     ModControls.Clear();
     _db.GetAll <Mod>("mods").ToList().ForEach(x =>
     {
         ModControls.Add(new Mod_Control(x, _db));
     });
 }
        public ModManager(DatabaseContext_Profile db, ListView modsTreeView, ListView downloadsTreeView,
                          AccountHandler ah)
        {
            _db             = db;
            _accountHandler = ah;
            Downloads_View  = downloadsTreeView;
            Mods_View       = modsTreeView;
            modsTreeView.Dispatcher.Invoke(() =>
            {
                DownloadsManager   = new DownloadManager(downloadsTreeView, AddModToGUI);
                _nexusCommunicator = new NexusCommunicationManager(_accountHandler.Token);

                ModControls           = new List <Mod_Control>();
                Mods_View.ItemsSource = ModControls;
            });
        }
        private void profilePicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = ((ComboBox)sender).SelectedIndex;

            if (index == 0)
            {
            }
            else
            {
                _currProfile = _db.GetAll <UserProfile>("profiles")
                               .Where(x => x.GameId == _currGame.Id).ElementAt(index - 1);

                _currProfileDb = _dbProfiles.ElementAt(index - 1);
                ChangeProfile();
            }
        }
        public MainWindow(Mutex mutex, DatabaseContext_Main db, Service_JsonParser jsonParser,
                          NamedPipeManager npm, List <DatabaseContext_Profile> profiles, ProfilesManager profMngr, Nexus.NexusUrl modUri = null)
        {
            InitializeComponent();

            _mutex            = mutex;
            _jsonParser       = jsonParser;
            _db               = db;
            _dbProfiles       = profiles;
            _currProfileDb    = _dbProfiles.FirstOrDefault(x => _currGame.Id == x.GameId);
            _namedPipeManager = npm;
            _profilesManager  = profMngr;
            _mulConverter     = new MultiplicationMathConverter();
            _addConverter     = new AdditionMathConverter();

            _namedPipeManager.ChangeMessageReceivedHandler(HandlePipeMessage);

            mainGrid.Dispatcher.BeginInvoke((Action)(() =>
            {
                InitGamePicker();
                _accountHandler = new AccountHandler(WhenLogsIn);
                _accountHandler.Init();
                _modManager = new ModManager(_currProfileDb, ModList_View, Downloads_View, _accountHandler);
                profilePicker.SelectionChanged += profilePicker_SelectionChanged;

                if (modUri != null)
                {
                    _modManager.CreateMod(_currGame, modUri).GetAwaiter();
                }
                _db.UpdateCurrentGame(_currGame, SetGame);
            }));

            if (!_namedPipeManager.IsRunning)
            {
                Task.Run(async() => await _namedPipeManager.Listen_NamedPipe(Dispatcher));
            }
        }
Exemple #5
0
 public Mod_Control(Mod m, DatabaseContext_Profile db)
 {
     AssociatedMod = m;
     _db           = db;
 }