├── LiteDB.dll ├── 最新政治理论考试题库.doc ├── Properties ├── Settings.settings ├── AssemblyInfo.cs ├── Settings.Designer.cs ├── Resources.Designer.cs └── Resources.resx ├── .gitattributes ├── Program.cs ├── ExportForm.cs ├── .gitignore ├── ExportForm.Designer.cs ├── ExamSystem.csproj ├── ExportForm.resx ├── MainForm.resx ├── MainForm.cs └── MainForm.Designer.cs /LiteDB.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asxinyu/ExamSystem/HEAD/LiteDB.dll -------------------------------------------------------------------------------- /最新政治理论考试题库.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asxinyu/ExamSystem/HEAD/最新政治理论考试题库.doc -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace ExamSystem 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// 应用程序的主入口点。 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new MainForm()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("ExamSystem")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("ExamSystem")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 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("c4fb6750-1b5b-4655-9b4c-1b0e735caa2b")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34209 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ExamSystem.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本: 4.0.30319.34209 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ExamSystem.Properties 12 | { 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 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 返回此类使用的、缓存的 ResourceManager 实例。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ExamSystem.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 为所有资源查找重写当前线程的 CurrentUICulture 属性, 56 | /// 方法是使用此强类型资源类。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ExportForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | using LiteDB; 6 | 7 | 8 | namespace ExamSystem 9 | { 10 | public partial class ExportForm : Form 11 | { 12 | public ExportForm() 13 | { 14 | InitializeComponent(); 15 | comboBox1.SelectedIndex = 0; 16 | } 17 | 18 | private void button1_Click(object sender, EventArgs e) 19 | { 20 | //获取题目类型 21 | var typeName = comboBox1.Text.Trim(); 22 | using (var db = new LiteDatabase("Prob.db")) 23 | { 24 | var col = db.GetCollection("Problem"); 25 | //先换行分割 26 | var prolist = textBox1.Text.Trim().Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); 27 | Problem model ; 28 | Int32 index = 0; 29 | //题目列表,多行的每次读最后一个 30 | List modelList = new List(); 31 | //根据每行的第一个字符和、号进行区分,如果不是新题目,就作为选项添加到上一个题目中去 32 | while (index 0) 38 | { 39 | int number; 40 | if(Int32.TryParse(titles[0],out number)) 41 | { //是数字,添加 42 | model = new Problem(); //如果分割第1个是数字,则说明是1个新的题目 43 | model.ProbId = number; 44 | model.ProbText = item; 45 | model.TypeName = typeName; 46 | //确定答案,答案在()里面,把括号里面是字符串分解并组合 47 | var ans = item.Split('(', ')'); 48 | if (ans.Length < 2) model.Answer = string.Empty; 49 | if (ans.Length > 1) model.Answer = ans[1]; 50 | if (ans.Length > 3) model.Answer = ans[1] + "\r\n" + ans[3]; 51 | modelList.Add(model); 52 | } 53 | else 54 | { 55 | //不是数字,就添加到前一个实体中去,并更新题目内容 56 | modelList.Last().ProbText += ("\r\n" + item); 57 | } 58 | } 59 | else 60 | { 61 | //不是数字,就添加到前一个实体中去,并更新题目内容 62 | modelList.Last().ProbText += ("\r\n" + item); 63 | } 64 | index++; 65 | } 66 | col.InsertBulk(modelList); 67 | } 68 | MessageBox.Show("导入完成,关闭软件,重新打开后生效"); 69 | } 70 | 71 | private void button2_Click(object sender, EventArgs e) 72 | { 73 | textBox1.Text = String.Empty; 74 | } 75 | } 76 | 77 | public class Problem 78 | { 79 | /// 题目编号,可以重复,注意不能使用Id 80 | public Int32 ProbId { get; set; } 81 | /// 整个题目内容,同时包括选项 82 | public String ProbText { get; set; } 83 | /// 答案,一般是题干答案中的东西 84 | public String Answer { get; set; } 85 | /// 题目类型 86 | public String TypeName { get; set; } 87 | } 88 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # Build results 11 | [Dd]ebug/ 12 | [Dd]ebugPublic/ 13 | [Rr]elease/ 14 | [Rr]eleases/ 15 | x64/ 16 | x86/ 17 | build/ 18 | bld/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | 22 | # Roslyn cache directories 23 | *.ide/ 24 | 25 | # MSTest test Results 26 | [Tt]est[Rr]esult*/ 27 | [Bb]uild[Ll]og.* 28 | 29 | #NUNIT 30 | *.VisualState.xml 31 | TestResult.xml 32 | 33 | # Build Results of an ATL Project 34 | [Dd]ebugPS/ 35 | [Rr]eleasePS/ 36 | dlldata.c 37 | 38 | *_i.c 39 | *_p.c 40 | *_i.h 41 | *.ilk 42 | *.meta 43 | *.obj 44 | *.pch 45 | *.pdb 46 | *.pgc 47 | *.pgd 48 | *.rsp 49 | *.sbr 50 | *.tlb 51 | *.tli 52 | *.tlh 53 | *.tmp 54 | *.tmp_proj 55 | *.log 56 | *.vspscc 57 | *.vssscc 58 | .builds 59 | *.pidb 60 | *.svclog 61 | *.scc 62 | 63 | # Chutzpah Test files 64 | _Chutzpah* 65 | 66 | # Visual C++ cache files 67 | ipch/ 68 | *.aps 69 | *.ncb 70 | *.opensdf 71 | *.sdf 72 | *.cachefile 73 | 74 | # Visual Studio profiler 75 | *.psess 76 | *.vsp 77 | *.vspx 78 | 79 | # TFS 2012 Local Workspace 80 | $tf/ 81 | 82 | # Guidance Automation Toolkit 83 | *.gpState 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper*/ 87 | *.[Rr]e[Ss]harper 88 | *.DotSettings.user 89 | 90 | # JustCode is a .NET coding addin-in 91 | .JustCode 92 | 93 | # TeamCity is a build add-in 94 | _TeamCity* 95 | 96 | # DotCover is a Code Coverage Tool 97 | *.dotCover 98 | 99 | # NCrunch 100 | _NCrunch_* 101 | .*crunch*.local.xml 102 | 103 | # MightyMoose 104 | *.mm.* 105 | AutoTest.Net/ 106 | 107 | # Web workbench (sass) 108 | .sass-cache/ 109 | 110 | # Installshield output folder 111 | [Ee]xpress/ 112 | 113 | # DocProject is a documentation generator add-in 114 | DocProject/buildhelp/ 115 | DocProject/Help/*.HxT 116 | DocProject/Help/*.HxC 117 | DocProject/Help/*.hhc 118 | DocProject/Help/*.hhk 119 | DocProject/Help/*.hhp 120 | DocProject/Help/Html2 121 | DocProject/Help/html 122 | 123 | # Click-Once directory 124 | publish/ 125 | 126 | # Publish Web Output 127 | *.[Pp]ublish.xml 128 | *.azurePubxml 129 | # TODO: Comment the next line if you want to checkin your web deploy settings 130 | # but database connection strings (with potential passwords) will be unencrypted 131 | *.pubxml 132 | *.publishproj 133 | 134 | # NuGet Packages 135 | *.nupkg 136 | # The packages folder can be ignored because of Package Restore 137 | **/packages/* 138 | # except build/, which is used as an MSBuild target. 139 | !**/packages/build/ 140 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 141 | #!**/packages/repositories.config 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | # ========================= 187 | # Operating System Files 188 | # ========================= 189 | 190 | # OSX 191 | # ========================= 192 | 193 | .DS_Store 194 | .AppleDouble 195 | .LSOverride 196 | 197 | # Thumbnails 198 | ._* 199 | 200 | # Files that might appear on external disk 201 | .Spotlight-V100 202 | .Trashes 203 | 204 | # Directories potentially created on remote AFP share 205 | .AppleDB 206 | .AppleDesktop 207 | Network Trash Folder 208 | Temporary Items 209 | .apdisk 210 | 211 | # Windows 212 | # ========================= 213 | 214 | # Windows image file caches 215 | Thumbs.db 216 | ehthumbs.db 217 | 218 | # Folder config file 219 | Desktop.ini 220 | 221 | # Recycle Bin used on file shares 222 | $RECYCLE.BIN/ 223 | 224 | # Windows Installer files 225 | *.cab 226 | *.msi 227 | *.msm 228 | *.msp 229 | 230 | # Windows shortcuts 231 | *.lnk 232 | -------------------------------------------------------------------------------- /ExportForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ExamSystem 2 | { 3 | partial class ExportForm 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.button1 = new System.Windows.Forms.Button(); 32 | this.comboBox1 = new System.Windows.Forms.ComboBox(); 33 | this.textBox1 = new System.Windows.Forms.TextBox(); 34 | this.button2 = new System.Windows.Forms.Button(); 35 | this.SuspendLayout(); 36 | // 37 | // button1 38 | // 39 | this.button1.Location = new System.Drawing.Point(13, 13); 40 | this.button1.Name = "button1"; 41 | this.button1.Size = new System.Drawing.Size(84, 30); 42 | this.button1.TabIndex = 0; 43 | this.button1.Text = "导入"; 44 | this.button1.UseVisualStyleBackColor = true; 45 | this.button1.Click += new System.EventHandler(this.button1_Click); 46 | // 47 | // comboBox1 48 | // 49 | this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 50 | this.comboBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 51 | this.comboBox1.FormattingEnabled = true; 52 | this.comboBox1.Items.AddRange(new object[] { 53 | "填空题", 54 | "单选题", 55 | "多选题", 56 | "判断题"}); 57 | this.comboBox1.Location = new System.Drawing.Point(125, 15); 58 | this.comboBox1.Name = "comboBox1"; 59 | this.comboBox1.Size = new System.Drawing.Size(147, 24); 60 | this.comboBox1.TabIndex = 1; 61 | // 62 | // textBox1 63 | // 64 | this.textBox1.Location = new System.Drawing.Point(14, 49); 65 | this.textBox1.MaxLength = 32700000; 66 | this.textBox1.Multiline = true; 67 | this.textBox1.Name = "textBox1"; 68 | this.textBox1.Size = new System.Drawing.Size(509, 557); 69 | this.textBox1.TabIndex = 2; 70 | // 71 | // button2 72 | // 73 | this.button2.Location = new System.Drawing.Point(352, 12); 74 | this.button2.Name = "button2"; 75 | this.button2.Size = new System.Drawing.Size(84, 30); 76 | this.button2.TabIndex = 3; 77 | this.button2.Text = "清空"; 78 | this.button2.UseVisualStyleBackColor = true; 79 | this.button2.Click += new System.EventHandler(this.button2_Click); 80 | // 81 | // ExportForm 82 | // 83 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 84 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 85 | this.ClientSize = new System.Drawing.Size(526, 607); 86 | this.Controls.Add(this.button2); 87 | this.Controls.Add(this.textBox1); 88 | this.Controls.Add(this.comboBox1); 89 | this.Controls.Add(this.button1); 90 | this.MaximizeBox = false; 91 | this.MinimizeBox = false; 92 | this.Name = "ExportForm"; 93 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 94 | this.Text = "导入数据"; 95 | this.ResumeLayout(false); 96 | this.PerformLayout(); 97 | 98 | } 99 | 100 | #endregion 101 | 102 | private System.Windows.Forms.Button button1; 103 | private System.Windows.Forms.ComboBox comboBox1; 104 | private System.Windows.Forms.TextBox textBox1; 105 | private System.Windows.Forms.Button button2; 106 | } 107 | } -------------------------------------------------------------------------------- /ExamSystem.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {81CEC3DC-2B70-4E3B-8619-0CEBCE0814D0} 8 | WinExe 9 | Properties 10 | ExamSystem 11 | ExamSystem 12 | v4.0 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | False 37 | .\LiteDB.dll 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Form 53 | 54 | 55 | ExportForm.cs 56 | 57 | 58 | Form 59 | 60 | 61 | MainForm.cs 62 | 63 | 64 | 65 | 66 | ExportForm.cs 67 | 68 | 69 | MainForm.cs 70 | 71 | 72 | ResXFileCodeGenerator 73 | Resources.Designer.cs 74 | Designer 75 | 76 | 77 | True 78 | Resources.resx 79 | 80 | 81 | SettingsSingleFileGenerator 82 | Settings.Designer.cs 83 | 84 | 85 | True 86 | Settings.settings 87 | True 88 | 89 | 90 | 91 | 92 | Always 93 | 94 | 95 | 96 | 103 | -------------------------------------------------------------------------------- /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 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /ExportForm.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 | -------------------------------------------------------------------------------- /MainForm.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 | -------------------------------------------------------------------------------- /MainForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | using System.Text; 6 | using System.Runtime.InteropServices; 7 | using System.Diagnostics; 8 | using LiteDB; 9 | 10 | namespace ExamSystem 11 | { 12 | public partial class MainForm : Form 13 | { 14 | #region api 15 | private const int WH_KEYBOARD_LL = 13; 16 | private const int WM_KEYDOWN = 0x0100; 17 | private LowLevelKeyboardProc _proc ; 18 | private IntPtr _hookID = IntPtr.Zero; 19 | /// 20 | /// 启动监测程序 21 | /// 22 | public void RunHook() 23 | { 24 | _hookID = SetHook(_proc); 25 | } 26 | 27 | /// 28 | /// 关闭监测程序 29 | /// 30 | public void UnHook() 31 | { 32 | UnhookWindowsHookEx(_hookID); 33 | } 34 | 35 | private IntPtr SetHook(LowLevelKeyboardProc proc) 36 | { 37 | using (Process curProcess = Process.GetCurrentProcess()) 38 | using (ProcessModule curModule = curProcess.MainModule) 39 | { 40 | return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); 41 | } 42 | } 43 | 44 | /// 45 | /// 设置默认值与数据 46 | /// 47 | /// 48 | /// "F:\图片\精品分类\品牌图片\google徽标\@_@.gif" 49 | public void Init(int initInt, string outString) 50 | { 51 | i = initInt; 52 | str = outString; 53 | } 54 | 55 | private static int i = 0; 56 | private static string str = @"I:\over\Images\google\@_@.jpg"; 57 | 58 | private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) 59 | { 60 | if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) 61 | { 62 | int vkCode = Marshal.ReadInt32(lParam); 63 | Keys key = (Keys)vkCode; 64 | //同时按下Ctrl+V键的时候 65 | if (Control.ModifierKeys == Keys.Control && key.Equals(Keys.C)) 66 | { 67 | //获得剪切板数据 68 | IDataObject iData = Clipboard.GetDataObject(); 69 | string data = ((String)iData.GetData(DataFormats.Text)).Trim();// Clipboard.GetText(TextDataFormat.UnicodeText).Trim(); 70 | 71 | #region 72 | txtKeyValue.Text = data; 73 | var models = list.Where(n => n.ProbText.Contains(data)).ToList(); 74 | if (models.Count == 1) 75 | { 76 | lblTypeName1.Text = models[0].TypeName; 77 | lblAnswer1.Text = String.IsNullOrEmpty(models[0].Answer) ? "题目寻找答案" : models[0].Answer; 78 | txtDisp1.Text = models[0].ProbText; 79 | } 80 | if (models.Count >= 2) 81 | { 82 | lblTypeName1.Text = models[0].TypeName; 83 | lblAnswer1.Text = String.IsNullOrEmpty(models[0].Answer) ? "题目寻找答案" : models[0].Answer; 84 | txtDisp1.Text = models[0].ProbText; 85 | 86 | lblTypeName2.Text = models[1].TypeName; 87 | lblAnswer2.Text = String.IsNullOrEmpty(models[1].Answer) ? "题目寻找答案" : models[1].Answer; 88 | txtDisp2.Text = models[1].ProbText; 89 | } 90 | #endregion 91 | 92 | //重新设置剪切板数据 93 | DataObject m_data = new DataObject(); 94 | m_data.SetData(DataFormats.Text, true, str.Replace("@_@", Convert.ToString(++i))); 95 | Clipboard.SetDataObject(m_data, true); 96 | } 97 | } 98 | return CallNextHookEx(_hookID, nCode, wParam, lParam); 99 | } 100 | #endregion 101 | 102 | #region 调用API 103 | private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); 104 | 105 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 106 | 107 | private static extern IntPtr SetWindowsHookEx(int idHook, 108 | 109 | LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId); 110 | 111 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 112 | 113 | [return: MarshalAs(UnmanagedType.Bool)] 114 | 115 | private static extern bool UnhookWindowsHookEx(IntPtr hhk); 116 | 117 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 118 | 119 | private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, 120 | 121 | IntPtr wParam, IntPtr lParam); 122 | 123 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 124 | 125 | private static extern IntPtr GetModuleHandle(string lpModuleName); 126 | 127 | #endregion 128 | 129 | public MainForm() 130 | { 131 | InitializeComponent(); 132 | 133 | using (var db = new LiteDatabase("Prob.db")) 134 | { 135 | var col = db.GetCollection("Problem"); 136 | var c = col.Count(); 137 | list = col.FindAll().ToList(); 138 | } 139 | _proc = HookCallback; 140 | RunHook(); 141 | } 142 | 143 | List list = new List(); 144 | private void button1_Click(object sender, EventArgs e) 145 | { 146 | //每次搜索前都要情况其他控件 147 | txtDisp1.Text = String.Empty; 148 | txtDisp2.Text = String.Empty; 149 | lblAnswer1.Text = String.Empty; 150 | lblAnswer2.Text = String.Empty; 151 | try 152 | { 153 | //获取剪切板数据 154 | IDataObject iData = Clipboard.GetDataObject(); 155 | if (iData.GetDataPresent(DataFormats.Text)) txtKeyValue.Text = ((String)iData.GetData(DataFormats.Text)).Trim(); 156 | //查找满足关键词的题目 157 | var models = list.Where(n => n.ProbText.Contains(txtKeyValue.Text)).ToList(); 158 | //最多只显示2个包括选择关键词的题目 159 | if (models.Count == 1) 160 | { 161 | lblTypeName1.Text = models[0].TypeName; 162 | lblAnswer1.Text = String.IsNullOrEmpty(models[0].Answer) ? "题目寻找答案" : models[0].Answer; 163 | txtDisp1.Text = models[0].ProbText; 164 | } 165 | if (models.Count >= 2) 166 | { 167 | lblTypeName1.Text = models[0].TypeName; 168 | lblAnswer1.Text = String.IsNullOrEmpty(models[0].Answer) ? "题目寻找答案" : models[0].Answer; 169 | txtDisp1.Text = models[0].ProbText; 170 | 171 | lblTypeName2.Text = models[1].TypeName; 172 | lblAnswer2.Text = String.IsNullOrEmpty(models[1].Answer) ? "题目寻找答案" : models[1].Answer; 173 | txtDisp2.Text = models[1].ProbText; 174 | } 175 | } 176 | catch(Exception err) 177 | { 178 | MessageBox.Show("出现错误,重启后再试!"); 179 | } 180 | } 181 | 182 | private void 导入题库ToolStripMenuItem_Click(object sender, EventArgs e) 183 | { 184 | ExportForm ef = new ExportForm(); 185 | ef.Show(); 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /MainForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ExamSystem 2 | { 3 | partial class MainForm 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 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 窗体设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.btnSearch = new System.Windows.Forms.Button(); 32 | this.txtKeyValue = new System.Windows.Forms.TextBox(); 33 | this.txtDisp1 = new System.Windows.Forms.TextBox(); 34 | this.txtDisp2 = new System.Windows.Forms.TextBox(); 35 | this.lblTypeName1 = new System.Windows.Forms.Label(); 36 | this.label1 = new System.Windows.Forms.Label(); 37 | this.lblAnswer1 = new System.Windows.Forms.Label(); 38 | this.lblAnswer2 = new System.Windows.Forms.Label(); 39 | this.label3 = new System.Windows.Forms.Label(); 40 | this.lblTypeName2 = new System.Windows.Forms.Label(); 41 | this.menuStrip1 = new System.Windows.Forms.MenuStrip(); 42 | this.导入题库ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 43 | this.menuStrip1.SuspendLayout(); 44 | this.SuspendLayout(); 45 | // 46 | // btnSearch 47 | // 48 | this.btnSearch.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 49 | this.btnSearch.Location = new System.Drawing.Point(13, 41); 50 | this.btnSearch.Name = "btnSearch"; 51 | this.btnSearch.Size = new System.Drawing.Size(77, 29); 52 | this.btnSearch.TabIndex = 0; 53 | this.btnSearch.Text = "搜索"; 54 | this.btnSearch.UseVisualStyleBackColor = true; 55 | this.btnSearch.Click += new System.EventHandler(this.button1_Click); 56 | // 57 | // txtKeyValue 58 | // 59 | this.txtKeyValue.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 60 | this.txtKeyValue.Location = new System.Drawing.Point(97, 42); 61 | this.txtKeyValue.Multiline = true; 62 | this.txtKeyValue.Name = "txtKeyValue"; 63 | this.txtKeyValue.Size = new System.Drawing.Size(253, 81); 64 | this.txtKeyValue.TabIndex = 1; 65 | // 66 | // txtDisp1 67 | // 68 | this.txtDisp1.Location = new System.Drawing.Point(13, 154); 69 | this.txtDisp1.Multiline = true; 70 | this.txtDisp1.Name = "txtDisp1"; 71 | this.txtDisp1.Size = new System.Drawing.Size(337, 78); 72 | this.txtDisp1.TabIndex = 2; 73 | // 74 | // txtDisp2 75 | // 76 | this.txtDisp2.Location = new System.Drawing.Point(13, 262); 77 | this.txtDisp2.Multiline = true; 78 | this.txtDisp2.Name = "txtDisp2"; 79 | this.txtDisp2.Size = new System.Drawing.Size(337, 91); 80 | this.txtDisp2.TabIndex = 3; 81 | // 82 | // lblTypeName1 83 | // 84 | this.lblTypeName1.AutoSize = true; 85 | this.lblTypeName1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 86 | this.lblTypeName1.Location = new System.Drawing.Point(11, 134); 87 | this.lblTypeName1.Name = "lblTypeName1"; 88 | this.lblTypeName1.Size = new System.Drawing.Size(56, 16); 89 | this.lblTypeName1.TabIndex = 4; 90 | this.lblTypeName1.Text = "label1"; 91 | // 92 | // label1 93 | // 94 | this.label1.AutoSize = true; 95 | this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 96 | this.label1.Location = new System.Drawing.Point(85, 134); 97 | this.label1.Name = "label1"; 98 | this.label1.Size = new System.Drawing.Size(56, 16); 99 | this.label1.TabIndex = 5; 100 | this.label1.Text = "答案:"; 101 | // 102 | // lblAnswer1 103 | // 104 | this.lblAnswer1.AutoSize = true; 105 | this.lblAnswer1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 106 | this.lblAnswer1.Location = new System.Drawing.Point(134, 134); 107 | this.lblAnswer1.Name = "lblAnswer1"; 108 | this.lblAnswer1.Size = new System.Drawing.Size(56, 16); 109 | this.lblAnswer1.TabIndex = 6; 110 | this.lblAnswer1.Text = "label1"; 111 | // 112 | // lblAnswer2 113 | // 114 | this.lblAnswer2.AutoSize = true; 115 | this.lblAnswer2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 116 | this.lblAnswer2.Location = new System.Drawing.Point(135, 242); 117 | this.lblAnswer2.Name = "lblAnswer2"; 118 | this.lblAnswer2.Size = new System.Drawing.Size(56, 16); 119 | this.lblAnswer2.TabIndex = 10; 120 | this.lblAnswer2.Text = "label1"; 121 | // 122 | // label3 123 | // 124 | this.label3.AutoSize = true; 125 | this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 126 | this.label3.Location = new System.Drawing.Point(86, 242); 127 | this.label3.Name = "label3"; 128 | this.label3.Size = new System.Drawing.Size(56, 16); 129 | this.label3.TabIndex = 9; 130 | this.label3.Text = "答案:"; 131 | // 132 | // lblTypeName2 133 | // 134 | this.lblTypeName2.AutoSize = true; 135 | this.lblTypeName2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 136 | this.lblTypeName2.Location = new System.Drawing.Point(12, 242); 137 | this.lblTypeName2.Name = "lblTypeName2"; 138 | this.lblTypeName2.Size = new System.Drawing.Size(56, 16); 139 | this.lblTypeName2.TabIndex = 8; 140 | this.lblTypeName2.Text = "label1"; 141 | // 142 | // menuStrip1 143 | // 144 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 145 | this.导入题库ToolStripMenuItem}); 146 | this.menuStrip1.Location = new System.Drawing.Point(0, 0); 147 | this.menuStrip1.Name = "menuStrip1"; 148 | this.menuStrip1.Size = new System.Drawing.Size(354, 25); 149 | this.menuStrip1.TabIndex = 12; 150 | this.menuStrip1.Text = "menuStrip1"; 151 | // 152 | // 导入题库ToolStripMenuItem 153 | // 154 | this.导入题库ToolStripMenuItem.Name = "导入题库ToolStripMenuItem"; 155 | this.导入题库ToolStripMenuItem.Size = new System.Drawing.Size(68, 21); 156 | this.导入题库ToolStripMenuItem.Text = "导入题库"; 157 | this.导入题库ToolStripMenuItem.Click += new System.EventHandler(this.导入题库ToolStripMenuItem_Click); 158 | // 159 | // MainForm 160 | // 161 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 162 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 163 | this.ClientSize = new System.Drawing.Size(354, 358); 164 | this.Controls.Add(this.lblAnswer2); 165 | this.Controls.Add(this.label3); 166 | this.Controls.Add(this.lblTypeName2); 167 | this.Controls.Add(this.lblAnswer1); 168 | this.Controls.Add(this.label1); 169 | this.Controls.Add(this.lblTypeName1); 170 | this.Controls.Add(this.txtDisp2); 171 | this.Controls.Add(this.txtDisp1); 172 | this.Controls.Add(this.txtKeyValue); 173 | this.Controls.Add(this.btnSearch); 174 | this.Controls.Add(this.menuStrip1); 175 | this.MainMenuStrip = this.menuStrip1; 176 | this.MaximizeBox = false; 177 | this.Name = "MainForm"; 178 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 179 | this.Text = "考试辅助"; 180 | this.menuStrip1.ResumeLayout(false); 181 | this.menuStrip1.PerformLayout(); 182 | this.ResumeLayout(false); 183 | this.PerformLayout(); 184 | 185 | } 186 | 187 | #endregion 188 | 189 | private System.Windows.Forms.Button btnSearch; 190 | private System.Windows.Forms.TextBox txtKeyValue; 191 | private System.Windows.Forms.TextBox txtDisp1; 192 | private System.Windows.Forms.TextBox txtDisp2; 193 | private System.Windows.Forms.Label lblTypeName1; 194 | private System.Windows.Forms.Label label1; 195 | private System.Windows.Forms.Label lblAnswer1; 196 | private System.Windows.Forms.Label lblAnswer2; 197 | private System.Windows.Forms.Label label3; 198 | private System.Windows.Forms.Label lblTypeName2; 199 | private System.Windows.Forms.MenuStrip menuStrip1; 200 | private System.Windows.Forms.ToolStripMenuItem 导入题库ToolStripMenuItem; 201 | } 202 | } 203 | 204 | --------------------------------------------------------------------------------