Introduction
~context~
(​The Copy App: Code Final) Part 3

Context
                                                       ~This assignment is a continuation from the previous week~
This C# code is part 3 of the previous code and represents a Windows Presentation Foundation (WPF) application that uses SQLite to store and retrieve clipboard items. It continues the development of the Copy App and introduces additional features and functionality. Here's a breakdown of the code:

1. **Using Statements:** The code begins with using statements that import the necessary namespaces. These include Microsoft.Data.Sqlite for working with SQLite, Microsoft.Win32 for file dialogs, System for basic classes, System.Diagnostics for debugging, System.IO for file operations, System.Windows for creating Windows applications, and System.Windows.Threading for timers and events.

2. **Namespace:** The code is within the CapturedCopyApp namespace, which is the name of the project.

3. **MainWindow Class:** The code defines a partial class named MainWindow, which represents the main window of the WPF application.

4. **Private Variables:** Several private variables are declared, including:
- `_timer`: A DispatcherTimer that triggers an event every second.
- `_connectionString`: A string containing the connection string to the SQLite database.
- `_lastClipboardText`: A string to keep track of the last copied text.

5. **MainWindow Constructor:** The MainWindow constructor initializes the components of the window and sets up the timer. It also opens a connection to the SQLite database, creates a table if it doesn't exist, and loads data from the table.

6. **Timer_Tick Method:** This method is called every second by the timer. It checks if there is text in the clipboard, and if so, it saves the text to the database, adds it to a listbox, and updates a label with the number of items in the clipboard.

7. **LoadData Method:** This method opens a connection to the database, executes a query to retrieve all text items from the table, and adds each item to the listbox.

8. **Window_Closing Method:** This method is called when the window is closing. You can add code here to perform actions when the window is closing.

9. **CloseApp_Click Method:** This method is called when the "CloseApp" button is clicked, and it shuts down the application.

10. **CleanDatabase_Click Method:** This method is called when the "CleanDatabase" button is clicked. It clears all items from the listbox and deletes all records from the database.

11. **Export_Click Method:** This method is called when the "Export" button is clicked. It opens a SaveFileDialog, allowing the user to save the clipboard items to a text file.

Overall, this code extends the functionality of the Copy App by adding features to clear the database, export clipboard items, and perform actions when the application window is closing. It continues to use SQLite as the database for storing clipboard items and relies on WPF for creating the user interface.

25 Points

Total Points if all the above steps are completed and submitted.

0u

5 unit credits when you receive 100% for all assignments in this pipeline.