diff --git a/NoteApp/Form1.Designer.cs b/NoteApp/Form1.Designer.cs index c19f21c..0064515 100644 --- a/NoteApp/Form1.Designer.cs +++ b/NoteApp/Form1.Designer.cs @@ -1,6 +1,6 @@ namespace NoteApp { - partial class Form1 + partial class NoteTaker { /// /// Required designer variable. @@ -28,12 +28,111 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.titelBox = new System.Windows.Forms.TextBox(); + this.noteBox = new System.Windows.Forms.TextBox(); + this.deleteButton = new System.Windows.Forms.Button(); + this.saveButton = new System.Windows.Forms.Button(); + this.addButton = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // titelBox + // + this.titelBox.Font = new System.Drawing.Font("Times New Roman", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.titelBox.Location = new System.Drawing.Point(313, 12); + this.titelBox.Name = "titelBox"; + this.titelBox.Size = new System.Drawing.Size(484, 44); + this.titelBox.TabIndex = 0; + this.titelBox.Text = "Titel"; + // + // noteBox + // + this.noteBox.AcceptsReturn = true; + this.noteBox.AcceptsTab = true; + this.noteBox.Font = new System.Drawing.Font("Times New Roman", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.noteBox.Location = new System.Drawing.Point(313, 49); + this.noteBox.Multiline = true; + this.noteBox.Name = "noteBox"; + this.noteBox.Size = new System.Drawing.Size(484, 389); + this.noteBox.TabIndex = 1; + // + // deleteButton + // + this.deleteButton.Location = new System.Drawing.Point(218, 404); + this.deleteButton.Name = "deleteButton"; + this.deleteButton.Size = new System.Drawing.Size(89, 34); + this.deleteButton.TabIndex = 2; + this.deleteButton.Text = "Delete"; + this.deleteButton.UseVisualStyleBackColor = true; + this.deleteButton.Click += new System.EventHandler(this.deleteButton_Click); + // + // saveButton + // + this.saveButton.Location = new System.Drawing.Point(114, 404); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(89, 34); + this.saveButton.TabIndex = 4; + this.saveButton.Text = "Save"; + this.saveButton.UseVisualStyleBackColor = true; + this.saveButton.Click += new System.EventHandler(this.saveButton_Click); + // + // addButton + // + this.addButton.Location = new System.Drawing.Point(10, 404); + this.addButton.Name = "addButton"; + this.addButton.Size = new System.Drawing.Size(89, 34); + this.addButton.TabIndex = 5; + this.addButton.Text = "Add"; + this.addButton.UseVisualStyleBackColor = true; + this.addButton.Click += new System.EventHandler(this.addButton_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + this.dataGridView1.AllowUserToResizeRows = false; + this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Window; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Location = new System.Drawing.Point(10, 12); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 62; + this.dataGridView1.RowTemplate.Height = 33; + this.dataGridView1.Size = new System.Drawing.Size(297, 386); + this.dataGridView1.TabIndex = 6; + this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); + this.dataGridView1.CellContentDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentDoubleClick); + // + // NoteTaker + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Linen; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.addButton); + this.Controls.Add(this.saveButton); + this.Controls.Add(this.deleteButton); + this.Controls.Add(this.noteBox); + this.Controls.Add(this.titelBox); + this.Name = "NoteTaker"; this.Text = "Form1"; + this.Load += new System.EventHandler(this.NoteTaker_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + + private TextBox titelBox; + private TextBox noteBox; + private Button deleteButton; + private Button saveButton; + private Button addButton; + private DataGridView dataGridView1; } } \ No newline at end of file diff --git a/NoteApp/Form1.cs b/NoteApp/Form1.cs index a0be3a7..e1ef6b2 100644 --- a/NoteApp/Form1.cs +++ b/NoteApp/Form1.cs @@ -1,10 +1,67 @@ +using System.Data; + namespace NoteApp { - public partial class Form1 : Form + public partial class NoteTaker : Form { - public Form1() + DataTable notes = new DataTable(); + bool editing = false; + public NoteTaker() { InitializeComponent(); } + + private void deleteButton_Click(object sender, EventArgs e) + { + try + { + notes.Rows[dataGridView1.CurrentCell.RowIndex].Delete(); + } + catch (Exception ex) { Console.WriteLine("Invalid note, no action taken"); } + } + + private void addButton_Click(object sender, EventArgs e) + { + titelBox.Text = ""; + noteBox.Text = ""; + } + + private void saveButton_Click(object sender, EventArgs e) + { + + if (editing) + { + notes.Rows[dataGridView1.CurrentCell.RowIndex]["Title"] = titelBox.Text; + notes.Rows[dataGridView1.CurrentCell.RowIndex]["note"] = noteBox.Text; + } + else + { + notes.Rows.Add(titelBox.Text, noteBox.Text); + } + titelBox.Text = "Title"; + noteBox.Text = ""; + editing = false; + } + + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) + { + titelBox.Text = notes.Rows[dataGridView1.CurrentCell.RowIndex].ItemArray[0].ToString(); + noteBox.Text = notes.Rows[dataGridView1.CurrentCell.RowIndex].ItemArray[1].ToString(); + + editing = true; + } + + private void NoteTaker_Load(object sender, EventArgs e) + { + notes.Columns.Add("Title"); + notes.Columns.Add("note"); + + dataGridView1.DataSource = notes; + } } } \ No newline at end of file diff --git a/NoteApp/Form1.resx b/NoteApp/Form1.resx index 1af7de1..f298a7b 100644 --- a/NoteApp/Form1.resx +++ b/NoteApp/Form1.resx @@ -1,64 +1,4 @@ - - - + diff --git a/NoteApp/Program.cs b/NoteApp/Program.cs index 858cf62..632f2ab 100644 --- a/NoteApp/Program.cs +++ b/NoteApp/Program.cs @@ -11,7 +11,7 @@ static void Main() // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new NoteTaker()); } } } \ No newline at end of file diff --git a/NoteApp/writeToCSV.cs b/NoteApp/writeToCSV.cs new file mode 100644 index 0000000..14bac0b --- /dev/null +++ b/NoteApp/writeToCSV.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; + +namespace NoteApp +{ + /* + public classwriteToCSV + { + DirectoryInfo[] cDirs = new DirectoryInfo(@"c:\").GetDirectories(); + + using (StreamWriter sw = new StreamWriter("CDriveDirs.txt")) + { + + } + } + */ +}