Exemplo n.º 1
0
        public Profile CreateProfile()
        {
            var pNew = new Profile()
            {
                Name = "NewProfile",
                Id   = PendingProfiles.Count > 0 ? PendingProfiles.Max(p => p.Id) + 1 : 1
            };

            IConfiguration config = ConfigurationManager.FirstOrDefault();

            if (config != null)
            {
                pNew.GameModel.Type = config.GameType;

                ConfigurationManager CM = ConfigurationManager as ConfigurationManager;
                // we should not provide this api as public
                pNew.GameModel.GamePath     = CM.GetGamePathFromRegistry(config);
                pNew.GameModel.LauncherPath = CM.GetLauncherPathFromRegistry(config);
                if (config.IsWebAvailable)
                {
                    Server serv = config.ServersProvider.ServerList.FirstOrDefault();
                    if (serv != null)
                    {
                        pNew.Rotation.ServerId = serv.Identifier;
                    }
                }
            }
            pNew.News.TwitterUser = Utils.GetDefaultTwitter();
            pNew.LaunchMode       = App.Kernel.Get <LauncherManager>().Default.Mnemonic;

            PendingProfiles.Add(pNew);
            OnCollectionChanged();
            return(pNew);
        }
Exemplo n.º 2
0
 public void Start()
 {
     lock (lockObject) {
         if (IsLoaded)
         {
             return;
         }
         PendingProfiles.Clear();
         foreach (Profile p in EnvironmentManager.Settings.Profiles)
         {
             PendingProfiles.Add(new Profile(p));
         }
         if (PendingProfiles.Count == 0)
         {
             CreateProfile();
         }
         if (EnvironmentManager.Settings.DefaultProfile != null)
         {
             PendingDefaultProfile = new Profile(EnvironmentManager.Settings.DefaultProfile);
         }
         else
         {
             PendingDefaultProfile = PendingProfiles.First();
         }
         ApplyChanges();
         if (EnvironmentManager.Settings.Profiles.Count == 0)
         {
             EnvironmentManager.Save();
         }
         IsLoaded = true;
     }
 }
Exemplo n.º 3
0
 public void RevertChanges()
 {
     PendingDefaultProfile = new Profile(DefaultProfile);
     PendingProfiles.Clear();
     foreach (Profile profile in Profiles)
     {
         PendingProfiles.Add(new Profile(profile));
     }
 }
Exemplo n.º 4
0
        public bool RemoveProfile(Profile profile)
        {
            if (profile == null)
            {
                throw new ArgumentException("profile argument cannot be null");
            }
            bool result = false;

            if (PendingProfiles.Count > 1)
            {
                bool IsDefault = profile.Id == PendingDefaultProfile.Id;
                result = PendingProfiles.Remove(profile);
                if (result)
                {
                    OnCollectionChanged();
                    if (IsDefault)
                    {
                        PendingDefaultProfile = PendingProfiles.First();
                    }
                }
            }
            return(result);
        }