Join us on Facebook

Please wait..10 SecondsCancel
TWEAKS N TRICKZ: NOTEPAD>>>2015>>> FOR BEGINNERS WITH CODE AND FEATURES

Sunday, 10 January 2016

NOTEPAD>>>2015>>> FOR BEGINNERS WITH CODE AND FEATURES

NOTEPAD>>>2015>>> FOR BEGINNERS WITH CODE AND FEATURES

DESIGN:


 Coding:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NotePadForm2
{
    public partial class Form1 : Form
    {
        string filename;
        bool Modified = false;
        string Find_String;
    //    Dim file_name As String
    //Dim Find_String As String
    //Dim Replace_String As String

        public Form1()
        {
            InitializeComponent();
        }
NEW TOOL
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = "";
        }
OPEN TOOL
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Text Documents(*.txt)|*.txt|All Files(*.*)|*.*";
            //dlg.Filter="pdf Documents(*.pdf)|*.pdf|All Files(*.*)|*.*";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                StreamReader sr = new StreamReader(dlg.FileName);
                richTextBox1.Text = sr.ReadToEnd();
                sr.Close();
                //Modified=False;
            }
        }
SAVE TOOL
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(filename))
            {
                SaveFileDialog dlg = new SaveFileDialog();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    filename = dlg.FileName;
                }
                else
                    return;
            }
            StreamWriter sw = new StreamWriter(filename);
            sw.Write(richTextBox1.Text);
            sw.Close();
            Modified = true;
        }
SAVE AS TOOL
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                filename = dlg.FileName;
                StreamWriter sw = new StreamWriter(filename);
                sw.Write(richTextBox1.Text);
                sw.Close();
                Modified = false;
            }
        }
EXIT TOOL
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
FONT TOOL:
        private void fontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FontDialog dlgFont = new FontDialog();
            dlgFont.Font = richTextBox1.Font;
            if (dlgFont.ShowDialog() == DialogResult.OK)
                richTextBox1.Font = dlgFont.Font;
        }
CUT TOOL
        private void cutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Cut();
        }
COPY TOOL
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Copy();
        }
PASTE TOOL
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Paste();
        }
UNDO TOOL
        private void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Undo();
        }
REDO TOOL:
        private void redoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Redo();
        }
CLEAR TOOL:
        private void clearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
        }

SELECT TOOL:
        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.SelectAll();
        }

        private void colorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ColorDialog cr = new ColorDialog();
            if (cr.ShowDialog() == DialogResult.OK)
            {
                richTextBox1.BackColor = cr.Color;
            }

            //           Try
            //                Dim dlg As FontDialog = New FontDialog
            //Try
            //Dim dlg As FontDialog = New FontDialog
            //dlg.Font = richTextBox1.font;
            //If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
            //richTextBox1.Font = dlg.Font
            //End If
            //Catch ex As Exception : End Try
        }
ABOUT TOOL
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Ver 1..0.0\n Created and Developed BY MANDEEP SINGH OBEROI");
        }

        private void fontToolStripMenuItem1_Click(object sender, EventArgs e)
        {

         
            Find findForm = new Find();

            findForm.ShowDialog();
            //Find_String = InputBox("What Do U Want To Find?");
            //richTextBox1.Find(Find_String);

            //calling and creating instance of findform and to search values    
            //findform findob = new findform(this);
            //findob.Show();
            //FindTab tab = new FindTab(this);
           // tab.Show();
        }

       
NEW TOOL
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            pageSetupDialog1.PageSettings = new System.Drawing.Printing.PageSettings();
            pageSetupDialog1.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
            pageSetupDialog1.ShowNetwork = false;
            DialogResult result = pageSetupDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                object[] results = new object[]
{
                    pageSetupDialog1.PageSettings.Margins,
                    pageSetupDialog1.PageSettings.PaperSize,
                    pageSetupDialog1.PageSettings.Landscape,
                    pageSetupDialog1.PrinterSettings.PrinterName,
                    pageSetupDialog1.PrinterSettings.PrintRange};
            }
        }
TIME AND DATE
        private void timeAndDeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string timeDate;
            timeDate = DateTime.Now.ToShortTimeString() + " " +
            DateTime.Now.ToShortDateString();
            int newSelectionStart = richTextBox1.SelectionStart + timeDate.Length;
            richTextBox1.Text = richTextBox1.Text.Insert(richTextBox1.SelectionStart, timeDate);
            richTextBox1.SelectionStart = newSelectionStart;
        }
DELETE TOOL
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (richTextBox1.Text != "")
            {
                richTextBox1.SelectedText = "";
            }
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            printDialog1.Document = printDocument1;

            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                printDocument1.Print();
            }
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();
        }
PRINT TOOL
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawString(richTextBox1.Text, richTextBox1.Font, Brushes.Black, 100, 20);
            e.Graphics.PageUnit = GraphicsUnit.Inch;
        }
WORD WRAP TOOL
        private void wordWrapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.WordWrap = true;
        }

        private void helpToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
    }
}

1 comment: