Exemple #1
0
        public VisualEditEx(string strOld, StringBuilder newString, SqlConnection Conn, Form parentForm, string RootDir, bool bImageSupport, int nDefFont)
        {
            InitializeComponent();

            m_bImageSupport = bImageSupport;
            Code            = strOld;
            m_Root          = RootDir;
            m_newString     = newString;
            m_nDefFont      = nDefFont;

            font = new FontHelper(m_Root + FontFile, m_Root + FontListFile, m_Root + ColorFile, m_Root);

            string[] FontNames = font.GetAllFontName();


            foreach (string strName in FontNames)
            {
                FontBox.Items.Add(strName);
            }
            FontBox.Items.Add("默认(" + m_nDefFont.ToString() + " )");

            m_nLastLength = 0;
            MarkArray     = new ArrayList();
            ImageArray    = new ArrayList();

            defFont  = font.GetFontByID(m_nDefFont);
            defColor = font.GetColorByID(m_nDefFont);
            textBox.SelectionFont  = defFont;
            textBox.SelectionColor = defColor;

            refreshText();
        }
Exemple #2
0
        public VisualEditEx(string strOld, StringBuilder newString, SqlConnection Conn, Form parentForm, string RootDir, bool bImageSupport, int nDefFont)
        {
            InitializeComponent();

            m_bImageSupport = bImageSupport;
            Code = strOld;
            m_Root = RootDir;
            m_newString = newString;
            m_nDefFont = nDefFont;

            font = new FontHelper(m_Root + FontFile, m_Root + FontListFile, m_Root + ColorFile, m_Root);

            string[] FontNames = font.GetAllFontName();

            
            foreach (string strName in FontNames)
            {
                FontBox.Items.Add(strName);
            }
            FontBox.Items.Add("默认(" + m_nDefFont.ToString() +" )");

            m_nLastLength = 0;
            MarkArray = new ArrayList();
            ImageArray = new ArrayList();

            defFont = font.GetFontByID(m_nDefFont);
            defColor = font.GetColorByID(m_nDefFont);
            textBox.SelectionFont = defFont;
            textBox.SelectionColor = defColor;

            refreshText();
        }
Exemple #3
0
        public VisualEditDungeonEx(SqlConnection Conn, Class1 parentClass, string RootDir, bool bImageSupport, int nFont)
        {
            InitializeComponent();

            m_bImageSupport = bImageSupport;
            m_Root = RootDir;
            m_bHasChanged = false;
            m_Parent = parentClass;
            m_strTabName = "tbl_Guide_Dungeon";
            m_Conn = Conn;
            m_LastTags = new Object[2];
			m_nDefFont = nFont;
            font = new FontHelper(m_Root + FontFile, m_Root + FontListFile, m_Root + ColorFile, m_Root);

            string[] FontNames = font.GetAllFontName();

            
            foreach (string strName in FontNames)
            {
                FontBox.Items.Add(strName);
            }
            FontBox.Items.Add("默认(" + m_nDefFont.ToString() + ")");

            m_nLastLength = 0;
            MarkArray = new ArrayList();
            ImageArray = new ArrayList();
            LinkArray = new ArrayList();

            defFont = font.GetFontByID(m_nDefFont);
            defColor = font.GetColorByID(m_nDefFont);
            textBox.SelectionColor = defColor;
            textBox.SelectionFont = defFont;

            refreshText();
        }
        public VisualEditDungeonEx(SqlConnection Conn, Class1 parentClass, string RootDir, bool bImageSupport, int nFont)
        {
            InitializeComponent();

            m_bImageSupport = bImageSupport;
            m_Root          = RootDir;
            m_bHasChanged   = false;
            m_Parent        = parentClass;
            m_strTabName    = "tbl_Guide_Dungeon";
            m_Conn          = Conn;
            m_LastTags      = new Object[2];
            m_nDefFont      = nFont;
            font            = new FontHelper(m_Root + FontFile, m_Root + FontListFile, m_Root + ColorFile, m_Root);

            string[] FontNames = font.GetAllFontName();


            foreach (string strName in FontNames)
            {
                FontBox.Items.Add(strName);
            }
            FontBox.Items.Add("默认(" + m_nDefFont.ToString() + ")");

            m_nLastLength = 0;
            MarkArray     = new ArrayList();
            ImageArray    = new ArrayList();
            LinkArray     = new ArrayList();

            defFont  = font.GetFontByID(m_nDefFont);
            defColor = font.GetColorByID(m_nDefFont);
            textBox.SelectionColor = defColor;
            textBox.SelectionFont  = defFont;

            refreshText();
        }
Exemple #5
0
        public void refreshText()
        {
            MarkArray.Clear();
            ImageArray.Clear();
            textBox.TextChanged -= new System.EventHandler(this.richTextBox2_TextChanged);

            textBox.Text = string.Empty;
            string strCode     = Code;
            int    nIndexP     = -1;
            int    nIndexE     = -1;
            int    nIndexMarkP = -1;
            int    nIndexMarkE = -1;
            int    nStart      = 0;

            bool bEnd      = false;
            bool bImageEnd = false;

            while (true)
            {
                string strToAdd = string.Empty;
                nIndexP = strCode.IndexOf(textMark, nIndexP + 1);
                if (!bImageEnd)
                {
                    nIndexMarkP = strCode.IndexOf(imageMark, nIndexMarkP + 1);
                    if (nIndexMarkP == -1)
                    {
                        bImageEnd = true;
                    }
                }

                string strImageMark = CheckImageMark(nIndexP, nIndexMarkP);

                if (nIndexP == -1 && nIndexMarkP < 0)
                {
                    strToAdd = strToAdd + strCode.Substring(nStart, strCode.Length - nStart);
                    bEnd     = true;
                }
                else
                {
                    if (strImageMark == string.Empty)
                    {
                        strToAdd = strToAdd + strCode.Substring(nStart, nIndexP - nStart);
                    }
                    else
                    {
                        strToAdd = strToAdd + strCode.Substring(nStart, nIndexMarkP - nStart);
                    }
                }

                int nIndex = 0;
                if (strToAdd != string.Empty)
                {
                    // 默认字体
                    strToAdd = strToAdd.Replace("\\\\\\n", "\n");
                    nIndex   = textBox.Text.Length;

                    textBox.AppendText(strToAdd);

                    textBox.Select(nIndex, strToAdd.Length);
                    textBox.SelectionFont  = defFont;
                    textBox.SelectionColor = defColor;

                    for (int i = 0; i < strToAdd.Length; i++)
                    {
                        MarkArray.Insert(nIndex++, m_nDefFont as Object);
                    }
                }

                if (bEnd)
                {
                    break;
                }

                if (strImageMark != string.Empty)
                {
                    MarkArray.Add(ImageArray.Count + ImageMark);
                    ImageArray.Add(strImageMark);

                    int nCurPos = strImageMark.IndexOf(frameMark);

                    string filename = strImageMark.Substring(imageMark.Length, nCurPos - imageMark.Length);
                    filename = m_Root + filename;


                    int nWidthMarkPos = strImageMark.IndexOf(widthMark, nCurPos);
                    int nFrame        = Int32.Parse(strImageMark.Substring(nCurPos + frameMark.Length, nWidthMarkPos - nCurPos - frameMark.Length));
                    //int nWidth = 0;
                    //int nHeight = 0;
                    //////////////////////////////////////////////////////////////////////////
                    //这个功能暂未实现,标签有,无预览效果
                    //////////////////////////////////////////////////////////////////////////

                    string retRTF = RTFHelper.GetRTFFromTgaFile(filename, textBox, nFrame);
                    textBox.Select(textBox.Text.Length, 0);
                    textBox.SelectedRtf = retRTF;

                    nIndexMarkE = strCode.IndexOf(frameEndMark, nIndexMarkP);
                    nStart      = nIndexMarkE + frameEndMark.Length;
                    nIndexP     = nStart - 1;
                    continue;
                }

                // 特定字体
                strToAdd = string.Empty;
                nIndexP  = nIndexP + textMark.Length;
                nIndexE  = strCode.IndexOf(fontMark, nIndexP);

                strToAdd = strToAdd + strCode.Substring(nIndexP, nIndexE - nIndexP);

                nIndexP = nIndexP + strToAdd.Length + fontMark.Length;
                nIndexE = strCode.IndexOf(fontEndMark, nIndexP);

                string strFontID = strCode.Substring(nIndexP, nIndexE - nIndexP);
                int    nFontID   = Int32.Parse(strFontID);
                nStart = nIndexE + fontEndMark.Length;

                Color CurColor = font.GetColorByID(nFontID);
                Font  CurFont  = font.GetFontByID(nFontID);

                strToAdd = strToAdd.Replace("\\\\\\n", "\n");

                nIndex = textBox.Text.Length;
                textBox.AppendText(strToAdd);

                textBox.Select(nIndex, strToAdd.Length);
                textBox.SelectionColor = CurColor;
                textBox.SelectionFont  = CurFont;


                for (int i = 0; i < strToAdd.Length; i++)
                {
                    MarkArray.Insert(nIndex++, nFontID as Object);
                }

                nIndexMarkP--;
            }
            textBox.TextChanged += new System.EventHandler(this.richTextBox2_TextChanged);
            m_nLastLength        = textBox.Text.Length;
        }