Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 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 lenghtTextt;
  20. public int i = -1;
  21. int[] first = new int[100000];
  22. public fMain()
  23. {
  24. InitializeComponent();
  25. }
  26. private void tsmiExit_Click(object sender, EventArgs e)
  27. {
  28. SaveTextPad();
  29. this.Close();
  30. }
  31. private void tsmiAbout_Click(object sender, EventArgs e)
  32. {
  33. MessageBox.Show("Программа: Блокнот. \nАвтор: Королев Дмитрий Сергеевич. \nСтудия: Lona Games", "О программе");
  34. }
  35. private void tsmiClear_Click(object sender, EventArgs e)
  36. {
  37. rtbTextPad.Clear();
  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. //rtbTextPad.LoadFile("nodepad.rtf");
  60. Textt.ReadParam();
  61. }
  62. catch
  63. {
  64. MessageBox.Show("Ошибка при загрузке.");
  65. }
  66. finally
  67. {
  68. rtbTextPad.Text = Textt.allText;
  69. }
  70.  
  71. }
  72. void SaveTextPad()
  73. {
  74. try
  75. {
  76. //rtbTextPad.SaveFile("nodepad.rtf");
  77. Textt.WriteParam();
  78. }
  79. catch
  80. {
  81. MessageBox.Show("Ошибка при сохранении.");
  82. }
  83. }
  84. public void Search()
  85. {
  86. lenghtText = Textt.findText.Length;
  87. if (lenghtText > 1)
  88. {
  89. while (firstCharacter != -1)
  90. {
  91. i++;
  92. if (i > -1)
  93. {
  94. first[i] = firstCharacter;
  95. Textt.first[i] = first[i];
  96. System.Console.WriteLine("mass{0}", first[i]);
  97. }
  98. firstCharacter = Textt.allText.IndexOf(Textt.findText, startIndex);
  99. secondCharacter = (firstCharacter + lenghtText) - 1;
  100. startIndex = secondCharacter;
  101. Textt.allCount = i;
  102. System.Console.WriteLine("first {0}, second {1}, lenght {2}, start {3}" , firstCharacter, secondCharacter, lenghtText, startIndex);
  103. }
  104. }
  105. else if (lenghtText <= 1)
  106. {
  107. Textt.allCount = 0;
  108. }
  109. if (firstCharacter == -1)
  110. {
  111. return;
  112. }
  113. }
  114. public void Selection()
  115. {
  116. lenghtTextt = Textt.findText.Length - 1;
  117. rtbTextPad.Text = Textt.allText;
  118.  
  119. if (!String.IsNullOrEmpty(rtbTextPad.Text))
  120. {
  121. rtbTextPad.SelectionStart = Textt.first[Textt.count];
  122. rtbTextPad.SelectionLength = Textt.first[Textt.count] + lenghtTextt;
  123. //rtbTextPad.SelectionColor = Color.Red;
  124. 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);
  125.  
  126. }
  127.  
  128. }
  129. private void tsmiSearchWindow_Click(object sender, EventArgs e)
  130. {
  131. fSearch form2 = new fSearch();
  132. form2.Show();
  133. }
  134. private void fMain_FormClosed(object sender, FormClosedEventArgs e)
  135. {
  136. SaveTextPad();
  137. }
  138. private void fMain_Load(object sender, EventArgs e)
  139. {
  140. LoadTextPad();
  141. }
  142. private void rtbTextPad_TextChanged(object sender, EventArgs e)
  143. {
  144. Textt.allText = rtbTextPad.Text;
  145. }
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement