コード例 #1
0
ファイル: Form1.cs プロジェクト: shawwwn/BJ_Edit
 private wts_struct[] bubbleUp(wts_struct[] Array)
 {
     for (int i = 0; i < Array.Length; i++)
     {
         for (int j = i + 1; j < Array.Length; j++)
         {
             if (Array[i].index > Array[j].index)
             {
                 wts_struct temp = Array[i];
                 Array[i] = Array[j];
                 Array[j] = temp;
             }
         }
     }
     return Array;
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: shawwwn/BJ_Edit
 private wts_struct[] bubbleUp(wts_struct[] Array)
 {
     for (int i = 0; i < Array.Length; i++)
     {
         for (int j = i + 1; j < Array.Length; j++)
         {
             if (Array[i].index > Array[j].index)
             {
                 wts_struct temp = Array[i];
                 Array[i] = Array[j];
                 Array[j] = temp;
             }
         }
     }
     return(Array);
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: shawwwn/BJ_Edit
        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            listBox1.Items.Clear();
            StreamReader sr      = new StreamReader(openFileDialog1.FileName);
            string       content = sr.ReadToEnd();

            sr.Close();
            Regex           r  = new Regex(@"STRING(?:.|\n)*?}", RegexOptions.IgnoreCase);
            Regex           r2 = new Regex(@"{(?:.|\n)*?}", RegexOptions.IgnoreCase);
            MatchCollection mc = r.Matches(content);

            wts = new wts_struct[mc.Count];
            for (int i = 0; i < mc.Count; i++)
            {
                wts[i] = new wts_struct();
                string tmp = mc[i].Value;
                wts[i].index = int.Parse(tmp.Substring(6, tmp.IndexOf(Environment.NewLine) - 6).Trim());
                //listBox1.Items.Add(wts[i].index);
                wts[i].header = "STRING " + wts[i].index.ToString();
                listBox1.Items.Add(wts[i].header);  //添加到listbox

                string[] lines = tmp.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < lines.Length; j++)
                {
                    if (lines[j].IndexOf(@"//") == 0)
                    {
                        wts[i].description += lines[j] + Environment.NewLine;
                    }
                }
                wts[i].content = r2.Match(tmp).Value.Trim(new[] { '{', '}' }).Trim();
            }
            //=========完毕=========
            IsFirstTime = true;

            /*
             * listBox1.DataSource = wts;
             * listBox1.DisplayMember = "header";
             * listBox1.ValueMember = "index";
             */
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: shawwwn/BJ_Edit
        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; }
            listBox1.Items.Clear();
            StreamReader sr = new StreamReader(openFileDialog1.FileName);
            string content = sr.ReadToEnd();
            sr.Close();
            Regex r = new Regex(@"STRING(?:.|\n)*?}", RegexOptions.IgnoreCase);
            Regex r2 = new Regex(@"{(?:.|\n)*?}", RegexOptions.IgnoreCase);
            MatchCollection mc = r.Matches(content);
            wts = new wts_struct[mc.Count];
            for (int i = 0; i < mc.Count; i++)
            {
                wts[i]=new wts_struct();
                string tmp = mc[i].Value;
                wts[i].index = int.Parse(tmp.Substring(6, tmp.IndexOf(Environment.NewLine) - 6).Trim());
                //listBox1.Items.Add(wts[i].index);
                wts[i].header = "STRING " + wts[i].index.ToString();
                listBox1.Items.Add(wts[i].header);  //添加到listbox

                string[] lines = tmp.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < lines.Length; j++)
                {
                    if (lines[j].IndexOf(@"//") == 0)
                    {
                        wts[i].description += lines[j] + Environment.NewLine;
                    }
                }
                wts[i].content = r2.Match(tmp).Value.Trim(new[] { '{', '}' }).Trim();
            }
            //=========完毕=========
            IsFirstTime = true;
            /*
            listBox1.DataSource = wts;
            listBox1.DisplayMember = "header";
            listBox1.ValueMember = "index";
            */
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: shawwwn/BJ_Edit
        private void button3_Click(object sender, EventArgs e)
        {
            if (wts == null || wts.Length<=0) { MessageBox.Show("需要先载入wts。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
            if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; }
            //listBox1.ClearSelected();
            listBox1.Enabled = false;
            Application.DoEvents();
            StreamReader sr = new StreamReader(openFileDialog1.FileName);
            string content = sr.ReadToEnd();
            sr.Close();
            Regex r = new Regex(@"STRING(?:.|\n)*?}", RegexOptions.IgnoreCase);
            Regex r2 = new Regex(@"{(?:.|\n)*?}", RegexOptions.IgnoreCase);
            MatchCollection mc = r.Matches(content);
            wts_struct[] import = new wts_struct[mc.Count];
            int count = 0;
            for (int i = 0; i < mc.Count; i++)
            {
                import[i] = new wts_struct();
                string tmp = mc[i].Value;
                import[i].index = int.Parse(tmp.Substring(6, tmp.IndexOf(Environment.NewLine) - 6).Trim());
                //listBox1.Items.Add(wts[i].index);
                import[i].header = "STRING " + import[i].index.ToString();
                string[] lines = tmp.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < lines.Length; j++)
                {
                    if (lines[j].IndexOf(@"//") == 0)
                    {
                        import[i].description += lines[j] + Environment.NewLine;
                    }
                }
                import[i].content = r2.Match(tmp).Value.Trim(new[] { '{', '}' }).Trim();
                //查找并替换
                if (import[i].description.Trim() != "")
                {

                    int point = import[i].description.IndexOf(":") + 1;
                    string ID = import[i].description.Substring(point, import[i].description.IndexOf('(') - point).Trim();
                    //MessageBox.Show(ID);
                    point = import[i].description.LastIndexOf('[') + 1;
                    string subID = import[i].description.Substring(point, import[i].description.LastIndexOf(']') - point).Trim();
                    //MessageBox.Show(subID);

                    if (ID != "" && subID != "")
                    {
                        for (int k = 0; k < wts.Length; k++)
                        {
                            if (wts[k].description.Trim() != "")
                            {
                                point = wts[k].description.IndexOf(':') + 1;
                                string ID2 = wts[k].description.Substring(point, wts[k].description.IndexOf('(') - point).Trim();
                                point = wts[k].description.LastIndexOf('[') + 1;
                                string subID2 = wts[k].description.Substring(point, wts[k].description.IndexOf(']') - point).Trim();
                                if (ID == ID2 && subID == subID2)   //找到
                                {
                                    wts[k].header = import[i].header;
                                    wts[k].description = import[i].description;
                                    wts[k].content = import[i].content;
                                    wts[k].index = import[i].index;
                                    listBox1.Items[k] = import[i].header;
                                    count++;
                                    Application.DoEvents();
                                }
                            }
                        }
                    }
                }
            }
            listBox1.Enabled = true;
            IsFirstTime = true;
            MessageBox.Show("一共替换 " + count + " 个字符串。");
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: shawwwn/BJ_Edit
        private void button3_Click(object sender, EventArgs e)
        {
            if (wts == null || wts.Length <= 0)
            {
                MessageBox.Show("需要先载入wts。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            //listBox1.ClearSelected();
            listBox1.Enabled = false;
            Application.DoEvents();
            StreamReader sr      = new StreamReader(openFileDialog1.FileName);
            string       content = sr.ReadToEnd();

            sr.Close();
            Regex           r  = new Regex(@"STRING(?:.|\n)*?}", RegexOptions.IgnoreCase);
            Regex           r2 = new Regex(@"{(?:.|\n)*?}", RegexOptions.IgnoreCase);
            MatchCollection mc = r.Matches(content);

            wts_struct[] import = new wts_struct[mc.Count];
            int          count  = 0;

            for (int i = 0; i < mc.Count; i++)
            {
                import[i] = new wts_struct();
                string tmp = mc[i].Value;
                import[i].index = int.Parse(tmp.Substring(6, tmp.IndexOf(Environment.NewLine) - 6).Trim());
                //listBox1.Items.Add(wts[i].index);
                import[i].header = "STRING " + import[i].index.ToString();
                string[] lines = tmp.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < lines.Length; j++)
                {
                    if (lines[j].IndexOf(@"//") == 0)
                    {
                        import[i].description += lines[j] + Environment.NewLine;
                    }
                }
                import[i].content = r2.Match(tmp).Value.Trim(new[] { '{', '}' }).Trim();
                //查找并替换
                if (import[i].description.Trim() != "")
                {
                    int    point = import[i].description.IndexOf(":") + 1;
                    string ID    = import[i].description.Substring(point, import[i].description.IndexOf('(') - point).Trim();
                    //MessageBox.Show(ID);
                    point = import[i].description.LastIndexOf('[') + 1;
                    string subID = import[i].description.Substring(point, import[i].description.LastIndexOf(']') - point).Trim();
                    //MessageBox.Show(subID);

                    if (ID != "" && subID != "")
                    {
                        for (int k = 0; k < wts.Length; k++)
                        {
                            if (wts[k].description.Trim() != "")
                            {
                                point = wts[k].description.IndexOf(':') + 1;
                                string ID2 = wts[k].description.Substring(point, wts[k].description.IndexOf('(') - point).Trim();
                                point = wts[k].description.LastIndexOf('[') + 1;
                                string subID2 = wts[k].description.Substring(point, wts[k].description.IndexOf(']') - point).Trim();
                                if (ID == ID2 && subID == subID2)   //找到
                                {
                                    wts[k].header      = import[i].header;
                                    wts[k].description = import[i].description;
                                    wts[k].content     = import[i].content;
                                    wts[k].index       = import[i].index;
                                    listBox1.Items[k]  = import[i].header;
                                    count++;
                                    Application.DoEvents();
                                }
                            }
                        }
                    }
                }
            }
            listBox1.Enabled = true;
            IsFirstTime      = true;
            MessageBox.Show("一共替换 " + count + " 个字符串。");
        }