Example #1
0
        private void PoolListCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems != null && e.AddedItems.Count != 0)
            {
                PoolData poolData = e.AddedItems[0] as PoolData;

                // If it's the same value, don't change, it might override custom pool input
                if (lastPoolDataValue != null && lastPoolDataValue.id == poolData.id)
                {
                    return;
                }

                // If it's a custom, show the pool input
                if (poolData.name == "Custom")
                {
                    PoolInput      = "";
                    ShowCustomPool = true;
                }
                // If it's not, set pool input to the first stratum
                else
                {
                    PoolInput      = poolData.Value();
                    ShowCustomPool = false;
                }

                lastPoolDataValue = poolData;

                // Don't want to override the saved pool on initialization because it can't be changed  by user at that point
                if (!initializing)
                {
                    logger.Info("Using pool: " + poolData);
                    // Save the selected pool as the savedPool for auto-select
                    linker.minerManager.data.savedPool = poolData;
                }
            }
        }
Example #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;
        }