Esempio n. 1
0
 public RowControl()
 {
     InitializeComponent();
     var btnPlus = new PlusControl();
     btnPlus.PlusClick += BtnPlusPlusClick;
     rowPanel.Children.Add(btnPlus);
     DataContextChanged += RowControlDataContextChanged;
 }
Esempio n. 2
0
        private void BDTReady(BlazorDomTree bdt)
        {
            BlazorSession ses = BlazorSession.Current;

            PlusControl resultdiv = bdt.Root.Create("div style='margin:8px 0;max-width:100%;height:400px;background-color:black;color:white;overflow-y:scroll;padding:5px 5px 15px;'");

            PlusControl div1 = bdt.Root.Create("div style='display:flex;'");
            // div1.Create("label style='width:100px").InnerText("Command:");
            PlusControl inpword = div1.Create("input type='text' style='flex:99;padding:0 5px'");
            PlusControl button  = div1.Create("button").InnerText("Send");

            div1.Create("button").InnerText("^C").OnClick(delegate
            {
                this.shellstream.WriteByte(3);
                this.shellstream.Flush();
            });

            string _lastcolor = null;

            PlusControl SetLastColor(PlusControl span)
            {
                if (_lastcolor != null)
                {
                    span.Style("color", _lastcolor);
                    if (_lastcolor == "black")
                    {
                        span.Style("background-color", "white");
                    }
                }
                return(span);
            }

            void SendLine(string line, string color)
            {
                ses.ConsoleLog("line", System.Text.Json.JsonSerializer.Serialize(line));

                var d = resultdiv.Create("div style='color:" + color + "'");

                if (string.IsNullOrEmpty(line))
                {
                    d.InnerHTML("<br/>");
                    return;
                }

                if (line.IndexOf("\x1b[") == -1)
                {
                    if (color == null)
                    {
                        SetLastColor(d);
                    }

                    d.InnerText(line);
                    return;
                }

                //parse ssh color:
                int pos = 0;

                while (pos < line.Length)
                {
                    int p33 = line.SafeIndexOf("\x1b[", pos);
                    if (p33 == -1)
                    {
                        string laststr = line[pos..];
                        if (!string.IsNullOrEmpty(laststr))
                        {
                            //ses.ConsoleLog("last", System.Text.Json.JsonSerializer.Serialize(laststr));
                            SetLastColor(d.Create("span")).InnerText(laststr);
                        }
                        break;
                    }