protected virtual void OnReplaceText(ReplaceEventArgs args)
 {
     if (ReplaceText != null)
     {
         ReplaceText.Invoke(this, args);
     }
 }
Exemple #2
0
        private void btnAddReplaceText_Click(object sender, EventArgs e)
        {
            ReplaceText rt = new ReplaceText();

            rt.OriginalText = txtOriginalText.Text;
            rt.NewText      = txtNewText.Text;
            admin.Library.configuration.GitHubFile_TextToReplace_List.Add(rt);
            RefreshReplaceTextList();
        }
Exemple #3
0
        public void Do( ITextBuffer target )
        {
            if( replaceTextCommand == null )
            {
                target.MovePoint( Direction.Left, removed.Length );
                replaceTextCommand = new ReplaceText( target, "" );
            }

            replaceTextCommand.Do( target );
        }
        public void ShouldFormatTextIntoString()
        {
            //Arrange
            ReplaceText subject = new ReplaceText(new TextOf("any text ##Name##"), new TextOf("##Name##"), new TextOf("Peg"));

            //Act
            string actual = subject;

            //Assert
            actual.Should().Be("any text Peg");
        }
Exemple #5
0
        /// <summary>
        /// Replace a text with new value into the document
        /// </summary>
        /// <param name="FileName"></param>
        /// <param name="OldValue"></param>
        /// <param name="NewValue"></param>
        /// <param name="IsMatchCase"></param>
        /// <param name="IsMatchWholeWord"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        public void replaceText(string FileName, string OldValue, string NewValue, bool IsMatchCase, bool IsMatchWholeWord, string output)
        {
            try
            {
                //build URI to get Image
                string strURI = Product.BaseProductUri + "/words/" + FileName + "/replaceText";

                string signedURI = Utils.Sign(strURI);

                //serialize the JSON request content
                ReplaceText repacetext = new ReplaceText();
                repacetext.OldValue         = OldValue;
                repacetext.NewValue         = NewValue;
                repacetext.IsMatchCase      = IsMatchCase;
                repacetext.IsMatchWholeWord = IsMatchWholeWord;

                string strJSON = JsonConvert.SerializeObject(repacetext);

                Stream responseStream = Utils.ProcessCommand(signedURI, "POST", strJSON);

                StreamReader reader      = new StreamReader(responseStream);
                string       strResponse = reader.ReadToEnd();

                //Parse the json string to JObject
                JObject pJSON = JObject.Parse(strResponse);

                ReplaceTextResponse baseResponse = JsonConvert.DeserializeObject <ReplaceTextResponse>(pJSON.ToString());

                //sign URI
                signedURI = Utils.Sign(baseResponse.DocumentLink.Href + "?format=doc");

                //get response stream
                responseStream = Utils.ProcessCommand(signedURI, "GET");

                using (Stream fileStream = System.IO.File.OpenWrite(output))
                {
                    Utils.CopyStream(responseStream, fileStream);
                }
                responseStream.Close();
            }
            catch (Exception ex)
            {
            }
        }
Exemple #6
0
        /// <summary>
        /// 修改 variable.txt
        /// </summary>
        /// <param name="relocalizeLanguage">新的语言</param>
        /// <param name="relocalizeAsset">新的语音包</param>
        public static void ChangeVarTXT(String relocalizeLanguage, String relocalizeAsset)
        {
            try
            {
                String sc2VarLocation = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\StarCraft II\\Variables.txt";
                FileBackup.MultipleBackup(sc2VarLocation, 4);//备份文件
                //如果文件不存在,创建一个
                if (!File.Exists(sc2VarLocation))
                {
                    File.Create(sc2VarLocation);
                }

                //如果文件只读,取消只读
                FileInfo fInfo = new FileInfo(sc2VarLocation);
                if (fInfo.IsReadOnly)
                {
                    fInfo.IsReadOnly = false;
                }

                String text = File.ReadAllText(sc2VarLocation);

                //如果localeidassets不存在
                if (text.IndexOf("localeidassets=") == -1)
                {
                    text = text + "localeidassets=" + relocalizeAsset + "\r\n";
                    File.WriteAllText(sc2VarLocation, text);
                }
                //如果localeiddata不存在
                if (text.IndexOf("localeiddata=") == -1)
                {
                    text = text + "localeiddata=" + relocalizeLanguage + "\r\n";
                    File.WriteAllText(sc2VarLocation, text);
                }

                text = ReplaceText.ReplaceAfterSearchString(text, "localeiddata=", 4, relocalizeLanguage);
                text = ReplaceText.ReplaceAfterSearchString(text, "localeidassets=", 4, relocalizeAsset);
                File.WriteAllText(sc2VarLocation, text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #7
0
        private void CommitButton_Click(object sender, RoutedEventArgs e)
        {
            int i = 0;

            foreach (GameObject g in EngineManagerViewModel.instance.SelectedGameObjects)
            {
                ++i;

                //do replace pass first
                if (ReplaceText.Text.Count() != 0)
                {
                    g.SetName(ReplaceText.Text);
                }

                //then do prefix and suffix
                if (AppendText.Text.Count() != 0)
                {
                    g.SetName(g.GetName() + AppendText.Text);
                }
                if (PrefixText.Text.Count() != 0)
                {
                    g.SetName(PrefixText.Text + g.GetName());
                }

                //do append numbers pass last
                if (AppendNumbers.IsChecked.HasValue && AppendNumbers.IsChecked.Value)
                {
                    g.SetName(g.GetName() + i.ToString());
                }
            }

            ReplaceText.Clear();
            AppendText.Clear();
            PrefixText.Clear();

            EngineManagerViewModel.instance.ForceRefreshGameObjects();
        }
Exemple #8
0
 private void btnDeleteReplaceTextHTML_Click(object sender, EventArgs e)
 {
     try
     {
         if (listReplaceTextHTML.SelectedItems.Count > 0)
         {
             ReplaceText        rt  = (ReplaceText)listReplaceTextHTML.SelectedItem;
             List <ReplaceText> aux = new List <ReplaceText>();
             foreach (ReplaceText r in admin.Library.configuration.GitHubFile_TextToReplace_HTML_List)
             {
                 aux.Add(r);
             }
             foreach (ReplaceText r in aux)
             {
                 if (r == rt)
                 {
                     admin.Library.configuration.GitHubFile_TextToReplace_HTML_List.Remove(rt);
                 }
             }
         }
         RefreshReplaceTextHTMLList();
     }
     catch { }
 }
        /// <summary>
        /// Replace a text with new value into the document
        /// </summary>
        /// <param name="FileName"></param>
        /// <param name="OldValue"></param>
        /// <param name="NewValue"></param>
        /// <param name="IsMatchCase"></param>
        /// <param name="IsMatchWholeWord"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        public void replaceText(string FileName, string OldValue, string NewValue, bool IsMatchCase, bool IsMatchWholeWord, string output)
        {
            try
            {
                //build URI to get Image
                string strURI = Product.BaseProductUri + "/words/" + FileName + "/replaceText";

                string signedURI = Utils.Sign(strURI);

                //serialize the JSON request content
                ReplaceText repacetext = new ReplaceText();
                repacetext.OldValue = OldValue;
                repacetext.NewValue = NewValue;
                repacetext.IsMatchCase = IsMatchCase;
                repacetext.IsMatchWholeWord = IsMatchWholeWord;

                string strJSON = JsonConvert.SerializeObject(repacetext);

                Stream responseStream = Utils.ProcessCommand(signedURI, "POST", strJSON);

                StreamReader reader = new StreamReader(responseStream);
                string strResponse = reader.ReadToEnd();

                //Parse the json string to JObject
                JObject pJSON = JObject.Parse(strResponse);

                ReplaceTextResponse baseResponse = JsonConvert.DeserializeObject<ReplaceTextResponse>(pJSON.ToString());

                //sign URI
                signedURI = Utils.Sign(baseResponse.DocumentLink.Href + "?format=doc");

                //get response stream
                responseStream = Utils.ProcessCommand(signedURI, "GET");

                using (Stream fileStream = System.IO.File.OpenWrite(output))
                {
                    Utils.CopyStream(responseStream, fileStream);
                }
                responseStream.Close();
            }
            catch (Exception ex)
            {

            }
        }