-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.cs
127 lines (110 loc) · 4.28 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Filename: Form1.cs
using System;
using System.Drawing;
using System.Windows.Forms;
public partial class Form1 : Form
{
private Button selectFolderButton=null!;
private Button exitButton=null!;
private RichTextBox instructionsTextBox = null!;
private string? selectedFolderPath;
private static string? lastSaveLocation = null;
public Form1()
{
InitializeComponent();
InitializeUI();
}
private void InitializeUI()
{
this.Text = "Code Aggregator";
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
var menuStrip = new MenuStrip();
var settingsMenu = new ToolStripMenuItem("Settings");
var resetFileAssociationMenuItem = new ToolStripMenuItem("Reset Default File Association");
resetFileAssociationMenuItem.Click += ResetFileAssociationMenuItem_Click;
settingsMenu.DropDownItems.Add(resetFileAssociationMenuItem);
menuStrip.Items.Add(settingsMenu);
Controls.Add(menuStrip);
instructionsTextBox = new RichTextBox
{
ReadOnly = true,
BorderStyle = BorderStyle.None,
BackColor = this.BackColor,
Margin = new Padding(25), // Add margins
Dock = DockStyle.Fill
};
instructionsTextBox.Rtf = @"{\rtf1\ansi\deff0{\fonttbl{\f0\fswiss Helvetica;}}
{\b\ul Code Aggregator}\par\par
This application allows you to select a root folder and aggregate all text files within the selected folder and its subfolders into a single text file. This is particularly useful for consolidating code files or other text-based files.\par\par
{\b How to Use:}\par
1. Click the 'Select Folder' button below to choose the root folder for aggregation.\par
2. Use the checkboxes to include or exclude specific files and folders. By default, all folders and files are included.\par
3. Click 'Start Operation' to begin the aggregation process. You will be prompted to specify the location and name of the output file.\par\par
Note: It is recommended to exclude folders like .git, .vs, or other dependency folders to avoid including unnecessary files.\par}";
selectFolderButton = new Button
{
Text = "Select Folder",
AutoSize = true,
Dock = DockStyle.Right,
Margin = new Padding(20) // Add margins
};
selectFolderButton.Click += SelectFolderButton_Click;
exitButton = new Button
{
Text = "Exit",
AutoSize = true,
Dock = DockStyle.Left,
Margin = new Padding(20) // Add margins
};
exitButton.Click += ExitButton_Click;
var buttonPanel = new Panel
{
Dock = DockStyle.Bottom,
Height = 40
};
buttonPanel.Controls.Add(selectFolderButton);
buttonPanel.Controls.Add(exitButton);
var mainPanel = new Panel
{
Dock = DockStyle.Fill,
Padding = new Padding(10, 40, 10, 10) // Add padding around the panel and move it down
};
mainPanel.Controls.Add(instructionsTextBox);
Controls.Add(mainPanel);
Controls.Add(buttonPanel);
MainMenuStrip = menuStrip;
}
private void SelectFolderButton_Click(object? sender, EventArgs e)
{
var folderPath = FolderSelector.SelectFolder();
if (!string.IsNullOrEmpty(folderPath))
{
selectedFolderPath = folderPath;
var settingsManager = new SettingsManager(folderPath);
var includedFiles = settingsManager.LoadSettings();
var folderTreeView = new FolderTreeView(folderPath)
{
Dock = DockStyle.Fill
};
folderTreeView.FormClosing += (s, args) =>
{
settingsManager.SaveSettings(folderTreeView.GetIncludedFiles());
};
folderTreeView.ShowDialog();
}
else
{
MessageBox.Show("No folder selected.");
}
}
private void ExitButton_Click(object? sender, EventArgs e)
{
Application.Exit();
}
private void ResetFileAssociationMenuItem_Click(object? sender, EventArgs e)
{
lastSaveLocation = null;
MessageBox.Show("Default file association has been reset.");
}
}