public void Undo(TextBox tb, Frmmain frm) { if (currentposition > 0 || (!aghabgard && currentposition >= 0)) { if (!aghabgard) { if (index - currentposition <= 5) { setText(tb, frm); currentposition--; } tb.Text = temp[currentposition]; tb.SelectionStart = tempSelectionStart[currentposition]; tb.SelectionLength = tempSelectionLength[currentposition]; tb.ScrollToCaret(); aghabgard = true; } else { tb.Text = temp[--currentposition]; tb.SelectionStart = tempSelectionStart[currentposition]; tb.SelectionLength = tempSelectionLength[currentposition]; tb.ScrollToCaret(); aghabgard = true; } setUndoRedoChecked(frm); } }
static void Main(string[] args) { //with args(user open file with the program) if (args != null && args.Length > 0) { string fileName = args[0]; //Check file exists if (System.IO.File.Exists(fileName)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Frmmain MainFrom = new Frmmain(); MainFrom.openFile(fileName); Application.Run(MainFrom); } //The file does not exist else { MessageBox.Show("The file does not exist!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Frmmain()); } } //without args else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Frmmain()); } }
//agar tabe e settext farakhani shavad darhali ke pas az an textchanged etefagh nayoftad //bayad be surate dasti aghabgard true shavad. public void setText(TextBox tb, Frmmain frm) { if (tb.Text != temp[currentposition]) { if (currentposition == 349) { for (int i = 0; 250 > i; i++) { temp[i] = temp[i + 100]; tempSelectionStart[i] = tempSelectionStart[i + 100]; tempSelectionLength[i] = tempSelectionLength[i + 100]; } currentposition = 249; index = 249; } index = currentposition + 1; temp[index] = tb.Text; tempSelectionStart[index] = tb.SelectionStart; tempSelectionLength[index] = tb.SelectionLength; currentposition++; } else if (tb.SelectionStart != tempSelectionStart[currentposition]) { index = currentposition; tempSelectionStart[index] = tb.SelectionStart; tempSelectionLength[index] = tb.SelectionLength; } setUndoRedoChecked(frm); }
public void Redo(TextBox tb, Frmmain frm) { if (index > currentposition) { tb.Text = temp[++currentposition]; tb.SelectionStart = tempSelectionStart[currentposition]; tb.SelectionLength = tempSelectionLength[currentposition]; tb.ScrollToCaret(); aghabgard = true; } setUndoRedoChecked(frm); }
public void startFromBeginning(TextBox tb, Frmmain frm) { temp[0] = tb.Text; tempSelectionStart[0] = tb.SelectionStart; tempSelectionLength[0] = tb.SelectionLength; currentposition = 0; index = 0; numberOfSpaces = 0; allowUndoSetText = true; aghabgard = true; setUndoRedoChecked(frm); }
public void setUndoRedoChecked(Frmmain frm) { if (sendAllowUndo()) { frm.setUndoChecked(true); } else { frm.setUndoChecked(false); } if (sendAllowRedo()) { frm.setRedoChecked(true); } else { frm.setRedoChecked(false); } }
//protected ta agar az in form ers bari kardim betavanim az an estefade konim. public Frmfind(Frmmain frm) { frmgeneral = frm; InitializeComponent(); }
public frmgoto(Frmmain frm) { frmgeneral = frm; InitializeComponent(); }
public frmreplace(Frmmain frm) { frmgeneral = frm; InitializeComponent(); }