Exemple #1
0
        private void Init()
        {
            progressWidget = new ProgressWidget();

            refreshButton          = new Button("Refresh");
            refreshButton.Clicked += async(sender, e) => await RebuildIndex();

            pageStatusLabel = new Label();

            lastRefreshLabel = new Label("-");
            var autoRefreshBox = new HBox();

            autoRefreshBox.PackStart(pageStatusLabel);
            autoRefreshBox.PackStart(new Label(string.Empty), true);
            autoRefreshBox.PackStart(progressWidget);
            autoRefreshBox.PackStart(new Label(string.Empty), true);
            autoRefreshBox.PackStart(new Label("Log state from:"));
            autoRefreshBox.PackStart(lastRefreshLabel);
            autoRefreshBox.PackStart(refreshButton);
            PackStart(autoRefreshBox);

            var hbox = new HBox();

            var buttons = new LogLevelsSelectionWidget();

            hbox.PackStart(new Label("Filter:"));
            hbox.PackStart(buttons);

            hbox.PackStart(new HSeparator());
            filterTextEntry = new TextEntry();
            hbox.PackStart(filterTextEntry, true);
            filterTextEntry.KeyReleased += async(sender, e) =>
            {
                if (e.Key == Key.Return || e.Key == Key.NumPadEnter)
                {
                    await HandleFilterButtonClicked();
                }
            };
            var queryButton = new Button("Query");

            queryButton.Clicked += async(sender, e) => await HandleFilterButtonClicked();

            hbox.PackStart(queryButton);

            var helpButton = new Button("Help");

            helpButton.Clicked += (sender, e) =>
            {
                using (var dialog = new LogViewerHelpDialog())
                {
                    dialog.Run();
                }
            };
            hbox.PackStart(helpButton);

            listViewLog = new ListViewLog(false);
            listViewLog.ButtonPressed += (s, ea) =>
            {
                if (ea.Button != PointerButton.Right)
                {
                    return;
                }

                var menu = new Menu();
                var item = new MenuItem("Show surrounding log entries");

                item.Clicked += async(sender, e) =>
                {
                    var id = listViewLog.SelectedItemId;
                    if (!id.HasValue)
                    {
                        return;
                    }

                    var idFrom = Math.Max(0, id.Value - 20);
                    var idTo   = id.Value + 20;
                    filterTextEntry.Text = string.Format("id:[{0} TO {1}]", idFrom, idTo);
                    await FilterEntriesAsync(progressWidget.ProgressMonitor);
                };

                menu.Items.Add(item);
                menu.Popup();
            };

            PackStart(listViewLog, true);
            PackStart(hbox);

            buttons.SelectionChanged += async(level, isSelected) =>
            {
                if (isSelected)
                {
                    levels.Add(level);
                }
                else
                {
                    levels.Remove(level);
                }
                await FilterEntriesAsync(progressWidget.ProgressMonitor, true);
            };

            listViewLog.Scrolled += async state =>
            {
                if (Interlocked.Increment(ref eventDepth) > 1)
                {
                    Interlocked.Decrement(ref eventDepth);
                    return;
                }

                await LoadEntriesAsync(progressWidget.ProgressMonitor,
                                       state == ListViewLog.ScrolledState.ScrolledUp?Direction.Backward : Direction.Forward,
                                       () => Interlocked.Decrement(ref eventDepth));
            };

            var searchBox = new HBox();

            searchTextEntry              = new TextEntry();
            searchTextEntry.KeyReleased += async(sender, e) =>
            {
                if (e.Key == Key.Return || e.Key == Key.NumPadEnter)
                {
                    await HandleSearchButtonClicked();
                }
            };
            searchBox.PackStart(new Label("Search:"));
            searchBox.PackStart(searchTextEntry, true);
            searchButton          = new Button("Search");
            searchButton.Clicked += async(sender, e) => await HandleSearchButtonClicked();

            searchBox.PackStart(searchButton);
            searchLabel                     = new Label();
            nextSearchResultButton          = new Button("Next");
            prevSearchResultButton          = new Button("Previous");
            resetSearchButton               = new Button("Reset");
            resetSearchButton.Clicked      += (sender, e) => ResetSearch();
            nextSearchResultButton.Clicked += async(sender, e) => await SearchEntriesAsync(progressWidget.ProgressMonitor, Direction.Forward);

            prevSearchResultButton.Clicked += async(sender, e) => await SearchEntriesAsync(progressWidget.ProgressMonitor, Direction.Backward);

            searchBox.PackStart(searchLabel);
            searchBox.PackStart(nextSearchResultButton);
            searchBox.PackStart(prevSearchResultButton);
            searchBox.PackStart(resetSearchButton);

            PackStart(searchBox);
            ResetSearch();

            RefreshPaging(0);
        }
Exemple #2
0
        private void Init()
        {
            progressWidget = new ProgressWidget();

            refreshButton = new Button("Refresh");
            refreshButton.Clicked += async (sender, e) => await RebuildIndex();

            pageStatusLabel = new Label();

            lastRefreshLabel = new Label("-");
            var autoRefreshBox = new HBox();
            autoRefreshBox.PackStart(pageStatusLabel);
            autoRefreshBox.PackStart(new Label(string.Empty), true);
            autoRefreshBox.PackStart(progressWidget);
            autoRefreshBox.PackStart(new Label(string.Empty), true);
            autoRefreshBox.PackStart(new Label("Log state from:"));
            autoRefreshBox.PackStart(lastRefreshLabel);
            autoRefreshBox.PackStart(refreshButton);
            PackStart(autoRefreshBox);

            var hbox = new HBox();

            var buttons = new LogLevelsSelectionWidget();

            hbox.PackStart(new Label("Filter:"));
            hbox.PackStart(buttons);

            hbox.PackStart(new HSeparator());
            filterTextEntry = new TextEntry();
            hbox.PackStart(filterTextEntry, true);
            filterTextEntry.KeyReleased += async (sender, e) => 
            {
                if (e.Key == Key.Return || e.Key == Key.NumPadEnter)
                {
                    await HandleFilterButtonClicked();
                }
            };
            var queryButton = new Button("Query");
            queryButton.Clicked += async (sender, e) => await HandleFilterButtonClicked();

            hbox.PackStart(queryButton);

            var helpButton = new Button("Help");
            helpButton.Clicked += (sender, e) => 
            {
                using (var dialog = new LogViewerHelpDialog())
                {
                    dialog.Run();
                }
            };
            hbox.PackStart(helpButton);

            listViewLog = new ListViewLog(false);
            listViewLog.ButtonPressed += (s, ea) =>
            {
                if (ea.Button != PointerButton.Right)
                {
                    return;
                }

                var menu = new Menu();
                var item = new MenuItem("Show surrounding log entries");

                item.Clicked += async (sender, e) =>
                {
                    var id = listViewLog.SelectedItemId;
                    if (!id.HasValue)
                    {
                        return;
                    }

                    var idFrom = Math.Max(0, id.Value - 20);
                    var idTo = id.Value + 20;
                    filterTextEntry.Text = string.Format("id:[{0} TO {1}]", idFrom, idTo);
                    await FilterEntriesAsync(progressWidget.ProgressMonitor);
                };

                menu.Items.Add(item);
                menu.Popup();
            };

            PackStart(listViewLog, true);
            PackStart(hbox);

            buttons.SelectionChanged += async (level, isSelected) => 
            {
                if (isSelected)
                {
                    levels.Add(level);
                }
                else
                {
                    levels.Remove(level);
                }
                await FilterEntriesAsync(progressWidget.ProgressMonitor, true);
            };

            listViewLog.Scrolled += async state =>
            {
                if(Interlocked.Increment(ref eventDepth) > 1)
                {
                    Interlocked.Decrement(ref eventDepth);
                    return;
                }

                await LoadEntriesAsync(progressWidget.ProgressMonitor, 
                    state == ListViewLog.ScrolledState.ScrolledUp ? Direction.Backward : Direction.Forward,
                    () => Interlocked.Decrement(ref eventDepth));
            };

            var searchBox = new HBox();
            searchTextEntry = new TextEntry();
            searchTextEntry.KeyReleased += async (sender, e) => 
            {
                if (e.Key == Key.Return || e.Key == Key.NumPadEnter)
                {
                    await HandleSearchButtonClicked();
                }
            };
            searchBox.PackStart(new Label("Search:"));
            searchBox.PackStart(searchTextEntry, true);
            searchButton = new Button("Search");
            searchButton.Clicked += async (sender, e) => await HandleSearchButtonClicked();
            searchBox.PackStart(searchButton);
            searchLabel = new Label();
            nextSearchResultButton = new Button("Next");
            prevSearchResultButton = new Button("Previous");
            resetSearchButton = new Button("Reset");
            resetSearchButton.Clicked += (sender, e) => ResetSearch();
            nextSearchResultButton.Clicked += async (sender, e) => await SearchEntriesAsync(progressWidget.ProgressMonitor, Direction.Forward);
            prevSearchResultButton.Clicked += async (sender, e) => await SearchEntriesAsync(progressWidget.ProgressMonitor, Direction.Backward);
            searchBox.PackStart(searchLabel);
            searchBox.PackStart(nextSearchResultButton);
            searchBox.PackStart(prevSearchResultButton);
            searchBox.PackStart(resetSearchButton);

            PackStart(searchBox);
            ResetSearch();

            RefreshPaging(0);
        }