Skip to content

Commit 657e088

Browse files
committed
Revert "Revert "upload project""
This reverts commit ed8cd3c.
1 parent ed8cd3c commit 657e088

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+8254
-0
lines changed

App.cs

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Text;
5+
using System.Text.RegularExpressions;
6+
7+
namespace ExportBlog
8+
{
9+
public class App
10+
{
11+
public static string BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
12+
13+
public static int ToInt(string s)
14+
{
15+
int i = 0;
16+
int.TryParse(s, out i);
17+
return i;
18+
}
19+
20+
public static string ToHtmlDecoded(string s)
21+
{
22+
return System.Web.HttpUtility.HtmlDecode(s);
23+
}
24+
25+
public static string GetDescription(Enum cur)
26+
{
27+
var fi = cur.GetType().GetField(cur.ToString());
28+
29+
var da = (DescriptionAttribute)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
30+
31+
return da != null ? da.Description : cur.ToString();
32+
}
33+
34+
static Regex reg_unicode = new Regex(@"\\u[a-f0-9]{4}", RegexOptions.IgnoreCase | RegexOptions.Compiled);
35+
public static string UtoGB(string str)
36+
{
37+
Match mat = reg_unicode.Match(str);
38+
while (mat.Success)
39+
{
40+
char c = Convert.ToChar(Convert.ToInt32(mat.Value.Substring(2), 16));
41+
str = str.Replace(mat.Value, c.ToString());
42+
mat = reg_unicode.Match(str);
43+
}
44+
return str;
45+
}
46+
47+
}
48+
49+
public enum Type
50+
{
51+
Blog = 1,
52+
Url = 2,
53+
Column = 4,
54+
}
55+
56+
[Flags]
57+
public enum Format
58+
{
59+
CHM = 1,
60+
PDF = 2,
61+
HTML = 4,
62+
TXT = 8,
63+
EPUB = 16,
64+
}
65+
}

ArticleListForm.Designer.cs

+137
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ArticleListForm.cs

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Text;
7+
using System.Windows.Forms;
8+
using System.Threading;
9+
using System.Runtime.InteropServices;
10+
11+
namespace ExportBlog
12+
{
13+
public partial class ArticleListForm : Form
14+
{
15+
FeedService feedService = null;
16+
17+
public ArticleListForm(FeedService feedService)
18+
{
19+
this.feedService = feedService;
20+
InitializeComponent();
21+
}
22+
23+
private void ArticleListForm_Load(object sender, EventArgs e)
24+
{
25+
checkBox1.Checked = true;
26+
27+
new Thread(() =>
28+
{
29+
Thread.Sleep(50);
30+
SetChkItem();
31+
})
32+
{
33+
IsBackground = true
34+
}.Start();
35+
}
36+
37+
private void checkBox1_CheckedChanged(object sender, EventArgs e)
38+
{
39+
for (int i = 0; i < checkedListBox1.Items.Count; i++)
40+
{
41+
checkedListBox1.SetItemChecked(i, checkBox1.Checked);
42+
}
43+
}
44+
45+
private void button1_Click(object sender, EventArgs e)
46+
{
47+
var list = feedService.GetList();
48+
int total = 0;
49+
int cnt = checkedListBox1.Items.Count;
50+
for (int i = 0; i < cnt; i++)
51+
{
52+
if (!checkedListBox1.GetItemChecked(i))
53+
{
54+
list[cnt - i - 1].IsDown = false;
55+
total++;
56+
}
57+
}
58+
if (total == checkedListBox1.Items.Count)
59+
{
60+
MessageBox.Show("请选择要导出的文章。");
61+
return;
62+
}
63+
this.DialogResult = DialogResult.OK;
64+
this.Dispose();
65+
}
66+
67+
private void button2_Click(object sender, EventArgs e)
68+
{
69+
this.DialogResult = DialogResult.Cancel;
70+
this.Dispose();
71+
}
72+
73+
private delegate void SetItem();
74+
private void SetChkItem()
75+
{
76+
SetItem st = new SetItem(delegate()
77+
{
78+
var list = feedService.GetList();
79+
label1.Invoke(new SetItem(delegate()
80+
{
81+
label1.Visible = false;
82+
}));
83+
for (int i = list.Count - 1; i >= 0; i--)
84+
{
85+
checkedListBox1.Items.Add(list[i].Title, true);
86+
}
87+
});
88+
89+
checkedListBox1.Invoke(st);
90+
}
91+
92+
#region move
93+
94+
[DllImport("user32.dll")]
95+
public static extern bool ReleaseCapture();
96+
[DllImport("user32.dll")]
97+
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
98+
public const int WM_SYSCOMMAND = 0x0112;
99+
public const int SC_MOVE = 0xF010;
100+
public const int HTCAPTION = 0x0002;
101+
102+
private void ArticleListForm_MouseMove(object sender, MouseEventArgs e)
103+
{
104+
ReleaseCapture();
105+
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
106+
}
107+
#endregion
108+
}
109+
}

0 commit comments

Comments
 (0)