forked from sqzhuyi/ExportBlog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ArticleListForm.cs
109 lines (97 loc) · 3.16 KB
/
ArticleListForm.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
namespace ExportBlog
{
public partial class ArticleListForm : Form
{
FeedService feedService = null;
public ArticleListForm(FeedService feedService)
{
this.feedService = feedService;
InitializeComponent();
}
private void ArticleListForm_Load(object sender, EventArgs e)
{
checkBox1.Checked = true;
new Thread(() =>
{
Thread.Sleep(50);
SetChkItem();
})
{
IsBackground = true
}.Start();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
checkedListBox1.SetItemChecked(i, checkBox1.Checked);
}
}
private void button1_Click(object sender, EventArgs e)
{
var list = feedService.GetList();
int total = 0;
int cnt = checkedListBox1.Items.Count;
for (int i = 0; i < cnt; i++)
{
if (!checkedListBox1.GetItemChecked(i))
{
list[cnt - i - 1].IsDown = false;
total++;
}
}
if (total == checkedListBox1.Items.Count)
{
MessageBox.Show("请选择要导出的文章。");
return;
}
this.DialogResult = DialogResult.OK;
this.Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Dispose();
}
private delegate void SetItem();
private void SetChkItem()
{
SetItem st = new SetItem(delegate()
{
var list = feedService.GetList();
label1.Invoke(new SetItem(delegate()
{
label1.Visible = false;
}));
for (int i = list.Count - 1; i >= 0; i--)
{
checkedListBox1.Items.Add(list[i].Title, true);
}
});
checkedListBox1.Invoke(st);
}
#region move
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
private void ArticleListForm_MouseMove(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
#endregion
}
}