Ejemplo n.º 1
0
        private void OnRequestedThemeChanged(object sender, AppThemeChangedEventArgs e)
        {
            DebugPage.WriteLine($"Theme changed on {GetType().Name} to: {e.RequestedTheme}");

            // Re-render UI when app theme changes between dark/light
            StateHasChanged();
        }
Ejemplo n.º 2
0
        protected override void OnInitialized()
        {
            base.OnInitialized();

            var theme = Application.Current.RequestedTheme;

            DebugPage.WriteLine($"Current theme: {theme}");
        }
Ejemplo n.º 3
0
        protected override void ComposeTree(TreeComposer composer)
        {
            switch (NavigationStore.CurrentPage)
            {
            case NavigationStore.PageId.Edit:
                EditPage.Inject(composer);
                break;

            case NavigationStore.PageId.Run:
                RunPage.Inject(composer);
                break;

            case NavigationStore.PageId.Debug:
                DebugPage.Inject(composer);
                break;

            default:
                throw ExceptionUtilities.UnexpectedValue(NavigationStore.CurrentPage);
            }
        }
Ejemplo n.º 4
0
        private void InitializeOptionsStorage()
        {
            Options             = (GeneralOptionsPage)GetDialogPage(typeof(GeneralOptionsPage));
            StorageOptions      = (StorageOptionsPage)GetDialogPage(typeof(StorageOptionsPage));
            ConfirmationOptions = (ConfirmationsPage)GetDialogPage(typeof(ConfirmationsPage));
            DebugOptions        = (DebugPage)GetDialogPage(typeof(DebugPage));

            Options.GlyphColorChanged += (sender, args) =>
            {
                BookmarkGlyphFactory.SetGlyphColor(Options.GlyphColor);

                //Force redraw of currently visible bookmarks
                //(there must be a better way to do this...)
                if (CurrentWindowFrame?.IsVisible() == VSConstants.S_OK)
                {
                    CurrentWindowFrame.Hide();
                    CurrentWindowFrame.Show();
                }
            };

            Options.ShowMenuOptionChanged += (sender, args) => UpdateMenuVisibilityAndText();
        }
Ejemplo n.º 5
0
        public PageDrawing(
            IDebugDrawing drawing,
            DebugPage debugPage,
            int headingLevel,
            bool showButtons)
            : base(
                null,
                "Page '" + debugPage.Name + "'",
                headingLevel)
        {
            LeftMargin   = 20;
            RightMargin  = 20;
            TopMargin    = 20;
            BottomMargin = 20;

            CssClass = "page";

            var text = new List <string>();

            if (!string.IsNullOrEmpty(debugPage.RequiredPermission))
            {
                text.Add("Requires the '" + debugPage.RequiredPermission + "' permission");
            }

            if (text.Count > 0)
            {
                var textDrawing = new TextDrawing
                {
                    Text = text.ToArray()
                };
                AddChild(textDrawing);
            }

            var details = new List <string>();

            AddDebugInfo(details, debugPage);
            AddDetails(details, this);

            if (debugPage.Routes != null)
            {
                foreach (var route in debugPage.Routes)
                {
                    AddChild(new RouteDrawing(route));
                }
            }

            if (debugPage.Layout != null)
            {
                var layout = new LayoutDrawing(
                    drawing,
                    this,
                    debugPage.Layout,
                    headingLevel + 1,
                    showButtons);
                AddChild(layout);
            }

            if (!ReferenceEquals(debugPage.Scope, null))
            {
                AddHeaderButton(this, "Scope")
                .AddChild(new DataScopeRulesDrawing(
                              drawing,
                              this,
                              debugPage.Scope,
                              headingLevel + 1,
                              false,
                              -1));
            }

            if (!ReferenceEquals(debugPage.DataContext, null))
            {
                AddHeaderButton(this, "Context")
                .AddChild(new DataScopeRulesDrawing(
                              drawing,
                              this,
                              debugPage.DataContext,
                              headingLevel + 1,
                              false,
                              -1));
            }
        }
        private void WriteHtml(IHtmlWriter html, DebugPage page, int depth)
        {
            if (page.Routes != null && page.Routes.Count > 0)
            {
                html.WriteElementLine("h3", "Page routes");
                foreach (var route in page.Routes)
                {
                    html.WriteElementLine("p", "Route: " + route);
                }
            }

            if (page.Scope != null)
            {
                html.WriteElementLine("p", "Page has a data scope");
                StartIndent(html, true);
                WriteDebugInfo(html, page.Scope, depth - 1);
                EndIndent(html);
            }

            if (page.DataContext != null)
            {
                html.WriteElementLine("p", "Page has a data context");
                StartIndent(html, true);
                WriteDebugInfo(html, page.DataContext, depth - 1);

                var dataContextBuilder = page.DataContext.Instance as IDataContextBuilder;
                if (dataContextBuilder != null)
                {
                    DebugRenderContext debugRenderContext;
                    try
                    {
                        var renderContext = _renderContextFactory.Create((c, f) => { });
                        dataContextBuilder.SetupDataContext(renderContext);
                        debugRenderContext = renderContext.GetDebugInfo <DebugRenderContext>();
                    }
                    catch (Exception ex)
                    {
                        debugRenderContext = null;
                        html.WriteElementLine("p", "Exception thrown when constructing data context tree: " + ex.Message);
                        if (!string.IsNullOrEmpty(ex.StackTrace))
                        {
                            html.WriteOpenTag("pre");
                            html.WriteLine();
                            html.WritePreformatted(ex.StackTrace);
                            html.WriteLine();
                            html.WriteCloseTag("pre");
                            html.WriteLine();
                        }
                    }

                    WriteHtml(html, debugRenderContext, depth - 1);
                }

                EndIndent(html);
            }

            if (page.Layout != null)
            {
                html.WriteElementLine("p", "Page has a layout");
                if (depth != 1)
                {
                    StartIndent(html, true);
                    WriteDebugInfo(html, page.Layout, depth - 1);
                    EndIndent(html);
                }
            }
        }