This repository has been archived by the owner on May 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfrmPictureDB.cs
61 lines (57 loc) · 2.22 KB
/
frmPictureDB.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
using Manina.Windows.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Note_Profiler
{
/// <summary>
/// A simple database viewer for Notes and Pages
/// </summary>
public partial class frmPictureDB : Form
{
DBAdapter db;
BindingList<DBPage> pagesList;
BindingList<DBNote> noteList;
public frmPictureDB()
{
InitializeComponent();
db = new DBAdapter();
pagesList = new BindingList<DBPage>(db.PageList());
noteList = new BindingList<DBNote>(db.NotesInDB());
foreach (DBNote note in noteList)
{
notesView.Items.Add(note, note.ToString(), note.Image); //Populates the image list. Note that if you do this twice, for some reason - it doesn't work.
}
foreach (DBPage page in pagesList)
{
pagesView.Items.Add(page, page.ToString(), page.Image); //Populates the image list. Note that if you do this twice, for some reason - it doesn't work.
}
}
/// <summary>
/// Deletes the selected image(s) from the database.
/// Doesn't really reload the view - just deletes the items from the list as well.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDelete_Click(object sender, EventArgs e)
{
DialogResult yesNo = MessageBox.Show(this, "Are you sure you want to delete this page from the database?\nThis action is non-reversible!", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
foreach (ImageListViewItem item in notesView.SelectedItems)
{
int id = ((DBNote)item.VirtualItemKey).ID;
db.DeleteNote(id);
notesView.Items.Remove(item);
db.SaveAll();
}
}
}
}