Context
~This assignment is a continuation from the previous week~
Copying and pasting text is a common task in the digital world, but it can be hard to keep track of all the snippets you copy. Wouldn’t it be great if you had a tool that could store, organize, and search your copied text with ease? That’s what our Copy App can do for you.In this beginner-level assignment, we will learn C# by making a Copy App from scratch. This practical experience will help you master the fundamentals of C# and also expose you to the world of Windows Presentation Foundation (WPF) and SQLite databases.
Objective: The main objective of this assignment is to give you a thorough introduction to C# while creating a fully functional application. By the end you will have built a Copy App using C# and WPF, which saves all copied text into an SQLite database.
Key Learning Points
In this assignment you will learn how to create a C# WPF app that uses SQLite to store and retrieve clipboard items. SQLite is a lightweight database system that stores data in a file. To use SQLite, you need to install the Microsoft.Data.Sqlite NuGet package. You can learn more about SQLite and C# from this video or this article.
The code consists of the following parts:
~The using statements import the necessary namespaces for working with SQLite, Windows, and timers.
~The namespace statement defines the name of your project as CapturedCopyApp.
~The public partial class MainWindow inherits from the Window class and represents the main window of your app.
~The private variables declare the timer, the connection string, and the last clipboard text for your app.
~The public MainWindow() constructor initializes the components, sets up the timer, opens a connection to the database, creates a table if it does not exist, and loads the data from the table.
~The private void Timer_Tick() method checks if the clipboard contains text every second. If it does, it saves it and adds it to the database and the listbox. It also updates the label with the current clipboard text.
~The private void LoadData() method opens a connection to the database, executes a command to get all text from the table, reads the result, and adds each item to the listbox.
~The private void Window_Closing() method is called when the window is closing. You can add code here if you want to do something when the window is closing.
~The private void CloseApp_Click() method is called when the CloseApp button is clicked. You can add code here to close the app when the button is clicked.
What to Expect: Throughout this assignment, I will guide you with step-by-step tutorials, code samples, and explanations to ensure that you not only complete the Copy App successfully but also gain a deep understanding of the principles and best practices of C# programming. I encourage you to actively participate in the learning process, ask questions, and experiment with the code to reinforce your understanding. By the end of this assignment, you will not only have a working Copy App but also a solid foundation in C# programming and WPF development.
The preparation section provides you with the elements needed to complete the requirements.
The following steps must be completed to receive the associated points for each task.
Requirements(1-3) are demonstrated in the tutorial provided in the resources area.
Any requirement marked with a * must be completed to receive a score above 0.