Guest User

Untitled

a guest
Sep 30th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Блокнот
  12. {
  13. public partial class fMain : Form
  14. {
  15. public int firstCharacter;
  16. public int secondCharacter;
  17. public int startIndex;
  18. public int lenghtText;
  19. public int i = -1;
  20. int[] first = new int[100000];
  21. public fMain()
  22. {
  23. InitializeComponent();
  24. }
  25. private void tsmiExit_Click(object sender, EventArgs e)
  26. {
  27. SaveTextPad();
  28. this.Close();
  29. }
  30. private void tsmiAbout_Click(object sender, EventArgs e)
  31. {
  32. MessageBox.Show("Программа: Блокнот. \nАвтор: Королев Дмитрий Сергеевич. \nСтудия: Lona Games", "О программе");
  33. }
  34. private void tsmiClear_Click(object sender, EventArgs e)
  35. {
  36. rtbTextPad.Clear();
  37. Textt.allText = rtbTextPad.Text;
  38. }
  39. private void tsmiLoad_Click(object sender, EventArgs e)
  40. {
  41. LoadTextPad();
  42. }
  43. private void tsmiSave_Click(object sender, EventArgs e)
  44. {
  45. SaveTextPad();
  46. }
  47. private void tsmiInsertDateAndTime_Click(object sender, EventArgs e)
  48. {
  49. rtbTextPad.AppendText("\n" + DateTime.Now + "\n");
  50. }
  51. private void tsmiInsertTime_Click(object sender, EventArgs e)
  52. {
  53. rtbTextPad.AppendText("\n" + DateTime.Now.ToShortTimeString() + "\n");
  54. }
  55. void LoadTextPad()
  56. {
  57. try
  58. {
  59. Textt.ReadParam();
  60. }
  61. catch
  62. {
  63. MessageBox.Show("Ошибка при загрузке.");
  64. }
  65. finally
  66. {
  67. rtbTextPad.Text = Textt.allText;
  68. }
  69. }
  70. void SaveTextPad()
  71. {
  72. try
  73. {
  74. Textt.WriteParam();
  75. }
  76. catch
  77. {
  78. MessageBox.Show("Ошибка при сохранении.");
  79. }
  80. }
  81. public void Search()
  82. {
  83. lenghtText = Textt.findText.Length;
  84. if (lenghtText > 1)
  85. {
  86. while (firstCharacter != -1)
  87. {
  88. i++;
  89. if (i > -1)
  90. {
  91. first[i] = firstCharacter;
  92. Textt.first[i] = first[i];
  93. System.Console.WriteLine("mass{0}", first[i]);
  94. }
  95. firstCharacter = Textt.allText.IndexOf(Textt.findText, startIndex);
  96. secondCharacter = (firstCharacter + lenghtText) - 1;
  97. startIndex = secondCharacter;
  98. Textt.allCount = i;
  99. System.Console.WriteLine("first {0}, second {1}, lenght {2}, start {3}" , firstCharacter, secondCharacter, lenghtText, startIndex);
  100. }
  101. if (firstCharacter == -1)
  102. {
  103. return;
  104. }
  105. }
  106. else if (lenghtText <= 1)
  107. {
  108. Textt.allCount = 0;
  109. }
  110. }
  111. private void tsmiSearchWindow_Click(object sender, EventArgs e)
  112. {
  113. fSearch form2 = new fSearch();
  114. form2.Show();
  115. }
  116. private void fMain_FormClosed(object sender, FormClosedEventArgs e)
  117. {
  118. SaveTextPad();
  119. }
  120. private void fMain_Load(object sender, EventArgs e)
  121. {
  122. LoadTextPad();
  123. }
  124. private void rtbTextPad_TextChanged(object sender, EventArgs e)
  125. {
  126. Textt.allText = rtbTextPad.Text;
  127. }
  128. public void Selection()
  129. {
  130. rtbTextPad.Text = Textt.allText;
  131. lenghtText = Textt.findText.Length;
  132. if (!String.IsNullOrEmpty(rtbTextPad.Text))
  133. {
  134. rtbTextPad.SelectionStart = Textt.first[Textt.count];
  135. rtbTextPad.SelectionLength = lenghtText;
  136. }
  137. }
  138. }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment