The editing module only supports the full selection and time functions, and the automatic line feed function is not yet written.
If you need all source code, please leave a message or mail to henanlinzhoulcl@163.com
Version: 1.0
The main code is as follows:
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. IO;
Namespace mynotepad
{
Public partial class mynotepad: Form
{
Public mynotepad ()
{
Initializecomponent ();
This. toolstripstatuslabel3.text = datetime. Now. dayofweek. tostring ();
}
Private void textbox1_keypress (Object sender, keypresseventargs E)
{
// Textbox1.text + = E. keychar;
}
Private void exit toolstripmenuitem_click (Object sender, eventargs E)
{
Application. Exit ();
}
Private void date toolstripmenuitem_click (Object sender, eventargs E)
{
If (this. textbox1.selectedtext! = "")
{
This. textbox1.selectedtext = datetime. Now. tostring ();
}
Else
{
This. textbox1.text + = datetime. now;
}
}
Private void timereffectick (Object sender, eventargs E)
{
This. toolstripstatuslabel1.text = "the current time is:" + datetime. Now. tostring ();
}
Private void status bar toolstripmenuitem_click (Object sender, eventargs E)
{
If (this. statusstrip1.visible = false)
{
This. statusstrip1.visible = true;
}
Else
{
This. statusstrip1.visible = false;
This. textbox1.height + = 10;
}
}
Private void about mynotepadatoolstripmenuitem_click (Object sender, eventargs E)
{
About AB = new about ();
AB. Show ();
}
Private void select all toolstripmenuitem_click (Object sender, eventargs E)
{
This. textbox1.selectall ();
}
Private void font toolstripmenuitem_click (Object sender, eventargs E)
{
If (fontdialog1.showdialog () = dialogresult. OK)
{
Textbox1.font = fontdialog1.font;
}
}
Private void mynotepad_resize (Object sender, eventargs E)
{
This. panel1.width = This. Size. Width-25;
This. panel1.height = This. Size. Height-50;
This. textbox1.width = This. panel1.width;
This. textbox1.height = This. panel1.height;
}
Private void automatic line feed toolstripmenuitem_click (Object sender, eventargs E)
{
}
Private void save toolstripmenuitem_click (Object sender, eventargs E)
{
Using (savefiledialog savedig = new savefiledialog ())
{
Savedig. Filter = @ "Text Document (*. txt) | *. txt ";
Savedig. filename = "*. txt ";
If (savedig. showdialog () = dialogresult. OK)
{
Streamwriter Sw = new streamwriter (savedig. filename, false, system. Text. encoding. Default );
Sw. Write (this. textbox1.text );
Sw. Close ();
This. Text = savedig. filename;
}
}
}
Private void Save As toolstripmenuitem_click (Object sender, eventargs E)
{
Using (savefiledialog savedig = new savefiledialog ())
{
Savedig. Filter = @ "Text Document (*. txt) | *. txt ";
Savedig. filename = This. text;
If (savedig. showdialog () = dialogresult. OK)
{
Streamwriter Sw = new streamwriter (savedig. filename, false, system. Text. encoding. Default );
Sw. Write (this. textbox1.text );
Sw. Close ();
}
}
}
Private void create toolstripmenuitem_click (Object sender, eventargs E)
{
If (this. textbox1.text! = "")
{
Dialogresult d = MessageBox. Show (the text of "file" + this. Text + @ "has changed.
Do you want to save the file? "," Mynotepad ", messageboxbuttons. yesnocancel, messageboxicon. Information, messageboxdefaultbutton. button1, messageboxoptions. defaulttoptoponly );
Switch (d)
{
Case dialogresult. Yes:
Using (savefiledialog savedig = new savefiledialog ())
{
Savedig. Filter = @ "Text Document (*. txt) | *. txt ";
Savedig. filename = "*. txt ";
If (savedig. showdialog () = dialogresult. OK)
{
Streamwriter Sw = new streamwriter (savedig. filename, false, system. Text. encoding. Default );
Sw. Write (this. textbox1.text );
Sw. Close ();
This. Text = savedig. filename;
}
}
Break;
Case dialogresult. No:
This. textbox1.text = "";
Break;
Case dialogresult. Cancel:
Break;
Default: system. Diagnostics. Debug. Assert (false );
Break;
}
}
}
Private void open toolstripmenuitem_click (Object sender, eventargs E)
{
If (this. textbox1.text! = "")
{
Dialogresult d = MessageBox. Show (the text of "file" + this. Text + @ "has changed.
Do you want to save the file? "," Mynotepad ", messageboxbuttons. yesnocancel, messageboxicon. Information, messageboxdefaultbutton. button1, messageboxoptions. defaulttoptoponly );
Switch (d)
{
Case dialogresult. Yes:
Using (savefiledialog savedig = new savefiledialog ())
{
Savedig. Filter = @ "Text Document (*. txt) | *. txt ";
Savedig. filename = "*. txt ";
If (savedig. showdialog () = dialogresult. OK)
{
Streamwriter Sw = new streamwriter (savedig. filename, false, system. Text. encoding. Default );
Sw. Write (this. textbox1.text );
Sw. Close ();
This. Text = savedig. filename;
}
}
Break;
Case dialogresult. No:
This. textbox1.text = "";
Break;
Case dialogresult. Cancel:
Break;
Default: system. Diagnostics. Debug. Assert (false );
Break;
}
}
Else
{
Using (openfiledialog dlgtext = new openfiledialog ())
{
Dlgtext. Filter = @ "(*. txt) | *. txt ";
If (dlgtext. showdialog () = dialogresult. OK)
{
If (file. exists (dlgtext. filename ))
{
Streamreader rstream = new streamreader (dlgtext. filename, system. Text. encoding. Default );
String S = default (string );
This. textbox1.text = "";
While (S = rstream. Readline ())! = NULL)
{
This. textbox1.text + = s;
}
Rstream. Close ();
}
}
}
}
}
Private void mynotepad_formclosing (Object sender, formclosingeventargs E)
{
If (this. textbox1.text! = "")
{
Dialogresult d = MessageBox. Show (the text of "file" + this. Text + @ "has changed.
Do you want to save the file? "," Mynotepad ", messageboxbuttons. yesnocancel, messageboxicon. Information, messageboxdefaultbutton. button1, messageboxoptions. defaulttoptoponly );
Switch (d)
{
Case dialogresult. Yes:
Using (savefiledialog savedig = new savefiledialog ())
{
Savedig. Filter = @ "Text Document (*. txt) | *. txt ";
Savedig. filename = "*. txt ";
If (savedig. showdialog () = dialogresult. OK)
{
Streamwriter Sw = new streamwriter (savedig. filename, false, system. Text. encoding. Default );
Sw. Write (this. textbox1.text );
Sw. Close ();
This. Text = savedig. filename;
}
}
Break;
Case dialogresult. No:
Break;
Case dialogresult. Cancel:
Break;
Default: system. Diagnostics. Debug. Assert (false );
Break;
}
}
}
}
}
Other code can be omitted...