Permalink
Browse files

Revert "Revert "upload project""

This reverts commit ed8cd3c.
  • Loading branch information...
sqzhuyi committed Sep 18, 2012
1 parent ed8cd3c commit 657e088c42d4a6794acac289fe45fa3d54b89dc0
View
65 App.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace ExportBlog
+{
+ public class App
+ {
+ public static string BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
+
+ public static int ToInt(string s)
+ {
+ int i = 0;
+ int.TryParse(s, out i);
+ return i;
+ }
+
+ public static string ToHtmlDecoded(string s)
+ {
+ return System.Web.HttpUtility.HtmlDecode(s);
+ }
+
+ public static string GetDescription(Enum cur)
+ {
+ var fi = cur.GetType().GetField(cur.ToString());
+
+ var da = (DescriptionAttribute)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
+
+ return da != null ? da.Description : cur.ToString();
+ }
+
+ static Regex reg_unicode = new Regex(@"\\u[a-f0-9]{4}", RegexOptions.IgnoreCase | RegexOptions.Compiled);
+ public static string UtoGB(string str)
+ {
+ Match mat = reg_unicode.Match(str);
+ while (mat.Success)
+ {
+ char c = Convert.ToChar(Convert.ToInt32(mat.Value.Substring(2), 16));
+ str = str.Replace(mat.Value, c.ToString());
+ mat = reg_unicode.Match(str);
+ }
+ return str;
+ }
+
+ }
+
+ public enum Type
+ {
+ Blog = 1,
+ Url = 2,
+ Column = 4,
+ }
+
+ [Flags]
+ public enum Format
+ {
+ CHM = 1,
+ PDF = 2,
+ HTML = 4,
+ TXT = 8,
+ EPUB = 16,
+ }
+}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,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
+ }
+}
Oops, something went wrong.

0 comments on commit 657e088

Please sign in to comment.