Exemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists(FilePath))
            {
                MessageBox.Show(string.Format("Invalid path [{0}]", FilePath), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var files = Directory.GetFiles(FilePath, "*", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                string filePath = file;

                string content;
                content = File.ReadAllText(filePath);

                content = content.Replace(OldText, NewText);

                File.Delete(filePath);
                if (System.IO.Path.GetFileNameWithoutExtension(file).Trim() == OldText.Trim())
                {
                    filePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(file), NewText + System.IO.Path.GetExtension(file));
                }

                File.WriteAllText(filePath, content);

                OutputText += string.Format("{0}File [{1}] changed.", Environment.NewLine, filePath);
            }
        }
Exemplo n.º 2
0
        //判断脚本文件内容是否改变
        private bool ScriptTextChange()
        {
            bool   ScriptTextChange = false;
            string Present          = ScriptTextBox.Text;

            //选中的脚本不为空 点击的节点不为空(树节点的父节点或者叶子结点)
            if (SelectScript != string.Empty && ClickNode != null && ClickNode.Nodes.Count == 0)
            {
                //旧文本为空,当前文本内容为空,则Flag为False
                if (OldText == string.Empty && Present == string.Empty)
                {
                    return(false);
                }
                //旧文本不为空,当前文本为空,Flag为True
                else if (OldText != string.Empty && Present == string.Empty)
                {
                    ScriptTextChange = true;
                }
                //旧文本为空,当前文本不为空,Flag为True
                else if (OldText == string.Empty && Present != string.Empty)
                {
                    ScriptTextChange = true;
                }
                //旧文本不等于当前文本,Flag为False
                else if (OldText.CompareTo(Present) != 0)
                {
                    ScriptTextChange = true;
                }
                //其他情况,默认Flag为False,即没有改变
            }

            return(ScriptTextChange);
        }
Exemplo n.º 3
0
 public void GetSql(DbTarget db_target, ref StringBuilder sql)
 {
     sql.Append("REPLACE(");
     if (!Text.IsLiteral)
     {
         sql.Append("(");
     }
     Text.GetSql(db_target, ref sql);
     if (!Text.IsLiteral)
     {
         sql.Append(")");
     }
     sql.Append(",");
     if (!OldText.IsLiteral)
     {
         sql.Append("(");
     }
     OldText.GetSql(db_target, ref sql);
     if (!OldText.IsLiteral)
     {
         sql.Append(")");
     }
     sql.Append(",");
     if (!NewText.IsLiteral)
     {
         sql.Append("(");
     }
     NewText.GetSql(db_target, ref sql);
     if (!NewText.IsLiteral)
     {
         sql.Append(")");
     }
     sql.Append(")");
 }
Exemplo n.º 4
0
 private void ShowOldStats(Staff old)
 {
     oldname.text    = old.name;
     olddescrip.text = WrapText(old.descrip, 20);
     oldp.text       = old.power.ToString();
     oldf.text       = old.firerate.ToString();
     oldr.text       = old.reloadspeed.ToString();
     OldText.SetActive(true);
 }
Exemplo n.º 5
0
 void ShowText()
 {
     transform.Find("to").gameObject.SetActive(true);
     newptextg.GetComponent <TextMesh>().text = "POWER:";
     newftextg.GetComponent <TextMesh>().text = "FIRERATE:";
     newrtextg.GetComponent <TextMesh>().text = "RELOAD:";
     OldText.SetActive(true);
     slothightlight.SetActive(true);
 }
Exemplo n.º 6
0
        private static void GetAllLines(string fullPath, string path)
        {
            var tmpText = File.ReadAllLines(fullPath);

            //var fi = new FileInfo(path);
            for (int i = 0; i < tmpText.Length; i++)
            {
                var tmpLine = new Line(LineBuilder.GetWords(tmpText[i]), tmpText[i]);
                tmpLine.Number = i + 1;
                //tmpLine.FileName = IncludeName + Extension.BPInclude;
                tmpLine.FileName = fullPath;
                //tmpLine.FileName = fi.Name;
                tmpLine.Type = LineBuilder.GetType(tmpLine);

                if (tmpLine.Type == LineType.INCLUDE)
                {
                    Data.Errors.Add(new Errore(tmpLine.Number, IncludeName + Extension.BPInclude, 1105, ""));
                    //Data.Errors.Add(new Errore(tmpLine.Number, fi.Name, 1105, ""));
                    return;
                }
                else if (tmpLine.Type == LineType.FOLDER)
                {
                    Data.Errors.Add(new Errore(tmpLine.Number, IncludeName + Extension.BPInclude, 1106, ""));
                    //Data.Errors.Add(new Errore(tmpLine.Number, fi.Name, 1106, ""));
                    return;
                }
                else if (tmpLine.Type == LineType.IMPORT)
                {
                    ImportErrorParser.Start(tmpLine, path);
                    if (Data.Errors.Count > 0)
                    {
                        return;
                    }
                }

                // Парсим ошибки на количество скобок в строке
                BracketErrorParser.Start(tmpLine);
                if (Data.Errors.Count > 0)
                {
                    return;
                }

                Lines.Add(tmpLine);
                OldText.Add(tmpText[i]);
            }
        }
Exemplo n.º 7
0
        public void Execute(CaseSet testCases)
        {
            if (!testCases.Variables.Contains(ColumnName))
            {
                throw new ArgumentOutOfRangeException(String.Format("No column named '{0}' has been found.", ColumnName));
            }

            var index = testCases.Variables.ToList().FindIndex(v => v == ColumnName);

            foreach (DataRow row in testCases.Content.Rows)
            {
                if ((string)row[ColumnName] != "(none)")
                {
                    if (NewText.GetValue(row) != "(none)" && OldText.GetValue(row) != "(none)")
                    {
                        row[ColumnName] = ((string)row[ColumnName]).Replace(OldText.GetValue(row), NewText.GetValue(row));
                    }
                    else
                    {
                        row[ColumnName] = "(none)";
                    }
                }
            }
        }
Exemplo n.º 8
0
 private void ClearOldStats()
 {
     OldText.SetActive(false);
 }