示例#1
0
        private void otherSwapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmParameters parameters = new frmParameters();
            DialogResult  result     = parameters.ShowDialog();

            if (result == DialogResult.OK)
            {
                string swapAt = parameters.SwapAt;
                if (swapAt.Length > 0)
                {
                    swapAt = SubstituteShorthand(swapAt);
                    string[] lines = txtDocument.Lines;
                    for (int index = 0; index < lines.Length; index++)
                    {
                        string text = string.Empty;
                        string line = lines[index];
                        int    pos  = line.IndexOf(swapAt);
                        if (pos > -1)
                        {
                            text  = line.Substring(pos + swapAt.Length);
                            text += swapAt;
                            text += line.Substring(0, pos);
                        }
                        else
                        {
                            text = line;
                        }
                        lines[index] = text;
                    }
                    txtDocument.Lines = lines;
                }
            }
        }
示例#2
0
        private void otherReplaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmParameters parameters = new frmParameters();
            DialogResult  result     = parameters.ShowDialog();

            if (result == DialogResult.OK)
            {
                string replace = parameters.Replace;
                string with    = parameters.With;
                if (replace.Length > 0)
                {
                    replace = SubstituteShorthand(replace);
                    if (with.Length > 0)
                    {
                        with             = SubstituteShorthand(with);
                        txtDocument.Text = txtDocument.Text.Replace(replace, with);
                    }
                }
            }
        }