private void Handler(object?sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                if (_completionWindow != null)
                {
                    if (_completionWindow.CompletionList.CurrentList.Count == 0)
                    {
                        _completionWindow.Close();
                    }
                    else
                    {
                        return;
                    }
                }

                if (e.KeyModifiers == KeyModifiers.Shift)
                {
                    editor.TextArea.PerformTextInput("\n");
                }
                else
                {
                    ((PacketDocumentViewModel)DataContext !).ApplyFilterCommand.ExecuteAsync();
                }
                e.Handled = true;
            }
        }
        private static void OnAccept(object?sender, ExecutedRoutedEventArgs args)
        {
            var editor = (TextEditor?)sender;

            args.Handled = true;
            ((PacketDocumentViewModel)editor !.DataContext !).ApplyFilterCommand.ExecuteAsync();
        }
Пример #3
0
        private async Task LoadSniff()
        {
            LoadingInProgress   = true;
            FilteringInProgress = true;

            AssertNoOnGoingTask();
            currentActionToken = new CancellationTokenSource();

            try
            {
                var packets = await sniffLoader.LoadSniff(solutionItem.File, currentActionToken.Token, this);

                if (currentActionToken.IsCancellationRequested)
                {
                    LoadingInProgress  = false;
                    currentActionToken = null;
                    return;
                }

                using (AllPackets.SuspendNotifications())
                {
                    foreach (var packet in packets.Packets_)
                    {
                        AllPackets.Add(packetViewModelCreator.Process(packet) !);
                    }
                }
            }
            catch (ParserException e)
            {
                await messageBoxService.ShowDialog(new MessageBoxFactory <bool>()
                                                   .SetIcon(MessageBoxIcon.Error)
                                                   .SetTitle("Error with parser")
                                                   .SetMainInstruction("Parser error")
                                                   .SetContent(e.Message)
                                                   .WithOkButton(false)
                                                   .Build());

                if (CloseCommand != null)
                {
                    await CloseCommand.ExecuteAsync();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            FilteringProgress = -1;
            await SplitPacketsIfNeededAsync().ConfigureAwait(true);

            LoadingInProgress   = false;
            FilteringInProgress = false;
            currentActionToken  = null;
            await ApplyFilterCommand.ExecuteAsync();
        }