示例#1
0
 void replaceForm_ReplaceClick(object sender, ReplaceEventArgs e)
 {
     TextBoxHelper.Replace(GetActiveTextBox, e.template, e.newTemplate, e.matchCase);
     if (string.IsNullOrEmpty(GetActiveTextBox.SelectedText))
     {
         form_FindClick(sender, new FindEventArgs(e.template, e.matchCase, true));
     }
 }
示例#2
0
 private void toolStripButtonImage_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         if (!TextBoxHelper.PasteImage(GetActiveTextBox, openFileDialog1.FileName))
         {
             MessageBox.Show(this, "The data format that you attempted to paste is not supported by this control.");
         }
     }
 }
示例#3
0
        void form_FindClick(object sender, FindEventArgs e)
        {
            int index = TextBoxHelper.Find(GetActiveTextBox, e.template, e.matchCase, e.searchDown);

            if (index < 0)
            {
                GetActiveTextBox.Select(GetActiveTextBox.Text.Length, 0);
                MessageBox.Show((Form)sender, "Can't find " + "\"" + e.template + "\"", "TextEditor", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                GetActiveTextBox.Select(index, e.template.Length);
            }
        }
示例#4
0
 private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     saveFileDialog.FileName = tabControl1.SelectedTab.Text;
     if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             TextBoxHelper.SaveFile(GetActiveTextBox, saveFileDialog.FileName);
             tabControl1.SelectedTab.Text = GetActiveTextBox.Tag.ToString();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
示例#5
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty((string)GetActiveTextBox.Tag))
     {
         try
         {
             TextBoxHelper.SaveFile(GetActiveTextBox, GetActiveTextBox.Tag.ToString());
             tabControl1.SelectedTab.Text = GetActiveTextBox.Tag.ToString();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         saveAsToolStripMenuItem_Click(this, new EventArgs());
     }
 }
示例#6
0
        public static void ReplaceAll(RichTextBoxPrintCtrl.RichTextBoxPrint e, string template, string newTemplate, bool matchCase)
        {
            int index = 0;

            e.SelectionStart = index;
            RichTextBoxFinds caseComparison = matchCase ? RichTextBoxFinds.MatchCase : RichTextBoxFinds.None;

            while (index != -1)
            {
                index = TextBoxHelper.Find(e, template, matchCase, true);
                if (index != -1)
                {
                    e.Select(index, template.Length);
                    TextBoxHelper.Replace(e, template, newTemplate, matchCase);
                }
            }
            e.SelectionLength = 0;
            e.SelectionStart  = 0;
        }
示例#7
0
 void GetActiveTextBox_SelectionChanged(object sender, EventArgs e)
 {
     SetFontStyleToControlButtons();
     toolStripStatusLabelLine.Text = String.Format("Ln: {0}", TextBoxHelper.GetLine(GetActiveTextBox) + 1);
     toolStripStatusLabelCol.Text  = String.Format("Col: {0}", TextBoxHelper.GetColumn(GetActiveTextBox) + 1);
 }
示例#8
0
 void replaceForm_ReplaceAllClick(object sender, ReplaceEventArgs e)
 {
     TextBoxHelper.ReplaceAll(GetActiveTextBox, e.template, e.newTemplate, e.matchCase);
 }