├── .gitignore ├── About.Designer.cs ├── About.cs ├── About.resx ├── AccessAdo.cs ├── AesHelper.cs ├── App.config ├── AttRenameDialog.Designer.cs ├── AttRenameDialog.cs ├── AttRenameDialog.resx ├── Attachment.cs ├── AuthorAPI.cs ├── CheckDb.cs ├── ClassDiagram1.cd ├── ContentExcs.cs ├── DiaChgLocalPSW.Designer.cs ├── DiaChgLocalPSW.cs ├── DiaChgLocalPSW.resx ├── DialogPSW.Designer.cs ├── DialogPSW.cs ├── DialogPSW.resx ├── DialogPSWYouDao.Designer.cs ├── DialogPSWYouDao.cs ├── DialogPSWYouDao.resx ├── DialogUpdate.Designer.cs ├── DialogUpdate.cs ├── DialogUpdate.resx ├── DirNode.cs ├── DocFind.Designer.cs ├── DocFind.cs ├── DocFind.resx ├── DocMark.Designer.cs ├── DocMark.cs ├── DocMark.resx ├── DocumentForm.Designer.cs ├── DocumentForm.cs ├── DocumentForm.resx ├── Download.Designer.cs ├── Download.cs ├── Download.resx ├── EncryptDecrptt.cs ├── ExportYoudaoForm.Designer.cs ├── ExportYoudaoForm.cs ├── ExportYoudaoForm.resx ├── FormAttachment.Designer.cs ├── FormAttachment.cs ├── FormAttachment.resx ├── FormAuthor.Designer.cs ├── FormAuthor.cs ├── FormAuthor.resx ├── FormMain.Designer.cs ├── FormMain.cs ├── FormMain.resx ├── FormTreeLeft.Designer.cs ├── FormTreeLeft.cs ├── FormTreeLeft.resx ├── IniLexer.cs ├── LICENSE ├── NoteAPI.cs ├── Program.cs ├── ProperDialog.Designer.cs ├── ProperDialog.cs ├── ProperDialog.resx ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs ├── Settings.settings └── app.manifest ├── PubFunc.cs ├── README.md ├── Resources ├── app.ico └── tongbu.gif ├── TreeNodeLocal.xml ├── UpLoad.Designer.cs ├── UpLoad.cs ├── UpLoad.resx ├── UserInfo.Designer.cs ├── UserInfo.cs ├── UserInfo.resx ├── WeCode.csproj ├── WeCode.csproj.user ├── WeCode.sln ├── WelcomeDoc.Designer.cs ├── WelcomeDoc.cs ├── WelcomeDoc.resx ├── XML2DB.cs ├── XMLAPI.cs ├── YouDaoTree.Designer.cs ├── YouDaoTree.cs ├── YouDaoTree.resx ├── bin └── Release │ ├── DockPanel.config │ ├── Interop.ADODB.dll │ ├── Interop.ADOX.dll │ ├── Interop.JRO.dll │ ├── Newtonsoft.Json.dll │ ├── Newtonsoft.Json.pdb │ ├── Newtonsoft.Json.xml │ ├── SciLexer.dll │ ├── SciLexer64.dll │ ├── ScintillaNET.dll │ ├── TreeNodeLocal.xml │ ├── WeCode.exe │ ├── WeCode.exe.Config │ ├── WeifenLuo.WinFormsUI.Docking.dll │ ├── db │ ├── helpdb.mdb │ └── youdao_ead93e3e-a218-42d3-922f-36243aa50eda.mdb │ └── temp │ └── m.ico ├── db └── helpdb.mdb ├── m.ico ├── packages.config ├── packages ├── Newtonsoft.Json.6.0.6 │ ├── Newtonsoft.Json.6.0.6.nupkg │ ├── Newtonsoft.Json.6.0.6.nuspec │ ├── lib │ │ ├── net20 │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.xml │ │ ├── net35 │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.xml │ │ ├── net40 │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.xml │ │ ├── net45 │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.xml │ │ ├── netcore45 │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.xml │ │ ├── portable-net40+sl5+wp80+win8+wpa81 │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.xml │ │ └── portable-net45+wp80+win8+wpa81+aspnetcore50 │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.xml │ └── tools │ │ └── install.ps1 └── repositories.config ├── test.Designer.cs ├── test.cs ├── test.resx ├── treeTagBook.cs ├── treeTagNote.cs ├── utils └── StringUtils.cs ├── wecode.ico └── youdao └── YouDaoNode2.cs /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/Debug 2 | /bin/Release/WeCode.pdb 3 | /bin/Release/db/youdao* 4 | /obj 5 | /*.suo 6 | -------------------------------------------------------------------------------- /About.cs: -------------------------------------------------------------------------------- 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 | 9 | namespace WeCode1._0 10 | { 11 | public partial class About : Form 12 | { 13 | public About() 14 | { 15 | InitializeComponent(); 16 | //从配置文件读取版本 17 | label2.Text = "Version " + PubFunc.GetConfiguration("Version"); 18 | } 19 | 20 | private void StartProcess(string url) 21 | { 22 | try 23 | { 24 | System.Diagnostics.Process.Start(url); 25 | } 26 | catch (System.ComponentModel.Win32Exception noBrowser) 27 | { 28 | if (noBrowser.ErrorCode == -2147467259) 29 | MessageBox.Show(noBrowser.Message); 30 | } 31 | catch (System.Exception other) 32 | { 33 | MessageBox.Show(other.Message); 34 | } 35 | } 36 | 37 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 38 | { 39 | StartProcess("http://thinkry.github.io"); 40 | } 41 | 42 | private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 43 | { 44 | StartProcess("https://github.com/thinkry/wecode/issues"); 45 | } 46 | 47 | private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 48 | { 49 | StartProcess("mailto:thinkry@qq.com"); 50 | } 51 | 52 | private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 53 | { 54 | StartProcess("mailto:thinkry@qq.com"); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /AesHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Security.Cryptography; 5 | using System.IO; 6 | 7 | namespace WeCode1._0 8 | { 9 | //对称加密与解密类, 10 | public class AesHelper 11 | { 12 | private SymmetricAlgorithm mobjCryptoService; 13 | private string Key; 14 | 15 | //构造函数--------------------------------------------------------------------- 16 | public AesHelper(string sKey) 17 | { 18 | //Rijndael由比利时计算机科学家Vincent Rijmen和Joan Daemen开发的"对称加密算法" 19 | mobjCryptoService = new RijndaelManaged(); 20 | //下面的KEY需要保密,可以自己定义,不要被它人得到---------------------------- 21 | Key = sKey; 22 | } 23 | //----------------------------------------------------------------------------- 24 | 25 | /// 获得密钥 26 | private byte[] GetLegalKey() 27 | { 28 | string sTemp = Key; 29 | mobjCryptoService.GenerateKey(); 30 | byte[] bytTemp = mobjCryptoService.Key; 31 | int KeyLength = bytTemp.Length; 32 | 33 | if (sTemp.Length > KeyLength) sTemp = sTemp.Substring(0, KeyLength); 34 | else if (sTemp.Length < KeyLength) sTemp = sTemp.PadRight(KeyLength, ' '); 35 | 36 | return ASCIIEncoding.ASCII.GetBytes(sTemp); 37 | } 38 | 39 | /// 获得初始向量IV 40 | private byte[] GetLegalIV() 41 | { 42 | string sTemp = "123456789"; 43 | mobjCryptoService.GenerateIV(); 44 | byte[] bytTemp = mobjCryptoService.IV; 45 | int IVLength = bytTemp.Length; 46 | 47 | if (sTemp.Length > IVLength) sTemp = sTemp.Substring(0, IVLength); 48 | else if (sTemp.Length < IVLength) sTemp = sTemp.PadRight(IVLength, ' '); 49 | 50 | return ASCIIEncoding.ASCII.GetBytes(sTemp); 51 | } 52 | 53 | /// 加密方法 54 | public string EncryptoData(string Source) 55 | { 56 | //类UTF8Encoding使用 8 位形式的 UCS 转换格式 (UTF-8) 对 Unicode 字符进行编码 57 | byte[] bytIn = UTF8Encoding.UTF8.GetBytes(Source); 58 | MemoryStream ms = new MemoryStream(); 59 | mobjCryptoService.Key = GetLegalKey(); 60 | mobjCryptoService.IV = GetLegalIV(); 61 | ICryptoTransform encrypto = mobjCryptoService.CreateEncryptor(); 62 | CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write); 63 | cs.Write(bytIn, 0, bytIn.Length); 64 | cs.FlushFinalBlock(); 65 | ms.Close(); 66 | byte[] bytOut = ms.ToArray(); 67 | return Convert.ToBase64String(bytOut); 68 | } 69 | 70 | /// 解密方法 71 | public string DecryptoData(string Source) 72 | { 73 | byte[] bytIn = Convert.FromBase64String(Source); 74 | MemoryStream ms = new MemoryStream(bytIn, 0, bytIn.Length); 75 | mobjCryptoService.Key = GetLegalKey(); 76 | mobjCryptoService.IV = GetLegalIV(); 77 | ICryptoTransform encrypto = mobjCryptoService.CreateDecryptor(); 78 | CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Read); 79 | StreamReader sr = new StreamReader(cs); 80 | return sr.ReadToEnd(); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /AttRenameDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class AttRenameDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AttRenameDialog)); 32 | this.labelReName = new System.Windows.Forms.Label(); 33 | this.textBoxReName = new System.Windows.Forms.TextBox(); 34 | this.buttonOk = new System.Windows.Forms.Button(); 35 | this.buttonCancel = new System.Windows.Forms.Button(); 36 | this.label1 = new System.Windows.Forms.Label(); 37 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 38 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 39 | this.SuspendLayout(); 40 | // 41 | // labelReName 42 | // 43 | this.labelReName.AutoSize = true; 44 | this.labelReName.Location = new System.Drawing.Point(13, 73); 45 | this.labelReName.Name = "labelReName"; 46 | this.labelReName.Size = new System.Drawing.Size(53, 12); 47 | this.labelReName.TabIndex = 0; 48 | this.labelReName.Text = "重命名:"; 49 | // 50 | // textBoxReName 51 | // 52 | this.textBoxReName.Location = new System.Drawing.Point(82, 70); 53 | this.textBoxReName.Name = "textBoxReName"; 54 | this.textBoxReName.Size = new System.Drawing.Size(289, 21); 55 | this.textBoxReName.TabIndex = 1; 56 | // 57 | // buttonOk 58 | // 59 | this.buttonOk.Location = new System.Drawing.Point(199, 105); 60 | this.buttonOk.Name = "buttonOk"; 61 | this.buttonOk.Size = new System.Drawing.Size(75, 23); 62 | this.buttonOk.TabIndex = 2; 63 | this.buttonOk.Text = "确定(&O)"; 64 | this.buttonOk.UseVisualStyleBackColor = true; 65 | this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); 66 | // 67 | // buttonCancel 68 | // 69 | this.buttonCancel.Location = new System.Drawing.Point(296, 105); 70 | this.buttonCancel.Name = "buttonCancel"; 71 | this.buttonCancel.Size = new System.Drawing.Size(75, 23); 72 | this.buttonCancel.TabIndex = 3; 73 | this.buttonCancel.Text = "取消(&C)"; 74 | this.buttonCancel.UseVisualStyleBackColor = true; 75 | this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); 76 | // 77 | // label1 78 | // 79 | this.label1.AutoSize = true; 80 | this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 81 | this.label1.Location = new System.Drawing.Point(15, 29); 82 | this.label1.Name = "label1"; 83 | this.label1.Size = new System.Drawing.Size(44, 12); 84 | this.label1.TabIndex = 4; 85 | this.label1.Text = "重命名"; 86 | // 87 | // pictureBox1 88 | // 89 | this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); 90 | this.pictureBox1.Location = new System.Drawing.Point(312, 12); 91 | this.pictureBox1.Name = "pictureBox1"; 92 | this.pictureBox1.Size = new System.Drawing.Size(50, 50); 93 | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; 94 | this.pictureBox1.TabIndex = 5; 95 | this.pictureBox1.TabStop = false; 96 | // 97 | // AttRenameDialog 98 | // 99 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 100 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 101 | this.ClientSize = new System.Drawing.Size(383, 138); 102 | this.Controls.Add(this.pictureBox1); 103 | this.Controls.Add(this.label1); 104 | this.Controls.Add(this.buttonCancel); 105 | this.Controls.Add(this.buttonOk); 106 | this.Controls.Add(this.textBoxReName); 107 | this.Controls.Add(this.labelReName); 108 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 109 | this.MaximizeBox = false; 110 | this.MinimizeBox = false; 111 | this.Name = "AttRenameDialog"; 112 | this.ShowIcon = false; 113 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 114 | this.Text = "重命名"; 115 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 116 | this.ResumeLayout(false); 117 | this.PerformLayout(); 118 | 119 | } 120 | 121 | #endregion 122 | 123 | private System.Windows.Forms.Label labelReName; 124 | private System.Windows.Forms.TextBox textBoxReName; 125 | private System.Windows.Forms.Button buttonOk; 126 | private System.Windows.Forms.Button buttonCancel; 127 | private System.Windows.Forms.Label label1; 128 | private System.Windows.Forms.PictureBox pictureBox1; 129 | } 130 | } -------------------------------------------------------------------------------- /AttRenameDialog.cs: -------------------------------------------------------------------------------- 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 | 9 | namespace WeCode1._0 10 | { 11 | public partial class AttRenameDialog : Form 12 | { 13 | public string[] ReturnVal { get; protected set; } 14 | 15 | public AttRenameDialog(string Attname) 16 | { 17 | InitializeComponent(); 18 | this.textBoxReName.Text = Attname; 19 | } 20 | 21 | private void buttonOk_Click(object sender, EventArgs e) 22 | { 23 | if (string.IsNullOrEmpty(textBoxReName.Text)) 24 | { 25 | MessageBox.Show("不能为空!"); 26 | return; 27 | } 28 | ReturnVal = new string[1]; 29 | ReturnVal[0] = this.textBoxReName.Text; 30 | 31 | DialogResult = DialogResult.OK; 32 | this.Close(); 33 | } 34 | 35 | private void buttonCancel_Click(object sender, EventArgs e) 36 | { 37 | DialogResult = DialogResult.Cancel; 38 | this.Close(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Attachment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace WeCode1._0 6 | { 7 | public static class Attachment 8 | { 9 | public static string ActiveNodeId="-1"; 10 | public static FormAttachment AttForm; 11 | public static FormMain frmMain; 12 | public static string isWelcomePageopen = "1"; 13 | public static int DocCount; 14 | 15 | public static int IsTokeneffective = 0; 16 | 17 | public static string isDeleteClose = "0"; 18 | 19 | public static string ActiveDOCType = "local"; 20 | 21 | public static string isnewOpenDoc = "1"; 22 | 23 | public static string KeyD = ""; 24 | public static string KeyDYouDao = ""; 25 | 26 | public static string isYUN2XMLSuccess = "1"; 27 | 28 | //加密文章是否成功打开 29 | public static string EncryptdeContentOpenSuccess="1"; 30 | 31 | public static System.Windows.Forms.FormWindowState WinState = System.Windows.Forms.FormWindowState.Maximized; 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ClassDiagram1.cd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ContentExcs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace WeCode1._0 6 | { 7 | public class ContentExcs:WeifenLuo.WinFormsUI.Docking.DockContent 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /DiaChgLocalPSW.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class DiaChgLocalPSW 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.labelInput = new System.Windows.Forms.Label(); 32 | this.textBoxOldpsw = new System.Windows.Forms.TextBox(); 33 | this.buttonOK = new System.Windows.Forms.Button(); 34 | this.buttonCancel = new System.Windows.Forms.Button(); 35 | this.labelConfirm = new System.Windows.Forms.Label(); 36 | this.textBoxnewpsw = new System.Windows.Forms.TextBox(); 37 | this.textBoxnewConfirm = new System.Windows.Forms.TextBox(); 38 | this.label1 = new System.Windows.Forms.Label(); 39 | this.SuspendLayout(); 40 | // 41 | // labelInput 42 | // 43 | this.labelInput.AutoSize = true; 44 | this.labelInput.Location = new System.Drawing.Point(13, 13); 45 | this.labelInput.Name = "labelInput"; 46 | this.labelInput.Size = new System.Drawing.Size(65, 12); 47 | this.labelInput.TabIndex = 0; 48 | this.labelInput.Text = "原始密码:"; 49 | // 50 | // textBoxOldpsw 51 | // 52 | this.textBoxOldpsw.Location = new System.Drawing.Point(84, 10); 53 | this.textBoxOldpsw.Name = "textBoxOldpsw"; 54 | this.textBoxOldpsw.Size = new System.Drawing.Size(156, 21); 55 | this.textBoxOldpsw.TabIndex = 1; 56 | this.textBoxOldpsw.UseSystemPasswordChar = true; 57 | // 58 | // buttonOK 59 | // 60 | this.buttonOK.Location = new System.Drawing.Point(84, 92); 61 | this.buttonOK.Name = "buttonOK"; 62 | this.buttonOK.Size = new System.Drawing.Size(75, 23); 63 | this.buttonOK.TabIndex = 5; 64 | this.buttonOK.Text = "确定"; 65 | this.buttonOK.UseVisualStyleBackColor = true; 66 | this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); 67 | // 68 | // buttonCancel 69 | // 70 | this.buttonCancel.Location = new System.Drawing.Point(165, 92); 71 | this.buttonCancel.Name = "buttonCancel"; 72 | this.buttonCancel.Size = new System.Drawing.Size(75, 23); 73 | this.buttonCancel.TabIndex = 6; 74 | this.buttonCancel.Text = "取消"; 75 | this.buttonCancel.UseVisualStyleBackColor = true; 76 | this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); 77 | // 78 | // labelConfirm 79 | // 80 | this.labelConfirm.AutoSize = true; 81 | this.labelConfirm.Location = new System.Drawing.Point(13, 40); 82 | this.labelConfirm.Name = "labelConfirm"; 83 | this.labelConfirm.Size = new System.Drawing.Size(53, 12); 84 | this.labelConfirm.TabIndex = 2; 85 | this.labelConfirm.Text = "新密码:"; 86 | // 87 | // textBoxnewpsw 88 | // 89 | this.textBoxnewpsw.Location = new System.Drawing.Point(84, 37); 90 | this.textBoxnewpsw.Name = "textBoxnewpsw"; 91 | this.textBoxnewpsw.Size = new System.Drawing.Size(156, 21); 92 | this.textBoxnewpsw.TabIndex = 3; 93 | this.textBoxnewpsw.UseSystemPasswordChar = true; 94 | // 95 | // textBoxnewConfirm 96 | // 97 | this.textBoxnewConfirm.Location = new System.Drawing.Point(84, 65); 98 | this.textBoxnewConfirm.Name = "textBoxnewConfirm"; 99 | this.textBoxnewConfirm.Size = new System.Drawing.Size(156, 21); 100 | this.textBoxnewConfirm.TabIndex = 4; 101 | this.textBoxnewConfirm.UseSystemPasswordChar = true; 102 | // 103 | // label1 104 | // 105 | this.label1.AutoSize = true; 106 | this.label1.Location = new System.Drawing.Point(13, 68); 107 | this.label1.Name = "label1"; 108 | this.label1.Size = new System.Drawing.Size(65, 12); 109 | this.label1.TabIndex = 6; 110 | this.label1.Text = "确认密码:"; 111 | // 112 | // DiaChgLocalPSW 113 | // 114 | this.AcceptButton = this.buttonOK; 115 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 116 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 117 | this.ClientSize = new System.Drawing.Size(267, 124); 118 | this.Controls.Add(this.textBoxnewConfirm); 119 | this.Controls.Add(this.label1); 120 | this.Controls.Add(this.buttonCancel); 121 | this.Controls.Add(this.buttonOK); 122 | this.Controls.Add(this.textBoxnewpsw); 123 | this.Controls.Add(this.labelConfirm); 124 | this.Controls.Add(this.textBoxOldpsw); 125 | this.Controls.Add(this.labelInput); 126 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 127 | this.Name = "DiaChgLocalPSW"; 128 | this.ShowIcon = false; 129 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 130 | this.Text = "密码"; 131 | this.ResumeLayout(false); 132 | this.PerformLayout(); 133 | 134 | } 135 | 136 | #endregion 137 | 138 | private System.Windows.Forms.Label labelInput; 139 | private System.Windows.Forms.TextBox textBoxOldpsw; 140 | private System.Windows.Forms.Button buttonOK; 141 | private System.Windows.Forms.Button buttonCancel; 142 | private System.Windows.Forms.Label labelConfirm; 143 | private System.Windows.Forms.TextBox textBoxnewpsw; 144 | private System.Windows.Forms.TextBox textBoxnewConfirm; 145 | private System.Windows.Forms.Label label1; 146 | } 147 | } -------------------------------------------------------------------------------- /DiaChgLocalPSW.cs: -------------------------------------------------------------------------------- 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.Data.OleDb; 9 | using System.Xml; 10 | 11 | namespace WeCode1._0 12 | { 13 | public partial class DiaChgLocalPSW : Form 14 | { 15 | public string ReturnVal { get; protected set; } 16 | 17 | public string strOpenType = ""; 18 | 19 | public DiaChgLocalPSW(string OpenType) 20 | { 21 | InitializeComponent(); 22 | strOpenType = OpenType; 23 | if (OpenType == "0") 24 | { 25 | //修改本地密码 26 | this.Text = "修改本地笔记本加密密码!"; 27 | } 28 | else if (OpenType == "1") 29 | { 30 | //修改有道云密码 31 | this.Text = "修改有道云加密密码!"; 32 | } 33 | 34 | } 35 | 36 | private void buttonOK_Click(object sender, EventArgs e) 37 | { 38 | 39 | string oldpwd = textBoxOldpsw.Text; 40 | string newpwd = textBoxnewpsw.Text; 41 | string newpwdconfirm = textBoxnewConfirm.Text; 42 | 43 | 44 | if (strOpenType == "0") 45 | { 46 | string d5 = AccessAdo.ExecuteScalar("select top 1 KeyD5 from MyKeys").ToString(); 47 | //keyD需用keyE和keyA解密 48 | string KeyE = AccessAdo.ExecuteScalar("select top 1 KeyE from MyKeys").ToString(); 49 | string KeyD = EncryptDecrptt.DecrptyByKey(KeyE, oldpwd); 50 | string d51 = EncryptDecrptt.str2MD5(EncryptDecrptt.KeyA2KeyD(oldpwd)); 51 | if (d5 != d51) 52 | { 53 | MessageBox.Show("原密码错误!"); 54 | return; 55 | } 56 | 57 | //校验密码长度以及两次输入是否一样 58 | if (newpwd != newpwdconfirm) 59 | { 60 | MessageBox.Show("新密码两次不一致,请重新输入!"); 61 | return; 62 | } 63 | 64 | if (newpwd.Length > 16 || newpwd.Length < 6) 65 | { 66 | MessageBox.Show("新密码长度需在6-16位之间!"); 67 | return; 68 | } 69 | 70 | //新的密码转换,写入到内存以及数据库中 71 | string keyDmd5 = EncryptDecrptt.str2MD5(EncryptDecrptt.KeyA2KeyD(newpwd)); 72 | KeyE = EncryptDecrptt.EncrptyByKey(KeyD, newpwd); 73 | 74 | //写入到数据库 75 | OleDbParameter p1 = new OleDbParameter("@KeyE", OleDbType.VarChar); 76 | p1.Value = KeyE; 77 | OleDbParameter p2 = new OleDbParameter("@KeyD5", OleDbType.VarChar); 78 | p2.Value = keyDmd5; 79 | 80 | OleDbParameter[] ArrPara = new OleDbParameter[2]; 81 | ArrPara[0] = p1; 82 | ArrPara[1] = p2; 83 | string SQL = "update MyKeys set KeyE=@KeyE,KeyD5=@KeyD5"; 84 | AccessAdo.ExecuteNonQuery(SQL, ArrPara); 85 | 86 | //临时存储keyD到内存,避免每次加密文章输入密码 87 | Attachment.KeyD = KeyD; 88 | 89 | //返回keyD 90 | ReturnVal = KeyD; 91 | DialogResult = DialogResult.OK; 92 | this.Close(); 93 | 94 | } 95 | else if (strOpenType == "1") 96 | { 97 | //加密,验证密码是否与数据库MD5匹配 98 | XmlDocument xDoc = new XmlDocument(); 99 | xDoc.Load("TreeNodeLocal.xml"); 100 | XmlNode preNode = xDoc.SelectSingleNode("//wecode"); 101 | string d5 = preNode.Attributes["KeyD5"].Value; 102 | string KeyE = preNode.Attributes["KeyE"].Value; ; 103 | 104 | string d51 = EncryptDecrptt.str2MD5(EncryptDecrptt.KeyA2KeyD(oldpwd)); 105 | if (d5 != d51) 106 | { 107 | MessageBox.Show("原密码错误!"); 108 | return; 109 | } 110 | 111 | //校验密码长度以及两次输入是否一样 112 | if (newpwd != newpwdconfirm) 113 | { 114 | MessageBox.Show("新密码两次不一致,请重新输入!"); 115 | return; 116 | } 117 | 118 | if (newpwd.Length > 16 || newpwd.Length < 6) 119 | { 120 | MessageBox.Show("新密码长度需在6-16位之间!"); 121 | return; 122 | } 123 | 124 | //keyD需从keyE和明文密码解密出来,修改了密码也不会改变 125 | //存储在数据库的keyD5会随着密码变化变化,目的是为了对比密码是否正确 126 | string KeyD = EncryptDecrptt.DecrptyByKey(KeyE, oldpwd); 127 | 128 | //新的密码转换,写入到内存以及数据库中 129 | string keyDmd5 = EncryptDecrptt.str2MD5(EncryptDecrptt.KeyA2KeyD(newpwd)); 130 | KeyE = EncryptDecrptt.EncrptyByKey(KeyD, newpwd); 131 | 132 | //写入新的keyd5和KeyE 133 | XmlNode xnode = xDoc.SelectSingleNode("//wecode"); 134 | if (xnode != null) 135 | { 136 | ((XmlElement)xnode).SetAttribute("KeyD5", keyDmd5); 137 | ((XmlElement)xnode).SetAttribute("KeyE", KeyE); 138 | 139 | } 140 | xDoc.Save("TreeNodeLocal.xml"); 141 | XMLAPI.XML2Yun(); 142 | 143 | 144 | //更新缓存数据 145 | OleDbConnection ExportConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+PubFunc.GetYoudaoDBPath()); 146 | OleDbParameter p1 = new OleDbParameter("@KeyE", OleDbType.VarChar); 147 | p1.Value = KeyE; 148 | OleDbParameter p2 = new OleDbParameter("@KeyD5", OleDbType.VarChar); 149 | p2.Value = keyDmd5; 150 | 151 | OleDbParameter[] ArrPara = new OleDbParameter[2]; 152 | ArrPara[0] = p1; 153 | ArrPara[1] = p2; 154 | string SQL = "update MyKeys set KeyE=@KeyE,KeyD5=@KeyD5"; 155 | AccessAdo.ExecuteNonQuery(ExportConn, SQL, ArrPara); 156 | 157 | //临时存储keyD到内存,避免每次加密文章输入密码 158 | Attachment.KeyDYouDao = KeyD; 159 | 160 | //返回keyD 161 | ReturnVal = KeyD; 162 | DialogResult = DialogResult.OK; 163 | this.Close(); 164 | } 165 | } 166 | 167 | private void buttonCancel_Click(object sender, EventArgs e) 168 | { 169 | DialogResult = DialogResult.Cancel; 170 | this.Close(); 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /DiaChgLocalPSW.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DialogPSW.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class DialogPSW 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.labelInput = new System.Windows.Forms.Label(); 32 | this.textBoxInput = new System.Windows.Forms.TextBox(); 33 | this.buttonOK = new System.Windows.Forms.Button(); 34 | this.buttonCancel = new System.Windows.Forms.Button(); 35 | this.labelConfirm = new System.Windows.Forms.Label(); 36 | this.textBoxConfirm = new System.Windows.Forms.TextBox(); 37 | this.SuspendLayout(); 38 | // 39 | // labelInput 40 | // 41 | this.labelInput.AutoSize = true; 42 | this.labelInput.Location = new System.Drawing.Point(13, 13); 43 | this.labelInput.Name = "labelInput"; 44 | this.labelInput.Size = new System.Drawing.Size(65, 12); 45 | this.labelInput.TabIndex = 0; 46 | this.labelInput.Text = "输入密码:"; 47 | // 48 | // textBoxInput 49 | // 50 | this.textBoxInput.Location = new System.Drawing.Point(84, 10); 51 | this.textBoxInput.Name = "textBoxInput"; 52 | this.textBoxInput.Size = new System.Drawing.Size(156, 21); 53 | this.textBoxInput.TabIndex = 1; 54 | this.textBoxInput.TextChanged += new System.EventHandler(this.textBoxInput_TextChanged); 55 | this.textBoxInput.DoubleClick += new System.EventHandler(this.textBoxInput_DoubleClick); 56 | // 57 | // buttonOK 58 | // 59 | this.buttonOK.Location = new System.Drawing.Point(84, 64); 60 | this.buttonOK.Name = "buttonOK"; 61 | this.buttonOK.Size = new System.Drawing.Size(75, 23); 62 | this.buttonOK.TabIndex = 4; 63 | this.buttonOK.Text = "确定"; 64 | this.buttonOK.UseVisualStyleBackColor = true; 65 | this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); 66 | // 67 | // buttonCancel 68 | // 69 | this.buttonCancel.Location = new System.Drawing.Point(165, 64); 70 | this.buttonCancel.Name = "buttonCancel"; 71 | this.buttonCancel.Size = new System.Drawing.Size(75, 23); 72 | this.buttonCancel.TabIndex = 5; 73 | this.buttonCancel.Text = "取消"; 74 | this.buttonCancel.UseVisualStyleBackColor = true; 75 | this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); 76 | // 77 | // labelConfirm 78 | // 79 | this.labelConfirm.AutoSize = true; 80 | this.labelConfirm.Location = new System.Drawing.Point(13, 40); 81 | this.labelConfirm.Name = "labelConfirm"; 82 | this.labelConfirm.Size = new System.Drawing.Size(65, 12); 83 | this.labelConfirm.TabIndex = 2; 84 | this.labelConfirm.Text = "确认密码:"; 85 | // 86 | // textBoxConfirm 87 | // 88 | this.textBoxConfirm.Location = new System.Drawing.Point(84, 37); 89 | this.textBoxConfirm.Name = "textBoxConfirm"; 90 | this.textBoxConfirm.Size = new System.Drawing.Size(156, 21); 91 | this.textBoxConfirm.TabIndex = 3; 92 | this.textBoxConfirm.UseSystemPasswordChar = true; 93 | // 94 | // DialogPSW 95 | // 96 | this.AcceptButton = this.buttonOK; 97 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 98 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 99 | this.ClientSize = new System.Drawing.Size(267, 98); 100 | this.Controls.Add(this.buttonCancel); 101 | this.Controls.Add(this.buttonOK); 102 | this.Controls.Add(this.textBoxConfirm); 103 | this.Controls.Add(this.labelConfirm); 104 | this.Controls.Add(this.textBoxInput); 105 | this.Controls.Add(this.labelInput); 106 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 107 | this.Name = "DialogPSW"; 108 | this.ShowIcon = false; 109 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 110 | this.Text = "密码"; 111 | this.TopMost = true; 112 | this.ResumeLayout(false); 113 | this.PerformLayout(); 114 | 115 | } 116 | 117 | #endregion 118 | 119 | private System.Windows.Forms.Label labelInput; 120 | private System.Windows.Forms.TextBox textBoxInput; 121 | private System.Windows.Forms.Button buttonOK; 122 | private System.Windows.Forms.Button buttonCancel; 123 | private System.Windows.Forms.Label labelConfirm; 124 | private System.Windows.Forms.TextBox textBoxConfirm; 125 | } 126 | } -------------------------------------------------------------------------------- /DialogPSW.cs: -------------------------------------------------------------------------------- 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.Data.OleDb; 9 | 10 | namespace WeCode1._0 11 | { 12 | public partial class DialogPSW : Form 13 | { 14 | public string ReturnVal { get; protected set; } 15 | 16 | public string strOpenType = ""; 17 | 18 | public DialogPSW(string OpenType) 19 | { 20 | InitializeComponent(); 21 | 22 | strOpenType = OpenType; 23 | if (OpenType == "0") 24 | { 25 | //第一次设置密码 26 | this.Text = "第一次使用本地加密,请设置密码!"; 27 | } 28 | else if (OpenType == "1") 29 | { 30 | //加密 31 | this.Text = "加密"; 32 | labelConfirm.Visible = false; 33 | textBoxConfirm.Visible = false; 34 | } 35 | else if (OpenType == "2") 36 | { 37 | //取消加密 38 | this.Text = "解密"; 39 | labelConfirm.Visible = false; 40 | textBoxConfirm.Visible = false; 41 | } 42 | else if(OpenType=="3") 43 | { 44 | //查看时输入密码 45 | this.Text = "请输入密码"; 46 | labelConfirm.Visible = false; 47 | textBoxConfirm.Visible = false; 48 | } 49 | 50 | } 51 | 52 | private void buttonOK_Click(object sender, EventArgs e) 53 | { 54 | 55 | string pswInput = textBoxInput.Text; 56 | string pswConfirm = textBoxConfirm.Text; 57 | 58 | if (strOpenType == "0") 59 | { 60 | 61 | //校验密码长度以及两次输入是否一样 62 | if (pswInput != pswConfirm) 63 | { 64 | MessageBox.Show("两次密码不一致,请重新输入!"); 65 | return; 66 | } 67 | 68 | if (pswInput.Length > 16 || pswInput.Length < 6) 69 | { 70 | MessageBox.Show("密码长度需在6-16位之间!"); 71 | return; 72 | } 73 | 74 | //密码转换,写入到内存以及数据库中 75 | string keyD = EncryptDecrptt.KeyA2KeyD(pswInput); 76 | string keyDmd5 = EncryptDecrptt.str2MD5(keyD); 77 | string keyE = EncryptDecrptt.EncrptyByKey(keyD, pswInput); 78 | 79 | //第一次设置密码,写入到数据库 80 | OleDbParameter p1 = new OleDbParameter("@KeyE", OleDbType.VarChar); 81 | p1.Value = keyE; 82 | OleDbParameter p2 = new OleDbParameter("@KeyD5", OleDbType.VarChar); 83 | p2.Value = keyDmd5; 84 | 85 | OleDbParameter[] ArrPara = new OleDbParameter[2]; 86 | ArrPara[0] = p1; 87 | ArrPara[1] = p2; 88 | string SQL = "insert into MyKeys(KeyE,KeyD5) values(@KeyE,@KeyD5)"; 89 | AccessAdo.ExecuteNonQuery(SQL, ArrPara); 90 | 91 | //临时存储keyD到内存,避免每次加密文章输入密码 92 | Attachment.KeyD = keyD; 93 | 94 | //返回keyD 95 | ReturnVal = keyD; 96 | DialogResult = DialogResult.OK; 97 | this.Close(); 98 | 99 | } 100 | else if (strOpenType == "1" || strOpenType == "2"||strOpenType=="3") 101 | { 102 | //加密,验证密码是否与数据库MD5匹配 103 | string d5 = AccessAdo.ExecuteScalar("select top 1 KeyD5 from MyKeys").ToString(); 104 | //string KeyD = EncryptDecrptt.KeyA2KeyD(pswInput); 105 | //keyD需用keyE和keyA解密 106 | string KeyE=AccessAdo.ExecuteScalar("select top 1 KeyE from MyKeys").ToString(); 107 | string d51 = EncryptDecrptt.str2MD5(EncryptDecrptt.KeyA2KeyD(pswInput)); 108 | if(d5!=d51) 109 | { 110 | MessageBox.Show("密码错误!"); 111 | return; 112 | } 113 | //keyD需从keyE和明文密码解密出来,修改了密码也不会改变 114 | //存储在数据库的keyD5会随着密码变化变化,目的是为了对比密码是否正确 115 | string KeyD = EncryptDecrptt.DecrptyByKey(KeyE, pswInput); 116 | 117 | //写入到内存 118 | Attachment.KeyD = KeyD; 119 | //返回keyD 120 | ReturnVal = KeyD; 121 | DialogResult = DialogResult.OK; 122 | this.Close(); 123 | } 124 | } 125 | 126 | private void buttonCancel_Click(object sender, EventArgs e) 127 | { 128 | DialogResult = DialogResult.Cancel; 129 | this.Close(); 130 | } 131 | 132 | private void textBoxInput_DoubleClick(object sender, EventArgs e) 133 | { 134 | 135 | } 136 | 137 | private void textBoxInput_KeyPress(object sender, KeyPressEventArgs e) 138 | { 139 | 140 | } 141 | 142 | private void textBoxInput_TextChanged(object sender, EventArgs e) 143 | { 144 | this.textBoxInput.PasswordChar = '●'; 145 | } 146 | 147 | private void DialogPSW_KeyUp(object sender, KeyEventArgs e) 148 | { 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /DialogPSW.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DialogPSWYouDao.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class DialogPSWYouDao 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.labelInput = new System.Windows.Forms.Label(); 32 | this.textBoxInput = new System.Windows.Forms.TextBox(); 33 | this.buttonOK = new System.Windows.Forms.Button(); 34 | this.buttonCancel = new System.Windows.Forms.Button(); 35 | this.labelConfirm = new System.Windows.Forms.Label(); 36 | this.textBoxConfirm = new System.Windows.Forms.TextBox(); 37 | this.SuspendLayout(); 38 | // 39 | // labelInput 40 | // 41 | this.labelInput.AutoSize = true; 42 | this.labelInput.Location = new System.Drawing.Point(13, 13); 43 | this.labelInput.Name = "labelInput"; 44 | this.labelInput.Size = new System.Drawing.Size(65, 12); 45 | this.labelInput.TabIndex = 0; 46 | this.labelInput.Text = "输入密码:"; 47 | // 48 | // textBoxInput 49 | // 50 | this.textBoxInput.Location = new System.Drawing.Point(84, 10); 51 | this.textBoxInput.Name = "textBoxInput"; 52 | this.textBoxInput.Size = new System.Drawing.Size(156, 21); 53 | this.textBoxInput.TabIndex = 1; 54 | this.textBoxInput.TextChanged += new System.EventHandler(this.textBoxInput_TextChanged); 55 | // 56 | // buttonOK 57 | // 58 | this.buttonOK.Location = new System.Drawing.Point(84, 64); 59 | this.buttonOK.Name = "buttonOK"; 60 | this.buttonOK.Size = new System.Drawing.Size(75, 23); 61 | this.buttonOK.TabIndex = 4; 62 | this.buttonOK.Text = "确定"; 63 | this.buttonOK.UseVisualStyleBackColor = true; 64 | this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); 65 | // 66 | // buttonCancel 67 | // 68 | this.buttonCancel.Location = new System.Drawing.Point(165, 64); 69 | this.buttonCancel.Name = "buttonCancel"; 70 | this.buttonCancel.Size = new System.Drawing.Size(75, 23); 71 | this.buttonCancel.TabIndex = 5; 72 | this.buttonCancel.Text = "取消"; 73 | this.buttonCancel.UseVisualStyleBackColor = true; 74 | this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); 75 | // 76 | // labelConfirm 77 | // 78 | this.labelConfirm.AutoSize = true; 79 | this.labelConfirm.Location = new System.Drawing.Point(13, 40); 80 | this.labelConfirm.Name = "labelConfirm"; 81 | this.labelConfirm.Size = new System.Drawing.Size(65, 12); 82 | this.labelConfirm.TabIndex = 2; 83 | this.labelConfirm.Text = "确认密码:"; 84 | // 85 | // textBoxConfirm 86 | // 87 | this.textBoxConfirm.Location = new System.Drawing.Point(84, 37); 88 | this.textBoxConfirm.Name = "textBoxConfirm"; 89 | this.textBoxConfirm.Size = new System.Drawing.Size(156, 21); 90 | this.textBoxConfirm.TabIndex = 3; 91 | this.textBoxConfirm.UseSystemPasswordChar = true; 92 | // 93 | // DialogPSWYouDao 94 | // 95 | this.AcceptButton = this.buttonOK; 96 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 97 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 98 | this.ClientSize = new System.Drawing.Size(267, 98); 99 | this.Controls.Add(this.buttonCancel); 100 | this.Controls.Add(this.buttonOK); 101 | this.Controls.Add(this.textBoxConfirm); 102 | this.Controls.Add(this.labelConfirm); 103 | this.Controls.Add(this.textBoxInput); 104 | this.Controls.Add(this.labelInput); 105 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 106 | this.Name = "DialogPSWYouDao"; 107 | this.ShowIcon = false; 108 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 109 | this.Text = "密码"; 110 | this.TopMost = true; 111 | this.ResumeLayout(false); 112 | this.PerformLayout(); 113 | 114 | } 115 | 116 | #endregion 117 | 118 | private System.Windows.Forms.Label labelInput; 119 | private System.Windows.Forms.TextBox textBoxInput; 120 | private System.Windows.Forms.Button buttonOK; 121 | private System.Windows.Forms.Button buttonCancel; 122 | private System.Windows.Forms.Label labelConfirm; 123 | private System.Windows.Forms.TextBox textBoxConfirm; 124 | } 125 | } -------------------------------------------------------------------------------- /DialogPSWYouDao.cs: -------------------------------------------------------------------------------- 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.Data.OleDb; 9 | using System.Xml; 10 | 11 | namespace WeCode1._0 12 | { 13 | public partial class DialogPSWYouDao : Form 14 | { 15 | public string ReturnVal { get; protected set; } 16 | 17 | public string strOpenType = ""; 18 | 19 | public DialogPSWYouDao(string OpenType) 20 | { 21 | InitializeComponent(); 22 | strOpenType = OpenType; 23 | if (OpenType == "0") 24 | { 25 | //第一次设置密码 26 | this.Text = "第一次使用有道云加密,请设置密码!"; 27 | } 28 | else if (OpenType == "1") 29 | { 30 | //加密 31 | this.Text = "加密"; 32 | labelConfirm.Visible = false; 33 | textBoxConfirm.Visible = false; 34 | } 35 | else if (OpenType == "2") 36 | { 37 | //取消加密 38 | this.Text = "解密"; 39 | labelConfirm.Visible = false; 40 | textBoxConfirm.Visible = false; 41 | } 42 | else 43 | { 44 | //查看时输入密码 45 | this.Text = "请输入密码"; 46 | labelConfirm.Visible = false; 47 | textBoxConfirm.Visible = false; 48 | } 49 | 50 | } 51 | 52 | private void buttonOK_Click(object sender, EventArgs e) 53 | { 54 | 55 | string pswInput = textBoxInput.Text; 56 | string pswConfirm = textBoxConfirm.Text; 57 | 58 | 59 | if (strOpenType == "0") 60 | { 61 | 62 | //校验密码长度以及两次输入是否一样 63 | if (pswInput != pswConfirm) 64 | { 65 | MessageBox.Show("两次密码不一致,请重新输入!"); 66 | return; 67 | } 68 | 69 | if (pswInput.Length > 16 || pswInput.Length < 6) 70 | { 71 | MessageBox.Show("密码长度需在6-16位之间!"); 72 | return; 73 | } 74 | 75 | //密码转换,写入到内存以及数据库中 76 | string keyD = EncryptDecrptt.KeyA2KeyD(pswInput); 77 | string keyDmd5 = EncryptDecrptt.str2MD5(keyD); 78 | string keyE = EncryptDecrptt.EncrptyByKey(keyD, pswInput); 79 | 80 | XmlDocument xDoc = new XmlDocument(); 81 | xDoc.Load("TreeNodeLocal.xml"); 82 | XmlNode preNode = xDoc.SelectSingleNode("//wecode"); 83 | if (preNode != null) 84 | { 85 | ((XmlElement)preNode).SetAttribute("KeyD5",keyDmd5); 86 | ((XmlElement)preNode).SetAttribute("KeyE", keyE); 87 | 88 | } 89 | xDoc.Save("TreeNodeLocal.xml"); 90 | XMLAPI.XML2Yun(); 91 | 92 | //更新缓存数据 93 | OleDbConnection ExportConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+PubFunc.GetYoudaoDBPath()); 94 | OleDbParameter p1 = new OleDbParameter("@KeyE", OleDbType.VarChar); 95 | p1.Value = keyE; 96 | OleDbParameter p2 = new OleDbParameter("@KeyD5", OleDbType.VarChar); 97 | p2.Value = keyDmd5; 98 | 99 | OleDbParameter[] ArrPara = new OleDbParameter[2]; 100 | ArrPara[0] = p1; 101 | ArrPara[1] = p2; 102 | string SQL = "insert into MyKeys(KeyE,KeyD5) values(@KeyE,@KeyD5)"; 103 | AccessAdo.ExecuteNonQuery(ExportConn,SQL, ArrPara); 104 | 105 | //临时存储keyD到内存,避免每次加密文章输入密码 106 | Attachment.KeyDYouDao = keyD; 107 | 108 | //返回keyD 109 | ReturnVal = keyD; 110 | DialogResult = DialogResult.OK; 111 | this.Close(); 112 | 113 | } 114 | else if (strOpenType == "1" || strOpenType == "2"||strOpenType=="3") 115 | { 116 | //加密,验证密码是否与数据库MD5匹配 117 | XmlDocument xDoc = new XmlDocument(); 118 | xDoc.Load("TreeNodeLocal.xml"); 119 | XmlNode preNode = xDoc.SelectSingleNode("//wecode"); 120 | string d5 = preNode.Attributes["KeyD5"].Value; 121 | //string KeyD = EncryptDecrptt.KeyA2KeyD(pswInput); 122 | //keyD需用keyE和keyA解密 123 | string KeyE = preNode.Attributes["KeyE"].Value; ; 124 | 125 | string d51 = EncryptDecrptt.str2MD5(EncryptDecrptt.KeyA2KeyD(pswInput)); 126 | if(d5!=d51) 127 | { 128 | MessageBox.Show("密码错误!"); 129 | return; 130 | } 131 | 132 | //keyD需从keyE和明文密码解密出来,修改了密码也不会改变 133 | //存储在数据库的keyD5会随着密码变化变化,目的是为了对比密码是否正确 134 | string KeyD = EncryptDecrptt.DecrptyByKey(KeyE, pswInput); 135 | 136 | //写入到内存 137 | Attachment.KeyDYouDao = KeyD; 138 | //返回keyD 139 | ReturnVal = KeyD; 140 | DialogResult = DialogResult.OK; 141 | this.Close(); 142 | } 143 | } 144 | 145 | private void buttonCancel_Click(object sender, EventArgs e) 146 | { 147 | DialogResult = DialogResult.Cancel; 148 | this.Close(); 149 | } 150 | 151 | private void textBoxInput_TextChanged(object sender, EventArgs e) 152 | { 153 | this.textBoxInput.PasswordChar = '●'; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /DialogPSWYouDao.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DialogUpdate.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class DialogUpdate 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.label2 = new System.Windows.Forms.Label(); 33 | this.textBox1 = new System.Windows.Forms.TextBox(); 34 | this.button1 = new System.Windows.Forms.Button(); 35 | this.button2 = new System.Windows.Forms.Button(); 36 | this.button3 = new System.Windows.Forms.Button(); 37 | this.label3 = new System.Windows.Forms.Label(); 38 | this.SuspendLayout(); 39 | // 40 | // label1 41 | // 42 | this.label1.AutoSize = true; 43 | this.label1.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 44 | this.label1.Location = new System.Drawing.Point(12, 9); 45 | this.label1.Name = "label1"; 46 | this.label1.Size = new System.Drawing.Size(79, 20); 47 | this.label1.TabIndex = 0; 48 | this.label1.Text = "有新版本!"; 49 | // 50 | // label2 51 | // 52 | this.label2.AutoSize = true; 53 | this.label2.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 54 | this.label2.Location = new System.Drawing.Point(12, 70); 55 | this.label2.Name = "label2"; 56 | this.label2.Size = new System.Drawing.Size(65, 20); 57 | this.label2.TabIndex = 1; 58 | this.label2.Text = "更新说明"; 59 | // 60 | // textBox1 61 | // 62 | this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; 63 | this.textBox1.Enabled = false; 64 | this.textBox1.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 65 | this.textBox1.Location = new System.Drawing.Point(95, 70); 66 | this.textBox1.Multiline = true; 67 | this.textBox1.Name = "textBox1"; 68 | this.textBox1.ReadOnly = true; 69 | this.textBox1.Size = new System.Drawing.Size(357, 149); 70 | this.textBox1.TabIndex = 2; 71 | // 72 | // button1 73 | // 74 | this.button1.Location = new System.Drawing.Point(67, 237); 75 | this.button1.Name = "button1"; 76 | this.button1.Size = new System.Drawing.Size(75, 23); 77 | this.button1.TabIndex = 3; 78 | this.button1.Text = "立即下载"; 79 | this.button1.UseVisualStyleBackColor = true; 80 | this.button1.Click += new System.EventHandler(this.button1_Click); 81 | // 82 | // button2 83 | // 84 | this.button2.Location = new System.Drawing.Point(203, 237); 85 | this.button2.Name = "button2"; 86 | this.button2.Size = new System.Drawing.Size(75, 23); 87 | this.button2.TabIndex = 4; 88 | this.button2.Text = "以后再更新"; 89 | this.button2.UseVisualStyleBackColor = true; 90 | this.button2.Click += new System.EventHandler(this.button2_Click); 91 | // 92 | // button3 93 | // 94 | this.button3.Location = new System.Drawing.Point(342, 236); 95 | this.button3.Name = "button3"; 96 | this.button3.Size = new System.Drawing.Size(75, 23); 97 | this.button3.TabIndex = 5; 98 | this.button3.Text = "取消"; 99 | this.button3.UseVisualStyleBackColor = true; 100 | this.button3.Click += new System.EventHandler(this.button3_Click); 101 | // 102 | // label3 103 | // 104 | this.label3.AutoSize = true; 105 | this.label3.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 106 | this.label3.Location = new System.Drawing.Point(12, 38); 107 | this.label3.Name = "label3"; 108 | this.label3.Size = new System.Drawing.Size(79, 20); 109 | this.label3.TabIndex = 6; 110 | this.label3.Text = "最新版本:"; 111 | // 112 | // DialogUpdate 113 | // 114 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 115 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 116 | this.ClientSize = new System.Drawing.Size(464, 271); 117 | this.Controls.Add(this.label3); 118 | this.Controls.Add(this.button3); 119 | this.Controls.Add(this.button2); 120 | this.Controls.Add(this.button1); 121 | this.Controls.Add(this.textBox1); 122 | this.Controls.Add(this.label2); 123 | this.Controls.Add(this.label1); 124 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 125 | this.MaximizeBox = false; 126 | this.MinimizeBox = false; 127 | this.Name = "DialogUpdate"; 128 | this.ShowIcon = false; 129 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 130 | this.Text = "检查更新"; 131 | this.TopMost = true; 132 | this.Load += new System.EventHandler(this.DialogUpdate_Load); 133 | this.ResumeLayout(false); 134 | this.PerformLayout(); 135 | 136 | } 137 | 138 | #endregion 139 | 140 | private System.Windows.Forms.Label label1; 141 | private System.Windows.Forms.Label label2; 142 | private System.Windows.Forms.TextBox textBox1; 143 | private System.Windows.Forms.Button button1; 144 | private System.Windows.Forms.Button button2; 145 | private System.Windows.Forms.Button button3; 146 | private System.Windows.Forms.Label label3; 147 | } 148 | } -------------------------------------------------------------------------------- /DialogUpdate.cs: -------------------------------------------------------------------------------- 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 | 9 | namespace WeCode1._0 10 | { 11 | public partial class DialogUpdate : Form 12 | { 13 | string sVer, sTips, sdlUrl; 14 | public DialogUpdate(string Ver,string Tips,string dlUrl) 15 | { 16 | InitializeComponent(); 17 | sVer = Ver; 18 | sTips = Tips; 19 | sdlUrl = dlUrl; 20 | } 21 | 22 | //打开下载地址,终止程序 23 | private void button1_Click(object sender, EventArgs e) 24 | { 25 | string target = sdlUrl; 26 | try 27 | { 28 | System.Diagnostics.Process.Start(target); 29 | } 30 | catch (System.ComponentModel.Win32Exception noBrowser) 31 | { 32 | if (noBrowser.ErrorCode == -2147467259) 33 | MessageBox.Show(noBrowser.Message); 34 | } 35 | catch (System.Exception other) 36 | { 37 | MessageBox.Show(other.Message); 38 | } 39 | finally { 40 | System.Environment.Exit(System.Environment.ExitCode); 41 | this.Dispose(); 42 | this.Close(); 43 | } 44 | } 45 | 46 | //以后再提醒 47 | private void button2_Click(object sender, EventArgs e) 48 | { 49 | PubFunc.SetConfiguration("checkVerAlert", "0"); 50 | PubFunc.SetConfiguration("lastVerAlertTime",DateTime.Now.ToShortDateString()); 51 | DialogResult = DialogResult.No; 52 | this.Close(); 53 | 54 | } 55 | 56 | //取消,程序继续运行 57 | private void button3_Click(object sender, EventArgs e) 58 | { 59 | DialogResult = DialogResult.Cancel; 60 | this.Close(); 61 | } 62 | 63 | private void DialogUpdate_Load(object sender, EventArgs e) 64 | { 65 | this.textBox1.Text = sTips; 66 | this.label3.Text = "最新版本:" + sVer; 67 | 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /DialogUpdate.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DirNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace WeCode1._0 6 | { 7 | public class DirNode : System.Windows.Forms.TreeNode 8 | { 9 | public DirNode() 10 | { 11 | 12 | } 13 | 14 | public bool SubDirectoriesAdded; 15 | public DirNode(string text) 16 | : base(text) 17 | { 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Download.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class Download 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Download)); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.lblURL = new System.Windows.Forms.Label(); 34 | this.lblSaveAs = new System.Windows.Forms.Label(); 35 | this.label4 = new System.Windows.Forms.Label(); 36 | this.lblDownLoad = new System.Windows.Forms.Label(); 37 | this.label6 = new System.Windows.Forms.Label(); 38 | this.lblSpeed = new System.Windows.Forms.Label(); 39 | this.label8 = new System.Windows.Forms.Label(); 40 | this.progressBar1 = new System.Windows.Forms.ProgressBar(); 41 | this.SuspendLayout(); 42 | // 43 | // label1 44 | // 45 | this.label1.AutoSize = true; 46 | this.label1.Location = new System.Drawing.Point(13, 13); 47 | this.label1.Name = "label1"; 48 | this.label1.Size = new System.Drawing.Size(65, 12); 49 | this.label1.TabIndex = 0; 50 | this.label1.Text = "下载链接:"; 51 | // 52 | // lblURL 53 | // 54 | this.lblURL.AutoSize = true; 55 | this.lblURL.Location = new System.Drawing.Point(83, 13); 56 | this.lblURL.Name = "lblURL"; 57 | this.lblURL.Size = new System.Drawing.Size(41, 12); 58 | this.lblURL.TabIndex = 1; 59 | this.lblURL.Text = "label2"; 60 | // 61 | // lblSaveAs 62 | // 63 | this.lblSaveAs.AutoSize = true; 64 | this.lblSaveAs.Location = new System.Drawing.Point(83, 40); 65 | this.lblSaveAs.Name = "lblSaveAs"; 66 | this.lblSaveAs.Size = new System.Drawing.Size(41, 12); 67 | this.lblSaveAs.TabIndex = 3; 68 | this.lblSaveAs.Text = "label3"; 69 | // 70 | // label4 71 | // 72 | this.label4.AutoSize = true; 73 | this.label4.Location = new System.Drawing.Point(24, 40); 74 | this.label4.Name = "label4"; 75 | this.label4.Size = new System.Drawing.Size(53, 12); 76 | this.label4.TabIndex = 2; 77 | this.label4.Text = "保存到:"; 78 | // 79 | // lblDownLoad 80 | // 81 | this.lblDownLoad.AutoSize = true; 82 | this.lblDownLoad.Location = new System.Drawing.Point(83, 69); 83 | this.lblDownLoad.Name = "lblDownLoad"; 84 | this.lblDownLoad.Size = new System.Drawing.Size(41, 12); 85 | this.lblDownLoad.TabIndex = 5; 86 | this.lblDownLoad.Text = "label5"; 87 | // 88 | // label6 89 | // 90 | this.label6.AutoSize = true; 91 | this.label6.Location = new System.Drawing.Point(13, 69); 92 | this.label6.Name = "label6"; 93 | this.label6.Size = new System.Drawing.Size(65, 12); 94 | this.label6.TabIndex = 4; 95 | this.label6.Text = "当前下载:"; 96 | // 97 | // lblSpeed 98 | // 99 | this.lblSpeed.AutoSize = true; 100 | this.lblSpeed.Location = new System.Drawing.Point(83, 95); 101 | this.lblSpeed.Name = "lblSpeed"; 102 | this.lblSpeed.Size = new System.Drawing.Size(41, 12); 103 | this.lblSpeed.TabIndex = 7; 104 | this.lblSpeed.Text = "label7"; 105 | // 106 | // label8 107 | // 108 | this.label8.AutoSize = true; 109 | this.label8.Location = new System.Drawing.Point(13, 95); 110 | this.label8.Name = "label8"; 111 | this.label8.Size = new System.Drawing.Size(65, 12); 112 | this.label8.TabIndex = 6; 113 | this.label8.Text = "下载速度:"; 114 | // 115 | // progressBar1 116 | // 117 | this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom; 118 | this.progressBar1.Location = new System.Drawing.Point(0, 138); 119 | this.progressBar1.Name = "progressBar1"; 120 | this.progressBar1.Size = new System.Drawing.Size(515, 20); 121 | this.progressBar1.TabIndex = 8; 122 | // 123 | // Download 124 | // 125 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 126 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 127 | this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 128 | this.ClientSize = new System.Drawing.Size(515, 158); 129 | this.Controls.Add(this.progressBar1); 130 | this.Controls.Add(this.lblSpeed); 131 | this.Controls.Add(this.label8); 132 | this.Controls.Add(this.lblDownLoad); 133 | this.Controls.Add(this.label6); 134 | this.Controls.Add(this.lblSaveAs); 135 | this.Controls.Add(this.label4); 136 | this.Controls.Add(this.lblURL); 137 | this.Controls.Add(this.label1); 138 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 139 | this.MaximizeBox = false; 140 | this.Name = "Download"; 141 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 142 | this.Text = "下载"; 143 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Download_FormClosing); 144 | this.Shown += new System.EventHandler(this.Download_Shown); 145 | this.ResumeLayout(false); 146 | this.PerformLayout(); 147 | 148 | } 149 | 150 | #endregion 151 | 152 | private System.Windows.Forms.Label label1; 153 | private System.Windows.Forms.Label lblURL; 154 | private System.Windows.Forms.Label lblSaveAs; 155 | private System.Windows.Forms.Label label4; 156 | private System.Windows.Forms.Label lblDownLoad; 157 | private System.Windows.Forms.Label label6; 158 | private System.Windows.Forms.Label lblSpeed; 159 | private System.Windows.Forms.Label label8; 160 | private System.Windows.Forms.ProgressBar progressBar1; 161 | } 162 | } -------------------------------------------------------------------------------- /Download.cs: -------------------------------------------------------------------------------- 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 | 10 | namespace WeCode1._0 11 | { 12 | public partial class Download : Form 13 | { 14 | Thread t; 15 | private string _URL; 16 | private string _Filename; 17 | 18 | public Download(string URL, string Filename) 19 | { 20 | InitializeComponent(); 21 | this._URL = URL; 22 | this._Filename = Filename; 23 | } 24 | 25 | private void Download_Shown(object sender, EventArgs e) 26 | { 27 | lblSaveAs.Text = _Filename; 28 | lblURL.Text = _URL; 29 | lblDownLoad.Text = "0/0"; 30 | lblSpeed.Text = "O KB/S"; 31 | //DownloadFile(_URL, _Filename, this.progressBar1); 32 | //新线程下载 33 | Control.CheckForIllegalCrossThreadCalls = false; 34 | t = new Thread(new ThreadStart(ThFun)); 35 | t.Start(); 36 | } 37 | 38 | public void ThFun() 39 | { 40 | DownloadFile(_URL, _Filename, this.progressBar1); 41 | } 42 | 43 | /// 44 | /// 下载文件 45 | /// 46 | /// 下载文件地址 47 | /// 下载后的存放地址 48 | /// 用于显示的进度条 49 | public void DownloadFile(string URL, string filename, System.Windows.Forms.ProgressBar prog) 50 | { 51 | System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create); 52 | 53 | try 54 | { 55 | System.Net.HttpWebRequest Myrq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(URL); 56 | System.Net.HttpWebResponse myrp = (System.Net.HttpWebResponse)Myrq.GetResponse(); 57 | long totalBytes = myrp.ContentLength; 58 | 59 | lblDownLoad.Text = "0字节/" + totalBytes.ToString() + "字节"; 60 | 61 | if (prog != null) 62 | { 63 | prog.Maximum = (int)totalBytes; 64 | } 65 | 66 | System.IO.Stream st = myrp.GetResponseStream(); 67 | //System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create); 68 | long totalDownloadedByte = 0; 69 | byte[] by = new byte[1024]; 70 | int osize = st.Read(by, 0, (int)by.Length); 71 | 72 | //已上传的字节数 73 | long offset = 0; 74 | 75 | //开始上传时间 76 | DateTime startTime = DateTime.Now; 77 | 78 | while (osize > 0) 79 | { 80 | totalDownloadedByte = osize + totalDownloadedByte; 81 | //System.Windows.Forms.Application.DoEvents(); 82 | so.Write(by, 0, osize); 83 | 84 | TimeSpan span = DateTime.Now - startTime; 85 | double second = span.TotalSeconds; 86 | offset += osize; 87 | if (second > 0.001) 88 | { 89 | lblSpeed.Text = " 平均速度:" + (offset / 1024 / second).ToString("0.00") + "KB/秒"; 90 | } 91 | 92 | lblDownLoad.Text = (totalDownloadedByte/1024).ToString("F2") + "KB/" + (totalBytes/1024).ToString("F2") + "KB"; 93 | if (prog != null) 94 | { 95 | prog.Value = (int)totalDownloadedByte; 96 | } 97 | osize = st.Read(by, 0, (int)by.Length); 98 | } 99 | so.Close(); 100 | st.Close(); 101 | MessageBox.Show("下载完成!"); 102 | this.Close(); 103 | } 104 | catch (System.Exception) 105 | { 106 | 107 | } 108 | finally { 109 | so.Close(); 110 | } 111 | } 112 | 113 | private void Download_FormClosing(object sender, FormClosingEventArgs e) 114 | { 115 | //Thread.CurrentThread.Abort(); 116 | //t.DisableComObjectEagerCleanup(); 117 | t.Abort(); 118 | 119 | this.Dispose(); 120 | 121 | this.Close(); 122 | } 123 | 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /EncryptDecrptt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Security.Cryptography; 5 | 6 | namespace WeCode1._0 7 | { 8 | public static class EncryptDecrptt 9 | { 10 | 11 | //字符串转MD5 12 | public static string str2MD5(string str) 13 | { 14 | byte[] data = Encoding.GetEncoding("GB2312").GetBytes(str); 15 | MD5 md5 = new MD5CryptoServiceProvider(); 16 | byte[] OutBytes = md5.ComputeHash(data); 17 | 18 | string OutString = ""; 19 | for (int i = 0; i < OutBytes.Length; i++) 20 | { 21 | OutString += OutBytes[i].ToString("x2"); 22 | } 23 | // return OutString.ToUpper(); 24 | return OutString.ToLower(); 25 | } 26 | 27 | //keyA转化为KeyD(先固定AES加密),keyD为加密秘钥 28 | public static string KeyA2KeyD(string KeyA) 29 | { 30 | string result = ""; 31 | AesHelper ah1 = new AesHelper("herbertmarson1990loveoutcat"); 32 | string keyD=ah1.EncryptoData(KeyA); 33 | result = keyD; 34 | return result; 35 | } 36 | 37 | /// 38 | /// 加密 39 | /// 40 | /// 要加密的字符串 41 | /// 秘钥 42 | /// 加密后经过BASE64编码的字符串 43 | public static string EncrptyByKey(string str2encrypt, string key) 44 | { 45 | string result = ""; 46 | AesHelper ah = new AesHelper(key); 47 | result = ah.EncryptoData(str2encrypt); 48 | 49 | return result; 50 | } 51 | 52 | /// 53 | /// 解密 54 | /// 55 | /// 要解密的字符串 56 | /// 秘钥 57 | /// 解密并经过解码的字符串 58 | public static string DecrptyByKey(string str2decrypt, string key) 59 | { 60 | string result = ""; 61 | try 62 | { 63 | AesHelper ah = new AesHelper(key); 64 | result = ah.DecryptoData(str2decrypt); 65 | } 66 | catch (Exception ex) 67 | { 68 | result = ""; 69 | } 70 | 71 | return result; 72 | } 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /ExportYoudaoForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class ExportYoudaoForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExportYoudaoForm)); 32 | this.labelMessage = new System.Windows.Forms.Label(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.progressBar1 = new System.Windows.Forms.ProgressBar(); 35 | this.SuspendLayout(); 36 | // 37 | // labelMessage 38 | // 39 | this.labelMessage.AutoSize = true; 40 | this.labelMessage.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 41 | this.labelMessage.Location = new System.Drawing.Point(12, 76); 42 | this.labelMessage.Name = "labelMessage"; 43 | this.labelMessage.Size = new System.Drawing.Size(43, 17); 44 | this.labelMessage.TabIndex = 0; 45 | this.labelMessage.Text = "label1"; 46 | // 47 | // label1 48 | // 49 | this.label1.AutoSize = true; 50 | this.label1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 51 | this.label1.Location = new System.Drawing.Point(13, 29); 52 | this.label1.Name = "label1"; 53 | this.label1.Size = new System.Drawing.Size(0, 17); 54 | this.label1.TabIndex = 1; 55 | // 56 | // progressBar1 57 | // 58 | this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom; 59 | this.progressBar1.Location = new System.Drawing.Point(0, 113); 60 | this.progressBar1.Name = "progressBar1"; 61 | this.progressBar1.Size = new System.Drawing.Size(495, 20); 62 | this.progressBar1.TabIndex = 2; 63 | // 64 | // ExportYoudaoForm 65 | // 66 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 67 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 68 | this.ClientSize = new System.Drawing.Size(495, 133); 69 | this.Controls.Add(this.progressBar1); 70 | this.Controls.Add(this.label1); 71 | this.Controls.Add(this.labelMessage); 72 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 73 | this.MaximizeBox = false; 74 | this.Name = "ExportYoudaoForm"; 75 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 76 | this.Text = "导出云笔记"; 77 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ExportYoudaoForm_FormClosing); 78 | this.Shown += new System.EventHandler(this.ExportYoudaoForm_Shown); 79 | this.ResumeLayout(false); 80 | this.PerformLayout(); 81 | 82 | } 83 | 84 | #endregion 85 | 86 | private System.Windows.Forms.Label labelMessage; 87 | private System.Windows.Forms.Label label1; 88 | private System.Windows.Forms.ProgressBar progressBar1; 89 | } 90 | } -------------------------------------------------------------------------------- /FormAttachment.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 200, 17 125 | 126 | 127 | 383, 17 128 | 129 | 130 | 564, 17 131 | 132 | -------------------------------------------------------------------------------- /FormAuthor.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class FormAuthor 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAuthor)); 32 | this.webBrowser1 = new System.Windows.Forms.WebBrowser(); 33 | this.SuspendLayout(); 34 | // 35 | // webBrowser1 36 | // 37 | this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; 38 | this.webBrowser1.Location = new System.Drawing.Point(0, 0); 39 | this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); 40 | this.webBrowser1.Name = "webBrowser1"; 41 | this.webBrowser1.ScriptErrorsSuppressed = true; 42 | this.webBrowser1.Size = new System.Drawing.Size(1000, 720); 43 | this.webBrowser1.TabIndex = 0; 44 | this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted); 45 | // 46 | // FormAuthor 47 | // 48 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 49 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 50 | this.AutoSize = true; 51 | this.ClientSize = new System.Drawing.Size(1000, 720); 52 | this.Controls.Add(this.webBrowser1); 53 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 54 | this.Name = "FormAuthor"; 55 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 56 | this.Text = "登录"; 57 | this.Load += new System.EventHandler(this.FormAuthor_Load); 58 | this.ResumeLayout(false); 59 | 60 | } 61 | 62 | #endregion 63 | 64 | private System.Windows.Forms.WebBrowser webBrowser1; 65 | } 66 | } -------------------------------------------------------------------------------- /FormAuthor.cs: -------------------------------------------------------------------------------- 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.Configuration; 9 | using System.Net; 10 | using System.IO; 11 | using Newtonsoft.Json.Linq; 12 | 13 | namespace WeCode1._0 14 | { 15 | public partial class FormAuthor : Form 16 | { 17 | public string ReturnVal { get; protected set; } 18 | 19 | 20 | //获取authorization_code 21 | public Uri GetAuthorizationCodeUri = new Uri("https://note.youdao.com/oauth/authorize2"); 22 | //获取access_token 23 | public Uri GetAccessTokenUri = new Uri("https://note.youdao.com/oauth/access2"); 24 | //浏览器返回autorization_code 25 | public string autorizationCode = ""; 26 | public string accessToken = ""; 27 | 28 | public FormAuthor() 29 | { 30 | InitializeComponent(); 31 | } 32 | 33 | private void FormAuthor_Load(object sender, EventArgs e) 34 | { 35 | //获取authorization_code构造URL 36 | StringBuilder url = new StringBuilder(GetAuthorizationCodeUri.ToString()); //可变字符串 37 | //追加组合格式字符串 38 | url.AppendFormat("?client_id={0}&",ConfigurationManager.AppSettings["ConsumerKey"]); 39 | url.AppendFormat("redirect_uri={0}&", ConfigurationManager.AppSettings["RedirectUri"]); 40 | url.AppendFormat("response_type={0}&", "code"); 41 | url.AppendFormat("state={0}", "state"); 42 | //url.AppendFormat("scope={0}", "scope=shuo_basic_r,shuo_basic_w"); 43 | //显示输入URL 44 | string Input = url.ToString(); 45 | //将指定URL加载到WebBrowser控件中 46 | webBrowser1.Navigate(Input); 47 | } 48 | 49 | private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) 50 | { 51 | //获取当前文档URL 52 | string reUrl = this.webBrowser1.Url.ToString(); 53 | 54 | if (!string.IsNullOrEmpty(reUrl)) 55 | { 56 | //获取问号后面字符串 57 | string LastUrl = reUrl.Substring(reUrl.LastIndexOf("?") + 1, (reUrl.Length - reUrl.LastIndexOf("?") - 1)); 58 | //根据参数间的&号获取参数数组 59 | string[] urlParam = LastUrl.Split('&'); 60 | foreach (string s in urlParam) 61 | { 62 | //将参数名与参数值赋值给数组 value[0]参数名称 value[1]参数值 63 | string[] value = s.Split('='); 64 | //MessageBox.Show("参数名称为:" + value[0] + " 参数值为:" + value[1]); 65 | if (value[0] == "code") 66 | { 67 | autorizationCode = value[1]; 68 | GetAccessToken(autorizationCode); 69 | } 70 | } 71 | } 72 | } 73 | 74 | public void GetAccessToken(string Code) 75 | { 76 | try 77 | { 78 | //获取AccessTokon构造URL 79 | StringBuilder url = new StringBuilder(GetAccessTokenUri.ToString()); //可变字符串 80 | //追加组合格式字符串 81 | url.AppendFormat("?client_id={0}&", ConfigurationManager.AppSettings["ConsumerKey"]); 82 | url.AppendFormat("client_secret={0}&", ConfigurationManager.AppSettings["ConsumerSecret"]); 83 | url.AppendFormat("grant_type={0}&", "authorization_code"); 84 | url.AppendFormat("redirect_uri={0}&", ConfigurationManager.AppSettings["RedirectUri"]); 85 | url.AppendFormat("code={0}", autorizationCode); 86 | //url.AppendFormat("scope={0}", "scope=shuo_basic_r,shuo_basic_w"); 87 | //显示输入URL 88 | string Input = url.ToString(); 89 | //HttpWebRequest对象实例:该类用于获取和操作HTTP请求 90 | var request = (HttpWebRequest)WebRequest.Create(Input); //Create:创建WebRequest对象 91 | //设置请求方法为GET 92 | //request.Headers.Add("Authorization", "Bearer " + accessToken); 93 | request.Method = "GET"; 94 | //HttpWebResponse对象实例:该类用于获取和操作HTTP应答 95 | var response = (HttpWebResponse)request.GetResponse(); //GetResponse:获取答复 96 | //构造数据流对象实例 97 | Stream stream = response.GetResponseStream(); //GetResponseStream:获取应答流 98 | StreamReader sr = new StreamReader(stream); //从字节流中读取字符 99 | //从流当前位置读取到末尾并显示在WebBrower控件中 100 | string content = sr.ReadToEnd(); 101 | webBrowser1.DocumentText = content; 102 | 103 | //获取的数据装换为Json格式 此时返回的json格式的数据 104 | JObject obj = JObject.Parse(content); 105 | accessToken = (string)obj["accessToken"]; //accesstoken 106 | 107 | //MessageBox.Show("授权成功!"); 108 | 109 | //写入accessToken 110 | SetConfiguration("AccessToken", accessToken); 111 | 112 | //关闭响应流 113 | stream.Close(); 114 | sr.Close(); 115 | response.Close(); 116 | 117 | //返回成功,关闭当前窗口 118 | DialogResult = DialogResult.OK; 119 | this.Close(); 120 | } 121 | catch (Exception msg) //异常处理 122 | { 123 | MessageBox.Show(msg.Message); 124 | } 125 | } 126 | 127 | /// 128 | /// 写入值 129 | /// 130 | /// 131 | /// 132 | public static void SetConfiguration(string key, string value) 133 | { 134 | //增加的内容写在appSettings段下 135 | System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 136 | if (config.AppSettings.Settings[key] == null) 137 | { 138 | config.AppSettings.Settings.Add(key, value); 139 | } 140 | else 141 | { 142 | config.AppSettings.Settings[key].Value = value; 143 | } 144 | config.Save(ConfigurationSaveMode.Modified); 145 | ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件 146 | } 147 | 148 | /**/ 149 | /// 150 | /// 取得appSettings里的值 151 | /// 152 | /// 键 153 | /// 154 | public static string GetConfiguration(string key) 155 | { 156 | return ConfigurationManager.AppSettings[key]; 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /IniLexer.cs: -------------------------------------------------------------------------------- 1 | #region Using Directives 2 | 3 | using System; 4 | using System.Drawing; 5 | using ScintillaNET; 6 | 7 | #endregion Using Directives 8 | 9 | 10 | namespace WeCode1._0 11 | { 12 | // A helper class to use the Scintilla container as an INI lexer. 13 | // We'll ignore the fact that SciLexer.DLL already has an INI capable lexer. ;) 14 | internal sealed class IniLexer 15 | { 16 | #region Constants 17 | 18 | private const int EOL = -1; 19 | 20 | // SciLexer's weird choice for a default style _index 21 | private const int DEFAULT_STYLE = 32; 22 | 23 | // Our custom styles (indexes chosen not to conflict with anything else) 24 | private const int KEY_STYLE = 11; 25 | private const int VALUE_STYLE = 12; 26 | private const int ASSIGNMENT_STYLE = 13; 27 | private const int SECTION_STYLE = 14; 28 | private const int COMMENT_STYLE = 15; 29 | private const int QUOTED_STYLE = 16; 30 | 31 | #endregion Constants 32 | 33 | 34 | #region Fields 35 | 36 | private Scintilla _scintilla; 37 | private int _startPos; 38 | 39 | private int _index; 40 | private string _text; 41 | 42 | #endregion Fields 43 | 44 | 45 | #region Methods 46 | 47 | public static void Init(Scintilla scintilla) 48 | { 49 | // Reset any current language and enable the StyleNeeded 50 | // event by setting the lexer to container. 51 | scintilla.Indentation.SmartIndentType = SmartIndent.None; 52 | scintilla.ConfigurationManager.Language = String.Empty; 53 | scintilla.Lexing.LexerName = "container"; 54 | scintilla.Lexing.Lexer = Lexer.Container; 55 | 56 | // Add our custom styles to the collection 57 | scintilla.Styles[QUOTED_STYLE].ForeColor = Color.FromArgb(153, 51, 51); 58 | scintilla.Styles[KEY_STYLE].ForeColor = Color.FromArgb(0, 0, 153); 59 | scintilla.Styles[ASSIGNMENT_STYLE].ForeColor = Color.OrangeRed; 60 | scintilla.Styles[VALUE_STYLE].ForeColor = Color.FromArgb(102, 0, 102); 61 | scintilla.Styles[COMMENT_STYLE].ForeColor = Color.FromArgb(102, 102, 102); 62 | scintilla.Styles[SECTION_STYLE].ForeColor = Color.FromArgb(0, 0, 102); 63 | scintilla.Styles[SECTION_STYLE].Bold = true; 64 | } 65 | 66 | 67 | private int Read() 68 | { 69 | if (_index < _text.Length) 70 | return _text[_index]; 71 | 72 | return EOL; 73 | } 74 | 75 | 76 | private void SetStyle(int style, int length) 77 | { 78 | if (length > 0) 79 | { 80 | // TODO Still using old API 81 | // This will style the _length of chars and advance the style pointer. 82 | ((INativeScintilla)_scintilla).SetStyling(length, style); 83 | } 84 | } 85 | 86 | 87 | public void Style() 88 | { 89 | // TODO Still using the old API 90 | // Signals that we're going to begin styling from this point. 91 | ((INativeScintilla)_scintilla).StartStyling(_startPos, 0x1F); 92 | 93 | // Run our humble lexer... 94 | StyleWhitespace(); 95 | switch(Read()) 96 | { 97 | case '[': 98 | 99 | // Section, default, comment 100 | StyleUntilMatch(SECTION_STYLE, new char[] { ']' }); 101 | StyleCh(SECTION_STYLE); 102 | StyleUntilMatch(DEFAULT_STYLE, new char[] { ';' }); 103 | goto case ';'; 104 | 105 | case ';': 106 | 107 | // Comment 108 | SetStyle(COMMENT_STYLE, _text.Length - _index); 109 | break; 110 | 111 | default: 112 | 113 | // Key, assignment, quote, value, comment 114 | StyleUntilMatch(KEY_STYLE, new char[] { '=', ';' }); 115 | switch (Read()) 116 | { 117 | case '=': 118 | 119 | // Assignment, quote, value, comment 120 | StyleCh(ASSIGNMENT_STYLE); 121 | switch (Read()) 122 | { 123 | case '"': 124 | 125 | // Quote 126 | StyleCh(QUOTED_STYLE); // '"' 127 | StyleUntilMatch(QUOTED_STYLE, new char[] { '"' }); 128 | 129 | // Make sure it wasn't an escaped quote 130 | if (_index > 0 && _index < _text.Length && _text[_index - 1] == '\\') 131 | goto case '"'; 132 | 133 | StyleCh(QUOTED_STYLE); // '"' 134 | goto default; 135 | 136 | default: 137 | 138 | // Value, comment 139 | StyleUntilMatch(VALUE_STYLE, new char[] { ';' }); 140 | SetStyle(COMMENT_STYLE, _text.Length - _index); 141 | break; 142 | } 143 | break; 144 | 145 | default: // ';', EOL 146 | 147 | // Comment 148 | SetStyle(COMMENT_STYLE, _text.Length - _index); 149 | break; 150 | } 151 | break; 152 | } 153 | } 154 | 155 | 156 | private void StyleCh(int style) 157 | { 158 | // Style just one char and advance 159 | SetStyle(style, 1); 160 | _index++; 161 | } 162 | 163 | 164 | public static void StyleNeeded(Scintilla scintilla, Range range) 165 | { 166 | // Create an instance of our lexer and bada-bing the line! 167 | IniLexer lexer = new IniLexer(scintilla, range.Start, range.StartingLine.Length); 168 | lexer.Style(); 169 | } 170 | 171 | 172 | private void StyleUntilMatch(int style, char[] chars) 173 | { 174 | // Advance until we match a char in the array 175 | int startIndex = _index; 176 | while (_index < _text.Length && Array.IndexOf(chars, _text[_index]) < 0) 177 | _index++; 178 | 179 | if (startIndex != _index) 180 | SetStyle(style, _index - startIndex); 181 | } 182 | 183 | 184 | private void StyleWhitespace() 185 | { 186 | // Advance the _index until non-whitespace character 187 | int startIndex = _index; 188 | while (_index < _text.Length && Char.IsWhiteSpace(_text[_index])) 189 | _index++; 190 | 191 | SetStyle(DEFAULT_STYLE, _index - startIndex); 192 | } 193 | 194 | #endregion Methods 195 | 196 | 197 | #region Constructors 198 | 199 | private IniLexer(Scintilla scintilla, int startPos, int length) 200 | { 201 | this._scintilla = scintilla; 202 | this._startPos = startPos; 203 | 204 | // One line of _text 205 | this._text = scintilla.GetRange(startPos, startPos + length).Text; 206 | } 207 | 208 | #endregion Constructors 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 thinkry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | using System.Threading; 5 | using System.Net; 6 | using System.Text; 7 | using System.Xml; 8 | using System.Runtime.InteropServices; 9 | using System.Diagnostics; 10 | using System.Reflection; 11 | 12 | namespace WeCode1._0 13 | { 14 | static class Program 15 | { 16 | /// 17 | /// 应用程序的主入口点。 18 | /// 19 | 20 | static System.Threading.Mutex m; 21 | public static EventWaitHandle ProgramStarted; 22 | //当前版本 23 | public static string sVer="1.1.9"; 24 | 25 | 26 | private static void CheckConfig() 27 | { 28 | //更新版本号 29 | string ConfigVer = PubFunc.GetConfiguration("Version"); 30 | if (sVer != ConfigVer) 31 | { 32 | PubFunc.SetConfiguration("Version", sVer); 33 | } 34 | 35 | } 36 | 37 | 38 | [STAThread] 39 | static void Main() 40 | { 41 | //初始化上传信息 42 | if (PubFunc.GetConfiguration("UUID") == "") 43 | { 44 | string UUID = System.Guid.NewGuid().ToString(); 45 | PubFunc.SetConfiguration("UUID", UUID); 46 | } 47 | 48 | 49 | //检查当前的appconfig 50 | CheckConfig(); 51 | 52 | 53 | bool bRun = true; 54 | m = new System.Threading.Mutex(true, Application.ProductName, out bRun); 55 | 56 | bool createNew; 57 | ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "MyStartEvent", out createNew); 58 | 59 | if (bRun) 60 | { 61 | Application.EnableVisualStyles(); 62 | Application.SetCompatibleTextRenderingDefault(false); 63 | Application.Run(new FormMain());//设置启动窗口为悬浮窗 64 | } 65 | else 66 | { 67 | //MessageBox.Show("已经有一个此程序的实例在运行 ", "注意"); 68 | //1.2 已经有一个实例在运行 69 | ProgramStarted.Set(); 70 | return; 71 | } 72 | 73 | } 74 | 75 | 76 | //2.在进程中查找是否已经有实例在运行 77 | #region 确保程序只运行一个实例 78 | private static Process RunningInstance() 79 | { 80 | Process current = Process.GetCurrentProcess(); 81 | Process[] processes = Process.GetProcessesByName(current.ProcessName); 82 | //遍历与当前进程名称相同的进程列表 83 | foreach (Process process in processes) 84 | { 85 | //如果实例已经存在则忽略当前进程 86 | if (process.Id != current.Id) 87 | { 88 | return process; 89 | } 90 | } 91 | return null; 92 | } 93 | 94 | //3.已经有了就把它激活,并将其窗口放置最前端 95 | private static void HandleRunningInstance(Process instance) 96 | { 97 | MessageBox.Show("已经在运行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); 98 | ShowWindowAsync(instance.MainWindowHandle, 1); //调用api函数,正常显示窗口 99 | SetForegroundWindow(instance.MainWindowHandle); //将窗口放置最前端 100 | } 101 | [DllImport("User32.dll")] 102 | private static extern bool ShowWindowAsync(System.IntPtr hWnd, int cmdShow); 103 | [DllImport("User32.dll")] 104 | private static extern bool SetForegroundWindow(System.IntPtr hWnd); 105 | #endregion 106 | 107 | 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /ProperDialog.cs: -------------------------------------------------------------------------------- 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 | 9 | namespace WeCode1._0 10 | { 11 | public partial class ProperDialog : Form 12 | { 13 | 14 | public string[] ReturnVal { get; protected set; } 15 | 16 | public ProperDialog(string OpenType,string Title,string Language) 17 | { 18 | InitializeComponent(); 19 | this.comboBoxLanguageType.Text = Language; 20 | 21 | switch (OpenType) 22 | { 23 | case "0": 24 | this.Text = "新建目录"; 25 | this.labelTitle.Text="输入目录标题:"; 26 | this.labelTip.Text = "新建目录的默认语法高亮和父目录相同"; 27 | this.checkBoxIsOnRootCreate.Text = "在顶层新建目录"; 28 | break; 29 | case "1": 30 | this.Text="新建文章"; 31 | this.labelTitle.Text="输入文章标题:"; 32 | this.labelTip.Text = "新建文章的默认语法高亮和父目录相同"; 33 | this.checkBoxIsOnRootCreate.Text = "在顶层新建文章"; 34 | break; 35 | case "2": 36 | this.Text = "目录属性"; 37 | this.labelTitle.Text="输入目录标题:"; 38 | this.labelTip.Text = "目录属性"; 39 | this.textBoxTitle.Text = Title; 40 | this.checkBoxIsOnRootCreate.Visible = false; 41 | break; 42 | case "3": 43 | this.Text = "文章属性"; 44 | this.labelTitle.Text="输入文章标题:"; 45 | this.labelTip.Text = "文章属性"; 46 | this.textBoxTitle.Text = Title; 47 | this.checkBoxIsOnRootCreate.Visible = false; 48 | break; 49 | default: 50 | break; 51 | 52 | } 53 | 54 | 55 | 56 | } 57 | 58 | private void buttonOk_Click(object sender, EventArgs e) 59 | { 60 | if (string.IsNullOrEmpty(textBoxTitle.Text)) 61 | { 62 | MessageBox.Show("标题不能为空!"); 63 | return; 64 | } 65 | else if (textBoxTitle.Text.Length > 50) 66 | { 67 | MessageBox.Show("标题长度不能超过50字节!"); 68 | return; 69 | } 70 | ReturnVal = new string[3]; 71 | ReturnVal[0] = this.textBoxTitle.Text; 72 | ReturnVal[1] = this.comboBoxLanguageType.Text; 73 | ReturnVal[2]=this.checkBoxIsOnRootCreate.Checked.ToString(); 74 | 75 | DialogResult = DialogResult.OK; 76 | this.Close(); 77 | } 78 | 79 | private void buttonCancel_Click(object sender, EventArgs e) 80 | { 81 | DialogResult = DialogResult.Cancel; 82 | this.Close(); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ProperDialog.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("WeCode程序员云笔记")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WeCode程序员云笔记")] 13 | [assembly: AssemblyCopyright("Copyright © 2015-2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("910334d9-a348-46f1-b19f-fb124d35d234")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.9")] 36 | [assembly: AssemblyFileVersion("1.1.9")] 37 | -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.18408 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeCode1._0.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeCode1._0.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 65 | /// 66 | internal static System.Drawing.Bitmap app { 67 | get { 68 | object obj = ResourceManager.GetObject("app", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 75 | /// 76 | internal static System.Drawing.Bitmap tongbu { 77 | get { 78 | object obj = ResourceManager.GetObject("tongbu", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\app.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | 126 | ..\Resources\tongbu.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 127 | 128 | -------------------------------------------------------------------------------- /Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.18408 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeCode1._0.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Properties/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | wecode 2 | ====== 3 | 4 | --- 5 | wecode简介 6 | ------ 7 | wecode是CodeHelp的升级版本,是专门为我们程序员设计的一款源代码管理软件。 它能方便的管理您在编程和学习中有用的源代码,减少经常到处查找资料的劳动,节省您在开发中的时间和精力。 8 | 9 | 知识管理越来越被大家所重视,源代码也应该做为一种知识资源,纳入知识管理体系中去。 利用wecode,可以方便的管理你的各种技术资料和源代码。 10 | 11 | --- 12 | wecode特色 13 | ------ 14 | * 【语法高亮】目前支持 C/C++、C#、Pascal、Java、VB.Net、XML、HTML、Python、SQL等多种方。 15 | * 【云端存储】除了本地笔记本外,还增加了云存储功能,目前使用有道云笔记做为云存储。 16 | * 【文档加密】提供了文档加密功能,确保敏感文档的安全性。 17 | * 【多个本地笔记本】支持多个本地笔记本,你能够新建本地笔记本、打开、压缩和备份本地笔记本。 18 | * 【文章附件】能够为每个文章添加多个附件,并能够在临时目录中打开附件、导出附件。有道云的附件也存储在云端。 19 | * 【更多功能】敬请发现... 20 | -------------------------------------------------------------------------------- /Resources/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/Resources/app.ico -------------------------------------------------------------------------------- /Resources/tongbu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/Resources/tongbu.gif -------------------------------------------------------------------------------- /TreeNodeLocal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /UpLoad.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class UpLoad 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UpLoad)); 32 | this.lblTime = new System.Windows.Forms.Label(); 33 | this.lblSpeed = new System.Windows.Forms.Label(); 34 | this.lblSize = new System.Windows.Forms.Label(); 35 | this.lblState = new System.Windows.Forms.Label(); 36 | this.progressBar1 = new System.Windows.Forms.ProgressBar(); 37 | this.SuspendLayout(); 38 | // 39 | // lblTime 40 | // 41 | this.lblTime.AutoSize = true; 42 | this.lblTime.Location = new System.Drawing.Point(13, 13); 43 | this.lblTime.Name = "lblTime"; 44 | this.lblTime.Size = new System.Drawing.Size(41, 12); 45 | this.lblTime.TabIndex = 0; 46 | this.lblTime.Text = "label1"; 47 | // 48 | // lblSpeed 49 | // 50 | this.lblSpeed.AutoSize = true; 51 | this.lblSpeed.Location = new System.Drawing.Point(13, 36); 52 | this.lblSpeed.Name = "lblSpeed"; 53 | this.lblSpeed.Size = new System.Drawing.Size(41, 12); 54 | this.lblSpeed.TabIndex = 1; 55 | this.lblSpeed.Text = "label2"; 56 | // 57 | // lblSize 58 | // 59 | this.lblSize.AutoSize = true; 60 | this.lblSize.Location = new System.Drawing.Point(13, 83); 61 | this.lblSize.Name = "lblSize"; 62 | this.lblSize.Size = new System.Drawing.Size(41, 12); 63 | this.lblSize.TabIndex = 3; 64 | this.lblSize.Text = "label3"; 65 | // 66 | // lblState 67 | // 68 | this.lblState.AutoSize = true; 69 | this.lblState.Location = new System.Drawing.Point(13, 60); 70 | this.lblState.Name = "lblState"; 71 | this.lblState.Size = new System.Drawing.Size(41, 12); 72 | this.lblState.TabIndex = 2; 73 | this.lblState.Text = "label4"; 74 | // 75 | // progressBar1 76 | // 77 | this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom; 78 | this.progressBar1.Location = new System.Drawing.Point(0, 110); 79 | this.progressBar1.Name = "progressBar1"; 80 | this.progressBar1.Size = new System.Drawing.Size(496, 20); 81 | this.progressBar1.TabIndex = 4; 82 | // 83 | // UpLoad 84 | // 85 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 86 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 87 | this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 88 | this.ClientSize = new System.Drawing.Size(496, 130); 89 | this.Controls.Add(this.progressBar1); 90 | this.Controls.Add(this.lblSize); 91 | this.Controls.Add(this.lblState); 92 | this.Controls.Add(this.lblSpeed); 93 | this.Controls.Add(this.lblTime); 94 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 95 | this.MaximizeBox = false; 96 | this.Name = "UpLoad"; 97 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 98 | this.Text = "上传附件"; 99 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UpLoad_FormClosing); 100 | this.Load += new System.EventHandler(this.UpLoad_Load); 101 | this.Shown += new System.EventHandler(this.UpLoad_Shown); 102 | this.ResumeLayout(false); 103 | this.PerformLayout(); 104 | 105 | } 106 | 107 | #endregion 108 | 109 | private System.Windows.Forms.Label lblTime; 110 | private System.Windows.Forms.Label lblSpeed; 111 | private System.Windows.Forms.Label lblSize; 112 | private System.Windows.Forms.Label lblState; 113 | private System.Windows.Forms.ProgressBar progressBar1; 114 | } 115 | } -------------------------------------------------------------------------------- /UserInfo.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class UserInfo 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.panel1 = new System.Windows.Forms.Panel(); 32 | this.labelUInfo = new System.Windows.Forms.Label(); 33 | this.buttonOK = new System.Windows.Forms.Button(); 34 | this.buttonlogOut = new System.Windows.Forms.Button(); 35 | this.panel1.SuspendLayout(); 36 | this.SuspendLayout(); 37 | // 38 | // panel1 39 | // 40 | this.panel1.BackColor = System.Drawing.SystemColors.Window; 41 | this.panel1.Controls.Add(this.labelUInfo); 42 | this.panel1.Location = new System.Drawing.Point(0, 0); 43 | this.panel1.Name = "panel1"; 44 | this.panel1.Size = new System.Drawing.Size(244, 108); 45 | this.panel1.TabIndex = 0; 46 | // 47 | // labelUInfo 48 | // 49 | this.labelUInfo.AutoSize = true; 50 | this.labelUInfo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 51 | this.labelUInfo.Location = new System.Drawing.Point(24, 22); 52 | this.labelUInfo.Name = "labelUInfo"; 53 | this.labelUInfo.Size = new System.Drawing.Size(43, 17); 54 | this.labelUInfo.TabIndex = 0; 55 | this.labelUInfo.Text = "label1"; 56 | // 57 | // buttonOK 58 | // 59 | this.buttonOK.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 60 | this.buttonOK.Location = new System.Drawing.Point(26, 127); 61 | this.buttonOK.Name = "buttonOK"; 62 | this.buttonOK.Size = new System.Drawing.Size(75, 23); 63 | this.buttonOK.TabIndex = 1; 64 | this.buttonOK.Text = "确定"; 65 | this.buttonOK.UseVisualStyleBackColor = true; 66 | this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); 67 | // 68 | // buttonlogOut 69 | // 70 | this.buttonlogOut.DialogResult = System.Windows.Forms.DialogResult.Abort; 71 | this.buttonlogOut.Location = new System.Drawing.Point(142, 127); 72 | this.buttonlogOut.Name = "buttonlogOut"; 73 | this.buttonlogOut.Size = new System.Drawing.Size(75, 23); 74 | this.buttonlogOut.TabIndex = 2; 75 | this.buttonlogOut.Text = "注销"; 76 | this.buttonlogOut.UseVisualStyleBackColor = true; 77 | this.buttonlogOut.Click += new System.EventHandler(this.buttonlogOut_Click); 78 | // 79 | // UserInfo 80 | // 81 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 82 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 83 | this.ClientSize = new System.Drawing.Size(243, 157); 84 | this.Controls.Add(this.buttonlogOut); 85 | this.Controls.Add(this.buttonOK); 86 | this.Controls.Add(this.panel1); 87 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 88 | this.MaximizeBox = false; 89 | this.MinimizeBox = false; 90 | this.Name = "UserInfo"; 91 | this.ShowIcon = false; 92 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 93 | this.Text = "有道云账号信息"; 94 | this.panel1.ResumeLayout(false); 95 | this.panel1.PerformLayout(); 96 | this.ResumeLayout(false); 97 | 98 | } 99 | 100 | #endregion 101 | 102 | private System.Windows.Forms.Panel panel1; 103 | private System.Windows.Forms.Label labelUInfo; 104 | private System.Windows.Forms.Button buttonOK; 105 | private System.Windows.Forms.Button buttonlogOut; 106 | } 107 | } -------------------------------------------------------------------------------- /UserInfo.cs: -------------------------------------------------------------------------------- 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 | 9 | namespace WeCode1._0 10 | { 11 | public partial class UserInfo : Form 12 | { 13 | public UserInfo(string info) 14 | { 15 | InitializeComponent(); 16 | labelUInfo.Text = info; 17 | } 18 | 19 | private void buttonOK_Click(object sender, EventArgs e) 20 | { 21 | this.Close(); 22 | } 23 | 24 | //注销 25 | private void buttonlogOut_Click(object sender, EventArgs e) 26 | { 27 | this.Close() ; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /UserInfo.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /WeCode.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | zh-CN 11 | false 12 | 13 | -------------------------------------------------------------------------------- /WeCode.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeCode", "WeCode.csproj", "{B9AD3FFB-9135-4937-8E4B-6279C4F9B633}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x86 = Debug|x86 9 | Release|x86 = Release|x86 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {B9AD3FFB-9135-4937-8E4B-6279C4F9B633}.Debug|x86.ActiveCfg = Debug|x86 13 | {B9AD3FFB-9135-4937-8E4B-6279C4F9B633}.Debug|x86.Build.0 = Debug|x86 14 | {B9AD3FFB-9135-4937-8E4B-6279C4F9B633}.Release|x86.ActiveCfg = Release|x86 15 | {B9AD3FFB-9135-4937-8E4B-6279C4F9B633}.Release|x86.Build.0 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /WelcomeDoc.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class WelcomeDoc 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WelcomeDoc)); 32 | this.linkLabel2 = new System.Windows.Forms.LinkLabel(); 33 | this.label4 = new System.Windows.Forms.Label(); 34 | this.linkLabel1 = new System.Windows.Forms.LinkLabel(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.label2 = new System.Windows.Forms.Label(); 37 | this.pictureBox2 = new System.Windows.Forms.PictureBox(); 38 | this.label1 = new System.Windows.Forms.Label(); 39 | this.label5 = new System.Windows.Forms.Label(); 40 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); 41 | this.SuspendLayout(); 42 | // 43 | // linkLabel2 44 | // 45 | this.linkLabel2.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 46 | this.linkLabel2.Location = new System.Drawing.Point(155, 132); 47 | this.linkLabel2.Name = "linkLabel2"; 48 | this.linkLabel2.Size = new System.Drawing.Size(270, 15); 49 | this.linkLabel2.TabIndex = 17; 50 | this.linkLabel2.TabStop = true; 51 | this.linkLabel2.Text = "https://github.com/thinkry/wecode/issues"; 52 | this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked); 53 | // 54 | // label4 55 | // 56 | this.label4.AutoSize = true; 57 | this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 58 | this.label4.Location = new System.Drawing.Point(115, 129); 59 | this.label4.Name = "label4"; 60 | this.label4.Size = new System.Drawing.Size(44, 17); 61 | this.label4.TabIndex = 16; 62 | this.label4.Text = "反馈:"; 63 | // 64 | // linkLabel1 65 | // 66 | this.linkLabel1.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 67 | this.linkLabel1.Location = new System.Drawing.Point(155, 99); 68 | this.linkLabel1.Name = "linkLabel1"; 69 | this.linkLabel1.Size = new System.Drawing.Size(210, 15); 70 | this.linkLabel1.TabIndex = 15; 71 | this.linkLabel1.TabStop = true; 72 | this.linkLabel1.Text = "http://thinkry.github.io"; 73 | this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); 74 | // 75 | // label3 76 | // 77 | this.label3.AutoSize = true; 78 | this.label3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 79 | this.label3.Location = new System.Drawing.Point(115, 96); 80 | this.label3.Name = "label3"; 81 | this.label3.Size = new System.Drawing.Size(44, 17); 82 | this.label3.TabIndex = 14; 83 | this.label3.Text = "主页:"; 84 | // 85 | // label2 86 | // 87 | this.label2.AutoSize = true; 88 | this.label2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 89 | this.label2.Location = new System.Drawing.Point(115, 65); 90 | this.label2.Name = "label2"; 91 | this.label2.Size = new System.Drawing.Size(128, 17); 92 | this.label2.TabIndex = 13; 93 | this.label2.Text = "程序员的知识管理软件"; 94 | // 95 | // pictureBox2 96 | // 97 | this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image"))); 98 | this.pictureBox2.Location = new System.Drawing.Point(33, 32); 99 | this.pictureBox2.Name = "pictureBox2"; 100 | this.pictureBox2.Size = new System.Drawing.Size(63, 50); 101 | this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; 102 | this.pictureBox2.TabIndex = 12; 103 | this.pictureBox2.TabStop = false; 104 | // 105 | // label1 106 | // 107 | this.label1.AutoSize = true; 108 | this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 109 | this.label1.Location = new System.Drawing.Point(114, 32); 110 | this.label1.Name = "label1"; 111 | this.label1.Size = new System.Drawing.Size(72, 22); 112 | this.label1.TabIndex = 11; 113 | this.label1.Text = "wecode"; 114 | // 115 | // label5 116 | // 117 | this.label5.AutoSize = true; 118 | this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 119 | this.label5.Location = new System.Drawing.Point(202, 36); 120 | this.label5.Name = "label5"; 121 | this.label5.Size = new System.Drawing.Size(35, 17); 122 | this.label5.TabIndex = 18; 123 | this.label5.Text = "1.0.0"; 124 | // 125 | // WelcomeDoc 126 | // 127 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 128 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 129 | this.BackColor = System.Drawing.SystemColors.ControlLightLight; 130 | this.ClientSize = new System.Drawing.Size(762, 397); 131 | this.CloseButton = false; 132 | this.Controls.Add(this.label5); 133 | this.Controls.Add(this.linkLabel2); 134 | this.Controls.Add(this.label4); 135 | this.Controls.Add(this.linkLabel1); 136 | this.Controls.Add(this.label3); 137 | this.Controls.Add(this.label2); 138 | this.Controls.Add(this.pictureBox2); 139 | this.Controls.Add(this.label1); 140 | this.DockAreas = WeifenLuo.WinFormsUI.Docking.DockAreas.Document; 141 | this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 142 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 143 | this.Name = "WelcomeDoc"; 144 | this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.Document; 145 | this.Text = "欢迎"; 146 | this.Activated += new System.EventHandler(this.WelcomeDoc_Activated); 147 | this.Load += new System.EventHandler(this.WelcomeDoc_Load); 148 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); 149 | this.ResumeLayout(false); 150 | this.PerformLayout(); 151 | 152 | } 153 | 154 | #endregion 155 | 156 | private System.Windows.Forms.LinkLabel linkLabel2; 157 | private System.Windows.Forms.Label label4; 158 | private System.Windows.Forms.LinkLabel linkLabel1; 159 | private System.Windows.Forms.Label label3; 160 | private System.Windows.Forms.Label label2; 161 | private System.Windows.Forms.PictureBox pictureBox2; 162 | private System.Windows.Forms.Label label1; 163 | private System.Windows.Forms.Label label5; 164 | 165 | } 166 | } -------------------------------------------------------------------------------- /WelcomeDoc.cs: -------------------------------------------------------------------------------- 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 WeifenLuo.WinFormsUI.Docking; 9 | 10 | namespace WeCode1._0 11 | { 12 | public partial class WelcomeDoc :DockContent 13 | { 14 | 15 | #region Fields 16 | 17 | private string _nodeId; 18 | 19 | #endregion Fields 20 | 21 | #region Properties 22 | 23 | public string NodeId 24 | { 25 | get { return _nodeId; } 26 | set { _nodeId = value; } 27 | } 28 | #endregion 29 | 30 | 31 | public WelcomeDoc() 32 | { 33 | InitializeComponent(); 34 | label5.Text = PubFunc.GetConfiguration("Version"); 35 | } 36 | 37 | private void WelcomeDoc_Activated(object sender, EventArgs e) 38 | { 39 | Attachment.ActiveNodeId = "-1"; 40 | Attachment.ActiveDOCType = "local"; 41 | Attachment.AttForm.ReFreshAttachGrid(); 42 | Attachment.AttForm.GridDiable(); 43 | } 44 | 45 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 46 | { 47 | string target = "http://thinkry.github.io"; 48 | try 49 | { 50 | System.Diagnostics.Process.Start(target); 51 | } 52 | catch (System.ComponentModel.Win32Exception noBrowser) 53 | { 54 | if (noBrowser.ErrorCode == -2147467259) 55 | MessageBox.Show(noBrowser.Message); 56 | } 57 | catch (System.Exception other) 58 | { 59 | MessageBox.Show(other.Message); 60 | } 61 | } 62 | 63 | private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 64 | { 65 | string target = "https://github.com/thinkry/wecode/issues"; 66 | try 67 | { 68 | System.Diagnostics.Process.Start(target); 69 | } 70 | catch (System.ComponentModel.Win32Exception noBrowser) 71 | { 72 | if (noBrowser.ErrorCode == -2147467259) 73 | MessageBox.Show(noBrowser.Message); 74 | } 75 | catch (System.Exception other) 76 | { 77 | MessageBox.Show(other.Message); 78 | } 79 | } 80 | 81 | private void WelcomeDoc_Load(object sender, EventArgs e) 82 | { 83 | //设置随机语录 84 | int i = 0; 85 | string[] sWord = new string[5]; 86 | sWord[0] = "程序员的知识管理软件"; 87 | sWord[1] = "我们是程序员,我们改变世界"; 88 | sWord[2] = "总结 分享 提升"; 89 | sWord[3] = "自己用心又有计划去做事,是很难失败的"; 90 | sWord[4] = "一段写得好的代码,一用好多年,拷贝好带身边"; 91 | 92 | int random = new Random().Next(0, 2); 93 | label2.Text = sWord[random]; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /bin/Release/DockPanel.config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/DockPanel.config -------------------------------------------------------------------------------- /bin/Release/Interop.ADODB.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/Interop.ADODB.dll -------------------------------------------------------------------------------- /bin/Release/Interop.ADOX.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/Interop.ADOX.dll -------------------------------------------------------------------------------- /bin/Release/Interop.JRO.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/Interop.JRO.dll -------------------------------------------------------------------------------- /bin/Release/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /bin/Release/Newtonsoft.Json.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/Newtonsoft.Json.pdb -------------------------------------------------------------------------------- /bin/Release/SciLexer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/SciLexer.dll -------------------------------------------------------------------------------- /bin/Release/SciLexer64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/SciLexer64.dll -------------------------------------------------------------------------------- /bin/Release/ScintillaNET.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/ScintillaNET.dll -------------------------------------------------------------------------------- /bin/Release/WeCode.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/WeCode.exe -------------------------------------------------------------------------------- /bin/Release/WeCode.exe.Config: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /bin/Release/WeifenLuo.WinFormsUI.Docking.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/WeifenLuo.WinFormsUI.Docking.dll -------------------------------------------------------------------------------- /bin/Release/db/helpdb.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/db/helpdb.mdb -------------------------------------------------------------------------------- /bin/Release/db/youdao_ead93e3e-a218-42d3-922f-36243aa50eda.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/db/youdao_ead93e3e-a218-42d3-922f-36243aa50eda.mdb -------------------------------------------------------------------------------- /bin/Release/temp/m.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/bin/Release/temp/m.ico -------------------------------------------------------------------------------- /db/helpdb.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/db/helpdb.mdb -------------------------------------------------------------------------------- /m.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/m.ico -------------------------------------------------------------------------------- /packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/Newtonsoft.Json.6.0.6.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/Newtonsoft.Json.6.0.6.nupkg -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/Newtonsoft.Json.6.0.6.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Newtonsoft.Json 5 | 6.0.6 6 | Json.NET 7 | James Newton-King 8 | James Newton-King 9 | https://raw.github.com/JamesNK/Newtonsoft.Json/master/LICENSE.md 10 | http://james.newtonking.com/json 11 | false 12 | Json.NET is a popular high-performance JSON framework for .NET 13 | en-US 14 | json 15 | 16 | -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/lib/net20/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/lib/net20/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/lib/net35/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/lib/net35/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/lib/net40/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/lib/net40/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/lib/net45/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/lib/net45/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/lib/netcore45/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/lib/netcore45/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/lib/portable-net45+wp80+win8+wpa81+aspnetcore50/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/packages/Newtonsoft.Json.6.0.6/lib/portable-net45+wp80+win8+wpa81+aspnetcore50/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.6.0.6/tools/install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | # open json.net splash page on package install 4 | # don't open if json.net is installed as a dependency 5 | 6 | try 7 | { 8 | $url = "http://james.newtonking.com/json" 9 | $dte2 = Get-Interface $dte ([EnvDTE80.DTE2]) 10 | 11 | if ($dte2.ActiveWindow.Caption -eq "Package Manager Console") 12 | { 13 | # user is installing from VS NuGet console 14 | # get reference to the window, the console host and the input history 15 | # show webpage if "install-package newtonsoft.json" was last input 16 | 17 | $consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow]) 18 | 19 | $props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor ` 20 | [System.Reflection.BindingFlags]::NonPublic) 21 | 22 | $prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1 23 | if ($prop -eq $null) { return } 24 | 25 | $hostInfo = $prop.GetValue($consoleWindow) 26 | if ($hostInfo -eq $null) { return } 27 | 28 | $history = $hostInfo.WpfConsole.InputHistory.History 29 | 30 | $lastCommand = $history | select -last 1 31 | 32 | if ($lastCommand) 33 | { 34 | $lastCommand = $lastCommand.Trim().ToLower() 35 | if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json")) 36 | { 37 | $dte2.ItemOperations.Navigate($url) | Out-Null 38 | } 39 | } 40 | } 41 | else 42 | { 43 | # user is installing from VS NuGet dialog 44 | # get reference to the window, then smart output console provider 45 | # show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation 46 | 47 | $instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor ` 48 | [System.Reflection.BindingFlags]::NonPublic) 49 | $consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor ` 50 | [System.Reflection.BindingFlags]::NonPublic) 51 | if ($instanceField -eq $null -or $consoleField -eq $null) { return } 52 | 53 | $instance = $instanceField.GetValue($null) 54 | if ($instance -eq $null) { return } 55 | 56 | $consoleProvider = $consoleField.GetValue($instance) 57 | if ($consoleProvider -eq $null) { return } 58 | 59 | $console = $consoleProvider.CreateOutputConsole($false) 60 | 61 | $messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor ` 62 | [System.Reflection.BindingFlags]::NonPublic) 63 | if ($messagesField -eq $null) { return } 64 | 65 | $messages = $messagesField.GetValue($console) 66 | if ($messages -eq $null) { return } 67 | 68 | $operations = $messages -split "==============================" 69 | 70 | $lastOperation = $operations | select -last 1 71 | 72 | if ($lastOperation) 73 | { 74 | $lastOperation = $lastOperation.ToLower() 75 | 76 | $lines = $lastOperation -split "`r`n" 77 | 78 | $installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1 79 | 80 | if ($installMatch) 81 | { 82 | $dte2.ItemOperations.Navigate($url) | Out-Null 83 | } 84 | } 85 | } 86 | } 87 | catch 88 | { 89 | # stop potential errors from bubbling up 90 | # worst case the splash page won't open 91 | } 92 | 93 | # yolo -------------------------------------------------------------------------------- /packages/repositories.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WeCode1._0 2 | { 3 | partial class test 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.treeViewYouDao = new System.Windows.Forms.TreeView(); 32 | this.SuspendLayout(); 33 | // 34 | // treeViewYouDao 35 | // 36 | this.treeViewYouDao.BorderStyle = System.Windows.Forms.BorderStyle.None; 37 | this.treeViewYouDao.Dock = System.Windows.Forms.DockStyle.Fill; 38 | this.treeViewYouDao.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 39 | this.treeViewYouDao.Location = new System.Drawing.Point(0, 0); 40 | this.treeViewYouDao.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); 41 | this.treeViewYouDao.Name = "treeViewYouDao"; 42 | this.treeViewYouDao.Size = new System.Drawing.Size(325, 490); 43 | this.treeViewYouDao.TabIndex = 1; 44 | // 45 | // test 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.ClientSize = new System.Drawing.Size(325, 490); 50 | this.Controls.Add(this.treeViewYouDao); 51 | this.Name = "test"; 52 | this.Text = "test"; 53 | this.ResumeLayout(false); 54 | 55 | } 56 | 57 | #endregion 58 | 59 | private System.Windows.Forms.TreeView treeViewYouDao; 60 | 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /test.cs: -------------------------------------------------------------------------------- 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 | 9 | namespace WeCode1._0 10 | { 11 | public partial class test : Form 12 | { 13 | public test() 14 | { 15 | InitializeComponent(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /treeTagBook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace WeCode1._0 6 | { 7 | class treeTagBook 8 | { 9 | public string Language { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /treeTagNote.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace WeCode1._0 6 | { 7 | class treeTagNote 8 | { 9 | public string path { get; set; } 10 | 11 | public string createtime { get; set; } 12 | 13 | public string Language { get; set; } 14 | 15 | public string isMark { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /utils/StringUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Diagnostics; 5 | 6 | namespace WeCode1._0.utils 7 | { 8 | class StringUtils 9 | { 10 | /// 11 | /// 把<div upatetime="xxxx" ver="2">或upatetime="xxxx" ver="2"这一样的语句分割到Dict中 12 | /// 13 | /// 14 | /// 15 | public static Dictionary SplitXmlParams(string xmlParams) 16 | { 17 | char[] spaces = new char[] {' ', '\t', '\r', '\n', '>'}; 18 | 19 | //先跳过= 0) //是<打头的params,例如
这种 23 | { 24 | tagB = xmlParams.IndexOfAny(spaces, tagB + 1); 25 | tagE = xmlParams.IndexOf('>', tagB); 26 | } 27 | else 28 | { 29 | tagB = 0; 30 | tagE = xmlParams.Length; 31 | } 32 | 33 | char[] seps = new char[] {' ', '\t'}; 34 | string t = xmlParams.Substring(tagB, tagE - tagB); 35 | string[] items = t.Split(seps, StringSplitOptions.RemoveEmptyEntries); 36 | 37 | Dictionary ret = new Dictionary(); 38 | 39 | char[] seps2 = new char[] { '=' }; 40 | char[] seps3 = new char[] { '"', ' ', '\n', '\r', '\t' }; 41 | foreach (string item in items) 42 | { 43 | string[] values = item.Split(seps2, StringSplitOptions.RemoveEmptyEntries); 44 | if (values.Length != 2) 45 | { 46 | continue; 47 | } 48 | 49 | ret.Add(values[0].Trim(), values[1].Trim(seps3)); 50 | } 51 | 52 | return ret; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /wecode.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thinkry/wecode/2e91f25751f8276d08ec14743a9d7faee6cb4483/wecode.ico -------------------------------------------------------------------------------- /youdao/YouDaoNode2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Web; 5 | 6 | //第2版本的有道云笔记的节点类 7 | namespace WeCode1._0.youdao 8 | { 9 | class YouDaoNode2 10 | { 11 | public const string typeBase64 = "base64"; 12 | 13 | private string _path = ""; //该对象在有道云的path,可理解为key 14 | private string _title = ""; //标题 15 | private string _content = ""; //正文 16 | private Dictionary _contentParams = new Dictionary(); //正文的参数信息 updatetime/type等 17 | private List> _attachments = new List>(); //附件 18 | 19 | public YouDaoNode2() 20 | { 21 | _contentParams["type"] = typeBase64; 22 | } 23 | 24 | public string GetPath() 25 | { 26 | return _path; 27 | } 28 | 29 | public void SetPath(string value) 30 | { 31 | _path = value; 32 | } 33 | 34 | public string GetTitle() 35 | { 36 | return _title; 37 | } 38 | 39 | public void SetTitle(string value) 40 | { 41 | _title = value; 42 | } 43 | 44 | public string GetContent() 45 | { 46 | return _content; 47 | } 48 | 49 | public void SetContent(string value) 50 | { 51 | _content = value; 52 | } 53 | 54 | public string GetUpdateTime() 55 | { 56 | string result = _contentParams["updatetime"]; 57 | return (result != null) ? result.Trim() : result; 58 | } 59 | 60 | public void SetUpdateTime(string updatetime) 61 | { 62 | _contentParams["updatetime"] = updatetime; 63 | } 64 | 65 | public List> GetAttachments() 66 | { 67 | return _attachments; 68 | } 69 | 70 | public void AddAttachment(string fileUrl, string fileLength, string fileName) 71 | { 72 | Dictionary img = new Dictionary(); 73 | img.Add("src", ""); 74 | img.Add("alt", fileName); 75 | img.Add("title", fileName); 76 | img.Add("filename", ""); 77 | img.Add("filelength", fileLength); 78 | img.Add("path", fileUrl); 79 | img.Add("id", ""); 80 | _attachments.Add(img); 81 | } 82 | 83 | public bool DelAttachment(string fileUrl) 84 | { 85 | foreach (Dictionary img in _attachments) 86 | { 87 | if (fileUrl == img["path"]) 88 | { 89 | _attachments.Remove(img); 90 | return true; 91 | } 92 | } 93 | 94 | return false; 95 | } 96 | 97 | public bool RenameAttachment(string fileUrl, string fileName) 98 | { 99 | foreach (Dictionary img in _attachments) 100 | { 101 | if (fileUrl == img["path"]) 102 | { 103 | img["title"] = fileName; 104 | img["alt"] = fileName; 105 | return true; 106 | } 107 | } 108 | 109 | return false; 110 | } 111 | 112 | /// 113 | /// 解析data,返回YouDaoNode2 114 | /// 115 | /// 116 | public static YouDaoNode2 FromString(string path, string data, string createTime) 117 | { 118 | YouDaoNode2 result = new YouDaoNode2(); 119 | result.SetPath(path); 120 | 121 | //获取笔记的配置信息 122 | Dictionary contentParams = utils.StringUtils.SplitXmlParams(data); 123 | 124 | //解析内容 第一个div标记 125 | int firstB = data.IndexOf('>') + 1; 126 | int firstE = data.IndexOf("
", firstB, StringComparison.OrdinalIgnoreCase); 127 | string first = data.Substring(firstB, firstE - firstB); 128 | 129 | if (contentParams.ContainsKey("type") && contentParams["type"].Trim() == typeBase64) 130 | { 131 | result.SetContent(Encoding.Default.GetString(Convert.FromBase64String(first))); 132 | } 133 | else 134 | { 135 | string t = HttpUtility.HtmlDecode(first); 136 | t = t.Replace("\n
", "\n"); //未采用base64编码前,有道云会把\n替换为\n
,所以这里要处理下 137 | result.SetContent(t); 138 | } 139 | 140 | //获取最后更新时间 141 | if (contentParams.ContainsKey("updatetime") && contentParams["updatetime"].Length > 0) 142 | { 143 | result.SetUpdateTime(contentParams["updatetime"]); 144 | } 145 | else 146 | { 147 | result.SetUpdateTime(createTime); 148 | } 149 | 150 | //复制剩下的contentParam, type和updatetime已在上面处理 151 | foreach (string key in contentParams.Keys) 152 | { 153 | if (key != "type" && key != "updatetime") 154 | { 155 | result._contentParams[key] = contentParams[key]; 156 | } 157 | } 158 | 159 | //解析附件第二个div标记 160 | int secondB = data.IndexOf("= 0) //有附件 162 | { 163 | secondB = data.IndexOf('>', secondB + 4) + 1; 164 | int secondE = data.LastIndexOf("", StringComparison.OrdinalIgnoreCase); 165 | string second = data.Substring(secondB, secondE - secondB); 166 | result.ParseAttachments(second); 167 | } 168 | 169 | return result; 170 | } 171 | 172 | /// 173 | /// 拼装内容和附件组成一个字符串,用于提交到有道云 174 | /// 175 | /// 176 | public string ToString() 177 | { 178 | StringBuilder result = new StringBuilder(); 179 | 180 | //拼装内容 181 | result.Append(" kv in _contentParams) 183 | { 184 | result.AppendFormat(" {0}=\"{1}\"", kv.Key, kv.Value); 185 | } 186 | result.AppendFormat(">\n{0}\n\n", Convert.ToBase64String(Encoding.Default.GetBytes(_content))); 187 | 188 | //拼装附件 189 | if (_attachments.Count > 0) 190 | { 191 | result.Append("
\n"); 192 | foreach (Dictionary attachment in _attachments) 193 | { 194 | result.Append(" kv in attachment) 196 | { 197 | result.AppendFormat(" {0}=\"{1}\"", kv.Key, kv.Value); 198 | } 199 | result.Append(">\n"); 200 | } 201 | result.Append("
\n"); 202 | } 203 | 204 | return result.ToString(); 205 | } 206 | 207 | private void ParseAttachments(string str) 208 | { 209 | str = str.Trim(); 210 | string[] sep = new string[] { "', '/', ' ', '\r', '\n', '\t' }; 214 | foreach (string item in items) 215 | { 216 | string s = item.Trim(sep2); 217 | _attachments.Add(utils.StringUtils.SplitXmlParams(s)); 218 | } 219 | } 220 | } 221 | } 222 | --------------------------------------------------------------------------------