Exemple #1
0
        public TabletDebugger()
        {
            Title = "Tablet Debugger";

            var debugger = new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Height  = 400,
                Padding = 5,
                Spacing = 5,
                Items   =
                {
                    new DebuggerGroup
                    {
                        Text    = "Device",
                        Content = deviceName = new Label
                        {
                            Font = Fonts.Monospace(10)
                        }
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new StackLayout
                        {
                            Orientation = Orientation.Horizontal,
                            VerticalContentAlignment = VerticalAlignment.Stretch,
                            Items =
                            {
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new DebuggerGroup
                                    {
                                        Text    = "Raw Tablet Data",
                                        Content = rawTablet = new Label
                                        {
                                            Font = Fonts.Monospace(10)
                                        }
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new DebuggerGroup
                                    {
                                        Text    = "Tablet Report",
                                        Content = tablet = new Label
                                        {
                                            Font = Fonts.Monospace(10)
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new DebuggerGroup
                    {
                        Text    = "Report Rate",
                        Content = reportRate = new Label
                        {
                            Font = Fonts.Monospace(10)
                        }
                    },
                    new StackLayoutItem
                    {
                        Control = new StackLayout
                        {
                            Orientation = Orientation.Horizontal,
                            VerticalContentAlignment = VerticalAlignment.Bottom,
                            Items =
                            {
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new DebuggerGroup
                                    {
                                        Text    = "Reports Recorded",
                                        Content = reportsRecorded = new Label
                                        {
                                            Font = Fonts.Monospace(10)
                                        }
                                    }
                                },
                                new Group
                                {
                                    Text    = "Options",
                                    Content = enableDataRecording = new CheckBox
                                    {
                                        Text = "Enable Data Recording"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            this.Content = new Splitter
            {
                Orientation = Orientation.Vertical,
                Width       = 640,
                Height      = 800,
                FixedPanel  = SplitterFixedPanel.Panel2,
                Panel1      = new DebuggerGroup
                {
                    Text    = "Visualizer",
                    Content = tabletVisualizer = new TabletVisualizer()
                },
                Panel2 = debugger
            };

            var reportBinding = ReportDataBinding.Child(c => (c.ToObject() as IDeviceReport));

            deviceName.TextBinding.Bind(ReportDataBinding.Child(c => c.Tablet.Properties.Name));
            rawTablet.TextBinding.Bind(reportBinding.Child(c => ReportFormatter.GetStringRaw(c)));
            tablet.TextBinding.Bind(reportBinding.Child(c => ReportFormatter.GetStringFormat(c)));
            reportRate.TextBinding.Bind(ReportPeriodBinding.Convert(c => Math.Round(1000.0 / c) + "hz"));
            reportsRecorded.TextBinding.Bind(NumberOfReportsRecordedBinding.Convert(c => c.ToString()));
            tabletVisualizer.ReportDataBinding.Bind(ReportDataBinding);

            Application.Instance.AsyncInvoke(() =>
            {
                App.Driver.AddConnectionHook(ConnectionHook);
            });

            var outputStream = File.OpenWrite(Path.Join(AppInfo.Current.AppDataDirectory, "tablet-data.txt"));

            dataRecordingOutput = new StreamWriter(outputStream);
        }
Exemple #2
0
        public TabletDebugger()
            : base(Application.Instance.MainForm)
        {
            Title = "Tablet Debugger";

            var debugger = new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Height  = 320,
                Padding = SPACING,
                Spacing = SPACING,
                Items   =
                {
                    new StackLayoutItem
                    {
                        Control = new StackLayout
                        {
                            Orientation = Orientation.Horizontal,
                            VerticalContentAlignment = VerticalAlignment.Bottom,
                            Items =
                            {
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new DebuggerGroup
                                    {
                                        Text    = "Device",
                                        Content = deviceName = new Label
                                        {
                                            Font = Fonts.Monospace(LARGE_FONTSIZE)
                                        }
                                    }
                                },
                                new DebuggerGroup
                                {
                                    Text    = "Report Rate",
                                    Width   = LARGE_FONTSIZE * 6,
                                    Content = reportRate = new Label
                                    {
                                        Font = Fonts.Monospace(LARGE_FONTSIZE)
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Control = new DebuggerGroup
                                    {
                                        Text    = "Reports Recorded",
                                        Width   = LARGE_FONTSIZE * 10,
                                        Content = reportsRecorded = new Label
                                        {
                                            Font = Fonts.Monospace(LARGE_FONTSIZE)
                                        }
                                    }
                                },
                                new Group
                                {
                                    Text    = "Options",
                                    Content = enableDataRecording = new CheckBox
                                    {
                                        Text = "Enable Data Recording"
                                    }
                                }
                            }
                        }
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new StackLayout
                        {
                            Orientation = Orientation.Horizontal,
                            VerticalContentAlignment = VerticalAlignment.Stretch,
                            Height = 240,
                            Items  =
                            {
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new DebuggerGroup
                                    {
                                        Text    = "Raw Tablet Data",
                                        Width   = FONTSIZE * 33,
                                        Content = rawTablet = new Label
                                        {
                                            Font = Fonts.Monospace(FONTSIZE)
                                        }
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Control = new DebuggerGroup
                                    {
                                        Text    = "Tablet Report",
                                        Width   = FONTSIZE * 33,
                                        Content = tablet = new Label
                                        {
                                            Font = Fonts.Monospace(FONTSIZE)
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var splitter = new Splitter
            {
                Orientation = Orientation.Vertical,
                Width       = 660,
                Height      = 800,
                FixedPanel  = SplitterFixedPanel.Panel2,
                Panel1      = new DebuggerGroup
                {
                    Height  = 200,
                    Text    = "Visualizer",
                    Content = tabletVisualizer = new TabletVisualizer()
                },
                Panel2 = debugger
            };

            this.Content = new Scrollable
            {
                Content = splitter
            };

            var reportBinding = ReportDataBinding.Child(c => (c.ToObject() as IDeviceReport));

            deviceName.TextBinding.Bind(ReportDataBinding.Child(c => c.Tablet.Properties.Name));
            rawTablet.TextBinding.Bind(reportBinding.Child(c => ReportFormatter.GetStringRaw(c)));
            tablet.TextBinding.Bind(reportBinding.Child(c => ReportFormatter.GetStringFormat(c)));
            reportRate.TextBinding.Bind(ReportPeriodBinding.Convert(c => Math.Round(1000.0 / c) + "hz"));
            reportsRecorded.TextBinding.Bind(NumberOfReportsRecordedBinding.Convert(c => c.ToString()));
            tabletVisualizer.ReportDataBinding.Bind(ReportDataBinding);

            App.Driver.DeviceReport   += HandleReport;
            App.Driver.TabletsChanged += HandleTabletsChanged;
            App.Driver.Instance.SetTabletDebug(true);

            var outputStream = File.OpenWrite(Path.Join(AppInfo.Current.AppDataDirectory, "tablet-data.txt"));

            dataRecordingOutput = new StreamWriter(outputStream);
        }