Exemple #1
0
        /// <summary>
        /// A simple constructor that initializes the object with the given dependencies.
        /// </summary>
        /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
        /// <param name="p_gmrInstalledGames">The registry of insalled games.</param>
        /// <param name="p_gmdGameMode">The game mode currently being managed.</param>
        /// <param name="p_mrpModRepository">The repository we are logging in to.</param>
        /// <param name="p_dmtMonitor">The download monitor to use to track task progress.</param>
        /// <param name="p_umgUpdateManager">The update manager to use to perform updates.</param>
        /// <param name="p_mmgModManager">The <see cref="ModManager"/> to use to manage mods.</param>
        /// <param name="p_pmgPluginManager">The <see cref="PluginManager"/> to use to manage plugins.</param>
        public MainFormVM(IEnvironmentInfo p_eifEnvironmentInfo, GameModeRegistry p_gmrInstalledGames, IGameMode p_gmdGameMode, IModRepository p_mrpModRepository, DownloadMonitor p_dmtMonitor, ActivateModsMonitor p_ammMonitor, UpdateManager p_umgUpdateManager, ModManager p_mmgModManager, IPluginManager p_pmgPluginManager)
        {
            EnvironmentInfo = p_eifEnvironmentInfo;
            GameMode        = p_gmdGameMode;
            GameMode.GameLauncher.GameLaunching += new CancelEventHandler(GameLauncher_GameLaunching);
            ModManager    = p_mmgModManager;
            ModRepository = p_mrpModRepository;
            UpdateManager = p_umgUpdateManager;
            ModManagerVM  = new ModManagerVM(p_mmgModManager, p_eifEnvironmentInfo.Settings, p_gmdGameMode.ModeTheme);
            if (GameMode.UsesPlugins)
            {
                PluginManagerVM = new PluginManagerVM(p_pmgPluginManager, p_eifEnvironmentInfo.Settings, p_gmdGameMode);
            }
            DownloadMonitorVM     = new DownloadMonitorVM(p_dmtMonitor, p_eifEnvironmentInfo.Settings, p_mmgModManager, p_mrpModRepository);
            ActivateModsMonitorVM = new ActivateModsMonitorVM(p_ammMonitor, p_eifEnvironmentInfo.Settings, p_mmgModManager);
            HelpInfo = new HelpInformation(p_eifEnvironmentInfo);

            GeneralSettingsGroup gsgGeneralSettings = new GeneralSettingsGroup(p_eifEnvironmentInfo);

            foreach (IModFormat mftFormat in p_mmgModManager.ModFormats)
            {
                gsgGeneralSettings.AddFileAssociation(mftFormat.Extension, mftFormat.Name);
            }

            ModOptionsSettingsGroup mosModOptions = new ModOptionsSettingsGroup(p_eifEnvironmentInfo);

            List <ISettingsGroupView> lstSettingGroups = new List <ISettingsGroupView>();

            lstSettingGroups.Add(new GeneralSettingsPage(gsgGeneralSettings));
            lstSettingGroups.Add(new ModOptionsPage(mosModOptions));
            DownloadSettingsGroup dsgDownloadSettings = new DownloadSettingsGroup(p_eifEnvironmentInfo, ModRepository);

            lstSettingGroups.Add(new DownloadSettingsPage(dsgDownloadSettings));

            if (p_gmdGameMode.SettingsGroupViews != null)
            {
                lstSettingGroups.AddRange(p_gmdGameMode.SettingsGroupViews);
            }

            SettingsFormVM = new SettingsFormVM(p_gmdGameMode, p_eifEnvironmentInfo, lstSettingGroups);

            UpdateCommand = new Command("Update", String.Format("Update {0}", EnvironmentInfo.Settings.ModManagerName), UpdateProgramme);
            LogoutCommand = new Command("Logout", "Logout", Logout);

            List <Command>             lstChangeGameModeCommands = new List <Command>();
            List <IGameModeDescriptor> lstSortedModes            = new List <IGameModeDescriptor>(p_gmrInstalledGames.RegisteredGameModes);

            lstSortedModes.Sort((x, y) => x.Name.CompareTo(y.Name));
            foreach (IGameModeDescriptor gmdInstalledGame in lstSortedModes)
            {
                string strId          = gmdInstalledGame.ModeId;
                string strName        = gmdInstalledGame.Name;
                string strDescription = String.Format("Change game to {0}", gmdInstalledGame.Name);
                Image  imgCommandIcon = new Icon(gmdInstalledGame.ModeTheme.Icon, 32, 32).ToBitmap();
                lstChangeGameModeCommands.Add(new Command(strId, strName, strDescription, imgCommandIcon, () => ChangeGameMode(strId), true));
            }
            lstChangeGameModeCommands.Add(new Command("Change Default Game...", "Change Default Game", () => ChangeGameMode(CHANGE_DEFAULT_GAME_MODE)));
            lstChangeGameModeCommands.Add(new Command("Rescan Installed Games...", "Rescan Installed Games", () => ChangeGameMode(RESCAN_INSTALLED_GAMES)));
            ChangeGameModeCommands = lstChangeGameModeCommands;
        }
        private void SetBindings(DownloadSettingsGroup p_dsgSettings)
        {
            BindingSource bsFileServerZones = new BindingSource();

            if (m_fszFileServerZone != null)
            {
                m_fszFileServerZone.Clear();
            }
            m_fszFileServerZone = p_dsgSettings.FileServerZones;

            bsFileServerZones.DataSource = p_dsgSettings.FileServerZones;

            cbxServerLocation.DataSource    = bsFileServerZones.DataSource;
            cbxServerLocation.DisplayMember = "FileServerName";
            cbxServerLocation.ValueMember   = "FileServerID";

            if (cbxServerLocation.DataBindings != null)
            {
                cbxServerLocation.DataBindings.Clear();
            }
            BindingHelper.CreateFullBinding(cbxServerLocation, () => cbxServerLocation.SelectedValue, p_dsgSettings, () => p_dsgSettings.UserLocation);
            if (ckbPremiumOnly.DataBindings != null)
            {
                ckbPremiumOnly.DataBindings.Clear();
            }
            BindingHelper.CreateFullBinding(ckbPremiumOnly, () => ckbPremiumOnly.Checked, p_dsgSettings, () => p_dsgSettings.UseMultithreadedDownloads);
            ckbPremiumOnly.Enabled = p_dsgSettings.PremiumEnabled;
        }
        private void dsgSettings_UpdatedSettings(object sender, EventArgs e)
        {
            DownloadSettingsGroup dsgSettings = (DownloadSettingsGroup)sender;

            if (dsgSettings != null)
            {
                SetBindings(dsgSettings);
            }
        }
		/// <summary>
		/// A sinmple consturctor that initializes teh object with the given values.
		/// </summary>
		/// <param name="p_dsgSettings">The settings group whose settings will be editable with this view.</param>
		public DownloadSettingsPage(DownloadSettingsGroup p_dsgSettings)
		{
			SettingsGroup = p_dsgSettings;
			p_dsgSettings.UpdatedSettings += new EventHandler(dsgSettings_UpdatedSettings);
			InitializeComponent();

			butChromeFix.Image = new Bitmap(Properties.Resources.uac_icon, 20, 20);

			SetBindings(p_dsgSettings);
		}
        /// <summary>
        /// A sinmple consturctor that initializes teh object with the given values.
        /// </summary>
        /// <param name="p_dsgSettings">The settings group whose settings will be editable with this view.</param>
        public DownloadSettingsPage(DownloadSettingsGroup p_dsgSettings)
        {
            SettingsGroup = p_dsgSettings;
            p_dsgSettings.UpdatedSettings += new EventHandler(dsgSettings_UpdatedSettings);
            InitializeComponent();

            butChromeFix.Image = new Bitmap(Properties.Resources.uac_icon, 20, 20);

            SetBindings(p_dsgSettings);
        }
Exemple #6
0
        /// <summary>
        /// A simple constructor that initializes teh object with the given values.
        /// </summary>
        /// <param name="downloadSettingsGroup">The settings group whose settings will be editable with this view.</param>
        public DownloadSettingsPage(DownloadSettingsGroup downloadSettingsGroup)
        {
            SettingsGroup = downloadSettingsGroup;
            downloadSettingsGroup.UpdatedSettings += dsgSettings_UpdatedSettings;
            InitializeComponent();

            buttonChromeFix.Image = new Bitmap(Properties.Resources.uac_icon, 20, 20);

            SetBindings(downloadSettingsGroup);
        }
Exemple #7
0
        private void SetBindings(DownloadSettingsGroup downloadSettingsGroup)
        {
            checkBoxMaxConcurrentDownloads.DataSource = Enum.GetValues(typeof(MaxDownloadsInterval))
                                                        .Cast <MaxDownloadsInterval>()
                                                        .Select(p => new { Value = (int)p, Key = p.ToString() })
                                                        .ToList();
            checkBoxMaxConcurrentDownloads.DisplayMember = "Key";
            checkBoxMaxConcurrentDownloads.ValueMember   = "Value";

            checkBoxPremiumOnly.DataBindings?.Clear();
            BindingHelper.CreateFullBinding(checkBoxPremiumOnly, () => checkBoxPremiumOnly.Checked, downloadSettingsGroup, () => downloadSettingsGroup.UseMultithreadedDownloads);
            checkBoxPremiumOnly.Enabled = downloadSettingsGroup.PremiumEnabled;

            checkBoxMaxConcurrentDownloads.DataBindings?.Clear();
            BindingHelper.CreateFullBinding(checkBoxMaxConcurrentDownloads, () => checkBoxMaxConcurrentDownloads.SelectedValue, downloadSettingsGroup, () => downloadSettingsGroup.MaxConcurrentDownloads);
        }
        private void SetBindings(DownloadSettingsGroup p_dsgSettings)
        {
            BindingSource bsFileServerZones = new BindingSource();

            if (m_fszFileServerZone != null)
            {
                m_fszFileServerZone.Clear();
            }
            m_fszFileServerZone = p_dsgSettings.FileServerZones;

            bsFileServerZones.DataSource = p_dsgSettings.FileServerZones;

            cbxServerLocation.DataSource    = bsFileServerZones.DataSource;
            cbxServerLocation.DisplayMember = "FileServerName";
            cbxServerLocation.ValueMember   = "FileServerID";

            cbxMaxConcurrentDownloads.DataSource = Enum.GetValues(typeof(MaxDownloadsInterval))
                                                   .Cast <MaxDownloadsInterval>()
                                                   .Select(p => new { Value = (int)p, Key = p.ToString() })
                                                   .ToList();
            cbxMaxConcurrentDownloads.DisplayMember = "Key";
            cbxMaxConcurrentDownloads.ValueMember   = "Value";

            if (cbxServerLocation.DataBindings != null)
            {
                cbxServerLocation.DataBindings.Clear();
            }
            BindingHelper.CreateFullBinding(cbxServerLocation, () => cbxServerLocation.SelectedValue, p_dsgSettings, () => p_dsgSettings.UserLocation);
            if (ckbPremiumOnly.DataBindings != null)
            {
                ckbPremiumOnly.DataBindings.Clear();
            }
            BindingHelper.CreateFullBinding(ckbPremiumOnly, () => ckbPremiumOnly.Checked, p_dsgSettings, () => p_dsgSettings.UseMultithreadedDownloads);
            ckbPremiumOnly.Enabled = p_dsgSettings.PremiumEnabled;

            if (cbxMaxConcurrentDownloads.DataBindings != null)
            {
                cbxMaxConcurrentDownloads.DataBindings.Clear();
            }
            BindingHelper.CreateFullBinding(cbxMaxConcurrentDownloads, () => cbxMaxConcurrentDownloads.SelectedValue, p_dsgSettings, () => p_dsgSettings.MaxConcurrentDownloads);
        }
		private void SetBindings(DownloadSettingsGroup p_dsgSettings)
		{
			BindingSource bsFileServerZones = new BindingSource();
			if (m_fszFileServerZone != null)
				m_fszFileServerZone.Clear();
			m_fszFileServerZone = p_dsgSettings.FileServerZones;

			bsFileServerZones.DataSource = p_dsgSettings.FileServerZones;

			cbxServerLocation.DataSource = bsFileServerZones.DataSource;
			cbxServerLocation.DisplayMember = "FileServerName";
			cbxServerLocation.ValueMember = "FileServerID";

			if (cbxServerLocation.DataBindings != null)
				cbxServerLocation.DataBindings.Clear();
			BindingHelper.CreateFullBinding(cbxServerLocation, () => cbxServerLocation.SelectedValue, p_dsgSettings, () => p_dsgSettings.UserLocation);
			if (ckbPremiumOnly.DataBindings != null)
				ckbPremiumOnly.DataBindings.Clear();
			BindingHelper.CreateFullBinding(ckbPremiumOnly, () => ckbPremiumOnly.Checked, p_dsgSettings, () => p_dsgSettings.UseMultithreadedDownloads);
			ckbPremiumOnly.Enabled = p_dsgSettings.PremiumEnabled;
		}