Esempio n. 1
0
        private void USARTUP_Load(object sender, EventArgs e)
        {
            using (StreamReader reader = new StreamReader(m_binPath))
            {
                m_sizeTFT = (int)reader.BaseStream.Length;
                byte[] buffer = new byte[HmiOptions.InfoAppSize];
                if (reader.BaseStream.Length < (buffer.Length + 3))
                {
                    MessageBox.Show("Wrong resource file or resource file has been damaged".Translate());
                    reader.Close();
                    reader.Dispose();
                    base.Close();
                }

                reader.BaseStream.Read(buffer, 0, buffer.Length);
                m_appInf = Utility.ToStruct <InfoApp>(buffer);
                reader.Close();

                if (m_appInf.FileType != Utility.FILE_TYPE_CN_TFT &&
                    m_appInf.FileType != Utility.FILE_TYPE_EN_TFT
                    )
                {
                    MessageBox.Show("Wrong resource file or resource file has been damaged".Translate());
                    base.Close();
                }
            }

            BaudRate.Items.Clear();
            BaudRate.Items.Add("2400");
            BaudRate.Items.Add("4800");
            BaudRate.Items.Add("9600");
            BaudRate.Items.Add("19200");
            BaudRate.Items.Add("38400");
            BaudRate.Items.Add("57600");
            BaudRate.Items.Add("115200");
            BaudRate.SelectedIndex = BaudRate.Items.Count - 1;
            // BaudRate.Text = "115200";

            getComPorts();

            m_comUser.Port = m_port;
        }
Esempio n. 2
0
        private void USARTUP_Load(object sender, EventArgs e)
        {
            using (StreamReader reader = new StreamReader(m_binPath))
            {
                m_sizeTFT = (int)reader.BaseStream.Length;
                byte[] buffer = new byte[HmiOptions.InfoAppSize];
                if (reader.BaseStream.Length < (buffer.Length + 3))
                {
                    MessageBox.Show("Wrong resource file or resource file has been damaged".Translate());
                    reader.Close();
                    reader.Dispose();
                    base.Close();
                }

                reader.BaseStream.Read(buffer, 0, buffer.Length);
                m_appInf = Utility.ToStruct<InfoApp>(buffer);
                reader.Close();

                if (m_appInf.FileType != Utility.FILE_TYPE_CN_TFT
                 && m_appInf.FileType != Utility.FILE_TYPE_EN_TFT
                    )
                {
                    MessageBox.Show("Wrong resource file or resource file has been damaged".Translate());
                    base.Close();
                }
            }

            BaudRate.Items.Clear();
            BaudRate.Items.Add("2400");
            BaudRate.Items.Add("4800");
            BaudRate.Items.Add("9600");
            BaudRate.Items.Add("19200");
            BaudRate.Items.Add("38400");
            BaudRate.Items.Add("57600");
            BaudRate.Items.Add("115200");
            BaudRate.SelectedIndex = BaudRate.Items.Count - 1;
            // BaudRate.Text = "115200";

            getComPorts();

            m_comUser.Port = m_port;
        }
Esempio n. 3
0
        private bool prepareToSave(
			ref InfoApp infoApp,
			bool compile,
			RichTextBox textCompile,
			SaveToFileData data
			)
        {
            infoApp.IsPotrait = (byte)(IsPotrait ? 1 : 0);
            infoApp.ScreenWidth = (IsPotrait ? LcdHeight : LcdWidth);
            infoApp.ScreenHeight = (IsPotrait ? LcdWidth : LcdHeight);

            bool success = true;
            ushort customDataLength = 0;
            OverBytes = Utility.ToBytes((uint)customDataLength);

            if (compile)
            {
                for (int idxPage = 0; idxPage < HmiPages.Count; idxPage++)
                {
                    HmiPage hmiPage = HmiPages[idxPage];
                    for (int idxObj = 0; idxObj < hmiPage.HmiObjects.Count; ++idxObj)
                    {
                        HmiObject hmiObj = hmiPage.HmiObjects[idxObj];

                        hmiObj.ObjInfo.ObjType = hmiObj.Attributes[0].Data[0];
                        hmiObj.ObjInfo.IsCustomData = hmiObj.Attributes[1].Data[0];

                        if (hmiObj.ObjInfo.IsCustomData == 1)
                        {
                            hmiObj.ObjInfo.AttributeStart = customDataLength;
                            int objRambytes = hmiObj.GetObjRamBytes(ref OverBytes, customDataLength);
                            if (objRambytes != 0)
                            {
                                hmiObj.ObjInfo.AttributeLength = (ushort)objRambytes;
                                customDataLength += hmiObj.ObjInfo.AttributeLength;
                            }
                        }
                    }
                }
            }
            addString(OverBytes, data);

            List<byte[]> bts = new List<byte[]>();
            for (int idxPage = 0; idxPage < HmiPages.Count; idxPage++)
            {
                HmiPage hmiPage = HmiPages[idxPage];

                if (compile && !hmiPage.Compile(textCompile))
                    success = false;
                else
                {
                    Application.DoEvents();

                    InfoPage infoPage = new InfoPage
                    {
                        ObjCount = (byte)hmiPage.HmiObjects.Count,
                        Name = Utility.ToStruct<InfoName>(Utility.ToBytes(hmiPage.Name, 14))
                    };
                    if (infoPage.ObjCount > 0)
                    {
                        infoPage.ObjStart = (ushort)data.m_infoObjects.Count;

                        for (int idxObj = 0; idxObj < hmiPage.HmiObjects.Count; idxObj++)
                        {
                            HmiObject hmiObj = hmiPage.HmiObjects[idxObj];
                            hmiObj.ObjInfo.Name = Utility.ToStruct<InfoName>(Utility.ToBytes(hmiObj.ObjName, 14));
                            bts.Clear();
                            if (compile)
                                hmiObj.CompileCodes(bts);
                            else
                                hmiObj.GetCodes(bts);

                            if (bts.Count > 0)
                            {
                                hmiObj.ObjInfo.StringInfoStart = (ushort)data.m_infoStrings.Count;
                                for (int k = 0; k < bts.Count; k++)
                                    addString(bts[k], data);

                                hmiObj.ObjInfo.StringInfoEnd = (ushort)((hmiObj.ObjInfo.StringInfoStart + bts.Count) - 1);
                            }
                            else
                            {
                                MessageBox.Show("Detect the component code is 0, error will occur when save the source file".Translate());
                                hmiObj.ObjInfo.StringInfoStart = 0xffff;
                                hmiObj.ObjInfo.StringInfoEnd = 0xffff;
                            }
                            data.m_infoObjects.Add(hmiObj.ObjInfo);
                        }
                        infoPage.ObjEnd = (ushort)((infoPage.ObjStart + hmiPage.HmiObjects.Count) - 1);
                    }
                    else
                    {
                        infoPage.ObjStart = 0xffff;
                        infoPage.ObjEnd = 0xffff;
                    }
                    if (compile)
                    {
                        infoPage.InstStart = (ushort)data.m_infoStrings.Count;
                        for (int num5 = 0; num5 < hmiPage.Codes.Count; num5++)
                            addString(hmiPage.Codes[num5], data);
                        infoPage.InstEnd = (ushort)(data.m_infoStrings.Count - 1);
                    }
                    else
                    {
                        infoPage.InstStart = 0xffff;
                        infoPage.InstEnd = 0xffff;
                    }
                    data.m_infoPages.Add(infoPage);
                }
            }

            if (success)
            {
                infoApp.PageCount = (ushort)data.m_infoPages.Count;
                infoApp.ObjectCount = (ushort)data.m_infoObjects.Count;
                infoApp.FontCount = (ushort)Fonts.Count;
                infoApp.PictureCount = (ushort)Pictures.Count;
                infoApp.PictureImageStart = (uint)HmiOptions.InfoAppSize;

                if (compile)
                    infoApp.PictureImageStart = 0x1000;

                infoApp.FontImageStart = infoApp.PictureImageStart + ((uint)getPictureImagesSize());
                infoApp.StringDataStart = infoApp.FontImageStart + ((uint)getFontImagesSize());
                if (compile)
                {
                    uint num6 = infoApp.StringDataStart % 0x1000;
                    if (num6 != 0)
                        infoApp.StringDataStart += 0x1000 - num6;
                }

                infoApp.FirmwareStart = infoApp.StringDataStart + (uint)data.m_stringDataAddress;
                infoApp.FirmwareSize = 0;

                if (compile)
                {	// Add bootloader if compile
                    StreamReader reader = new StreamReader(Path.Combine(Application.StartupPath, "fwc.bin"));
                    infoApp.FirmwareSize = (uint)reader.BaseStream.Length;
                    reader.Close();
                }

                infoApp.PageStart = infoApp.FirmwareStart + infoApp.FirmwareSize;
                infoApp.ObjectStart = infoApp.PageStart + ((uint)(data.m_infoPages.Count * HmiOptions.InfoPageSize));
                infoApp.PictureStart = infoApp.ObjectStart + ((uint)(infoApp.ObjectCount * HmiOptions.InfoObjectSize));
                infoApp.StringStart = infoApp.PictureStart + ((uint)(HmiOptions.InfoPictureSize * infoApp.PictureCount));
                infoApp.StringCount = (uint)data.m_infoStrings.Count;
                infoApp.FontStart = infoApp.StringStart + ((uint)(HmiOptions.InfoStringSize * data.m_infoStrings.Count));
                infoApp.FontDataStart = infoApp.FontStart + ((uint)(HmiOptions.InfoFontSize * infoApp.FontCount));
            }
            return success;
        }
Esempio n. 4
0
        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];
                    font.DataOffset = dataStart;
                    buffer = Utility.ToBytes(font);
                    writer.BaseStream.Write(buffer, 0, HmiOptions.InfoFontSize);
                    dataStart += (uint)FontImages[idx].Length;
                }
                writer.Close();
                writer.Dispose();
                textCompile.AddRichTextString(
                    string.Concat(
                        "Compile Success!".Translate(), " ",
                        Errors, " Errors,".Translate(), " ",
                        Warnings, " Warnings, FileSize:".Translate(), infoApp.FontDataStart
                        ),
                    Color.Black);
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return false;
        }
Esempio n. 5
0
        private bool prepareToSave(
            ref InfoApp infoApp,
            bool compile,
            RichTextBox textCompile,
            SaveToFileData data
            )
        {
            infoApp.IsPotrait    = (byte)(IsPotrait ? 1 : 0);
            infoApp.ScreenWidth  = (IsPotrait ? LcdHeight : LcdWidth);
            infoApp.ScreenHeight = (IsPotrait ? LcdWidth : LcdHeight);

            bool   success          = true;
            ushort customDataLength = 0;

            OverBytes = Utility.ToBytes((uint)customDataLength);

            if (compile)
            {
                for (int idxPage = 0; idxPage < HmiPages.Count; idxPage++)
                {
                    HmiPage hmiPage = HmiPages[idxPage];
                    for (int idxObj = 0; idxObj < hmiPage.HmiObjects.Count; ++idxObj)
                    {
                        HmiObject hmiObj = hmiPage.HmiObjects[idxObj];

                        hmiObj.ObjInfo.ObjType      = hmiObj.Attributes[0].Data[0];
                        hmiObj.ObjInfo.IsCustomData = hmiObj.Attributes[1].Data[0];

                        if (hmiObj.ObjInfo.IsCustomData == 1)
                        {
                            hmiObj.ObjInfo.AttributeStart = customDataLength;
                            int objRambytes = hmiObj.GetObjRamBytes(ref OverBytes, customDataLength);
                            if (objRambytes != 0)
                            {
                                hmiObj.ObjInfo.AttributeLength = (ushort)objRambytes;
                                customDataLength += hmiObj.ObjInfo.AttributeLength;
                            }
                        }
                    }
                }
            }
            addString(OverBytes, data);

            List <byte[]> bts = new List <byte[]>();

            for (int idxPage = 0; idxPage < HmiPages.Count; idxPage++)
            {
                HmiPage hmiPage = HmiPages[idxPage];

                if (compile && !hmiPage.Compile(textCompile))
                {
                    success = false;
                }
                else
                {
                    Application.DoEvents();

                    InfoPage infoPage = new InfoPage
                    {
                        ObjCount = (byte)hmiPage.HmiObjects.Count,
                        Name     = Utility.ToStruct <InfoName>(Utility.ToBytes(hmiPage.Name, 14))
                    };
                    if (infoPage.ObjCount > 0)
                    {
                        infoPage.ObjStart = (ushort)data.m_infoObjects.Count;

                        for (int idxObj = 0; idxObj < hmiPage.HmiObjects.Count; idxObj++)
                        {
                            HmiObject hmiObj = hmiPage.HmiObjects[idxObj];
                            hmiObj.ObjInfo.Name = Utility.ToStruct <InfoName>(Utility.ToBytes(hmiObj.ObjName, 14));
                            bts.Clear();
                            if (compile)
                            {
                                hmiObj.CompileCodes(bts);
                            }
                            else
                            {
                                hmiObj.GetCodes(bts);
                            }

                            if (bts.Count > 0)
                            {
                                hmiObj.ObjInfo.StringInfoStart = (ushort)data.m_infoStrings.Count;
                                for (int k = 0; k < bts.Count; k++)
                                {
                                    addString(bts[k], data);
                                }

                                hmiObj.ObjInfo.StringInfoEnd = (ushort)((hmiObj.ObjInfo.StringInfoStart + bts.Count) - 1);
                            }
                            else
                            {
                                MessageBox.Show("Detect the component code is 0, error will occur when save the source file".Translate());
                                hmiObj.ObjInfo.StringInfoStart = 0xffff;
                                hmiObj.ObjInfo.StringInfoEnd   = 0xffff;
                            }
                            data.m_infoObjects.Add(hmiObj.ObjInfo);
                        }
                        infoPage.ObjEnd = (ushort)((infoPage.ObjStart + hmiPage.HmiObjects.Count) - 1);
                    }
                    else
                    {
                        infoPage.ObjStart = 0xffff;
                        infoPage.ObjEnd   = 0xffff;
                    }
                    if (compile)
                    {
                        infoPage.InstStart = (ushort)data.m_infoStrings.Count;
                        for (int num5 = 0; num5 < hmiPage.Codes.Count; num5++)
                        {
                            addString(hmiPage.Codes[num5], data);
                        }
                        infoPage.InstEnd = (ushort)(data.m_infoStrings.Count - 1);
                    }
                    else
                    {
                        infoPage.InstStart = 0xffff;
                        infoPage.InstEnd   = 0xffff;
                    }
                    data.m_infoPages.Add(infoPage);
                }
            }

            if (success)
            {
                infoApp.PageCount         = (ushort)data.m_infoPages.Count;
                infoApp.ObjectCount       = (ushort)data.m_infoObjects.Count;
                infoApp.FontCount         = (ushort)Fonts.Count;
                infoApp.PictureCount      = (ushort)Pictures.Count;
                infoApp.PictureImageStart = (uint)HmiOptions.InfoAppSize;

                if (compile)
                {
                    infoApp.PictureImageStart = 0x1000;
                }

                infoApp.FontImageStart  = infoApp.PictureImageStart + ((uint)getPictureImagesSize());
                infoApp.StringDataStart = infoApp.FontImageStart + ((uint)getFontImagesSize());
                if (compile)
                {
                    uint num6 = infoApp.StringDataStart % 0x1000;
                    if (num6 != 0)
                    {
                        infoApp.StringDataStart += 0x1000 - num6;
                    }
                }

                infoApp.FirmwareStart = infoApp.StringDataStart + (uint)data.m_stringDataAddress;
                infoApp.FirmwareSize  = 0;

                if (compile)
                {                       // Add bootloader if compile
                    StreamReader reader = new StreamReader(Path.Combine(Application.StartupPath, "fwc.bin"));
                    infoApp.FirmwareSize = (uint)reader.BaseStream.Length;
                    reader.Close();
                }

                infoApp.PageStart     = infoApp.FirmwareStart + infoApp.FirmwareSize;
                infoApp.ObjectStart   = infoApp.PageStart + ((uint)(data.m_infoPages.Count * HmiOptions.InfoPageSize));
                infoApp.PictureStart  = infoApp.ObjectStart + ((uint)(infoApp.ObjectCount * HmiOptions.InfoObjectSize));
                infoApp.StringStart   = infoApp.PictureStart + ((uint)(HmiOptions.InfoPictureSize * infoApp.PictureCount));
                infoApp.StringCount   = (uint)data.m_infoStrings.Count;
                infoApp.FontStart     = infoApp.StringStart + ((uint)(HmiOptions.InfoStringSize * data.m_infoStrings.Count));
                infoApp.FontDataStart = infoApp.FontStart + ((uint)(HmiOptions.InfoFontSize * infoApp.FontCount));
            }
            return(success);
        }
Esempio n. 6
0
        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];
                    font.DataOffset = dataStart;
                    buffer          = Utility.ToBytes(font);
                    writer.BaseStream.Write(buffer, 0, HmiOptions.InfoFontSize);
                    dataStart += (uint)FontImages[idx].Length;
                }
                writer.Close();
                writer.Dispose();
                textCompile.AddRichTextString(
                    string.Concat(
                        "Compile Success!".Translate(), " ",
                        Errors, " Errors,".Translate(), " ",
                        Warnings, " Warnings, FileSize:".Translate(), infoApp.FontDataStart
                        ),
                    Color.Black);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(false);
        }