Ejemplo n.º 1
0
        public WorldOfWarcraftInstallationClient(WorldOfWarcraftInstallation worldOfWarcraftInstallation, DirectoryInfo directory)
        {
            Directory    = directory;
            Installation = worldOfWarcraftInstallation;
            var rootExecutables = directory.GetFiles("*.exe");

            Executible =
                rootExecutables.FirstOrDefault(rootExecutable => rootExecutable.Name.Equals("wow.exe", StringComparison.OrdinalIgnoreCase)) ??
                rootExecutables.FirstOrDefault(rootExecutable => rootExecutable.Name.Equals("wowt.exe", StringComparison.OrdinalIgnoreCase)) ??
                rootExecutables.FirstOrDefault(rootExecutable => rootExecutable.Name.Equals("wowb.exe", StringComparison.OrdinalIgnoreCase));
            if (Executible == null)
            {
                throw new WorldOfWarcraftInstallationClientExecutableNotFoundException();
            }
            if (!Version.TryParse(FileVersionInfo.GetVersionInfo(Executible.FullName).FileVersion, out var clientExecutableVersion))
            {
                throw new WorldOfWarcraftInstallationClientExecutableVersionFormatException();
            }
            var flavorInfoFile = new FileInfo(Path.Combine(Directory.FullName, ".flavor.info"));

            if (!flavorInfoFile.Exists)
            {
                throw new WorldOfWarcraftInstallationClientFlavorInfoNotFoundException();
            }
            var flavorInfo = File.ReadAllLines(flavorInfoFile.FullName);

            if (flavorInfo.Length <= 1 || !Enum.TryParse <Flavor>(flavorInfo[1], out var flavor))
            {
                throw new WorldOfWarcraftInstallationClientFlavorInfoNotFoundException();
            }
            Flavor = flavor;
        }
Ejemplo n.º 2
0
        async void Initialize(object state)
        {
            if (!singleInstance.IsFirstInstance)
            {
                await singleInstance.SendMessageAsync("showmainwindow");

                Environment.Exit(0);
            }

            updateAvailableVersion = new Timer(UpdateAvailableVersion, null, TimeSpan.Zero, TimeSpan.FromDays(1));

            try
            {
                worldOfWarcraftInstallation = new WorldOfWarcraftInstallation(synchronizationContext: synchronizationContext);
            }
            catch (WorldOfWarcraftInstallationUnavailableException)
            {
                await OnUiThreadAsync(() => MessageBox.Show("Dude and/or madame, you have World of Warcraft installed in an odd place or not at all. I can't manage add-ons for WoW without WoW!", "NOOOOOOOOPE", MessageBoxButton.OK, MessageBoxImage.Error)).ConfigureAwait(false);

                Environment.Exit(0);
            }

            addOnManager = new AddOnManager(await Utilities.GetCommonStorageDirectoryAsync().ConfigureAwait(false), worldOfWarcraftInstallation, synchronizationContext);
            addOnManager.AddOnAutomaticallyUpdated += AddOnManagerAddOnAutomaticallyUpdatedHandler;
            addOnManager.AddOnUpdateAvailable      += AddOnManagerAddOnUpdateAvailableHandler;

            stateFile = new FileInfo(Path.Combine(addOnManager.StorageDirectory.FullName, "appState.json"));
            if (stateFile.Exists)
            {
                var appState = JsonConvert.DeserializeObject <AppState>(await File.ReadAllTextAsync(stateFile.FullName).ConfigureAwait(false));
                MainWindowHeight       = appState.MainWindowHeight;
                MainWindowLeft         = appState.MainWindowLeft;
                MainWindowTop          = appState.MainWindowTop;
                MainWindowWidth        = appState.MainWindowWidth;
                ShowPrereleaseVersions = appState.ShowPrereleaseVersions;
                themeIsDark            = appState.ThemeIsDark;
                themeIsHorde           = appState.ThemeIsHorde;
                await OnUiThreadAsync(() => SetTheme()).ConfigureAwait(false);
            }

            await CreateMainWindow(openMinimized : Environment.GetCommandLineArgs().Contains("-startMinimized", StringComparer.OrdinalIgnoreCase)).ConfigureAwait(false);
        }