Ejemplo n.º 1
0
        public void FirstTimeSetup(Mutex m, Service_JsonParser jsp,
                                   NamedPipeManager npm, List <DatabaseContext_Profile> profiles, ProfilesManager profileManager)
        {
            if (GetCollection <Game>("games").Count() > 0)
            {
                GetCollection <Game>("games").Delete(x => true);
            }

            if (GetCollection <GameApplication>("game_apps").Count() > 0)
            {
                GetCollection <GameApplication>("game_apps").Delete(x => true);
            }
            foreach (var item in profiles)
            {
                item.Dispose();
            }
            profiles.Clear();

            foreach (var item in GetCollection <UserProfile>("profiles").FindAll())
            {
                profileManager.DeleteProfile(item.ProfileId);
            }

            AvailableGamesWindow chooseGames = new AvailableGamesWindow(m, this, jsp, npm, profiles, profileManager);

            chooseGames.Show();
        }
        public SettingsWindow(DatabaseContext_Main db, Service_JsonParser parser)
        {
            _db = db;
            InitializeComponent();
            AssociationWithNXM_CheckBox.IsChecked = Defined.Settings.IsNxmHandled;
            _jsonParser = parser;

            _nxmHandler = new NxmHandler(_jsonParser, AssociationWithNXM_CheckBox, _db);
        }
 public AvailableGamesWindow(Mutex m, DatabaseContext_Main db, Service_JsonParser jsp,
                             NamedPipeManager npm, List <DatabaseContext_Profile> profiles, ProfilesManager profMng)
     : this(db, ConfigurationPurpose.FirstTime)
 {
     _mutex            = m;
     _jsonParser       = jsp;
     _namedPipeManager = npm;
     _dbProfiles       = profiles;
     _profilesManager  = profMng;
 }
Ejemplo n.º 4
0
        public NxmHandler(Service_JsonParser jsonParser, CheckBox IsAssociated_CheckBox, DatabaseContext_Main db)
        {
            _jsonParser = jsonParser;
            _db         = db;

            if (IsUrlAssociated("nxm") != Defined.Settings.IsNxmHandled)
            {
                AssociationManagement(IsUrlAssociated("nxm"), IsAssociated_CheckBox, _db.GetCollection <Game>("games").FindAll());
            }
        }
        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));
            }
        }
Ejemplo n.º 6
0
        void App_Startup(object sender, StartupEventArgs e)
        {
            NexusUrl modArg        = null;
            bool     isMainProcess = false;

            _dbProfiles = new List <DatabaseContext_Profile>();

            _mutex = new Mutex(false, "Global\\" + appGuid);
            try
            {
                isMainProcess = _mutex.WaitOne(0, false);
            }
            catch (Exception)
            {
                isMainProcess = false;
            }


            // Application is running
            // Process command line args
            bool startMinimized = false;

            for (int i = 0; i < e.Args.Length; ++i)
            {
                if (e.Args[i] == "/StartMinimized")
                {
                    startMinimized = true;
                }
                else
                {
                    try
                    {
                        modArg = new NexusUrl(new Uri(e.Args[i]));
                    }
                    catch (Exception)
                    {
                        Current.Shutdown();
                    }
                }
            }
            if (!isMainProcess)
            {
                _mutex.ReleaseMutex();
                _mutex.Close();
                if (modArg != null)
                {
                    ProcessStartInfo info = new ProcessStartInfo(Defined.NAMED_PIPE_CLIENT_EXECUTABLE)
                    {
                        Arguments      = modArg.ToString(),
                        CreateNoWindow = true
                    };
                    Process.Start(info);
                    Current.Shutdown();
                }
            }
            else
            {
                _namedPipeManager   = new NamedPipeManager();
                _jsonParser         = new Service_JsonParser();
                RequiredDirectories = new string[] { Defined.Settings.ApplicationDataPath };
                foreach (var item in RequiredDirectories)
                {
                    if (!Directory.Exists(item))
                    {
                        Directory.CreateDirectory(item);
                    }
                }

                _db = new DatabaseContext_Main();// Strong Type Class
                foreach (var game in _db.GetCollection <Game>("games").FindAll())
                {
                    if (!Directory.Exists(game.ModsDirectory))
                    {
                        Directory.CreateDirectory(game.ModsDirectory);
                    }
                    if (!Directory.Exists(game.DownloadsDirectory))
                    {
                        Directory.CreateDirectory(game.DownloadsDirectory);
                    }
                    if (!Directory.Exists(game.ProfilesDirectory))
                    {
                        Directory.CreateDirectory(game.ProfilesDirectory);
                    }
                }
                _profilesManager = new ProfilesManager(_db);

                foreach (var item in _db.GetCollection <Classes.DatabaseClasses.UserProfile>("profiles").FindAll())
                {
                    _dbProfiles.Add(new DatabaseContext_Profile(item.ProfileDirectory, item.GameId));
                }

                if (Defined.Settings.State == StatesOfConfiguration.FirstTime || _db.GetCollection <Game>("games").FindAll().Count() < 1)
                {
                    _db.FirstTimeSetup(_mutex, _jsonParser, _namedPipeManager, _dbProfiles, _profilesManager);
                    foreach (var item in _dbProfiles)
                    {
                        item.FirstTimeSetup();
                    }
                    return;
                }
                else if (Defined.Settings.State == StatesOfConfiguration.Ready)
                {
                    // Create main application window, starting minimized if specified
                    MainWindow mainWindow = new MainWindow(_mutex, _db, _jsonParser,
                                                           _namedPipeManager, _dbProfiles, _profilesManager, modArg);
                    if (startMinimized)
                    {
                        mainWindow.WindowState = WindowState.Minimized;
                    }
                    mainWindow.Show();
                    mainWindow.InitBindings();
                }
            }
        }