Esempio n. 1
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            headerLogger.Info("");
            logger.Info("Loading...");
            // Setup Loading text
            LoadingText = "Loading...";
            Progress <string> loadingProgress = new Progress <string>((data) =>
            {
                LoadingText = data;
            });

            // Setup Managers & Linkers
            linker = new Linker();
            await linker.Setup(loadingProgress);

            // Get Pool List
            logger.Info("Loading Pool List...");
            PoolList = new List <PoolData>(await linker.networkManager.GetPoolData(linker.networkManager.data.pools));
            PoolList.Add(PoolData.Custom);

            // Check Saved Address
            AddressInput = linker.minerManager.GetSavedAddress();
            logger.Info("Using saved address: " + AddressInput);

            //await linker.minerManager.InstallMiner("nvidia_win", loadingProgress);
            logger.Info("Miners Installed: " + String.Join(", ", linker.minerManager.data.installed.Keys.ToArray()));

            // Set Default values
            ReadyToShow    = true;
            ShowStats      = false;
            ShowStop       = false;
            ShowCustomPool = false;
            InfoText       = "Ready!";

            // Tell it we're done
            logger.Info("Finished Loading.");
        }
Esempio n. 2
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            initializing = true;
            headerLogger.Info("");

            // Setup Loading text
            logger.Info("Loading...");
            LoadingText = "Loading...";

            // Check for Updates
            LoadingText = "Checking for Updates...";
            logger.Info("Checking for Updates...");
            try
            {
                // TODO: Make it so it applies major updates immediately
                // TODO: Change this to use a URL instead
                using (UpdateManager manager = new UpdateManager(@"D:\Projects\VS Projects\EasyGarlic\EasyGarlic\Releases"))
                {
                    await manager.UpdateApp();
                }
            }
            catch (Exception error)
            {
                // Don't show this error in debug mode because it's always gonna happen
                if (error.Message == "Update.exe not found, not a Squirrel-installed app?")
                {
#if !DEBUG
                    logger.Error("Updater: " + error);
                    LoadingText = "Could not check for updates.";
#endif
                }
                else
                {
                    logger.Error("Updater: " + error);
                    LoadingText = "Could not check for updates.";
                }
            }

            LoadingText = "Loading...";

            bool skipAPI = false;

            // Loading progress for the Linker
            Progress <ProgressReport> loadingProgress = new Progress <ProgressReport>((data) =>
            {
                LoadingText = data.message;

                // If there was an error
                if (data.error != null)
                {
                    // Problem while fetching API data
                    if (data.error.GetType() == typeof(System.Net.WebException))
                    {
                        logger.Error(data.message);
                        logger.Error(data.error);
                        skipAPI          = true;
                        ConnectionErrors = true;
                    }
                }
            });

            // Setup Managers & Linkers
            linker = new Linker();
            await linker.Setup(loadingProgress);

            // Start Output Window
            if (linker.minerManager.data.openConsole)
            {
                OpenDebugConsole();
            }

            // Get Pool List
            logger.Info("Loading Pool List...");
            PoolList = new List <PoolData>();
            // If there were no issues contacting Online Data
            if (!skipAPI)
            {
                // Fetch Pool List
                try
                {
                    PoolList = new List <PoolData>(await linker.networkManager.GetPoolData(linker.networkManager.data.pools));
                }
                // If there were issues contacting Pool List
                catch (System.Net.WebException err)
                {
                    // Report error
                    ((IProgress <ProgressReport>)loadingProgress).Report(new ProgressReport("Could not load Pool Data at " + linker.networkManager.data.pools, err));

                    // Create an empty list
                    PoolList = new List <PoolData>();
                }
            }
            // Add Custom item to the Pool List
            PoolList.Add(PoolData.Custom);

            // Select Pool List Item if LocalData.savedPool is set
            if (linker.minerManager.data.savedPool != null)
            {
                PoolData saved = linker.minerManager.data.savedPool;
                int      index = saved.id;

                // If that object is actually a custom
                if (saved.name == "Custom")
                {
                    // Use it as a custom (last index)
                    index = PoolList.Count - 1;
                    PoolList[index].stratum = saved.stratum;
                }

                PoolListIndex = index;
                logger.Info("Using saved pool: " + saved);
            }

            // Check Saved Address
            AddressInput = linker.minerManager.GetSavedAddress();
            logger.Info("Using saved address: " + AddressInput);

            logger.Info("Miners Installed: " + String.Join(", ", linker.minerManager.data.installed.Keys.ToArray()));

            // Set Default values
            ReadyToShow    = true;
            ShowStats      = false;
            ShowStop       = false;
            EnableAdvanced = true;
            ShowCustomPool = false;
            InfoText       = "Ready!";

            // Tell it we're done
            logger.Info("Finished Loading.");
            initializing = false;
        }