Esempio n. 1
0
        private void Btn_Run_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ToggleRunCancelButtonEnabledState(true);
                DisableInputs();
                BigSqlRunner = CreateBigSqlRunner();
                BigSqlRunner.SaveConfig(null);

                BgWorker.WorkerReportsProgress = true;
                BgWorker.DoWork             += DoWork;
                BgWorker.ProgressChanged    += ProgressChanged;
                BgWorker.RunWorkerCompleted += WorkerCompleted;

                WriteLogMessage(MakeLog(new ProgressData("Started running...")));
                BgWorker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                RemoveBgWorkerEh();

                MessageBox.Show(ex.Message);

                EnableInputs();
                ToggleRunCancelButtonEnabledState(false);
            }
        }
Esempio n. 2
0
 protected void DoWork(object sender, DoWorkEventArgs e)
 {
     BigSqlRunner.Run(
         (executedUnits, affectedRows) => BgWorker.ReportProgress(-1, new ProgressData(executedUnits, affectedRows)),
         message => BgWorker.ReportProgress(-1, new ProgressData(message))
         );
 }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowser.Description = "Please choose the location of your .txt files";
            FolderBrowser.ShowDialog();
            string TextFileFolder = FolderBrowser.SelectedPath.ToString();

            if (TextFileFolder != "")
            {
                FolderBrowser.Description = "Please choose your output location";

                if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
                {
                    string OutputFolder = FolderBrowser.SelectedPath.ToString();

                    if (TextFileFolder != OutputFolder)
                    {
                        button1.Enabled = false;
                        ScanSubfolderCheckbox.Enabled = false;
                        EncodingDropdown.Enabled      = false;
                        BgWorker.RunWorkerAsync(new string[] { TextFileFolder, OutputFolder });
                    }
                    else
                    {
                        MessageBox.Show("Your input folder cannot be the same as your output folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Esempio n. 4
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (ValidateRegex(RegexTextBox.Text))
            {
                FolderBrowser.Description = "Please choose the location of your INPUT .txt files that you want to split";

                if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
                {
                    string TextFileFolder = FolderBrowser.SelectedPath.ToString();

                    FolderBrowser.Description = "Please choose the OUTPUT location for your files";

                    if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
                    {
                        string OutputFileLocation = FolderBrowser.SelectedPath.ToString();

                        StartButton.Enabled                   = false;
                        SpeakerListTextBox.Enabled            = false;
                        ScanSubfolderCheckbox.Enabled         = false;
                        EncodingDropdown.Enabled              = false;
                        SpeakersMultipleLinesCheckbox.Enabled = false;
                        DetectSpeakersButton.Enabled          = false;
                        RegexTextBox.Enabled                  = false;
                        BgWorker.RunWorkerAsync(new string[] { TextFileFolder, OutputFileLocation });
                    }
                }
            }
        }
Esempio n. 5
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            FolderBrowser.Description = "Please choose the location of your .txt files to analyze";
            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                DictData.TextFileFolder = FolderBrowser.SelectedPath.ToString();

                if (DictData.TextFileFolder != "")
                {
                    saveFileDialog.FileName = "Senti-Gent_Output.csv";

                    saveFileDialog.InitialDirectory = DictData.TextFileFolder;
                    if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
                    {
                        DictData.OutputFileLocation = saveFileDialog.FileName;

                        if (DictData.OutputFileLocation != "")
                        {
                            StartButton.Enabled           = false;
                            ScanSubfolderCheckbox.Enabled = false;
                            EncodingDropdown.Enabled      = false;

                            BgWorker.RunWorkerAsync(DictData);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (CSVDelimiterTextbox.Text.Length < 1)
            {
                CSVDelimiterTextbox.Text = ",";
            }
            if (CSVQuoteTextbox.Text.Length < 1)
            {
                CSVQuoteTextbox.Text = "\"";
            }

            //make sure that our dictionary is loaded before anything else
            if (DictData.DictionaryLoaded != true)
            {
                MessageBox.Show("You must first load a dictionary file before you can analyze your texts.", "Dictionary not loaded!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            FolderBrowser.Description = "Please choose the location of your .txt files to analyze";
            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                DictData.TextFileFolder = FolderBrowser.SelectedPath.ToString();

                if (DictData.TextFileFolder != "")
                {
                    saveFileDialog.FileName = "Vocabulate_Output.csv";

                    saveFileDialog.InitialDirectory = DictData.TextFileFolder;
                    if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
                    {
                        DictData.OutputFileLocation = saveFileDialog.FileName;
                        DictData.RawWordCounts      = RawWCCheckbox.Checked;
                        DictData.StopListRawText    = StopListTextBox.Text;
                        DictData.CSVDelimiter       = CSVDelimiterTextbox.Text[0];
                        DictData.CSVQuote           = CSVQuoteTextbox.Text[0];
                        DictData.OutputCapturedText = OutputCapturedWordsCheckbox.Checked;

                        if (DictData.OutputFileLocation != "")
                        {
                            StopListTextBox.Enabled             = false;
                            StartButton.Enabled                 = false;
                            ScanSubfolderCheckbox.Enabled       = false;
                            EncodingDropdown.Enabled            = false;
                            LoadDictionaryButton.Enabled        = false;
                            RawWCCheckbox.Enabled               = false;
                            CSVDelimiterTextbox.Enabled         = false;
                            CSVQuoteTextbox.Enabled             = false;
                            OutputCapturedWordsCheckbox.Enabled = false;

                            BgWorker.RunWorkerAsync(DictData);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Stops the background worker.
 /// </summary>
 private void ScannerFormClosing(object sender, FormClosingEventArgs e)
 {
     if (!_isLoadingNow)
     {
         return;
     }
     // Cancels the asynchronous operation.
     BgWorker.CancelAsync();
     e.Cancel = true;
 }
 /// <summary>
 /// Skapar instansen
 /// </summary>
 /// <param name="kanaler">Driftavbrottskanaler</param>
 /// <param name="server">Server</param>
 /// <param name="port">Port</param>
 /// <param name="systemid">Systemets namn</param>
 /// <param name="https">Https</param>
 public DriftavbrottMonitor(IEnumerable <string> kanaler, string server, int port, string systemid, bool https = false)
 {
     workerClass = new BgWorker(new DriftavbrottKlient(server, port, systemid, https), kanaler);
     workerClass.DriftavbrottStatus += workerClassDriftavbrottStatus;
     workerClass.ErrorOccurred      += workerClassOnErrorOccurred;
     workerThread = new Thread(workerClass.Start);
     workerThread.Start();
     while (workerThread.IsAlive != true)
     {
     }
 }
 /// <summary>
 /// Skapar instansen
 /// </summary>
 /// <param name="kanaler">Driftavbrottskanaler</param>
 public DriftavbrottMonitor(IEnumerable <string> kanaler)
 {
     workerClass = new BgWorker(new DriftavbrottKlient(), kanaler);
     workerClass.DriftavbrottStatus += workerClassDriftavbrottStatus;
     workerClass.ErrorOccurred      += workerClassOnErrorOccurred;
     workerThread = new Thread(workerClass.Start);
     workerThread.Start();
     while (workerThread.IsAlive != true)
     {
     }
 }
Esempio n. 10
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            //make sure that our dictionary is loaded before anything else
            if (BGData.RegExListLoaded != true)
            {
                MessageBox.Show("You must first load a RegEx list before you can process your texts.", "RegEx list not loaded!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            FolderBrowser.Description = "Please choose the location of your .txt files to analyze";
            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                BGData.TextFileFolder = FolderBrowser.SelectedPath.ToString();

                if (BGData.TextFileFolder != "")
                {
                    saveOutputDialog.Description  = "Please choose a folder for your output files";
                    saveOutputDialog.SelectedPath = BGData.TextFileFolder;
                    if (saveOutputDialog.ShowDialog() != DialogResult.Cancel)
                    {
                        if (FolderBrowser.SelectedPath == saveOutputDialog.SelectedPath)
                        {
                            MessageBox.Show("You can not use the same folder for text input and text output. If you do this, your original data would be overwritten. Please use a different folder for your output location.", "Folder selection error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        BGData.OutputFileLocation = saveOutputDialog.SelectedPath;
                        BGData.CompactWhitespace  = CompactWhitespaceCheckbox.Checked;
                        BGData.Filetype           = FiletypeTextbox.Text;

                        if (BGData.OutputFileLocation != "")
                        {
                            StartButton.Enabled               = false;
                            CaseSensitiveCheckbox.Enabled     = false;
                            ScanSubfolderCheckbox.Enabled     = false;
                            EncodingDropdown.Enabled          = false;
                            LoadDictionaryButton.Enabled      = false;
                            CompactWhitespaceCheckbox.Enabled = false;
                            FiletypeTextbox.Enabled           = false;

                            BgWorker.RunWorkerAsync(BGData);
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (!uint.TryParse(SegmentTextbox.Text, out uint n) || int.Parse(SegmentTextbox.Text) < 1)
            {
                MessageBox.Show("Your selected number of segments must be a postive integer (i.e., a whole number greater than zero).", "Segmentation Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            FolderBrowser.Description = "Please choose the location of your .txt files to analyze";
            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                BGData.TextFileFolder = FolderBrowser.SelectedPath.ToString();

                if (BGData.TextFileFolder != "")
                {
                    saveFileDialog.FileName = "POSTModern_Results.csv";

                    saveFileDialog.InitialDirectory = BGData.TextFileFolder;
                    if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
                    {
                        BGData.OutputFileLocation = saveFileDialog.FileName;
                        BGData.SelectedModel      = ModelSelectionBox.SelectedItem.ToString();
                        BGData.OutputTaggedText   = SavePOStextCheckbox.Checked;
                        BGData.OrderedPOSTagText  = IncludeOrderedPOSTagsCheckbox.Checked;
                        BGData.NormalizeOutput    = NormalizeOutputCheckbox.Checked;
                        BGData.NumSegments        = int.Parse(SegmentTextbox.Text);

                        if (BGData.OutputFileLocation != "")
                        {
                            StartButton.Enabled                   = false;
                            ScanSubfolderCheckbox.Enabled         = false;
                            EncodingDropdown.Enabled              = false;
                            ModelSelectionBox.Enabled             = false;
                            SavePOStextCheckbox.Enabled           = false;
                            IncludeOrderedPOSTagsCheckbox.Enabled = false;
                            NormalizeOutputCheckbox.Enabled       = false;
                            SegmentTextbox.Enabled                = false;

                            BgWorker.RunWorkerAsync(BGData);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Check whether the strategy have been changed.
        /// </summary>
        private void OptimizerFormClosing(object sender, FormClosingEventArgs e)
        {
            if (!_isReset)
            {
                SaveOptions();
            }

            if (_isOptimizing)
            {
                // Cancel the asynchronous operation.
                BgWorker.CancelAsync();
                e.Cancel = true;
                return;
            }

            if (DialogResult == DialogResult.Cancel && _isStartegyChanged)
            {
                DialogResult dr = MessageBox.Show(Language.T("Do you want to accept changes to the strategy?"),
                                                  Language.T("Optimizer"), MessageBoxButtons.YesNoCancel,
                                                  MessageBoxIcon.Question);

                switch (dr)
                {
                case DialogResult.Cancel:
                    e.Cancel = true;
                    return;

                case DialogResult.Yes:
                    DialogResult = DialogResult.OK;
                    break;

                case DialogResult.No:
                    DialogResult = DialogResult.Cancel;
                    break;
                }
            }
            else if (DialogResult == DialogResult.OK && !_isStartegyChanged)
            {
                DialogResult = DialogResult.Cancel;
            }

            FormFSB.Visible = true;
        }
Esempio n. 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (Convert.ToUInt32(WordWindowSizeTextbox.Text) < 2)
            {
                MessageBox.Show("Word Window Size must be >= 2.", "Problem with settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Convert.ToUInt32(PhraseLengthTextbox.Text) > Convert.ToUInt32(WordWindowSizeTextbox.Text) - 1)
            {
                MessageBox.Show("Max Phrase Length must be less\r\n than the Word Window Size.", "Problem with settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            FolderBrowser.Description = "Please choose the location of your .txt files";
            FolderBrowser.ShowDialog();
            string TextFileFolder = FolderBrowser.SelectedPath.ToString();

            if (TextFileFolder != "")
            {
                saveFileDialog.FileName = "Repeatalizer.csv";

                saveFileDialog.InitialDirectory = TextFileFolder;
                saveFileDialog.ShowDialog();


                string OutputFileLocation = saveFileDialog.FileName;

                if (OutputFileLocation != "")
                {
                    button1.Enabled = false;
                    WordWindowSizeTextbox.Enabled = false;
                    FunctionWordTextBox.Enabled   = false;
                    ScanSubfolderCheckbox.Enabled = false;
                    PunctuationBox.Enabled        = false;
                    EncodingDropdown.Enabled      = false;
                    PhraseLengthTextbox.Enabled   = false;
                    BigWordTextBox.Enabled        = false;
                    BgWorker.RunWorkerAsync(new string[] { TextFileFolder, OutputFileLocation });
                }
            }
        }
Esempio n. 14
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            //make sure that our dictionary is loaded before anything else
            if (DictData.DictionaryLoaded != true)
            {
                MessageBox.Show("You must first load a dictionary file before you can analyze your texts.", "Dictionary not loaded!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            FolderBrowser.Description = "Please choose the location of your .txt files to analyze";
            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                DictData.TextFileFolder = FolderBrowser.SelectedPath.ToString();

                if (DictData.TextFileFolder != "")
                {
                    saveFileDialog.FileName = "RIOTLite.csv";

                    saveFileDialog.InitialDirectory = DictData.TextFileFolder;
                    if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
                    {
                        DictData.OutputFileLocation = saveFileDialog.FileName;
                        DictData.RawWordCounts      = RawWCCheckbox.Checked;

                        if (DictData.OutputFileLocation != "")
                        {
                            StartButton.Enabled           = false;
                            ScanSubfolderCheckbox.Enabled = false;
                            PunctuationBox.Enabled        = false;
                            EncodingDropdown.Enabled      = false;
                            LoadDictionaryButton.Enabled  = false;
                            RawWCCheckbox.Enabled         = false;

                            BgWorker.RunWorkerAsync(DictData);
                        }
                    }
                }
            }
        }
Esempio n. 15
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            FolderBrowser.Description = "Please choose the location of your .txt files to process";
            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                DictData.TextFileFolder = FolderBrowser.SelectedPath.ToString();

                if (DictData.TextFileFolder != "")
                {
                    saveOutputDialog.Description  = "Please choose a folder for your output files";
                    saveOutputDialog.SelectedPath = DictData.TextFileFolder;
                    if (saveOutputDialog.ShowDialog() != DialogResult.Cancel)
                    {
                        if (FolderBrowser.SelectedPath == saveOutputDialog.SelectedPath)
                        {
                            MessageBox.Show("You can not use the same folder for text input and text output. If you do this, your original data would be overwritten. Please use a different folder for your output location.", "Folder selection error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        DictData.OutputFileLocation = saveOutputDialog.SelectedPath;
                        DictData.FileExtension      = FileTypeTextbox.Text.Trim();
                        DictData.FixNULtermination  = NulTerminatedFixCheckbox.Checked;


                        if (DictData.OutputFileLocation != "")
                        {
                            StartButton.Enabled = false;
                            NulTerminatedFixCheckbox.Enabled = false;
                            ScanSubfolderCheckbox.Enabled    = false;
                            InputEncodingDropdown.Enabled    = false;
                            OutputEncodingDropdown.Enabled   = false;
                            FileTypeTextbox.Enabled          = false;

                            BgWorker.RunWorkerAsync(DictData);
                        }
                    }
                }
            }
        }
Esempio n. 16
0
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int showProgressEnableCounter = 0;
            //sync do
            var task = Task.Factory.StartNew(() => {
                var updateResult = ServiceClient.UploadFile(this.DestFileName, "", tokenSource.Token);
                if (!updateResult)
                {
                    IsSuccess = false;
                    MessageBox.Show($"upload { this.DestFileName} fail");
                }
                //delete client file
                File.Delete(this.DestFileName);
            }).ContinueWith(t =>
                            BgWorker.CancelAsync());
            int k = 0;

            while (true)
            {
                if (BgWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                Interlocked.Increment(ref showProgressEnableCounter);
                if (k == showProgressEnableCounter / 1000000)
                {
                    continue;
                }
                k = showProgressEnableCounter / 1000000;
                if (k > 100)
                {
                    showProgressEnableCounter = 0;
                }

                BgWorker.ReportProgress(k);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Starts intrabar data loading.
        /// </summary>
        private void StartLoading()
        {
            if (_isLoadingNow)
            {
                // Cancel the asynchronous operation.
                BgWorker.CancelAsync();
                return;
            }

            Cursor              = Cursors.WaitCursor;
            ProgressBar.Value   = 0;
            _warningMessage     = string.Empty;
            _isLoadingNow       = true;
            _progressPercent    = 0;
            LblProgress.Visible = true;
            ChbAutoscan.Visible = false;
            ChbTickScan.Visible = false;

            BtnClose.Text = Language.T("Cancel");

            // Start the bgWorker
            BgWorker.RunWorkerAsync();
        }
Esempio n. 18
0
 /// <summary>
 /// Begins processing the log
 /// </summary>
 public void Run()
 {
     ButtonText     = "Cancel";
     Metadata.State = RowState.Parsing;
     BgWorker.RunWorkerAsync(this);
 }
Esempio n. 19
0
 public void UpdateProgress(string status, int percent)
 {
     BgWorker.UpdateProgress(this, status, percent);
 }
Esempio n. 20
0
 /// <summary>
 /// 执行任务
 /// </summary>
 public void Do()
 {
     BgWorker.RunWorkerAsync();
 }
Esempio n. 21
0
//   _____ _ _      _       _____ _             _     ____        _   _
//  / ____| (_)    | |     / ____| |           | |   |  _ \      | | | |
// | |    | |_  ___| | __ | (___ | |_ __ _ _ __| |_  | |_) |_   _| |_| |_ ___  _ __
// | |    | | |/ __| |/ /  \___ \| __/ _` | '__| __| |  _ <| | | | __| __/ _ \| '_ \ 
// | |____| | | (__|   <   ____) | || (_| | |  | |_  | |_) | |_| | |_| || (_) | | | |
//  \_____|_|_|\___|_|\_\ |_____/ \__\__,_|_|   \__| |____/ \__,_|\__|\__\___/|_| |_|



        private void StartButton_Click(object sender, EventArgs e)
        {
            if (BgWorker.IsBusy)
            {
                BgWorker.CancelAsync();
                return;
            }


            string tokenstring = TokenTextbox.Text;

            tokenstring = tokenstring.Replace("\r\n", "\n").Replace('\r', '\n');
            tokenstring = tokenstring.Replace("\n", Environment.NewLine);
            tokenstring = tokenstring.Trim(Environment.NewLine.ToCharArray());

            string triplenewline = Environment.NewLine + Environment.NewLine + Environment.NewLine;
            string doublenewline = Environment.NewLine + Environment.NewLine;

            while (tokenstring.Contains(triplenewline))
            {
                tokenstring = tokenstring.Replace(triplenewline, doublenewline);
            }

            TokenTextbox.Text = tokenstring;


            //make sure the user has entered at least one thing
            if (TokenTextbox.Lines.Length == 0)
            {
                MessageBox.Show("You must enter at least one token.", "No Tokens Entered", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (LastColumnComboBox.SelectedIndex <= FirstColumnComboBox.SelectedIndex)
            {
                MessageBox.Show("Your \"Vector End\" column needs to come after\r\nyour \"Vector Start\" column.", "Invalid vector range", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            this.Enabled = false;



            FolderBrowser.SelectedPath = Path.GetDirectoryName(openFileDialog.FileName);

            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                BgWorkerInformation BgData = new BgWorkerInformation();

                BgData.InputFile      = FilenameDisplayBox.Text;
                BgData.OutputLocation = FolderBrowser.SelectedPath.ToString();
                BgData.HasHeaders     = HeaderRowDropdown.SelectedItem.ToString();
                BgData.Delimiters     = DelimiterTextBox.Text.ToString();
                BgData.UsingQuotes    = EnclosedInQuotesDropdown.SelectedItem.ToString();

                BgData.TokenCol    = TokenColumnComboBox.SelectedIndex;
                BgData.StartingCol = FirstColumnComboBox.SelectedIndex;
                BgData.EndingCol   = LastColumnComboBox.SelectedIndex;



                //here, we have to go through some steps to get our user-submitted word list into
                //separate chunks. First, we figure out where empty linebreaks occur

                List <int> split_indices = new List <int>();
                int        lastIndex     = 0;

                while ((lastIndex = Array.IndexOf(TokenTextbox.Lines, "", lastIndex)) != -1)
                {
                    split_indices.Add(lastIndex);
                    lastIndex++;
                }


                //now, we set up an array of lists so that we can assign tokens to each
                //list
                List <string>[] token_list_array = new List <string> [split_indices.Count() + 1];
                for (int i = 0; i <= split_indices.Count(); i++)
                {
                    token_list_array[i] = new List <string>();
                }

                string[] TokenTextbox_As_Array = TokenTextbox.Lines;

                //now, we do the assigning
                int split_position = 0;
                for (int i = 0; i < TokenTextbox_As_Array.Length; i++)
                {
                    if (split_position < split_indices.Count() && i >= split_indices[split_position])
                    {
                        split_position++;
                        continue;
                    }
                    token_list_array[split_position].Add(TokenTextbox_As_Array[i]);
                }


                BgData.Tokens = new HashSet <string> [token_list_array.Length];

                for (int i = 0; i < token_list_array.Length; i++)
                {
                    BgData.Tokens[i] = new HashSet <string>(token_list_array[i].Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray());
                }


                //we use "distinct" because we can't have dupes in a hashset
                BgData.Tokens_Altogether = new HashSet <string>(TokenTextbox.Lines.Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray());



                BgData.OmitBelowValue = 1.0 - ((OmissionValueComboBox.SelectedIndex + 1.0) / 10.0);

                DisableButtons();

                StartButton.Text = "Cancel";

                try
                {
                    using (StreamWriter outputFile = new StreamWriter(new FileStream(Path.Combine(BgData.OutputLocation, "_WELP_SeedList.txt"),
                                                                                     FileMode.Create, FileAccess.Write), Encoding.GetEncoding(EncodingDropdown.SelectedItem.ToString())))
                    {
                        outputFile.Write(TokenTextbox.Text);
                    }
                }
                catch
                {
                    MessageBox.Show("There was an error writing your seed list to the" + "\r\n" +
                                    "output directory. Please check all of your settings" + "\r\n" +
                                    "and folders before starting again.", "Output Write Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Enabled     = true;
                    StartButton.Text = "Start!";
                    EnableButtons();
                    return;
                }

                BgWorker.RunWorkerAsync(BgData);
            }

            this.Enabled = true;
        }
Esempio n. 22
0
 /// <summary>
 /// Cancels the log's processing
 /// </summary>
 public void Cancel()
 {
     Status         = "Cancelling...";
     Metadata.State = RowState.Cancelling;
     BgWorker.CancelAsync();
 }
Esempio n. 23
0
 public void Cancel()
 {
     BgWorker.CancelAsync();
 }
Esempio n. 24
0
//   _____ _ _      _       _____ _             _     ____        _   _
//  / ____| (_)    | |     / ____| |           | |   |  _ \      | | | |
// | |    | |_  ___| | __ | (___ | |_ __ _ _ __| |_  | |_) |_   _| |_| |_ ___  _ __
// | |    | | |/ __| |/ /  \___ \| __/ _` | '__| __| |  _ <| | | | __| __/ _ \| '_ \ 
// | |____| | | (__|   <   ____) | || (_| | |  | |_  | |_) | |_| | |_| || (_) | | | |
//  \_____|_|_|\___|_|\_\ |_____/ \__\__,_|_|   \__| |____/ \__,_|\__|\__\___/|_| |_|



        private void StartButton_Click(object sender, EventArgs e)
        {
            if (BgWorker.IsBusy)
            {
                BgWorker.CancelAsync();
                return;
            }


            int number_of_columns = ColumnNameCheckedListbox.CheckedIndices.Count;

            if (number_of_columns < 1)
            {
                MessageBox.Show("You must choose at least one column to keep.", "No columns selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //validate the subfolder numbers



            this.Enabled = false;


            FolderBrowser.Description = "Please choose the OUTPUT location for your files";

            FolderBrowser.SelectedPath = Path.GetDirectoryName(openFileDialog.FileName);


            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                BgWorkerInformation BgData = new BgWorkerInformation();

                BgData.InputFile      = FilenameDisplayBox.Text;
                BgData.OutputLocation = FolderBrowser.SelectedPath.ToString();
                BgData.HasHeaders     = HeaderRowDropdown.SelectedItem.ToString();
                BgData.Delimiters     = DelimiterTextBox.Text.ToString();
                BgData.UsingQuotes    = EnclosedInQuotesDropdown.SelectedItem.ToString();

                List <int> CheckedIndices = new List <int>();
                foreach (Object item in ColumnNameCheckedListbox.CheckedItems)
                {
                    CheckedIndices.Add(ColumnNameCheckedListbox.Items.IndexOf(item));
                }

                BgData.KeepCols        = CheckedIndices.ToArray();
                BgData.NumberOfColumns = BgData.KeepCols.Length;



                DisableButtons();

                StartButton.Text = "Cancel";

                BgWorker.RunWorkerAsync(BgData);
            }



            this.Enabled = true;
        }
Esempio n. 25
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("In a moment, you will be asked to locate the folder that contains your .txt files that you would like to translate.", "Locate your input files", MessageBoxButtons.OK, MessageBoxIcon.Information);

            FolderBrowser.Description = "Please choose the location of your .txt files to process";
            if (FolderBrowser.ShowDialog() != DialogResult.Cancel)
            {
                BackgroundWorkerData.TextFileFolder = FolderBrowser.SelectedPath.ToString();

                if (BackgroundWorkerData.TextFileFolder != "")
                {
                    MessageBox.Show("In a moment, you will be asked to choose an output location. This is where your translated texts will be stored.", "Choose an output location", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    saveOutputDialog.Description  = "Please choose a folder for your output files";
                    saveOutputDialog.SelectedPath = BackgroundWorkerData.TextFileFolder;
                    if (saveOutputDialog.ShowDialog() != DialogResult.Cancel)
                    {
                        if (FolderBrowser.SelectedPath == saveOutputDialog.SelectedPath)
                        {
                            MessageBox.Show("You can not use the same folder for text input and text output. If you do this, your original data would be overwritten. Please use a different folder for your output location.", "Folder selection error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        BackgroundWorkerData.OutputFileLocation = saveOutputDialog.SelectedPath;
                        BackgroundWorkerData.FileExtension      = FileTypeTextbox.Text.Trim();

                        try
                        {
                            BackgroundWorkerData.MaxCharsPerRequest = Convert.ToInt32(MaxCharsPerRequestTextbox.Text);
                            BackgroundWorkerData.DurationLength     = Convert.ToInt32(DurationLengthTextbox.Text);
                            BackgroundWorkerData.MaxRetries         = Convert.ToInt32(MaxRetriesPerRequestTextbox.Text);
                        }
                        catch
                        {
                            BackgroundWorkerData.MaxCharsPerRequest = 5000;
                            BackgroundWorkerData.DurationLength     = 100;
                            BackgroundWorkerData.MaxRetries         = 3;
                        }

                        BackgroundWorkerData.OutputLang = LanguageIndices[OutputTextLanguageBox.SelectedIndex];
                        BackgroundWorkerData.InputLang  = LanguageIndices[InputTextLanguageBox.SelectedIndex];


                        if (BackgroundWorkerData.OutputFileLocation != "")
                        {
                            StartButton.Enabled            = false;
                            ScanSubfolderCheckbox.Enabled  = false;
                            InputEncodingDropdown.Enabled  = false;
                            OutputEncodingDropdown.Enabled = false;
                            FileTypeTextbox.Enabled        = false;

                            InputTextLanguageBox.Enabled        = false;
                            OutputTextLanguageBox.Enabled       = false;
                            MaxCharsPerRequestTextbox.Enabled   = false;
                            DurationLengthTextbox.Enabled       = false;
                            MaxRetriesPerRequestTextbox.Enabled = false;

                            BgWorker.RunWorkerAsync(BackgroundWorkerData);
                        }
                    }
                }
            }
        }
Esempio n. 26
0
 public void Run()
 {
     BgWorker.RunWorkerAsync(Range);
 }
Esempio n. 27
0
 /// <summary>
 /// Cancels the log's processing
 /// </summary>
 public void Cancel()
 {
     State = RowState.Cancelling;
     BgWorker.CancelAsync();
 }
        /// <summary>
        /// BtnGenerate_Click
        /// </summary>
        private void BtnGenerateClick(object sender, EventArgs e)
        {
            if (_isGenerating)
            {
                // Cancel the asynchronous operation
                BgWorker.CancelAsync();
            }
            else
            {
                // Start the bgWorker
                PrepareStrategyForGenerating();
                CheckForLockedSlots();
                PrepareIndicatorLists();
                bool isEnoughIndicators = CheckAvailableIndicators();

                if (_isEntryLocked && _isExitLocked || !isEnoughIndicators)
                {
                    SystemSounds.Hand.Play();
                    return;
                }

                Cursor = Cursors.WaitCursor;

                _minutes          = (int)NUDWorkingMinutes.Value;
                ProgressBar.Style = _minutes > 0 ? ProgressBarStyle.Blocks : ProgressBarStyle.Marquee;

                GeneratedDescription = String.Empty;

                foreach (Control control in PnlCommon.Controls)
                {
                    control.Enabled = false;
                }
                foreach (Control control in PnlLimitations.Controls)
                {
                    control.Enabled = false;
                }
                foreach (Control control in PnlSettings.Controls)
                {
                    control.Enabled = false;
                }

                IndicatorsField.BlockIndicatorChange();

                TsbtLockAll.Enabled      = false;
                TsbtUnlockAll.Enabled    = false;
                TsbtLinkAll.Enabled      = false;
                TsbtOverview.Enabled     = false;
                TsbtStrategyInfo.Enabled = false;

                LblCalcStrInfo.Enabled = true;
                LblCalcStrNumb.Enabled = true;
                ChbHideFSB.Enabled     = true;

                BtnAccept.Enabled = false;
                BtnCancel.Enabled = false;
                BtnGenerate.Text  = Language.T("Stop");

                _isGenerating = true;

                ProgressBar.Value = 1;
                _progressPercent  = 0;
                _cycles           = 0;

                if (ChbGenerateNewStrategy.Checked)
                {
                    Top10Field.ClearTop10Slots();
                }

                BgWorker.RunWorkerAsync();
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Optimize.
        /// </summary>
        private void BtnOptimizeClick(object sender, EventArgs e)
        {
            if (_isOptimizing)
            {
                // Cancel the asynchronous operation.
                BgWorker.CancelAsync();
                return;
            }

            if (ChbOptimizerWritesReport.Checked)
            {
                InitReport();
            }

            // Counts the checked parameters
            _checkedParams = 0;
            for (int i = 0; i < _parameters; i++)
            {
                if (AchbxParameterName[i].Checked)
                {
                    _checkedParams++;
                }
            }

            // If there are no checked returns
            if (_checkedParams < 1)
            {
                SystemSounds.Hand.Play();
                return;
            }

            // Contains the checked parameters only
            _aiChecked = new int[_checkedParams];
            int indexChecked = 0;

            for (int i = 0; i < _parameters; i++)
            {
                if (AchbxParameterName[i].Checked)
                {
                    _aiChecked[indexChecked++] = i;
                }
            }

            SetNecessaryCycles();

            Cursor            = Cursors.WaitCursor;
            ProgressBar.Value = 1;
            _progressPercent  = 0;
            _computedCycles   = 0;
            _isOptimizing     = true;
            BtnCancel.Enabled = false;
            BtnAccept.Enabled = false;
            BtnOptimize.Text  = Language.T("Stop");

            for (int i = 0; i <= (int)OptimizerButtons.ResetStrategy; i++)
            {
                AOptimizerButtons[i].Enabled = false;
            }

            foreach (Control control in PnlParams.Controls)
            {
                if (control.GetType() != typeof(Label))
                {
                    control.Enabled = false;
                }
            }

            foreach (Control control in PnlLimitations.Controls)
            {
                control.Enabled = false;
            }

            foreach (Control control in PnlSettings.Controls)
            {
                control.Enabled = false;
            }
            ChbHideFSB.Enabled = true;

            // Start the bgWorker
            BgWorker.RunWorkerAsync();
        }