VPL Glob
VPL Glob
DOCUMENTATION ON
Simple text editor using C#.net
SUBMITTED IN PARTIAL FULFILLMENT OF
THE REQUIREMENTS TO AWARD
THE DEGREE OF BACHELOR OFM
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
R. Ravikumar(22241A66B5)
P. Harshavardhan Reddy(22241A66B1)
V. Nikhil (22241A66C5)
UNDER THE GUIDNCE OF:
Asst. professor
DEPARTMENT OF
(Bachupally, Hyderabad,500090
1
VISUAL PROGRAMING LAB
INDEX
1 Introduction 4
● Problem Statement
● Goal of the Project
2 Text Editor UI 5
● Description
● Why C# and .NET?
2
VISUAL PROGRAMING LAB
7 Formatting Text 9
9 Code Implementations 11
10 Result 18
12 Limitations 21
13 Conclusion
3
VISUAL PROGRAMING LAB
1.Introduction
In today's digital age, text editors are indispensable tools for software development,
document creation, and various other tasks. They allow users to create, edit, and
manage text files efficiently, providing essential functionalities like text
formatting, file handling, and search operations.
Problem Statement
While numerous advanced text editors are available, many are either too complex
for basic users or too limited for advanced users. Additionally, these editors often
come with features that may not be necessary for all, resulting in a cluttered and
overwhelming interface.
The goal of this project is to develop a simple, user-friendly text editor using C#
and the .NET framework. This text editor will offer essential features such as
creating, opening, saving, and editing text files, along with basic formatting
options. By focusing on core functionalities and an intuitive interface, the editor
aims to cater to both novice and experienced users who need a straightforward tool
for managing text documents.
This document will guide you through setting up the development environment,
designing the user interface, implementing core functionalities, and testing the
application. By the end of this project, you will have a functional text editor that
can be further enhanced with additional features as needed.
4
VISUAL PROGRAMING LAB
2.Text Editor UI
Description
C# and the .NET framework are ideal for building this text editor due to their
robust libraries, ease of use, and strong support for Windows Forms applications.
These technologies enable rapid development and offer built-in functionality for
file handling, text manipulation, and UI design. They ensure excellent performance
and stability, making the text editor reliable and efficient.
Using C# and .NET also benefits from extensive resources and community
support, facilitating problem-solving and future feature implementation. This
choice ensures efficient development and effective long-term maintenance of the
text editor.
5
VISUAL PROGRAMING LAB
This setup involves installing Visual Studio, creating a new Windows Forms
project, and designing the main form with essential UI components. The
MenuStrip provides easy access to commands, the ToolStrip offers quick action
buttons, and the RichTextBox serves as the primary text input area. This layout
ensures an intuitive and efficient user experience.
1. MenuStrip
o Add a MenuStrip: From the Toolbox, drag a MenuStrip onto the
form.
o Create Menu Items: Add the following top-level menu items: File,
Edit, Format, Help.
File Menu: Add sub-items: New, Open, Save, Save As, Exit.
Edit Menu: Add sub-items: Cut, Copy, Paste, Undo, Redo.
Format Menu: Add sub-items: Font, Color.
Help Menu: Add sub-item: About.
2. ToolStrip
6
VISUAL PROGRAMING LAB
o Add a ToolStrip: Drag a ToolStrip from the Toolbox onto the form
below the MenuStrip.
o Add Buttons: Add buttons for New, Open, Save, Cut, Copy, and
Paste.
o Set Images: Assign relevant images/icons to these buttons for better
user recognition.
3. RichTextBox
o Add a RichTextBox: Drag a RichTextBox from the Toolbox to fill
the remaining space on the form. This will be the main area for text
editing.
4. StatusStrip (Optional)
o Add a StatusStrip: Drag a StatusStrip onto the form.
o Add Status Labels: Use status labels to display information like
cursor position or file status.
New File
Functionality: Clears the current text in the RichTextBox and resets the
editor to a new, untitled document state.
Steps:
1. Check if the current document has unsaved changes.
2. Prompt the user to save the changes if any.
3. Clear the RichTextBox and reset any associated variables.
Open File
Functionality: Allows the user to open and edit an existing text file.
Steps:
1. Use an OpenFileDialog to let the user select a file.
2. Load the selected file’s content into the RichTextBox.
7
VISUAL PROGRAMING LAB
Save File
Save As
Functionality: Saves the current content to a new file specified by the user.
Steps:
1. Use a SaveFileDialog to let the user specify the file name and
location.
2. Save the content of the RichTextBox to the specified file.
3. Update the editor’s state to reflect the new file path.
Exit
Cut
Functionality: Removes the selected text from the RichTextBox and places
it on the clipboard.
8
VISUAL PROGRAMING LAB
Steps:
1. Check if there is any selected text.
2. Cut the selected text and place it on the clipboard.
Copy
Paste
Functionality: Inserts the content from the clipboard into the RichTextBox
at the current cursor position.
Steps:
1. Check if there is any text on the clipboard.
2. Paste the clipboard content into the RichTextBox.
Undo
Redo
9
VISUAL PROGRAMING LAB
7.Formatting Text
To enhance the text editor's functionality, it's important to include options for text
formatting such as changing the font, font size, and text color. Follow these steps
to implement these features:
Functionality: Allows users to select and apply different fonts and font sizes
to the text in the RichTextBox.
Steps:
1. Provide a Font dialog box for users to select a font and size.
2. Apply the selected font and size to the selected text or to the text that
will be typed next.
Functionality: Enables users to search for specific text within the document
and replace it with new text.
Steps:
1. Create a dialog box for finding and replacing text.
2. Allow users to input the text to find and the text to replace it with.
3. Implement search functionality to locate the specified text.
10
VISUAL PROGRAMING LAB
4. Replace the found text with the new text as specified by the user.
Word Wrap
Status Bar
9.Code Implementation:
MainWindow.xaml:
<Window x:Class="Super_simple_text_editor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-
compatibility/2006"
xmlns:local="clr-namespace:Super_simple_text_editor"
mc:Ignorable="d"
11
VISUAL PROGRAMING LAB
MainWindow.xaml.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
12
VISUAL PROGRAMING LAB
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.IO;
namespace Super_simple_text_editor
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public string fileDialogName = "";
public string[] readText = new string[1000];
public MainWindow()
{
InitializeComponent();
}
private void openFileBtn_Click(object sender,
RoutedEventArgs e)
{
var fileDialog = new OpenFileDialog();
fileDialog.InitialDirectory = @"C:\SampleTxtDocs";
fileDialog.DefaultExt = "txt";
fileDialog.Filter = "(*.txt)|";
fileDialog.Multiselect = false;
fileDialog.ShowDialog();
fileDialogName = fileDialog.FileName;
if (fileDialogName != "")
{
fileNameBlock.Text = "";
fileSpaceBox.Text = "";
fileNameBlock.Text = fileDialogName;
readText = File.ReadAllLines(fileDialogName);
for (int i = 0; i < readText.Length; i++)
{
13
VISUAL PROGRAMING LAB
SimpleTextEditor.csproj
14
VISUAL PROGRAMING LAB
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects
>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
15
VISUAL PROGRAMING LAB
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
16
VISUAL PROGRAMING LAB
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
</Project>
App.config
17
VISUAL PROGRAMING LAB
App.xaml
<Application x:Class="Super_simple_text_editor.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-
namespace:Super_simple_text_editor"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
10. Result:
18
VISUAL PROGRAMING LAB
19
VISUAL PROGRAMING LAB
20
VISUAL PROGRAMING LAB
Unit Testing
User Testing
Usability Testing: Have users (both novices and experienced) interact with
the text editor to evaluate its ease of use, intuitiveness, and learnability.
Feedback Collection: Gather feedback on features, interface design, and
overall user experience to identify areas for improvement.
Performance Testing: Evaluate the text editor’s performance in terms of
speed when opening, saving, and editing large files.
Documentation
Test Documentation: Document test cases, results, and any identified bugs
or issues. Maintain a record of improvements made based on testing
feedback.
21
VISUAL PROGRAMING LAB
Testing ensures that the text editor meets functional requirements, performs
reliably, and provides a satisfactory user experience. Continuous testing and
feedback are essential for refining and enhancing the editor’s capabilities over
time.
12. Limitations
To ensure transparency about the text editor's capabilities and potential
shortcomings, consider the following limitations:
13. Conclusion
In summary, the development of this simple text editor using C# and .NET aimed
to provide a straightforward yet effective tool for creating and editing text
documents. By focusing on essential functionalities such as file operations, text
formatting, and basic editing capabilities, the editor offers a user-friendly interface
suitable for both novice and experienced users.
22