Exemple #1
0
        private void Analyze(bool silent)
        {
            var watch    = new DiagnosticTimer();
            var bufferId = NotepadPPGateway.GetCurrentBufferId();

            var textLength = PluginBase.CurrentScintillaGateway.GetTextLength();
            var text       = PluginBase.CurrentScintillaGateway.GetTextRange(0, Math.Min(100000, textLength));

            watch.Checkpoint("GetText");

            var csvSettings = CsvAnalyzer.Analyze(text);

            if (csvSettings.Separator == '\0' && csvSettings.FieldWidths == null)
            {
                if (silent)
                {
                    return;
                }

                var askUserDialog = new ParseSettings(csvSettings);
                this.UiThread(() => askUserDialog.ShowDialog());
                if (askUserDialog.DialogResult != DialogResult.OK)
                {
                    return;
                }
                csvSettings = askUserDialog.Settings;
            }
            watch.Checkpoint("Analyze");

            using (var sr = ScintillaStreams.StreamAllText())
            {
                this.Parse(csvSettings, watch, sr, bufferId);
            }
        }
Exemple #2
0
 public void StartParse(CsvSettings settings)
 {
     StartSomething(() => Parse(settings,
                                new DiagnosticTimer(),
                                PluginBase.CurrentScintillaGateway.GetAllText(),
                                NotepadPPGateway.GetCurrentBufferId()));
 }
Exemple #3
0
 public void StartParse(CsvSettings settings)
 {
     this.StartSomething(() =>
     {
         using (var sr = ScintillaStreams.StreamAllText())
         {
             this.Parse(settings,
                        new DiagnosticTimer(),
                        sr,
                        NotepadPPGateway.GetCurrentBufferId());
         }
     });
 }
Exemple #4
0
        private void OnClickExecButton(object sender, EventArgs e)
        {
            this.StartSomething(() =>
            {
                var watch    = new DiagnosticTimer();
                var bufferId = NotepadPPGateway.GetCurrentBufferId();

                this.Execute(bufferId, watch);

                var diagnosticMessage = watch.LastCheckpoint("Save query in history");
                Trace.TraceInformation(diagnosticMessage);
                if (Main.Settings.DebugMode)
                {
                    this.Message(diagnosticMessage);
                }
            });
        }