public void Finish(int id)
 {
     ApplicationExtensions.InvokeInUIThread(() =>
     {
         widget.Visible = false;
     });
 }
        protected override void OnAttach(VideoBackend backend)
        {
            var videoPeripheral = (AutoRepaintingVideo)backend.Video;

            element     = videoPeripheral;
            lastRewrite = CustomDateTime.Now;
            EnsureAnalyserWidget();

            videoPeripheral.ConfigurationChanged += (w, h, f, e) => ApplicationExtensions.InvokeInUIThread(() => displayWidget.SetDisplayParameters(w, h, f, e));
            videoPeripheral.FrameRendered        += (f) => ApplicationExtensions.InvokeInUIThread(() => displayWidget.DrawFrame(f));

            displayWidget.InputAttached += i =>
            {
                if (i is IKeyboard)
                {
                    keyboardsComboBox.SelectedItem = i;
                }
                else if (i is IPointerInput)
                {
                    pointersComboBox.SelectedItem = i;
                }
            };

            if (backend.Frame != null)
            {
                // this must be called after setting `ConfigurationChanged` event;
                // otherwise the frame set here would be overrwritten by a new, empty, instance
                ApplicationExtensions.InvokeInUIThreadAndWait(() =>
                {
                    displayWidget.SetDisplayParameters(backend.Width, backend.Height, backend.Format, backend.Endianess);
                    displayWidget.DrawFrame(backend.Frame);
                });
            }
        }
        /// <summary>
        /// Draws the frame.
        /// </summary>
        /// <param name="frame">Frame represented as array of bytes. If this parameter is omitted previous frame is redrawn.</param>
        public void DrawFrame(byte[] frame = null)
        {
            if (!drawQueued)
            {
                lock (imgLock)
                {
                    if (img == null)
                    {
                        return;
                    }

                    if (frame != null)
                    {
                        converter.Convert(frame, ref outBuffer);
                        img.Copy(outBuffer);
                        cursorDrawn = false;
                    }

                    if (!anythingDrawnAfterLastReconfiguration && frame != null)
                    {
                        anythingDrawnAfterLastReconfiguration = true;
                        handler.Init();
                    }

                    ApplicationExtensions.InvokeInUIThread(QueueDraw);
                    drawQueued = true;
                }
            }
        }
 public void Run()
 {
     ApplicationExtensions.InvokeInUIThread(() => {
         var window     = new Window();
         window.Width   = 800;
         window.Height  = 600;
         window.Content = new LogViewer(LuceneLoggerBackend.Instance);
         window.Show();
     });
 }
Пример #5
0
        public void DrawFrame(byte[] frame)
        {
            if (!drawQueued)
            {
                lock (imgLock)
                {
                    if (img == null)
                    {
                        return;
                    }

                    converter.Convert(frame, ref outBuffer);
                    img.Copy(outBuffer);
                    ApplicationExtensions.InvokeInUIThread(QueueDraw);
                    drawQueued = true;
                }
            }
        }
            public void Update(int id, string description, int?progress)
            {
                ApplicationExtensions.InvokeInUIThread(() =>
                {
                    widget.Visible      = true;
                    widget.text.Text    = description;
                    widget.text.Visible = !string.IsNullOrEmpty(description);

                    if (progress.HasValue)
                    {
                        widget.progressBar.Indeterminate = false;
                        widget.progressBar.Fraction      = progress.Value / 100.0;
                    }
                    else
                    {
                        widget.progressBar.Indeterminate = true;
                    }
                });
            }
Пример #7
0
        private async Task LoadEntriesAsync(ProgressMonitor progressMonitor, Direction direction, Action afterCallback = null)
        {
            var view = new ViewFilter {
                LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text
            };

            using (var progress = progressMonitor.Start("Filtering log..."))
            {
                var referenceId = (direction == Direction.Backward) ? listViewLog.FirstItemId : listViewLog.LastItemId;
                var entries     = await luceneStore.FilterHistoryViewAsync(filterTextEntry.Text, view, pageSize, direction, referenceId);

                if (entries.Entries.Any())
                {
                    if (direction == Direction.Backward)
                    {
                        ApplicationExtensions.InvokeInUIThread(() =>
                        {
                            foreach (var entry in entries.Entries.Where(e => e.Id < referenceId).Reverse())
                            {
                                listViewLog.InsertItem(entry, false, maxPageCount * pageSize);
                            }
                        });
                    }
                    else
                    {
                        ApplicationExtensions.InvokeInUIThread(() =>
                        {
                            foreach (var entry in entries.Entries.Where(e => e.Id > referenceId))
                            {
                                listViewLog.AddItem(entry, false, maxPageCount * pageSize);
                            }
                        });
                    }
                }
            }

            if (afterCallback != null)
            {
                afterCallback();
            }
        }
Пример #8
0
        private async Task SearchEntriesAsync(ProgressMonitor progressMonitor, Direction direction)
        {
            using (var progress = progressMonitor.Start("Searching in log..."))
            {
                var view = new ViewFilter {
                    LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text
                };

                var entries = await luceneStore.FindAsync(searchTextEntry.Text, view, 2 *pageSize, direction, searchContext != null?searchContext.PreviousResultId : null);

                if (entries.Entries == null)
                {
                    ApplicationExtensions.InvokeInUIThread(() => MessageDialog.ShowWarning("No results found!"));
                    ResetSearch(false);
                    return;
                }

                if (searchContext == null)
                {
                    searchContext = new SearchContext(entries.TotalHits);
                }
                else
                {
                    searchContext.Advance(direction);
                }
                searchContext.PreviousResultId = entries.FoundId;

                ApplicationExtensions.InvokeInUIThread(() =>
                {
                    listViewLog.ClearItems();
                    foreach (var entry in entries.Entries)
                    {
                        listViewLog.AddItem(entry, entries.FoundId == entry.Id);
                    }

                    searchLabel.Text = string.Format("Showing result: {0} / {1}", searchContext.CurrentResult, searchContext.ResultsCount);
                    nextSearchResultButton.Sensitive = (searchContext.CurrentResult > 1);
                    prevSearchResultButton.Sensitive = (searchContext.CurrentResult < searchContext.ResultsCount);
                });
            }
        }
Пример #9
0
        private void Init(AutoRepaintingVideo videoPeripheral)
        {
            element     = videoPeripheral;
            lastRewrite = CustomDateTime.Now;
            EnsureAnalyserWidget();

            videoPeripheral.ConfigurationChanged += (w, h, f, e) => ApplicationExtensions.InvokeInUIThread(() => displayWidget.SetDisplayParameters(w, h, f, e));
            videoPeripheral.FrameRendered        += displayWidget.DrawFrame;

            displayWidget.InputAttached += i =>
            {
                if (i is IKeyboard)
                {
                    keyboardsComboBox.SelectedItem = i;
                }
                else if (i is IPointerInput)
                {
                    pointersComboBox.SelectedItem = i;
                }
            };
        }
Пример #10
0
        private async Task FilterEntriesAsync(ProgressMonitor progressMonitor, bool selectLastAddedItem = false)
        {
            using (var progress = progressMonitor.Start("Filtering log..."))
            {
                var view = new ViewFilter {
                    LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text
                };

                var entries = await luceneStore.FilterHistoryViewAsync(filterTextEntry.Text, view, maxPageCount *pageSize, Direction.Backward);

                ApplicationExtensions.InvokeInUIThread(() =>
                {
                    listViewLog.ClearItems();
                    foreach (var entry in entries.Entries)
                    {
                        listViewLog.AddItem(entry, selectLastAddedItem, maxPageCount * pageSize);
                    }

                    RefreshPaging(entries.TotalHits);
                });
            }
        }
        private void EnsureAnalyserWidget()
        {
            var emulation = EmulationManager.Instance.CurrentEmulation;

            if (analyserWidget == null)
            {
                // create display widget and attach it to the emulation
                displayWidget = new FrameBufferDisplayWidget();

                var keyboards = FindKeyboards();
                var pointers  = FindPointers();

                // create other widgets
                var displayModeComboBox = new ComboBox();
                displayModeComboBox.Items.Add(DisplayMode.Stretch);
                displayModeComboBox.Items.Add(DisplayMode.Fit);
                displayModeComboBox.Items.Add(DisplayMode.Center);

                displayModeComboBox.SelectionChanged += (sender, e) => displayWidget.Mode = (DisplayMode)displayModeComboBox.SelectedItem;
                ApplicationExtensions.InvokeInUIThread(() =>
                {
                    displayModeComboBox.SelectedIndex = 1;
                });

                keyboardsComboBox = new ComboBox();
                if (keyboards != null)
                {
                    foreach (var kbd in keyboards)
                    {
                        string name;
                        emulation.TryGetEmulationElementName(kbd, out name);
                        keyboardsComboBox.Items.Add(kbd, name);
                    }
                    keyboardsComboBox.SelectionChanged += (sender, e) =>
                                                          emulation.Connector.Connect((IKeyboard)keyboardsComboBox.SelectedItem, displayWidget);
                }
                keyboardsComboBox.SelectedIndex = 0;

                pointersComboBox = new ComboBox();
                if (pointers != null)
                {
                    foreach (var ptr in pointers)
                    {
                        string name;
                        emulation.TryGetEmulationElementName(ptr, out name);
                        pointersComboBox.Items.Add(ptr, name);
                    }
                    pointersComboBox.SelectionChanged += (sender, e) =>
                                                         emulation.Connector.Connect((IPointerInput)pointersComboBox.SelectedItem, displayWidget);
                }
                pointersComboBox.SelectedIndex = 0;

                var snapshotButton = new Button("Take screenshot!");
                snapshotButton.Clicked += (sender, e) =>
                {
                    var screenshotDir = Path.Combine(Emulator.UserDirectoryPath, "screenshots");
                    Directory.CreateDirectory(screenshotDir);
                    var filename = Path.Combine(screenshotDir, string.Format("screenshot-{0:yyyy_M_d_HHmmss}.png", CustomDateTime.Now));
                    displayWidget.SaveCurrentFrameToFile(filename);
                    MessageDialog.ShowMessage("Screenshot saved in {0}".FormatWith(filename));
                };

                var configurationPanel = new HBox();
                configurationPanel.PackStart(new Label("Display mode:"));
                configurationPanel.PackStart(displayModeComboBox);
                configurationPanel.PackStart(new Label(), true);
                configurationPanel.PackStart(new Label("Keyboard:"));
                configurationPanel.PackStart(keyboardsComboBox);
                configurationPanel.PackStart(new Label("Pointer:"));
                configurationPanel.PackStart(pointersComboBox);
                configurationPanel.PackStart(new Label(), true);
                configurationPanel.PackStart(snapshotButton);

                var svc = new VBox();
                svc.PackStart(configurationPanel);
                svc.PackStart(new Label());
                var sv = new ScrollView();
                sv.Content              = svc;
                sv.HeightRequest        = 50;
                sv.BorderVisible        = false;
                sv.VerticalScrollPolicy = ScrollPolicy.Never;

                var summaryVB   = new HBox();
                var resolutionL = new Label("unknown");
                displayWidget.DisplayParametersChanged += (w, h, f) => ApplicationExtensions.InvokeInUIThread(() => resolutionL.Text = string.Format("{0} x {1} ({2})", w, h, f));
                summaryVB.PackStart(new Label("Resolution: "));
                summaryVB.PackStart(resolutionL);
                summaryVB.PackStart(new Label(), true);
                var cursorPositionL = new Label("unknown");
                displayWidget.PointerMoved += (x, y) => ApplicationExtensions.InvokeInUIThread(() => cursorPositionL.Text = (x == -1 && y == -1) ? "unknown" : string.Format("{0} x {1}", x, y));
                summaryVB.PackStart(new Label("Cursor position: "));
                summaryVB.PackStart(cursorPositionL);
                summaryVB.PackStart(new Label(), true);
                summaryVB.PackStart(new Label("Framerate: "));
                framerateL = new Label("unknown");
                displayWidget.FrameDrawn += RefreshFramerate;
                summaryVB.PackStart(framerateL);

                var vbox = new VBox();
                vbox.PackStart(sv);
                vbox.PackStart(displayWidget, true, true);
                vbox.PackStart(summaryVB);
                analyserWidget = vbox;
            }
        }