示例#1
0
 private void DuplicateLine()
 {
     SelectCurrentLine();
     TextView.SelectedText = TextView.SelectedText + "\n" + TextView.SelectedText;
     TextView.DeselectAll();
 }
示例#2
0
        private void Format(string option)
        {
            switch (option.ToUpper())
            {
            case "B":
                try
                {
                    SelectCurrentLine();
                    FontStyle style = new FontStyle();
                    if (TextView.SelectionFont.Bold)
                    {
                        style = style | FontStyle.Regular;
                    }
                    else
                    {
                        style = style | FontStyle.Bold;
                    }
                    if (TextView.SelectionFont.Italic)
                    {
                        style = style | FontStyle.Italic;
                    }
                    if (TextView.SelectionFont.Underline)
                    {
                        style = style | FontStyle.Underline;
                    }
                    TextView.SelectionFont = new Font(TextView.SelectionFont, style);
                    TextView.DeselectAll();
                }
                catch { };
                break;

            case "I":
                try
                {
                    SelectCurrentLine();
                    FontStyle style = new FontStyle();
                    if (TextView.SelectionFont.Italic)
                    {
                        style = style | FontStyle.Regular;
                    }
                    else
                    {
                        style = style | FontStyle.Italic;
                    }
                    if (TextView.SelectionFont.Bold)
                    {
                        style = style | FontStyle.Bold;
                    }
                    if (TextView.SelectionFont.Underline)
                    {
                        style = style | FontStyle.Underline;
                    }

                    TextView.SelectionFont = new Font(TextView.SelectionFont, style);
                    TextView.DeselectAll();
                }
                catch { };
                break;

            case "U":
                try
                {
                    SelectCurrentLine();
                    FontStyle style = new FontStyle();
                    if (TextView.SelectionFont.Underline)
                    {
                        style = style | FontStyle.Regular;
                    }
                    else
                    {
                        style = style | FontStyle.Underline;
                    }
                    if (TextView.SelectionFont.Italic)
                    {
                        style = style | FontStyle.Italic;
                    }
                    if (TextView.SelectionFont.Bold)
                    {
                        style = style | FontStyle.Bold;
                    }

                    TextView.SelectionFont = new Font(TextView.SelectionFont, style);
                    TextView.DeselectAll();
                }
                catch { };
                break;

            case "T":
                try
                {
                    SelectCurrentLine();
                    FontDialog fd = new FontDialog();
                    fd.Font = TextView.SelectionFont;
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        TextView.SelectionFont = fd.Font;
                    }
                    TextView.DeselectAll();
                }
                catch { };
                break;

            case "UP":
                TextView.SelectionAlignment = HorizontalAlignment.Center;
                break;

            case "RIGHT":
                TextView.SelectionAlignment = HorizontalAlignment.Right;
                break;

            case "LEFT":
                TextView.SelectionAlignment = HorizontalAlignment.Left;
                break;

            case "A":
                TextView.SelectAll();
                break;

            case "C":
                TextView.Copy();
                break;

            case "V":
                TextView.Paste();
                break;

            case "X":
                TextView.Cut();
                break;

            case "Z":
                TextView.Undo();
                break;

            case "Y":
                TextView.Redo();
                break;

            case "P":
                SelectCurrentLine();
                if (TextView.SelectionProtected)
                {
                    TextView.SelectionColor = Color.FromArgb(
                        (TextView.SelectionColor.R + 70 > 255) ? 255 : TextView.SelectionColor.R + 70,
                        (TextView.SelectionColor.G + 70 > 255) ? 255 : TextView.SelectionColor.G + 70,
                        (TextView.SelectionColor.B + 70 > 255) ? 255 : TextView.SelectionColor.B + 70
                        );

                    TextView.SelectionProtected = false;
                }
                else
                {
                    TextView.SelectionColor = Color.FromArgb(
                        (TextView.SelectionColor.R - 70 < 0) ? 0 : TextView.SelectionColor.R - 70,
                        (TextView.SelectionColor.G - 70 < 0) ? 0 : TextView.SelectionColor.G - 70,
                        (TextView.SelectionColor.B - 70 < 0) ? 0 : TextView.SelectionColor.B - 70
                        );

                    TextView.SelectionProtected = true;
                }
                TextView.DeselectAll();
                break;

            case "R":
                SelectCurrentLine();
                ColorDialog CD = new ColorDialog();
                if (CD.ShowDialog() == DialogResult.OK)
                {
                    TextView.SelectionColor = CD.Color;
                }
                TextView.DeselectAll();
                break;

            case "S":
                save(true);
                break;

            case "N":
                if (MessageBox.Show("Do you want to create a new file?", "New File", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    CurrentFile = "";
                    TextView.Clear();
                    TextView.ForeColor = txt_color.ForeColor;
                    TextView.BackColor = bg_color.BackColor;
                }
                break;

            case "O":
                OpenFileDialog OFD = new OpenFileDialog();
                OFD.Title = "Select a file to open";
                if (OFD.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        TextView.LoadFile(OFD.FileName);
                    }
                    catch
                    {
                        try
                        {
                            TextView.Text = System.IO.File.ReadAllText(OFD.FileName);
                        }
                        catch { }
                    }
                    CurrentFile = OFD.FileName;
                    Properties.Settings.Default.last_opened_file = CurrentFile;
                    Properties.Settings.Default.Save();
                }
                break;

            case "Q":
                if (MessageBox.Show("Do you want to delete all?", "Delete All", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    TextView.SelectionProtected = false;
                    TextView.Clear();
                    TextView.ForeColor = txt_color.ForeColor;
                    TextView.BackColor = bg_color.BackColor;
                }
                break;

            case "D":
                DuplicateLine();
                break;

            case "E":
                CheckForFunctions();
                break;
            }
        }