当前位置: 首页>>代码示例>>C#>>正文


C# RichTextBox.AddRichTextString方法代码示例

本文整理汇总了C#中System.Windows.Forms.RichTextBox.AddRichTextString方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.AddRichTextString方法的具体用法?C# RichTextBox.AddRichTextString怎么用?C# RichTextBox.AddRichTextString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.RichTextBox的用法示例。


在下文中一共展示了RichTextBox.AddRichTextString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compile

        public bool Compile(RichTextBox textCompile)
        {
            byte index = 0;
            string[] pageTimers = new string[4];
            bool flag = true;

            List<byte[]> newlist = new List<byte[]>();
            List<byte[]> codes = new List<byte[]>();

            byte[] binTFT = new byte[HmiOptions.InfoPageObjectSize * HmiObjects.Count + 4];
            byte[] customData = new byte[0];

            Codes.Clear();
            ushort customDataAddress = (ushort)(App.OverBytes.Length - 4);

            try
            {
                int i;
                Utility.ToBytes(((uint)customDataAddress)).CopyTo(binTFT, 0);
                customDataAddress += (ushort)(binTFT.Length - 4);
                for (int idxObj = 0; idxObj < HmiObjects.Count; idxObj++)
                {
                    HmiObject hmiObj = HmiObjects[idxObj];
                    if (!objDetect(textCompile, hmiObj))
                    {
                        flag = false;
                        continue;
                    }

                    InfoPageObject infoPageObj;
                    infoPageObj.TouchState = 1;
                    if (hmiObj.ObjInfo.Panel.loadlei == 1)
                        infoPageObj.Visible = 1;
                    else
                        infoPageObj.Visible = 0;

                    infoPageObj.RefreshFlag = hmiObj.ObjInfo.Panel.loadlei;
                    Utility.ToBytes(infoPageObj).CopyTo(binTFT, idxObj * HmiOptions.InfoPageObjectSize + 4);

                    if (hmiObj.ObjInfo.IsCustomData == 0)
                    {
                        hmiObj.ObjInfo.AttributeStart = customDataAddress;
                        customData = Utility.ToBytes((uint)customDataAddress);
                        ushort objRamBytes = hmiObj.GetObjRamBytes(ref customData, customDataAddress);
                        if (objRamBytes != 0)
                        {
                            codes.Add(customData);
                            hmiObj.ObjInfo.AttributeLength = objRamBytes;
                            customDataAddress += hmiObj.ObjInfo.AttributeLength;
                        }
                    }
                }

                if (customDataAddress > HmiOptions.MaxCustomDataSize)
                {
                    textCompile.AddRichTextString(
                        string.Concat(
                            "Page:".Translate(),
                            Name,
                            " Error! Memory overflow:".Translate(), customDataAddress
                            ),
                        Color.Red
                        );
                    App.Errors++;
                    flag = false;
                }

                if (!flag)
                    return flag;

                textCompile.AddRichTextString(
                    string.Concat(
                        "Page:".Translate(),
                        Name,
                        " OK! Occupy memory:".Translate(),
                        customDataAddress), Color.Black);

                customData = Utility.MergeBytes(Utility.ToBytes((uint)0xffff), Utility.ToBytes((uint)customDataAddress));
                codes.Add(customData);

                Codes.Add(Utility.PatternBytes("cre"));
                Codes.Add(binTFT);
                Utility.AppendList(Codes, codes);
                Codes.Add(Utility.PatternBytes("end"));

                newlist.Clear();
                for (int idxObj = 0; idxObj < HmiObjects.Count; idxObj++)
                    if (HmiObjects[idxObj].ObjInfo.ObjType == HmiObjType.OBJECT_TYPE_CURVE)
                        newlist.Add(Utility.ToBytes("init " + idxObj.ToString()));
                Utility.AppendList(Codes, newlist);

                index = 0;
                newlist.Clear();
                for (int idxObj = 0; idxObj < HmiObjects.Count; idxObj++)
                {
                    HmiObject obj = HmiObjects[idxObj];
                    if (obj.ObjInfo.ObjType == HmiObjType.TIMER)
                    {
                        if (index > 3)
                        {	// Maximum 4 timer on page
//.........这里部分代码省略.........
开发者ID:x893,项目名称:NextionEditor,代码行数:101,代码来源:HmiPage.cs

示例2: SaveToFile

        public bool SaveToFile(string binPath, bool compile, RichTextBox textCompile)
        {
            SaveToFileData data = new SaveToFileData();
            StreamWriter writer = new StreamWriter(binPath);
            InfoApp infoApp = new InfoApp();
            try
            {
                if (!prepareToSave(ref infoApp, compile, textCompile, data))
                {
                    textCompile.AddRichTextString(
                        string.Concat(
                            "Compile failure!".Translate(), " ",
                            Errors, " Errors,".Translate(), " ",
                            Warnings, " Warnings,".Translate()
                        ), Color.Red);
                    writer.Close();
                    writer.Dispose();
                    return false;
                }

                infoApp.VersionMajor = HmiOptions.VersionMajor;
                infoApp.VersionMinor = HmiOptions.VersionMinor;

                infoApp.FileType = Utility.FileType(compile);

                byte[] buffer = Utility.ToBytes(infoApp);
                writer.BaseStream.Write(buffer, 0, HmiOptions.InfoAppSize);

                int idx;
                if (compile)
                {	// Fill zeros to 4K boundary
                    buffer = new byte[0x1000 - HmiOptions.InfoAppSize];
                    for (idx = 0; idx < buffer.Length; idx++)
                        buffer[idx] = 0;
                    writer.BaseStream.Write(buffer, 0, buffer.Length);
                }

                for (idx = 0; idx < Pictures.Count; idx++)
                    writer.BaseStream.Write(PictureImages[idx], 0, PictureImages[idx].Length);

                for (idx = 0; idx < Fonts.Count; idx++)
                    writer.BaseStream.Write(FontImages[idx], 0, FontImages[idx].Length);

                if (compile)
                {	// Compile :
                    int imgSize = (getPictureImagesSize() + getFontImagesSize()) % 0x1000;
                    if (imgSize != 0)
                    {
                        buffer = new byte[0x1000 - imgSize];
                        for (idx = 0; idx < buffer.Length; idx++)
                            buffer[idx] = 0;
                        writer.BaseStream.Write(buffer, 0, buffer.Length);
                    }
                }

                for (idx = 0; idx < data.m_infoStrings.Count; idx++)
                    writer.BaseStream.Write(data.m_stringDatas[idx], 0, data.m_stringDatas[idx].Length);

                if (compile)
                {
                    StreamReader reader = new StreamReader(Path.Combine(Application.StartupPath, "fwc.bin"));
                    buffer = new byte[reader.BaseStream.Length];
                    reader.BaseStream.Position = 0L;
                    reader.BaseStream.Read(buffer, 0, buffer.Length);
                    writer.BaseStream.Write(buffer, 0, buffer.Length);
                    reader.Close();
                }

                for (idx = 0; idx < data.m_infoPages.Count; idx++)
                {
                    buffer = Utility.ToBytes(data.m_infoPages[idx]);
                    writer.BaseStream.Write(buffer, 0, HmiOptions.InfoPageSize);
                }

                for (idx = 0; idx < data.m_infoObjects.Count; idx++)
                {
                    buffer = Utility.ToBytes(data.m_infoObjects[idx]);
                    writer.BaseStream.Write(buffer, 0, HmiOptions.InfoObjectSize);
                }

                uint dataStart = 0;
                for (idx = 0; idx < infoApp.PictureCount; idx++)
                {
                    InfoPicture picture = Pictures[idx];
                    picture.DataStart = dataStart;
                    buffer = Utility.ToBytes(picture);
                    writer.BaseStream.Write(buffer, 0, HmiOptions.InfoPictureSize);
                    dataStart += (uint)PictureImages[idx].Length;
                }

                for (idx = 0; idx < infoApp.StringCount; idx++)
                {
                    buffer = Utility.ToBytes(data.m_infoStrings[idx]);
                    writer.BaseStream.Write(buffer, 0, HmiOptions.InfoStringSize);
                }

                dataStart = 0;
                for (idx = 0; idx < infoApp.FontCount; idx++)
                {
                    InfoFont font = Fonts[idx];
//.........这里部分代码省略.........
开发者ID:x893,项目名称:NextionEditor,代码行数:101,代码来源:HmiApplication.cs

示例3: objDetect

        private bool objDetect(RichTextBox textCompile, HmiObject obj)
        {
            bool flag = true;

            if (obj.ObjInfo.Panel.X < 0
             || obj.ObjInfo.Panel.EndX >= App.LcdWidth
             || obj.ObjInfo.Panel.Y < 0
             || obj.ObjInfo.Panel.EndY >= App.LcdHeight
                )
            {
                textCompile.AddRichTextString(
                    string.Concat("Page:".Translate(), Name, " Error:".Translate(), obj.ObjName, " Position Invalid:".Translate()),
                    Color.Red
                    );
                App.Errors++;
                flag = false;
            }

            for (int i = 0; i < obj.Attributes.Count; i++)
            {
                if (obj.Attributes[i].InfoAttribute.AttrType < 15
                 && obj.Attributes[i].InfoAttribute.CanModify == 1
                 && obj.checkAttribute(obj.Attributes[i])
                    )
                {
                    string err = obj.CheckAttributeValue(obj.Attributes[i]);
                    if (err != "")
                    {
                        textCompile.AddRichTextString(
                            string.Concat(
                                "Page:".Translate(),
                                Name,
                                " Error:".Translate(),
                                obj.ObjName + "." + obj.Attributes[i].Name.ToString(),
                                " InputVal Invalid:".Translate(),
                                err),
                            Color.Red);
                        App.Errors++;
                        flag = false;
                    }
                }
            }
            return flag;
        }
开发者ID:x893,项目名称:NextionEditor,代码行数:44,代码来源:HmiPage.cs


注:本文中的System.Windows.Forms.RichTextBox.AddRichTextString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。