This repository has been archived by the owner on Jun 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
SelectPropertiesWindow.cs
87 lines (68 loc) · 2.35 KB
/
SelectPropertiesWindow.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
using System;
using System.Linq;
using System.Windows.Forms;
using RedditSaveTransfer.Properties;
namespace RedditSaveTransfer
{
public partial class SelectPropertiesWindow : Form
{
public SelectPropertiesWindow()
{
InitializeComponent();
AcceptButton = btnAccept;
CancelButton = btnCancel;
SetCheckedItems();
}
private void SetPropertiesToExport()
{
Common.PropertiesToExport.Clear();
foreach (var p in chkListBoxProps.CheckedItems)
Common.PropertiesToExport.Add(p.ToString());
}
private void SetCheckedItems()
{
foreach (var p in Common.PropertiesToExport)
{
var index = chkListBoxProps.Items.IndexOf(p);
if (index < 0 || index >= chkListBoxProps.Items.Count)
continue;
chkListBoxProps.SetItemChecked(index, true);
Console.WriteLine(p);
}
}
private void btnAccept_Click(object sender, EventArgs e)
{
if (chkListBoxProps.CheckedItems.Count == 0)
{
MessageBox.Show("You must have at least one property selected.");
return;
}
SetPropertiesToExport();
if (Common.PropertiesToExport != null && Common.PropertiesToExport.Any())
{
Settings.Default.PropertiesToExport = String.Join(",", Common.PropertiesToExport.ToArray());
Settings.Default.Save();
}
DialogResult = DialogResult.OK;
}
private void btnDefault_Click(object sender, EventArgs e)
{
CheckUncheckAll(false);
foreach (var p in Common.DefaultPropertiesToExport)
chkListBoxProps.SetItemChecked(chkListBoxProps.Items.IndexOf(p), true);
}
private void btnSelectAll_Click(object sender, EventArgs e)
{
CheckUncheckAll(true);
}
private void btnClear_Click(object sender, EventArgs e)
{
CheckUncheckAll(false);
}
private void CheckUncheckAll(bool itemChecked)
{
for (var i = 0; i < chkListBoxProps.Items.Count; i++)
chkListBoxProps.SetItemChecked(i, itemChecked);
}
}
}