簡體   English   中英

有什么方法可以將RichTextBox添加到Android的C#Xamarin項目中?

[英]Is there any way to add RichTextBox to C# Xamarin project for Android?

將為Windows創建的C#項目轉換為Android Xamarin時遇到問題。 我已經在網上搜索了有關RichTextBox以及用於構建Windows版本程序的其他功能和組件的任何解決方案,但是除了這里的一個主題之外,我找不到任何好的解決方案但是它沒有幫助我。 如果無法添加諸如Richtextbox之類的內容,是否還有其他支持.Lines的文本框,因此我可以獲得正確的行號?

這是我的代碼的一部分:

        private void ThreadTask1()
    {
        string link = "http://example.com/music-today.php";
        int TimeToWait = 300;
        int check_ID = 0;

        string ParsedResult = null;

        HtmlAgilityPack.HtmlDocument doc = null;
        HtmlWeb web1 = new HtmlWeb();

        while (true) {

            ParsedResult = "";
            RichTextBox1.Clear(); 
            RichTextBox2.Clear(); 

            web1.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)";
            web1.UsingCache = false;
            web1.UseCookies = true;

            doc = web1.Load(link);

            HtmlNode div = doc.DocumentNode.SelectSingleNode("//div[@class='latest-song14']"); 

            if ((div != null)) {
                ParsedResult = div.InnerText.Trim();
                RichTextBox1.Text = ParsedResult;
                RichTextBox2.Text = RichTextBox1.Lines[0];

                if (!RichTextBox2.Text.Contains("dj")) {
                    Sound vol = new Sound("nircmdc.exe");
                    vol.setVol(40);

                    while (true) {
                        MyMusicInformer.My.MyProject.Computer.Audio.Play("C:\\Windows\\media\\Alarm01.wav", AudioPlayMode.Background);
                        System.Threading.Thread.Sleep(700);
                        MyMusicInformer.My.MyProject.Computer.Audio.Play("C:\\Windows\\media\\Alarm01.wav", AudioPlayMode.Background);
                        System.Threading.Thread.Sleep(700);
                        MyMusicInformer.My.MyProject.Computer.Audio.Play("C:\\Windows\\media\\Alarm01.wav", AudioPlayMode.Background);
                        System.Threading.Thread.Sleep(5000);
                    }
                } else {
                    check_ID = check_ID + 1;
                    RichTextBox2.Text = "No new song yet. Try (" + check_ID.ToString() + ")";
                }
            }
            System.Threading.Thread.Sleep(TimeToWait * 1000);
        }
    }


    private Thread trd1;

    private void Form1_Load(object sender, EventArgs e)
    {
        System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;

        trd1 = new Thread(ThreadTask1);
        trd1.IsBackground = true;
        trd1.Start();
    }

我只想在有新歌曲更新時得到通知。 在Visual Studio中,我只能看到“多行文本”選項,但不能解決我的問題。

謝謝你的時間。

您是否嘗試過Xamarin.Forms.Editor控件? 我相信它可以為您提供幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM