有没有办法将RichTextBox添加到Android的C#Xamarin项目中?

时间:2018-05-09 14:55:46

标签: c# android windows visual-studio xamarin

我在将为Windows创建的C#项目转换为Android Xamarin时遇到问题。我已经在网上搜索了有关RichTextBox以及我用于构建Windows版本程序的其他功能和组件的任何解决方案但我找不到任何好的解决方案,除了一个主题here但它没有'帮帮我 如果没有办法添加类似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中,我只能看到" Multiline Text"选项,但它无法解决我的问题。

感谢您的时间。

0 个答案:

没有答案