Esempio n. 1
0
 public void undo(SimpleForm form)
 {
     form.getList().newGetString();
 }
Esempio n. 2
0
 public keyEvents(SimpleForm mFrame)
 {
     sframe = mFrame;
 }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
 public void redo(SimpleForm form)
 {
     form.getList().newRestoreString();
 }
Esempio n. 5
0
 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;
         }
     }
 }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 7
0
 public void copy(SimpleForm form)
 {
     if (form.getTextBox().SelectedText.Length != 0)
     {
         string stringSelection = form.getTextBox().SelectedText;
         Clipboard.SetText(stringSelection);
     }
 }
Esempio n. 8
0
        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();
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
0
        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("");
            }
        }
Esempio n. 11
0
 actionsHistory(SimpleForm frame)
 {
     mainFrame = frame;
     actionsList = new ArrayList();
 }