示例#1
0
        private void ResetResults()
        {
            m_Info = new CSyntacticInfo();
            LANGUAGES LangID = (ChooseLangComboBox.SelectedItem as ICloneExtension).LanguageID();

            m_Counter = new CCodeSizeDetector(LangID, new CLoadFilesOptions(CodeLocationTextBox.Text, ChoosenFilesExtensionsTextBox.Text));
            m_StopWatch.Reset();
        }
示例#2
0
        private void InitCodeCounter()
        {
            m_Info      = new CSyntacticInfo();
            m_StopWatch = new Stopwatch();
            LANGUAGES LangID = (ChooseLangComboBox.SelectedItem as ICloneExtension).LanguageID();

            m_Counter          = new CCodeSizeDetector(LangID, new CLoadFilesOptions(CodeLocationTextBox.Text, ChoosenFilesExtensionsTextBox.Text));
            m_BackgroundThread = new BackgroundWorker();
            m_BackgroundThread.WorkerReportsProgress      = true;
            m_BackgroundThread.WorkerSupportsCancellation = true;

            m_BackgroundThread.DoWork += (o, e) =>
            {
                m_Info = m_Counter.Calculate();
            };

            m_BackgroundThread.ProgressChanged += (o, e) =>
            {
                // ВНИМАНИЕ! ЗДЕСЬ НЕ ДОЛЖНО БЫТЬ НИКАКИХ Application.DoEvents();
                ShowResults();
            };

            m_BackgroundThread.RunWorkerCompleted += (o, e) =>
            {
                ShowResults();

                if (m_Counter.GetCancelOperationFlag())
                {
                    StatusLabel.Text = ICloneLocalization.CMNMESS_OperationCancelled;
                }
                else
                {
                    if (e.Error != null)
                    {
                        StatusLabel.Text = ICloneLocalization.CMNMESS_OperationtDoneWithErrors;
                    }
                    else
                    {
                        ShowSyntacticInfo();
                        StatusLabel.Text = ICloneLocalization.CMNMESS_OperationDoneSuccesfully;
                    }
                }

                m_StopWatch.Stop();
                CancelOpButton.Enabled = false;
            };
        }
示例#3
0
        private void PrepareLoadFilesOptions()
        {
            ICloneExtension     Ext              = ChooseLangComboBox.SelectedItem as ICloneExtension;
            CICloneEncodingInfo EncodeInfo       = CodeEncodingComboBox.SelectedItem as CICloneEncodingInfo;
            CLoadFilesOptions   LoadFilesOptions = new CLoadFilesOptions(CodeLocationTextBox.Text, ChoosenFilesExtensionsTextBox.Text, EncodeInfo.GetEncodingInfo().GetEncoding(), new CCodePreProcessingOptions(Ext.GetCommentSymbols()));

            LoadFilesOptions.SetSkippingFolders(Properties.Settings.Default.CSWSkippingFolders);
            LoadFilesOptions.SetIsUseParallelExtensions(Properties.Settings.Default.CSWIsUseParallelExtensions);

            m_CloneSearchExecutor.SetLoadFilesOptions(LoadFilesOptions);
            if (AutomaticKminCalculationCheckBox.Checked)
            {
                CCodeSizeDetector Counter = new CCodeSizeDetector(Ext.LanguageID(), new CLoadFilesOptions(CodeLocationTextBox.Text, ChoosenFilesExtensionsTextBox.Text));
                //Counter.LoadFilesProgress += new EventHandler(ReportProgress);
                CSyntacticInfo info = Counter.Calculate();
                CCodeFragment.SetKmin(info.Kmin);
            }
            else
            {
                CCodeFragment.SetKmin((long)KminValue.Value);
            }
            m_CloneSearchExecutor.Extension = Ext;
        }