public void undo(SimpleForm form) { form.getList().newGetString(); }
public keyEvents(SimpleForm mFrame) { sframe = mFrame; }
public void paste(SimpleForm form) { String clipboardText = Clipboard.GetText(); if (form.getTextBox().SelectionStart == 0) { form.setTextArea(clipboardText + form.getTextArea()); return; } if (form.getTextBox().SelectionStart > 0 && form.getTextBox().SelectionStart < form.getTextArea().Length) { form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart) + clipboardText + form.getTextArea().Substring(form.getTextBox().SelectionStart, form.getTextArea().Length)); return; } if (form.getTextBox().SelectionStart == form.getTextArea().Length) { form.setTextArea(form.getTextArea() + clipboardText); return; } }
public void redo(SimpleForm form) { form.getList().newRestoreString(); }
public void cut(SimpleForm form) { int cp; if (form.getTextBox().SelectedText.Length != 0) { copy(form); cp = form.getTextBox().SelectionStart; form.getList().newPutString(form.getTextBox().SelectedText, cp, actionsHistory.action.SUB); if (form.getTextBox().SelectionStart == 0) { form.setTextArea(form.getTextArea().Substring(form.getTextBox().SelectedText.Length, form.getTextArea().Length)); form.getTextBox().SelectionStart = cp; return; } if (form.getTextBox().SelectionStart > 0 && form.getTextBox().SelectionStart < form.getTextArea().Length) { form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart) + form.getTextArea().Substring(form.getTextBox().SelectionStart + form.getTextBox().SelectedText.Length, form.getTextArea().Length)); form.getTextBox().SelectionStart = cp; return; } if (form.getTextBox().SelectionStart == form.getTextArea().Length) { form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart)); form.getTextBox().SelectionStart = cp; return; } } }
public void delete(SimpleForm form) { if (form.getTextBox().SelectedText.Length != null) { form.setAction(false); form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart) + form.getTextArea().Substring(form.getTextBox().SelectionLength, form.getTextArea().Length)); form.getList().newPutString(form.getTextBox().SelectedText, form.getTextBox().SelectionStart, actionsHistory.action.SUB); form.setAction(true); } }
public void copy(SimpleForm form) { if (form.getTextBox().SelectedText.Length != 0) { string stringSelection = form.getTextBox().SelectedText; Clipboard.SetText(stringSelection); } }
public void fileSaveAs(SimpleForm frame) { SaveFileDialog chooser = new SaveFileDialog(); if (chooser.ShowDialog() == DialogResult.OK) { frame.setFileName(chooser.FileName); try { StreamWriter outStream = new StreamWriter(new FileStream(frame.getFileName(), FileMode.OpenOrCreate, FileAccess.Write)); String str = frame.getTextArea(); outStream.Write(str); outStream.Close(); } catch (IOException e) { } } frame.setIsFileNameSetted(true); frame.Name = "Text Editor - " + frame.getFileName(); }
public void fileOpen(SimpleForm frame) { if(frame.getIsChanged()) { DialogResult selection = MessageBox.Show("Do you want save document?", "Warrning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if(selection == DialogResult.No) { OpenFileDialog chooser = new OpenFileDialog(); if(chooser.ShowDialog() == DialogResult.OK) { frame.setFileName(chooser.FileName); String str = ""; try { StreamReader inStream = new StreamReader(new FileStream(frame.getFileName(),FileMode.OpenOrCreate, FileAccess.Read)); while (inStream.Peek() != -1) { str = inStream.ReadToEnd(); } frame.setTextArea(str); } catch (FileNotFoundException e) { } catch (IOException e) { } } } if(selection == DialogResult.Yes) { SaveFileDialog chooser = new SaveFileDialog(); if(chooser.ShowDialog() == DialogResult.OK) { frame.setFileName(chooser.FileName); try { StreamWriter outStream = new StreamWriter(new FileStream(frame.getFileName(),FileMode.OpenOrCreate, FileAccess.Write)); String str = frame.getTextArea(); outStream.Write(str); outStream.Close(); } catch (IOException e) { } } OpenFileDialog chooser2 = new OpenFileDialog(); if (chooser2.ShowDialog() == DialogResult.OK) { frame.setFileName(chooser2.FileName); String str = ""; try { StreamReader inStream = new StreamReader(new FileStream(frame.getFileName(),FileMode.OpenOrCreate, FileAccess.Read)); while (inStream.Peek() != -1) { str = inStream.ReadToEnd(); } frame.setTextArea(str); } catch (FileNotFoundException e) { } catch (IOException e) { } } } } else { OpenFileDialog chooser2 = new OpenFileDialog(); if (chooser2.ShowDialog() == DialogResult.OK) { frame.setFileName(chooser2.FileName); String str = ""; try { StreamReader inStream = new StreamReader(new FileStream(frame.getFileName(), FileMode.OpenOrCreate, FileAccess.Read)); while (inStream.Peek() != -1) { str = inStream.ReadToEnd(); } frame.setTextArea(str); } catch (FileNotFoundException e) { } catch (IOException e) { } } } frame.setIsFileNameSetted(true); frame.Name = "Text Editor " + frame.getFileName(); }
public void fileNew(SimpleForm frame) { frame.setIsFileNameSetted(false); frame.Text = "Text Editor"; if(frame.getIsChanged()) { DialogResult selection = MessageBox.Show("Do you want save document?", "Warrning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if(selection == DialogResult.No) { frame.setTextArea(""); frame.setIsChanged(false); frame.Text = "Text Editor"; } if(selection == DialogResult.Yes) { SaveFileDialog chooser = new SaveFileDialog(); if(chooser.ShowDialog() == DialogResult.OK) { frame.setFileName(chooser.FileName); try { StreamWriter outStream = new StreamWriter(new FileStream(frame.getFileName(),FileMode.OpenOrCreate, FileAccess.Write)); String str = frame.getTextArea(); outStream.Write(str); outStream.Close(); } catch (IOException e) { } } frame.setTextArea(""); frame.setIsChanged(false); frame.Name = "Text Editor"; } } else { frame.setTextArea(""); } }
actionsHistory(SimpleForm frame) { mainFrame = frame; actionsList = new ArrayList(); }