/
ThoughtInfo.cs
120 lines (103 loc) · 3.35 KB
/
ThoughtInfo.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
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 ThoughtQ.Data;
namespace ThoughtQ
{
public partial class ThoughtInfo : Form
{
private ListViewItem item;
private Thought displayed;
/* Object Reference */
private tQueue queue;
private MainWindow mainForm;
public ThoughtInfo(ref ListViewItem inView, ref tQueue inThoughtList, MainWindow mainForm)
{
InitializeComponent();
item = inView;
displayed = (Thought)item.Tag;
queue = inThoughtList;
txt_Title.Text = displayed.getTitle();
txt_Description.Text = displayed.getDescription();
txt_Created.Text = displayed.getTimeCreated().ToShortTimeString();
cbx_cat.Text = displayed.getCategory();
foreach (String el in inThoughtList.categories)
{
cbx_cat.Items.Add(el);
}
this.mainForm = mainForm;
if (displayed.tState == thought_state.archived)
{
btnArchive.Enabled = false;
}
this.Text = "Thought Info -- " + displayed.getTitle();
}
public Thought getThought()
{
return displayed;
}
private void btn_save_Click(object sender, EventArgs e)
{
displayed.setDescription(txt_Description.Text);
displayed.setTitle(txt_Title.Text);
item.Text = displayed.getTitle();
displayed.setCategory(cbx_cat.Text);
mainForm.addCategory(cbx_cat.Text);
mainForm.SaveQueue();
//mainForm.updateList();
this.Close();
}
private void btn_cancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnDelete_Click(object sender, EventArgs e)
{
if(displayed.tState == thought_state.active)
queue.deleteThought(displayed);
else
queue.deleteThought(displayed);
//mainForm.updateList();
this.Close();
}
private void btnArchive_Click(object sender, EventArgs e)
{
queue.archiveThought(displayed);
displayed.tState = thought_state.archived;
//mainForm.updateList();
this.Close();
}
private void txt_Description_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control & e.KeyCode == Keys.A)
{
txt_Description.SelectAll();
}
else if (e.Control & e.KeyCode == Keys.Back)
{
SendKeys.SendWait("^+{LEFT}{BACKSPACE}");
}
}
private void txt_Title_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control & e.KeyCode == Keys.A)
{
txt_Title.SelectAll();
}
else if (e.Control & e.KeyCode == Keys.Back)
{
SendKeys.SendWait("^+{LEFT}{BACKSPACE}");
}
}
private void ThoughtInfo_FormClosing(object sender, FormClosingEventArgs e)
{
mainForm.closeWin(this);
}
}
}