示例#1
0
 public static void style(nac.Forms.Form form, Control ctrl, Style style)
 {
     styleGeneric(form, ctrl, style);
     if (ctrl is Avalonia.Controls.Primitives.TemplatedControl tControl)
     {
         styleTemplated(tControl, style);
     }
     else if (ctrl is TextBlock textCtrl)
     {
         styleTextBlock(textCtrl, style);
     }
 }
示例#2
0
        public static nac.Forms.Form logViewer(nac.Forms.Form f)
        {
            var entries = new ObservableCollection <model.LogEntry>();

            model.LogEntry.onNewMessage += (_s, _e) =>
            {
                // Modifying the entries list has to be thread safe so use Invoke
                f.InvokeAsync(async() =>
                {
                    entries.Insert(0, _e);
                });
            };

            f.Model["logEntriesList"] = entries;

            f.List <model.LogEntry>("logEntriesList", populateItemRow: (_rF) =>
            {
                _rF.HorizontalStack(h =>
                {
                    var model = h.Model[nac.Forms.model.SpecialModelKeys.DataContext] as model.LogEntry;

                    var levelStyle = new nac.Forms.model.Style();
                    if (string.Equals(model.level, "warn", StringComparison.InvariantCulture))
                    {
                        levelStyle.foregroundColor = Avalonia.Media.Colors.Yellow;
                    }
                    else if (string.Equals(model.level, "info", StringComparison.OrdinalIgnoreCase))
                    {
                        levelStyle.foregroundColor = Avalonia.Media.Colors.Green;
                    }
                    else if (string.Equals(model.level, "debug", StringComparison.OrdinalIgnoreCase))
                    {
                        levelStyle.foregroundColor = Avalonia.Media.Colors.Cyan;
                    }
                    else if (string.Equals(model.level, "error", StringComparison.OrdinalIgnoreCase))
                    {
                        levelStyle.foregroundColor = Avalonia.Media.Colors.Red;
                    }

                    h.TextFor("date")
                    .Text(" - [")
                    .TextFor("level", style: levelStyle)
                    .Text("] - ")
                    .TextFor("message");
                });
            });

            return(f);
        }
示例#3
0
    public static nac.Forms.Form Browser(this nac.Forms.Form f)
    {
        // make a browser
        var browser = new WebViewControl.WebView();

        browser.Initialized += (_sender, _args) =>
        {
            System.Console.WriteLine("Web View Initialized"); // todo: change this to some kind of logging
            browser.LoadUrl("https://www.google.com");
        };

        f._Extend_AddRowToHost(browser, rowAutoHeight: false);

        return(f);
    }
示例#4
0
        private static void styleGeneric(nac.Forms.Form form, Control ctrl, Style style)
        {
            if (style?.height.IsSet == true)
            {
                ctrl.Height = Convert.ToDouble(style.height.Value);
            }

            if (style?.width.IsSet == true)
            {
                ctrl.Width = Convert.ToDouble(style.width.Value);
            }

            if (style?.isVisibleModelName.IsSet == true)
            {
                form.AddVisibilityTrigger(ctrl, isVisibleModelName: style.isVisibleModelName.Value);
            }
        }