Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Блокнот
- {
- public partial class fMain : Form
- {
- public int firstCharacter;
- public int secondCharacter;
- public int startIndex;
- public int lenghtText;
- public int lenghtTextt;
- public int i = -1;
- int[] first = new int[100000];
- public fMain()
- {
- InitializeComponent();
- }
- private void tsmiExit_Click(object sender, EventArgs e)
- {
- SaveTextPad();
- this.Close();
- }
- private void tsmiAbout_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Программа: Блокнот. \nАвтор: Королев Дмитрий Сергеевич. \nСтудия: Lona Games", "О программе");
- }
- private void tsmiClear_Click(object sender, EventArgs e)
- {
- rtbTextPad.Clear();
- }
- private void tsmiLoad_Click(object sender, EventArgs e)
- {
- LoadTextPad();
- }
- private void tsmiSave_Click(object sender, EventArgs e)
- {
- SaveTextPad();
- }
- private void tsmiInsertDateAndTime_Click(object sender, EventArgs e)
- {
- rtbTextPad.AppendText("\n" + DateTime.Now + "\n");
- }
- private void tsmiInsertTime_Click(object sender, EventArgs e)
- {
- rtbTextPad.AppendText("\n" + DateTime.Now.ToShortTimeString() + "\n");
- }
- void LoadTextPad()
- {
- try
- {
- //rtbTextPad.LoadFile("nodepad.rtf");
- Textt.ReadParam();
- }
- catch
- {
- MessageBox.Show("Ошибка при загрузке.");
- }
- finally
- {
- rtbTextPad.Text = Textt.allText;
- }
- }
- void SaveTextPad()
- {
- try
- {
- //rtbTextPad.SaveFile("nodepad.rtf");
- Textt.WriteParam();
- }
- catch
- {
- MessageBox.Show("Ошибка при сохранении.");
- }
- }
- public void Search()
- {
- lenghtText = Textt.findText.Length;
- if (lenghtText > 1)
- {
- while (firstCharacter != -1)
- {
- i++;
- if (i > -1)
- {
- first[i] = firstCharacter;
- Textt.first[i] = first[i];
- System.Console.WriteLine("mass{0}", first[i]);
- }
- firstCharacter = Textt.allText.IndexOf(Textt.findText, startIndex);
- secondCharacter = (firstCharacter + lenghtText) - 1;
- startIndex = secondCharacter;
- Textt.allCount = i;
- System.Console.WriteLine("first {0}, second {1}, lenght {2}, start {3}" , firstCharacter, secondCharacter, lenghtText, startIndex);
- }
- }
- else if (lenghtText <= 1)
- {
- Textt.allCount = 0;
- }
- if (firstCharacter == -1)
- {
- return;
- }
- }
- public void Selection()
- {
- lenghtTextt = Textt.findText.Length - 1;
- rtbTextPad.Text = Textt.allText;
- if (!String.IsNullOrEmpty(rtbTextPad.Text))
- {
- rtbTextPad.SelectionStart = Textt.first[Textt.count];
- rtbTextPad.SelectionLength = Textt.first[Textt.count] + lenghtTextt;
- //rtbTextPad.SelectionColor = Color.Red;
- System.Console.WriteLine("selsction firstMass{0}, second{1}, selStart{2}, selLenght{3}", Textt.first[Textt.count], Textt.first[Textt.count] + lenghtTextt, rtbTextPad.SelectionStart, rtbTextPad.SelectionLength);
- }
- }
- private void tsmiSearchWindow_Click(object sender, EventArgs e)
- {
- fSearch form2 = new fSearch();
- form2.Show();
- }
- private void fMain_FormClosed(object sender, FormClosedEventArgs e)
- {
- SaveTextPad();
- }
- private void fMain_Load(object sender, EventArgs e)
- {
- LoadTextPad();
- }
- private void rtbTextPad_TextChanged(object sender, EventArgs e)
- {
- Textt.allText = rtbTextPad.Text;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement