Beispiel #1
0
        private void RestoreAllButtons()
        {
            IsWorking = false;

            ControlBridge.SetControlVisibleState(panelCancel, false);
            ControlBridge.SetControlVisibleState(panelButtons, true);

            Logging.LogMessage($"Processing thread COMPLETED.");
        }
Beispiel #2
0
        private void SetAsProcessing()
        {
            ControlBridge.SetControlVisibleState(panelCancel, true);
            ControlBridge.SetControlVisibleState(panelButtons, false);

            _cancellationTokenSource = new CancellationTokenSource();
            _cancellationToken       = _cancellationTokenSource.Token;
            _cancellationToken.Register(new Action(() => RestoreAllButtons()));

            Logging.LogMessage($"Processing thread LAUNCHED.");

            IsWorking = true;
        }
Beispiel #3
0
 private void RefreshLoadSaveButtonState()
 {
     if (DoesSaveFileExist)
     {
         ControlBridge.SetControlEnabledState(btnLoad, true);
         ControlBridge.SetControlEnabledState(btnCreate, false);
         ControlBridge.SetControlEnabledState(btnSave, true);
     }
     else
     {
         ControlBridge.SetControlEnabledState(btnLoad, false);
         ControlBridge.SetControlEnabledState(btnCreate, true);
         ControlBridge.SetControlEnabledState(btnSave, false);
     }
 }
Beispiel #4
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            ControlBridge.SetControlText(tbN, Settings.N);
            ControlBridge.SetControlText(tbDegree, Settings.Degree);
            ControlBridge.SetControlText(tbBase, Settings.Base);
            ControlBridge.SetControlText(tbBound, Settings.Bound);
            ControlBridge.SetControlText(tbRelationQuantity, Settings.RelationQuantity);
            ControlBridge.SetControlText(tbRelationValueRange, Settings.RelationValueRange);

            ControlBridge.SetControlVisibleState(panelCancel, false);

            RefreshLoadSaveButtonState();

            this.tbN.TextChanged += new System.EventHandler(this.tbN_TextChanged);
        }
Beispiel #5
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (!IsWorking)
            {
                SetAsProcessing();
                //ControlBridge.SetControlEnabledState(btnCreate, false);

                n          = BigInteger.Parse(tbN.Text);
                degree     = int.Parse(tbDegree.Text);
                polyBase   = BigInteger.Parse(tbBase.Text);
                primeBound = BigInteger.Parse(tbBound.Text);

                int relationQuantity   = int.Parse(tbRelationQuantity.Text);
                int relationValueRange = int.Parse(tbRelationValueRange.Text);

                //Logging.OutputFilename = DirectoryLocations.GetUniqueNameFromN(n) + ".LOG.txt";
                //Logging.CreateLogFileIfNotExists();

                Logging.LogMessage($"[New factorization job creation initialization for N = {DirectoryLocations.GetUniqueNameFromN(n)}...]");

                CancellationToken token = cancellationTokenSource.Token;
                new Thread(() =>
                {
                    GNFS localGnfs =
                        GnfsUiBridge.CreateGnfs
                        (
                            token,                              // CancellationToken
                            n,                                  // Semi-prime to factor N = P*Q
                            polyBase,                           // Polynomial base (value for x)
                            degree,                             // Polynomial Degree
                            primeBound,                         //  BigInteger
                            relationQuantity,                   // Total # of relations to collect before proceeding.
                            relationValueRange                  //
                        );



                    SetGnfs(this, localGnfs);
                    HaultAllProcessing();
                    ControlBridge.SetControlEnabledState(panelFunctions, true);
                    Logging.LogMessage($"[New factorization job initialization complete]");
                    Logging.LogMessage($"NOTE: You should save your progress now.");
                }).Start();
            }
        }
Beispiel #6
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            if (!IsWorking)
            {
                SetAsProcessing();
                //ControlBridge.SetControlEnabledState(btnCreate, false);

                n = BigInteger.Parse(tbN.Text);

                //Logging.OutputFilename = DirectoryLocations.GetUniqueNameFromN(n) + ".LOG.txt";
                //Logging.CreateLogFileIfNotExists();

                string jsonFilename = Path.Combine(DirectoryLocations.GetSaveLocation(n), "GNFS.json");
                Logging.LogMessage($"[Loading factorization progress from \"{jsonFilename}\"...]");

                CancellationToken token = cancellationTokenSource.Token;
                new Thread(() =>
                {
                    GNFS localGnfs = GnfsUiBridge.LoadGnfs(n);
                    SetGnfs(this, localGnfs);
                    HaultAllProcessing();
                    ControlBridge.SetControlEnabledState(panelFunctions, true);
                    Logging.LogMessage();
                    Logging.LogMessage("Counts/Quantities:");
                    Logging.LogMessage();
                    Logging.LogMessage($"Algebraic Factor Base (Quantity):\t{localGnfs.PrimeFactorBase.AlgebraicFactorBase.Count}");
                    Logging.LogMessage($"Rational Factor Base (Quantity):\t{localGnfs.PrimeFactorBase.RationalFactorBase.Count}");
                    Logging.LogMessage($"Quadratic Factor Base (Quantity):\t{localGnfs.PrimeFactorBase.QuadraticFactorBase.Count}");
                    Logging.LogMessage();
                    Logging.LogMessage($"Algebraic Factor Pairs (Quantity):\t{localGnfs.AlgebraicFactorPairCollection.Count}");
                    Logging.LogMessage($"Rational Factor Pairs (Quantity):\t{localGnfs.RationalFactorPairCollection.Count}");
                    Logging.LogMessage($"Quadratic Factor Pairs (Quantity):\t{localGnfs.QuadraticFactorPairCollection.Count}");
                    Logging.LogMessage();
                    Logging.LogMessage($"     Smooth Relations (Quantity):\t{localGnfs.CurrentRelationsProgress.SmoothRelationsCounter}");
                    Logging.LogMessage($"      Rough Relations (Quantity):\t{localGnfs.CurrentRelationsProgress.RoughRelations.Count}");
                    Logging.LogMessage($"       Free Relations (Quantity):\t{localGnfs.CurrentRelationsProgress.FreeRelationsCounter}");
                    Logging.LogMessage();
                    Logging.LogMessage("[Loading factorization progress complete]");
                }).Start();
            }
        }
Beispiel #7
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            if (!IsWorking)
            {
                SetAsProcessing();

                BigInteger n = N;

                string jsonFilename = Path.Combine(DirectoryLocations.GetSaveLocation(n), DirectoryLocations.SaveFilename);
                Logging.LogMessage($"[Loading factorization progress from \"{jsonFilename}\"...]");

                CancellationToken token = _cancellationTokenSource.Token;

                new Thread(() =>
                {
                    GNFS localGnfs = GnfsUiBridge.LoadGnfs(n);
                    SetGnfs(this, localGnfs);
                    HaultAllProcessing();
                    ControlBridge.SetControlEnabledState(panelFunctions, true);
                    Logging.LogMessage();
                    Logging.LogMessage("Counts/Quantities:");
                    Logging.LogMessage();
                    Logging.LogMessage($"Algebraic Factor Base (MaxValue):\t{localGnfs.PrimeFactorBase.AlgebraicFactorBaseMax}");
                    Logging.LogMessage($"Rational Factor Base (MaxValue):\t{localGnfs.PrimeFactorBase.RationalFactorBaseMax}");
                    Logging.LogMessage($"Quadratic Factor Base (MaxValue):\t{localGnfs.PrimeFactorBase.QuadraticFactorBaseMax}");
                    Logging.LogMessage();
                    Logging.LogMessage($"Algebraic Factor Pairs (Quantity):\t{localGnfs.AlgebraicFactorPairCollection.Count}");
                    Logging.LogMessage($"Rational Factor Pairs (Quantity):\t{localGnfs.RationalFactorPairCollection.Count}");
                    Logging.LogMessage($"Quadratic Factor Pairs (Quantity):\t{localGnfs.QuadraticFactorPairCollection.Count}");
                    Logging.LogMessage();
                    Logging.LogMessage($"     Smooth Relations (Quantity):\t{localGnfs.CurrentRelationsProgress.SmoothRelationsCounter}");
                    Logging.LogMessage($"      Rough Relations (Quantity):\t{localGnfs.CurrentRelationsProgress.RoughRelations.Count}");
                    Logging.LogMessage($"       Free Relations (Quantity):\t{localGnfs.CurrentRelationsProgress.FreeRelationsCounter}");
                    Logging.LogMessage();
                    Logging.LogMessage("[Loading factorization progress complete]");
                    PrintCurrentCounts();
                    RefreshLoadSaveButtonState();
                }).Start();
            }
        }