diff --git a/NoteMan/Appointment.cs b/NoteMan/Appointment.cs index 0116188..f539605 100644 --- a/NoteMan/Appointment.cs +++ b/NoteMan/Appointment.cs @@ -2,15 +2,15 @@ namespace NoteMan { - class Appointment : Element + public class Appointment : Element { - private DateTime start; - private DateTime end; + public DateTime Start { get; set; } + public DateTime End { get; set; } public Appointment() { - start = new DateTime(); - end = new DateTime(); + Start = DateTime.Now; + End = DateTime.Now; } public Appointment(string title, string text, DateTime start, DateTime end) : base(title, text) @@ -20,8 +20,8 @@ namespace NoteMan Console.Out.WriteLine("DateTimeComparison: end < start!"); throw new EndBeforeStartException(); } - this.start = start; - this.end = end; + Start = start; + End = end; } @@ -33,8 +33,8 @@ namespace NoteMan throw new EndBeforeStartException(); } base.UpdateRecord(title, text); - this.start = start; - this.end = end; + Start = start; + End = end; } } } diff --git a/NoteMan/ClassDiagram1.cd b/NoteMan/ClassDiagram1.cd new file mode 100644 index 0000000..b7c8b40 --- /dev/null +++ b/NoteMan/ClassDiagram1.cd @@ -0,0 +1,60 @@ + + + + + + QAIAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Appointment.cs + + + + + + AAAAAABAAAAAAEAAAAAAgAAAAAAAAAgAAAABAAABAAA= + Data.cs + + + + + + QAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAACAAAAAA= + Element.cs + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Note.cs + + + + + + AApAAAAAAAgAAFAEAAAQAAAAAAAAAAAAAgAAAAAAAAA= + Project.cs + + + + + + QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAA= + Todo.cs + + + + + + A4IEDAVXIPAQAlgAQAKAgyACBJAJAQAHgUEADAhQAGA= + Form1.cs + + + + + + ABAAAAAAAiAAABEAAACAAMECAQAEAEAAAAAAAAAAAAA= + TextInput.cs + + + + \ No newline at end of file diff --git a/NoteMan/Controller.cs b/NoteMan/Controller.cs deleted file mode 100644 index ae725a7..0000000 --- a/NoteMan/Controller.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NoteMan -{ - class Controller - { - - - - } -} diff --git a/NoteMan/Data.cs b/NoteMan/Data.cs index dd95653..067249e 100644 --- a/NoteMan/Data.cs +++ b/NoteMan/Data.cs @@ -1,27 +1,45 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; +using System.IO; +using System.Xml; +using System.Xml.Serialization; namespace NoteMan { - class Data + public class Data { - private string filename = null; - private List projects = new List(); + public MyBindingList Projects = new MyBindingList(); - public Data() { } - - public Data(string filename) + public Data() { - this.filename = filename; - // TODO: implement import! + CurrentProject = new Project("Default project"); + Projects.Add(CurrentProject); } public void AddProject(string title) { - projects.Add(new Project(title)); + Projects.Add(new Project(title)); + Console.Out.WriteLine("Projekt '{0}' angelegt!", title); + } + + public BindingList GetProjectList() + { + return Projects; + } + + [XmlIgnore] + public Project CurrentProject { get; set; } + + public void ExportXml(string filename) + { + using (StreamWriter sw = new StreamWriter(filename)) + { + using (XmlWriter writer = XmlWriter.Create(sw)) + { + XmlSerializer ser = new XmlSerializer(typeof(Data)); + ser.Serialize(writer, this); + } + } } } -} +} \ No newline at end of file diff --git a/NoteMan/Element.cs b/NoteMan/Element.cs index 71b7289..e199c31 100644 --- a/NoteMan/Element.cs +++ b/NoteMan/Element.cs @@ -1,53 +1,32 @@ -using System; +using System.Xml.Serialization; namespace NoteMan { - class Element + [XmlInclude(typeof(Todo))] + [XmlInclude(typeof(Appointment))] + [XmlInclude(typeof(Note))] + public class Element { - protected string Title; - protected string Text; + public string Title { get; set; } + + public string Text { get; set; } public Element() { - Title = ""; + Title = "unnamed"; Text = ""; } - public Element(string Title, string Text) - { - this.Title = Title; - this.Text = Text; - } - - public string GetTitle() - { - return Title; - } - - public void SetTitle(string title) - { - if (title.Length < 3) - { - Console.Out.WriteLine("Mininum Title length is 3!"); - throw new InvalidArgument(); - } - this.Title = title; - } - - public string GetText() - { - return Text; - } - - public void SetText(string text) + public Element(string title, string text) { - this.Text = text; + Title = title; + Text = text; } public void UpdateRecord(string title, string text) { - SetTitle(title); - SetText(text); + Title = title; + Text = text; } } } diff --git a/NoteMan/Form1.Designer.cs b/NoteMan/Form1.Designer.cs index af713b3..e633f17 100644 --- a/NoteMan/Form1.Designer.cs +++ b/NoteMan/Form1.Designer.cs @@ -28,28 +28,31 @@ /// private void InitializeComponent() { - this.toolStrip1 = new System.Windows.Forms.ToolStrip(); - this.toolStripDropDownButton2 = new System.Windows.Forms.ToolStripDropDownButton(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton(); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripDropDownButton3 = new System.Windows.Forms.ToolStripDropDownButton(); - this.newToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.editToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + this.toolStripMenu = new System.Windows.Forms.ToolStrip(); + this.toolStripBtnNewProject = new System.Windows.Forms.ToolStripButton(); + this.toolStripBtnRenameProject = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); + this.toolStripBtnNewElement = new System.Windows.Forms.ToolStripButton(); + this.toolStripBtnDeleteElement = new System.Windows.Forms.ToolStripButton(); + this.toolStripBtnSaveElement = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripBtnExportXml = new System.Windows.Forms.ToolStripButton(); + this.toolStripBtnExitApplication = new System.Windows.Forms.ToolStripButton(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.listProjects = new System.Windows.Forms.ListBox(); this.labelProjects = new System.Windows.Forms.Label(); this.tabConrtolElements = new System.Windows.Forms.TabControl(); this.tabNotes = new System.Windows.Forms.TabPage(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.listNotes = new System.Windows.Forms.ListBox(); + this.dataNotes = new System.Windows.Forms.DataGridView(); + this.titleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.noteBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); @@ -57,7 +60,11 @@ this.textNotesNote = new System.Windows.Forms.TextBox(); this.tabAppointments = new System.Windows.Forms.TabPage(); this.splitContainer3 = new System.Windows.Forms.SplitContainer(); - this.listAppointments = new System.Windows.Forms.ListBox(); + this.dataAppointments = new System.Windows.Forms.DataGridView(); + this.titleDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Start = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.End = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.appointmentBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -69,7 +76,11 @@ this.label6 = new System.Windows.Forms.Label(); this.tabTodos = new System.Windows.Forms.TabPage(); this.splitContainer4 = new System.Windows.Forms.SplitContainer(); - this.listTodos = new System.Windows.Forms.ListBox(); + this.dataTodos = new System.Windows.Forms.DataGridView(); + this.titleDataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Deadline = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.todoBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); @@ -77,7 +88,8 @@ this.textTodoDescription = new System.Windows.Forms.TextBox(); this.dateTimePickerTodoDeadline = new System.Windows.Forms.DateTimePicker(); this.label9 = new System.Windows.Forms.Label(); - this.toolStrip1.SuspendLayout(); + this.elementBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.toolStripMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -88,146 +100,126 @@ this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataNotes)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.noteBindingSource)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.tabAppointments.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); this.splitContainer3.Panel1.SuspendLayout(); this.splitContainer3.Panel2.SuspendLayout(); this.splitContainer3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataAppointments)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.appointmentBindingSource)).BeginInit(); this.tableLayoutPanel2.SuspendLayout(); this.tabTodos.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).BeginInit(); this.splitContainer4.Panel1.SuspendLayout(); this.splitContainer4.Panel2.SuspendLayout(); this.splitContainer4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataTodos)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.todoBindingSource)).BeginInit(); this.tableLayoutPanel3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.elementBindingSource)).BeginInit(); this.SuspendLayout(); // - // toolStrip1 - // - this.toolStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripDropDownButton2, - this.toolStripDropDownButton1, - this.toolStripDropDownButton3}); - this.toolStrip1.Location = new System.Drawing.Point(0, 0); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(778, 31); - this.toolStrip1.TabIndex = 0; - this.toolStrip1.Text = "toolStrip1"; - // - // toolStripDropDownButton2 - // - this.toolStripDropDownButton2.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.saveToolStripMenuItem, - this.saveAsToolStripMenuItem, - this.openToolStripMenuItem, - this.toolStripSeparator2, - this.exitToolStripMenuItem}); - this.toolStripDropDownButton2.Image = global::NoteMan.Properties.Resources.media_playlist_repeat; - this.toolStripDropDownButton2.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripDropDownButton2.Name = "toolStripDropDownButton2"; - this.toolStripDropDownButton2.Size = new System.Drawing.Size(62, 28); - this.toolStripDropDownButton2.Text = "File"; - // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Image = global::NoteMan.Properties.Resources.document_save; - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.saveToolStripMenuItem.Text = "Save"; - // - // saveAsToolStripMenuItem - // - this.saveAsToolStripMenuItem.Image = global::NoteMan.Properties.Resources.document_save_as; - this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; - this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.saveAsToolStripMenuItem.Text = "Save As ..."; - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Image = global::NoteMan.Properties.Resources.document_open; - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.openToolStripMenuItem.Text = "Open"; - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(123, 6); - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Image = global::NoteMan.Properties.Resources.application_exit; - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.exitToolStripMenuItem.Text = "Exit"; - // - // toolStripDropDownButton1 - // - this.toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.editToolStripMenuItem, - this.deleteToolStripMenuItem}); - this.toolStripDropDownButton1.Image = global::NoteMan.Properties.Resources.project_development; - this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - this.toolStripDropDownButton1.Size = new System.Drawing.Size(81, 28); - this.toolStripDropDownButton1.Text = "Project"; - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Image = global::NoteMan.Properties.Resources.project_development_new_template; - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.newToolStripMenuItem.Text = "New"; - // - // editToolStripMenuItem - // - this.editToolStripMenuItem.Image = global::NoteMan.Properties.Resources.project_development; - this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.editToolStripMenuItem.Text = "Edit"; - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Image = global::NoteMan.Properties.Resources.project_development_close; - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.deleteToolStripMenuItem.Text = "Delete"; - // - // toolStripDropDownButton3 - // - this.toolStripDropDownButton3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem1, - this.editToolStripMenuItem1, - this.deleteToolStripMenuItem1}); - this.toolStripDropDownButton3.Image = global::NoteMan.Properties.Resources.text_plain; - this.toolStripDropDownButton3.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripDropDownButton3.Name = "toolStripDropDownButton3"; - this.toolStripDropDownButton3.Size = new System.Drawing.Size(87, 28); - this.toolStripDropDownButton3.Text = "Element"; - // - // newToolStripMenuItem1 - // - this.newToolStripMenuItem1.Image = global::NoteMan.Properties.Resources.document_new; - this.newToolStripMenuItem1.Name = "newToolStripMenuItem1"; - this.newToolStripMenuItem1.Size = new System.Drawing.Size(107, 22); - this.newToolStripMenuItem1.Text = "New"; - // - // editToolStripMenuItem1 - // - this.editToolStripMenuItem1.Image = global::NoteMan.Properties.Resources.document_edit1; - this.editToolStripMenuItem1.Name = "editToolStripMenuItem1"; - this.editToolStripMenuItem1.Size = new System.Drawing.Size(107, 22); - this.editToolStripMenuItem1.Text = "Edit"; - // - // deleteToolStripMenuItem1 - // - this.deleteToolStripMenuItem1.Image = global::NoteMan.Properties.Resources.document_close; - this.deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1"; - this.deleteToolStripMenuItem1.Size = new System.Drawing.Size(107, 22); - this.deleteToolStripMenuItem1.Text = "Delete"; + // toolStripMenu + // + this.toolStripMenu.ImageScalingSize = new System.Drawing.Size(24, 24); + this.toolStripMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripBtnNewProject, + this.toolStripBtnRenameProject, + this.toolStripSeparator1, + this.toolStripLabel1, + this.toolStripBtnNewElement, + this.toolStripBtnDeleteElement, + this.toolStripBtnSaveElement, + this.toolStripSeparator3, + this.toolStripBtnExportXml, + this.toolStripBtnExitApplication}); + this.toolStripMenu.Location = new System.Drawing.Point(0, 0); + this.toolStripMenu.Name = "toolStripMenu"; + this.toolStripMenu.Size = new System.Drawing.Size(778, 31); + this.toolStripMenu.TabIndex = 0; + this.toolStripMenu.Text = "toolStripMenu"; + // + // toolStripBtnNewProject + // + this.toolStripBtnNewProject.Image = global::NoteMan.Properties.Resources.project_development_new_template; + this.toolStripBtnNewProject.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripBtnNewProject.Name = "toolStripBtnNewProject"; + this.toolStripBtnNewProject.Size = new System.Drawing.Size(99, 28); + this.toolStripBtnNewProject.Text = "New Project"; + this.toolStripBtnNewProject.Click += new System.EventHandler(this.toolStripBtnNewProject_Click); + // + // toolStripBtnRenameProject + // + this.toolStripBtnRenameProject.Image = global::NoteMan.Properties.Resources.document_edit1; + this.toolStripBtnRenameProject.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripBtnRenameProject.Name = "toolStripBtnRenameProject"; + this.toolStripBtnRenameProject.Size = new System.Drawing.Size(78, 28); + this.toolStripBtnRenameProject.Text = "Rename"; + this.toolStripBtnRenameProject.Click += new System.EventHandler(this.toolStripBtnRenameProject_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 31); + // + // toolStripLabel1 + // + this.toolStripLabel1.Name = "toolStripLabel1"; + this.toolStripLabel1.Size = new System.Drawing.Size(53, 28); + this.toolStripLabel1.Text = "Element:"; + // + // toolStripBtnNewElement + // + this.toolStripBtnNewElement.Image = global::NoteMan.Properties.Resources.document_new; + this.toolStripBtnNewElement.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripBtnNewElement.Name = "toolStripBtnNewElement"; + this.toolStripBtnNewElement.Size = new System.Drawing.Size(59, 28); + this.toolStripBtnNewElement.Text = "New"; + this.toolStripBtnNewElement.Click += new System.EventHandler(this.toolStripBtnNewElement_Click); + // + // toolStripBtnDeleteElement + // + this.toolStripBtnDeleteElement.Image = global::NoteMan.Properties.Resources.document_close; + this.toolStripBtnDeleteElement.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripBtnDeleteElement.Name = "toolStripBtnDeleteElement"; + this.toolStripBtnDeleteElement.Size = new System.Drawing.Size(68, 28); + this.toolStripBtnDeleteElement.Text = "Delete"; + this.toolStripBtnDeleteElement.Click += new System.EventHandler(this.toolStripBtnDeleteElement_Click); + // + // toolStripBtnSaveElement + // + this.toolStripBtnSaveElement.Image = global::NoteMan.Properties.Resources.document_save; + this.toolStripBtnSaveElement.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripBtnSaveElement.Name = "toolStripBtnSaveElement"; + this.toolStripBtnSaveElement.Size = new System.Drawing.Size(59, 28); + this.toolStripBtnSaveElement.Text = "Save"; + this.toolStripBtnSaveElement.Click += new System.EventHandler(this.toolStripBtnSaveElement_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(6, 31); + // + // toolStripBtnExportXml + // + this.toolStripBtnExportXml.Image = global::NoteMan.Properties.Resources.document_save_as; + this.toolStripBtnExportXml.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripBtnExportXml.Name = "toolStripBtnExportXml"; + this.toolStripBtnExportXml.Size = new System.Drawing.Size(94, 28); + this.toolStripBtnExportXml.Text = "Export data"; + this.toolStripBtnExportXml.Click += new System.EventHandler(this.toolStripBtnExportXml_Click); + // + // toolStripBtnExitApplication + // + this.toolStripBtnExitApplication.Image = global::NoteMan.Properties.Resources.application_exit; + this.toolStripBtnExitApplication.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripBtnExitApplication.Name = "toolStripBtnExitApplication"; + this.toolStripBtnExitApplication.Size = new System.Drawing.Size(128, 28); + this.toolStripBtnExitApplication.Text = "Close Application"; + this.toolStripBtnExitApplication.Click += new System.EventHandler(this.toolStripBtnExitApplication_Click); // // splitContainer1 // @@ -255,7 +247,7 @@ this.listProjects.Name = "listProjects"; this.listProjects.Size = new System.Drawing.Size(224, 550); this.listProjects.TabIndex = 1; - this.listProjects.SelectedIndexChanged += new System.EventHandler(this.listProjects_SelectedIndexChanged); + this.listProjects.SelectedValueChanged += new System.EventHandler(this.listProjects_SelectedValueChanged); // // labelProjects // @@ -301,7 +293,7 @@ // // splitContainer2.Panel1 // - this.splitContainer2.Panel1.Controls.Add(this.listNotes); + this.splitContainer2.Panel1.Controls.Add(this.dataNotes); // // splitContainer2.Panel2 // @@ -310,14 +302,43 @@ this.splitContainer2.SplitterDistance = 372; this.splitContainer2.TabIndex = 0; // - // listNotes + // dataNotes + // + this.dataNotes.AllowUserToAddRows = false; + this.dataNotes.AllowUserToDeleteRows = false; + this.dataNotes.AutoGenerateColumns = false; + this.dataNotes.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataNotes.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataNotes.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.titleDataGridViewTextBoxColumn, + this.dataGridViewTextBoxColumn1}); + this.dataNotes.DataSource = this.noteBindingSource; + this.dataNotes.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataNotes.Location = new System.Drawing.Point(0, 0); + this.dataNotes.MultiSelect = false; + this.dataNotes.Name = "dataNotes"; + this.dataNotes.ReadOnly = true; + this.dataNotes.Size = new System.Drawing.Size(536, 372); + this.dataNotes.TabIndex = 0; + this.dataNotes.CurrentCellChanged += new System.EventHandler(this.dataNotes_CurrentCellChanged); + // + // titleDataGridViewTextBoxColumn // - this.listNotes.Dock = System.Windows.Forms.DockStyle.Fill; - this.listNotes.FormattingEnabled = true; - this.listNotes.Location = new System.Drawing.Point(0, 0); - this.listNotes.Name = "listNotes"; - this.listNotes.Size = new System.Drawing.Size(536, 372); - this.listNotes.TabIndex = 0; + this.titleDataGridViewTextBoxColumn.DataPropertyName = "Title"; + this.titleDataGridViewTextBoxColumn.HeaderText = "Title"; + this.titleDataGridViewTextBoxColumn.Name = "titleDataGridViewTextBoxColumn"; + this.titleDataGridViewTextBoxColumn.ReadOnly = true; + // + // dataGridViewTextBoxColumn1 + // + this.dataGridViewTextBoxColumn1.DataPropertyName = "Text"; + this.dataGridViewTextBoxColumn1.HeaderText = "Text"; + this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; + this.dataGridViewTextBoxColumn1.ReadOnly = true; + // + // noteBindingSource + // + this.noteBindingSource.DataSource = typeof(NoteMan.Note); // // tableLayoutPanel1 // @@ -347,7 +368,6 @@ this.label1.TabIndex = 0; this.label1.Text = "Title"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.label1.Click += new System.EventHandler(this.label1_Click); // // label2 // @@ -397,7 +417,7 @@ // // splitContainer3.Panel1 // - this.splitContainer3.Panel1.Controls.Add(this.listAppointments); + this.splitContainer3.Panel1.Controls.Add(this.dataAppointments); // // splitContainer3.Panel2 // @@ -406,14 +426,57 @@ this.splitContainer3.SplitterDistance = 372; this.splitContainer3.TabIndex = 0; // - // listAppointments - // - this.listAppointments.Dock = System.Windows.Forms.DockStyle.Fill; - this.listAppointments.FormattingEnabled = true; - this.listAppointments.Location = new System.Drawing.Point(0, 0); - this.listAppointments.Name = "listAppointments"; - this.listAppointments.Size = new System.Drawing.Size(536, 372); - this.listAppointments.TabIndex = 0; + // dataAppointments + // + this.dataAppointments.AllowUserToAddRows = false; + this.dataAppointments.AllowUserToDeleteRows = false; + this.dataAppointments.AutoGenerateColumns = false; + this.dataAppointments.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataAppointments.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataAppointments.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.titleDataGridViewTextBoxColumn1, + this.Start, + this.End}); + this.dataAppointments.DataSource = this.appointmentBindingSource; + this.dataAppointments.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataAppointments.Location = new System.Drawing.Point(0, 0); + this.dataAppointments.MultiSelect = false; + this.dataAppointments.Name = "dataAppointments"; + this.dataAppointments.ReadOnly = true; + this.dataAppointments.Size = new System.Drawing.Size(536, 372); + this.dataAppointments.TabIndex = 0; + this.dataAppointments.CurrentCellChanged += new System.EventHandler(this.dataAppointments_CurrentCellChanged); + // + // titleDataGridViewTextBoxColumn1 + // + this.titleDataGridViewTextBoxColumn1.DataPropertyName = "Title"; + this.titleDataGridViewTextBoxColumn1.HeaderText = "Title"; + this.titleDataGridViewTextBoxColumn1.Name = "titleDataGridViewTextBoxColumn1"; + this.titleDataGridViewTextBoxColumn1.ReadOnly = true; + // + // Start + // + this.Start.DataPropertyName = "Start"; + dataGridViewCellStyle1.Format = "G"; + dataGridViewCellStyle1.NullValue = "0000-00-00 00:00:00"; + this.Start.DefaultCellStyle = dataGridViewCellStyle1; + this.Start.HeaderText = "Start"; + this.Start.Name = "Start"; + this.Start.ReadOnly = true; + // + // End + // + this.End.DataPropertyName = "End"; + dataGridViewCellStyle2.Format = "G"; + dataGridViewCellStyle2.NullValue = "0000-00-00 00:00:00"; + this.End.DefaultCellStyle = dataGridViewCellStyle2; + this.End.HeaderText = "End"; + this.End.Name = "End"; + this.End.ReadOnly = true; + // + // appointmentBindingSource + // + this.appointmentBindingSource.DataSource = typeof(NoteMan.Appointment); // // tableLayoutPanel2 // @@ -460,7 +523,6 @@ this.label4.TabIndex = 1; this.label4.Text = "Description"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.label4.Click += new System.EventHandler(this.label4_Click); // // textAppointmentTitle // @@ -541,7 +603,7 @@ // // splitContainer4.Panel1 // - this.splitContainer4.Panel1.Controls.Add(this.listTodos); + this.splitContainer4.Panel1.Controls.Add(this.dataTodos); // // splitContainer4.Panel2 // @@ -550,14 +612,56 @@ this.splitContainer4.SplitterDistance = 372; this.splitContainer4.TabIndex = 0; // - // listTodos - // - this.listTodos.Dock = System.Windows.Forms.DockStyle.Fill; - this.listTodos.FormattingEnabled = true; - this.listTodos.Location = new System.Drawing.Point(0, 0); - this.listTodos.Name = "listTodos"; - this.listTodos.Size = new System.Drawing.Size(536, 372); - this.listTodos.TabIndex = 0; + // dataTodos + // + this.dataTodos.AllowUserToAddRows = false; + this.dataTodos.AllowUserToDeleteRows = false; + this.dataTodos.AutoGenerateColumns = false; + this.dataTodos.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataTodos.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataTodos.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.titleDataGridViewTextBoxColumn2, + this.Deadline, + this.Text}); + this.dataTodos.DataSource = this.todoBindingSource; + this.dataTodos.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataTodos.Location = new System.Drawing.Point(0, 0); + this.dataTodos.MultiSelect = false; + this.dataTodos.Name = "dataTodos"; + this.dataTodos.ReadOnly = true; + this.dataTodos.Size = new System.Drawing.Size(536, 372); + this.dataTodos.TabIndex = 0; + this.dataTodos.CurrentCellChanged += new System.EventHandler(this.dataTodos_CurrentCellChanged); + // + // titleDataGridViewTextBoxColumn2 + // + this.titleDataGridViewTextBoxColumn2.DataPropertyName = "Title"; + this.titleDataGridViewTextBoxColumn2.HeaderText = "Title"; + this.titleDataGridViewTextBoxColumn2.Name = "titleDataGridViewTextBoxColumn2"; + this.titleDataGridViewTextBoxColumn2.ReadOnly = true; + // + // Deadline + // + this.Deadline.DataPropertyName = "Deadline"; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.Format = "g"; + dataGridViewCellStyle3.NullValue = "0000-00-00 00:00"; + this.Deadline.DefaultCellStyle = dataGridViewCellStyle3; + this.Deadline.HeaderText = "Deadline"; + this.Deadline.MaxInputLength = 20; + this.Deadline.Name = "Deadline"; + this.Deadline.ReadOnly = true; + // + // Text + // + this.Text.DataPropertyName = "Text"; + this.Text.HeaderText = "Text"; + this.Text.Name = "Text"; + this.Text.ReadOnly = true; + // + // todoBindingSource + // + this.todoBindingSource.DataSource = typeof(NoteMan.Todo); // // tableLayoutPanel3 // @@ -639,7 +743,10 @@ this.label9.TabIndex = 6; this.label9.Text = "Deadline"; this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.label9.Click += new System.EventHandler(this.label9_Click); + // + // elementBindingSource + // + this.elementBindingSource.DataSource = typeof(NoteMan.Element); // // Form1 // @@ -647,11 +754,10 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(778, 598); this.Controls.Add(this.splitContainer1); - this.Controls.Add(this.toolStrip1); + this.Controls.Add(this.toolStripMenu); this.Name = "Form1"; - this.Text = "NoteMan"; - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); + this.toolStripMenu.ResumeLayout(false); + this.toolStripMenu.PerformLayout(); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel1.PerformLayout(); this.splitContainer1.Panel2.ResumeLayout(false); @@ -663,6 +769,8 @@ this.splitContainer2.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); this.splitContainer2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataNotes)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.noteBindingSource)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); this.tabAppointments.ResumeLayout(false); @@ -670,6 +778,8 @@ this.splitContainer3.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); this.splitContainer3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataAppointments)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.appointmentBindingSource)).EndInit(); this.tableLayoutPanel2.ResumeLayout(false); this.tableLayoutPanel2.PerformLayout(); this.tabTodos.ResumeLayout(false); @@ -677,8 +787,11 @@ this.splitContainer4.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).EndInit(); this.splitContainer4.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataTodos)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.todoBindingSource)).EndInit(); this.tableLayoutPanel3.ResumeLayout(false); this.tableLayoutPanel3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.elementBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -686,7 +799,7 @@ #endregion - private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStrip toolStripMenu; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.TabControl tabConrtolElements; private System.Windows.Forms.TabPage tabNotes; @@ -695,25 +808,8 @@ private System.Windows.Forms.SplitContainer splitContainer3; private System.Windows.Forms.TabPage tabTodos; private System.Windows.Forms.SplitContainer splitContainer4; - private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButton2; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButton1; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; - private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButton3; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem1; private System.Windows.Forms.ListBox listProjects; private System.Windows.Forms.Label labelProjects; - private System.Windows.Forms.ListBox listNotes; - private System.Windows.Forms.ListBox listAppointments; - private System.Windows.Forms.ListBox listTodos; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; @@ -735,6 +831,31 @@ private System.Windows.Forms.TextBox textTodoDescription; private System.Windows.Forms.DateTimePicker dateTimePickerTodoDeadline; private System.Windows.Forms.Label label9; + private System.Windows.Forms.DataGridView dataNotes; + private System.Windows.Forms.DataGridView dataAppointments; + private System.Windows.Forms.DataGridView dataTodos; + private System.Windows.Forms.BindingSource noteBindingSource; + private System.Windows.Forms.BindingSource appointmentBindingSource; + private System.Windows.Forms.BindingSource todoBindingSource; + private System.Windows.Forms.BindingSource elementBindingSource; + private System.Windows.Forms.DataGridViewTextBoxColumn titleDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; + private System.Windows.Forms.ToolStripButton toolStripBtnNewProject; + private System.Windows.Forms.ToolStripButton toolStripBtnExportXml; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripLabel toolStripLabel1; + private System.Windows.Forms.ToolStripButton toolStripBtnNewElement; + private System.Windows.Forms.ToolStripButton toolStripBtnDeleteElement; + private System.Windows.Forms.ToolStripButton toolStripBtnSaveElement; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripButton toolStripBtnExitApplication; + private System.Windows.Forms.DataGridViewTextBoxColumn titleDataGridViewTextBoxColumn1; + private System.Windows.Forms.DataGridViewTextBoxColumn Start; + private System.Windows.Forms.DataGridViewTextBoxColumn End; + private System.Windows.Forms.DataGridViewTextBoxColumn titleDataGridViewTextBoxColumn2; + private System.Windows.Forms.DataGridViewTextBoxColumn Deadline; + private System.Windows.Forms.DataGridViewTextBoxColumn Text; + private System.Windows.Forms.ToolStripButton toolStripBtnRenameProject; } } diff --git a/NoteMan/Form1.cs b/NoteMan/Form1.cs index 5ae3356..26fa49d 100644 --- a/NoteMan/Form1.cs +++ b/NoteMan/Form1.cs @@ -1,40 +1,168 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; +using NoteMan.Properties; namespace NoteMan { public partial class Form1 : Form { + private readonly Data d = new Data(); + public Form1() { InitializeComponent(); + listProjects.DisplayMember = "Title"; + listProjects.DataSource = d.GetProjectList(); + } + + private void toolStripBtnExitApplication_Click(object sender, EventArgs e) + { + Close(); + } + + private void toolStripBtnNewProject_Click(object sender, EventArgs e) + { + TextInput ti = new TextInput(); + string title = ti.Show("Project name:", ""); + if (title != null) + { + d.AddProject(title); + } + } + + private void listProjects_SelectedValueChanged(object sender, EventArgs e) + { + d.CurrentProject = listProjects.SelectedItem as Project; + if (d.CurrentProject == null) return; + dataAppointments.DataSource = d.CurrentProject.GetAppointments(); + dataTodos.DataSource = d.CurrentProject.GetTodos(); + dataNotes.DataSource = d.CurrentProject.GetNotes(); + } + + private void toolStripBtnNewElement_Click(object sender, EventArgs e) + { + // distinguish the different types + if (tabConrtolElements.SelectedTab == tabTodos) + { + d.CurrentProject.Add(new Todo()); + dataTodos.DataSource = d.CurrentProject.GetTodos(); + } + else if (tabConrtolElements.SelectedTab == tabAppointments) + { + d.CurrentProject.Add(new Appointment()); + dataAppointments.DataSource = d.CurrentProject.GetAppointments(); + } + else if (tabConrtolElements.SelectedTab == tabNotes) + { + d.CurrentProject.Add(new Note()); + dataNotes.DataSource = d.CurrentProject.GetNotes(); + } + } + + private void dataTodos_CurrentCellChanged(object sender, EventArgs e) + { + if (dataTodos.CurrentRow?.DataBoundItem == null) return; + var elem = (Todo) dataTodos.CurrentRow.DataBoundItem; + textTodoTitle.Text = elem.Title; + textTodoDescription.Text = elem.Text; + dateTimePickerTodoDeadline.Value = elem.Deadline; } - private void label1_Click(object sender, EventArgs e) + private void toolStripBtnExportXml_Click(object sender, EventArgs e) { + SaveFileDialog sfd = new SaveFileDialog + { + DefaultExt = "xml", + AddExtension = true, + Filter = Resources.ExportFileTypeXML, + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + }; + DialogResult r = sfd.ShowDialog(); + + if (r == DialogResult.OK) + { + d.ExportXml(sfd.FileName); + } } - private void label4_Click(object sender, EventArgs e) + private void toolStripBtnSaveElement_Click(object sender, EventArgs e) { + // distinguish the different types + if (tabConrtolElements.SelectedTab == tabTodos) + { + if (dataTodos.CurrentRow?.DataBoundItem == null) return; + Todo elem = (Todo) dataTodos.CurrentRow.DataBoundItem; + elem.Title = textTodoTitle.Text; + elem.Text = textTodoDescription.Text; + elem.Deadline = dateTimePickerTodoDeadline.Value; + } + else if (tabConrtolElements.SelectedTab == tabAppointments) + { + if (dataAppointments.CurrentRow?.DataBoundItem == null) return; + Appointment elem = (Appointment) dataAppointments.CurrentRow.DataBoundItem; + elem.UpdateRecord(textAppointmentTitle.Text, textAppointmentDescription.Text, dateTimePickerAppointmentStart.Value, dateTimePickerAppointmentEnd.Value); + } + else if (tabConrtolElements.SelectedTab == tabNotes) + { + if (dataNotes.CurrentRow?.DataBoundItem == null) return; + Note elem = (Note) dataNotes.CurrentRow.DataBoundItem; + elem.UpdateRecord(textNotesTitle.Text, textNotesNote.Text); + } + } + private void toolStripBtnDeleteElement_Click(object sender, EventArgs e) + { + // distinguish the different types + if (tabConrtolElements.SelectedTab == tabTodos) + { + if (dataTodos.CurrentRow?.DataBoundItem == null) return; + Todo elem = (Todo) dataTodos.CurrentRow.DataBoundItem; + d.CurrentProject.Elements.Remove(elem); + } + else if (tabConrtolElements.SelectedTab == tabAppointments) + { + if (dataAppointments.CurrentRow?.DataBoundItem == null) return; + Appointment elem = (Appointment) dataAppointments.CurrentRow.DataBoundItem; + d.CurrentProject.Elements.Remove(elem); + } + else if (tabConrtolElements.SelectedTab == tabNotes) + { + if (dataNotes.CurrentRow?.DataBoundItem == null) return; + Note elem = (Note) dataNotes.CurrentRow.DataBoundItem; + d.CurrentProject.Elements.Remove(elem); + } + } + + private void dataAppointments_CurrentCellChanged(object sender, EventArgs e) + { + if (dataAppointments.CurrentRow?.DataBoundItem != null) + { + Appointment elem = (Appointment) dataAppointments.CurrentRow.DataBoundItem; + textAppointmentTitle.Text = elem.Title; + textAppointmentDescription.Text = elem.Text; + dateTimePickerAppointmentStart.Value = elem.Start; + dateTimePickerAppointmentEnd.Value = elem.End; + } } - private void label9_Click(object sender, EventArgs e) + private void dataNotes_CurrentCellChanged(object sender, EventArgs e) { + if (dataNotes.CurrentRow?.DataBoundItem != null) + { + Note elem = (Note) dataNotes.CurrentRow.DataBoundItem; + textNotesTitle.Text = elem.Title; + textNotesNote.Text = elem.Text; + } } - private void listProjects_SelectedIndexChanged(object sender, EventArgs e) + private void toolStripBtnRenameProject_Click(object sender, EventArgs e) { - //listProjects.SelectedItem(); + + TextInput ti = new TextInput(); + string title = ti.Show("New project name:", d.CurrentProject.Title); + d.CurrentProject.Title = title; } } } diff --git a/NoteMan/Form1.resx b/NoteMan/Form1.resx index 5da7a24..b7b267b 100644 --- a/NoteMan/Form1.resx +++ b/NoteMan/Form1.resx @@ -117,7 +117,34 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 + + True + + + 479, 17 + + + True + + + True + + + 278, 17 + + + True + + + True + + + 122, 17 + + + 634, 17 + \ No newline at end of file diff --git a/NoteMan/MyBindingList.cs b/NoteMan/MyBindingList.cs new file mode 100644 index 0000000..cc0b1bb --- /dev/null +++ b/NoteMan/MyBindingList.cs @@ -0,0 +1,10 @@ +using System; +using System.ComponentModel; + +namespace NoteMan +{ + [Serializable] + public class MyBindingList : BindingList + { + } +} diff --git a/NoteMan/Note.cs b/NoteMan/Note.cs index 77d8bac..3066645 100644 --- a/NoteMan/Note.cs +++ b/NoteMan/Note.cs @@ -1,8 +1,8 @@ namespace NoteMan { - class Note : Element + public class Note : Element { - public Note() : base() { } + public Note() {} public Note(string title, string text) : base(title, text) { } } } diff --git a/NoteMan/NoteMan.csproj b/NoteMan/NoteMan.csproj index fad69b1..db386fe 100644 --- a/NoteMan/NoteMan.csproj +++ b/NoteMan/NoteMan.csproj @@ -47,7 +47,6 @@ - @@ -58,10 +57,17 @@ Form1.cs + + + Form + + + TextInput.cs + Form1.cs @@ -76,6 +82,14 @@ Resources.resx True + + TextInput.cs + + + + + + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/NoteMan/Program.cs b/NoteMan/Program.cs index a520ff1..d514ba7 100644 --- a/NoteMan/Program.cs +++ b/NoteMan/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; namespace NoteMan diff --git a/NoteMan/Project.cs b/NoteMan/Project.cs index 66fca3e..57fc336 100644 --- a/NoteMan/Project.cs +++ b/NoteMan/Project.cs @@ -1,31 +1,61 @@ using System; -using System.Collections.Generic; +using System.ComponentModel; namespace NoteMan { - class Project + public class Project { - private string title; - private List elements = new List(); + public BindingList Elements { get; } = new BindingList(); + public Project() + { + Title = ""; + } public Project(string title) { - SetTitle(title); + Title = title; + // TODO: remove Test + Elements.Add(new Todo(title + ": Test 1", "Just a Test :-)", new DateTime(2017, 1, 1, 0, 0, 0))); + Elements.Add(new Todo(title + ": Test 2", "Just a simple Test :-)", new DateTime(2017, 2, 1))); + Elements.Add(new Note("Test", "Test")); } - private string GetTitle() + public string Title { get; set; } + + public void Add(Element element) { - return title; + Elements.Add(element); } - private void SetTitle(string title) + private BindingList GetElementsOfType(Type type) { - if (title.Length < 3) + BindingList items = new BindingList(); + foreach (Element e in Elements) { - Console.Out.WriteLine("Mininum Title length is 3!"); - throw new InvalidArgument(); + if (e.GetType() == type) + { + items.Add(e); + } } - this.title = title; + return items; + } + + public BindingList GetAppointments() + { + return GetElementsOfType(typeof(Appointment)); + } + public BindingList GetTodos() + { + return GetElementsOfType(typeof(Todo)); + } + public BindingList GetNotes() + { + return GetElementsOfType(typeof(Note)); + } + + public override string ToString() + { + return Title; } } } diff --git a/NoteMan/Properties/DataSources/Appointment.datasource b/NoteMan/Properties/DataSources/Appointment.datasource new file mode 100644 index 0000000..0b40829 --- /dev/null +++ b/NoteMan/Properties/DataSources/Appointment.datasource @@ -0,0 +1,10 @@ + + + + NoteMan.Appointment, NoteMan, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/NoteMan/Properties/DataSources/Element.datasource b/NoteMan/Properties/DataSources/Element.datasource new file mode 100644 index 0000000..4841253 --- /dev/null +++ b/NoteMan/Properties/DataSources/Element.datasource @@ -0,0 +1,10 @@ + + + + NoteMan.Element, NoteMan, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/NoteMan/Properties/DataSources/Note.datasource b/NoteMan/Properties/DataSources/Note.datasource new file mode 100644 index 0000000..62c19d2 --- /dev/null +++ b/NoteMan/Properties/DataSources/Note.datasource @@ -0,0 +1,10 @@ + + + + NoteMan.Note, NoteMan, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/NoteMan/Properties/DataSources/Todo.datasource b/NoteMan/Properties/DataSources/Todo.datasource new file mode 100644 index 0000000..6c774db --- /dev/null +++ b/NoteMan/Properties/DataSources/Todo.datasource @@ -0,0 +1,10 @@ + + + + NoteMan.Todo, NoteMan, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/NoteMan/Properties/Resources.Designer.cs b/NoteMan/Properties/Resources.Designer.cs index 08f8089..5327ad6 100644 --- a/NoteMan/Properties/Resources.Designer.cs +++ b/NoteMan/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ namespace NoteMan.Properties { /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert - // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -33,7 +33,7 @@ namespace NoteMan.Properties { } /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ namespace NoteMan.Properties { } /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap application_exit { get { @@ -71,7 +71,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap dialog_cancel { get { @@ -81,7 +81,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap dialog_close { get { @@ -91,7 +91,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap dialog_ok { get { @@ -101,7 +101,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap dialog_ok_apply { get { @@ -111,7 +111,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap document_close { get { @@ -121,7 +121,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap document_edit { get { @@ -131,7 +131,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap document_edit1 { get { @@ -141,7 +141,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap document_new { get { @@ -151,7 +151,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap document_open { get { @@ -161,7 +161,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap document_save { get { @@ -171,7 +171,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap document_save_as { get { @@ -181,7 +181,16 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized string similar to XML Files (*.xml)|*.xml|All Files (*.*)|*.*. + /// + internal static string ExportFileTypeXML { + get { + return ResourceManager.GetString("ExportFileTypeXML", resourceCulture); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap media_playlist_repeat { get { @@ -191,7 +200,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap project_development { get { @@ -201,7 +210,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap project_development_close { get { @@ -211,7 +220,7 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap project_development_new_template { get { @@ -221,11 +230,11 @@ namespace NoteMan.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap text_plain { get { - object obj = ResourceManager.GetObject("Text-plain", resourceCulture); + object obj = ResourceManager.GetObject("text-plain", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/NoteMan/Properties/Resources.resx b/NoteMan/Properties/Resources.resx index ee2e42a..53decf1 100644 --- a/NoteMan/Properties/Resources.resx +++ b/NoteMan/Properties/Resources.resx @@ -169,4 +169,8 @@ ..\Resources\media-playlist-repeat.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + XML Files (*.xml)|*.xml|All Files (*.*)|*.* + XML or All Files + \ No newline at end of file diff --git a/NoteMan/TextInput.Designer.cs b/NoteMan/TextInput.Designer.cs new file mode 100644 index 0000000..0941257 --- /dev/null +++ b/NoteMan/TextInput.Designer.cs @@ -0,0 +1,104 @@ +namespace NoteMan +{ + partial class TextInput + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.txtInput = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btnOK + // + this.btnOK.BackColor = System.Drawing.Color.PaleGreen; + this.btnOK.Location = new System.Drawing.Point(13, 51); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(150, 23); + this.btnOK.TabIndex = 1; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = false; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // btnCancel + // + this.btnCancel.BackColor = System.Drawing.Color.OrangeRed; + this.btnCancel.Location = new System.Drawing.Point(169, 51); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(150, 23); + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = false; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // txtInput + // + this.txtInput.Location = new System.Drawing.Point(12, 25); + this.txtInput.Name = "txtInput"; + this.txtInput.Size = new System.Drawing.Size(305, 20); + this.txtInput.TabIndex = 0; + this.txtInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInput_KeyPress); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(41, 13); + this.label1.TabIndex = 3; + this.label1.Text = "Name?"; + // + // TextInput + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(329, 83); + this.ControlBox = false; + this.Controls.Add(this.label1); + this.Controls.Add(this.txtInput); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TextInput"; + this.ShowInTaskbar = false; + this.Text = "TextInput"; + this.TopMost = true; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.TextBox txtInput; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/NoteMan/TextInput.cs b/NoteMan/TextInput.cs new file mode 100644 index 0000000..1211d06 --- /dev/null +++ b/NoteMan/TextInput.cs @@ -0,0 +1,69 @@ +using System; +using System.Windows.Forms; + +namespace NoteMan +{ + public partial class TextInput : Form + { + private string _returnValue; + public TextInput() + { + InitializeComponent(); + } + + public new string Show() + { + return Show("Name?", ""); + } + + public new string ShowDialog() + { + return Show("Name?", ""); + } + + public string Show(string label) + { + return Show(label, ""); + } + + public string ShowDialog(string label) + { + return Show(label, ""); + } + + public string ShowDialog(string label, string value) + { + return Show(label, value); + } + + public string Show(string label, string value) + { + _returnValue = null; + txtInput.Text = ""; + label1.Text = label; + txtInput.Text = value; + base.ShowDialog(); + return _returnValue; + } + + private void btnOK_Click(object sender, EventArgs e) + { + _returnValue = txtInput.Text; + Close(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private void txtInput_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == (char) 13) + { + _returnValue = txtInput.Text; + Close(); + } + } + } +} diff --git a/NoteMan/TextInput.resx b/NoteMan/TextInput.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/NoteMan/TextInput.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/NoteMan/Todo.cs b/NoteMan/Todo.cs index 3c7947e..770f744 100644 --- a/NoteMan/Todo.cs +++ b/NoteMan/Todo.cs @@ -2,29 +2,24 @@ namespace NoteMan { - class Todo : Element + public class Todo : Element { - private DateTime deadline; + public DateTime Deadline { get; set; } - public Todo() : base() + public Todo() { - deadline = new DateTime(); + Deadline = new DateTime(); } public Todo(string title, string text, DateTime deadline) : base(title, text) { - this.deadline = deadline; + Deadline = deadline; } public void UpdateRecord(string title, string text, DateTime deadline) { base.UpdateRecord(title, text); - this.deadline = deadline; - } - - public DateTime GetDeadline() - { - return deadline; + Deadline = deadline; } } }