CrazyIter_Bin há 1 ano atrás
pai
commit
54fd5b4546

+ 20 - 0
HTEXMark/HTEXMark.csproj

@@ -123,6 +123,12 @@
   -->
   <ItemGroup>
     <Reference Include="Accessibility" />
+    <Reference Include="HtmlRenderer, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>F:\NuGet\packages\HtmlRenderer.Core.1.5.1-beta1\lib\net45\HtmlRenderer.dll</HintPath>
+    </Reference>
+    <Reference Include="HtmlRenderer.WinForms, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>F:\NuGet\packages\HtmlRenderer.WinForms.1.5.1-beta1\lib\net45\HtmlRenderer.WinForms.dll</HintPath>
+    </Reference>
     <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
     </Reference>
@@ -139,6 +145,12 @@
       <HintPath>F:\NuGet\packages\Microsoft.IdentityModel.Tokens.7.2.0\lib\net472\Microsoft.IdentityModel.Tokens.dll</HintPath>
     </Reference>
     <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
+    <Reference Include="PdfSharp, Version=1.50.4000.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
+      <HintPath>F:\NuGet\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll</HintPath>
+    </Reference>
+    <Reference Include="PdfSharp.Charting, Version=1.50.4000.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
+      <HintPath>F:\NuGet\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>F:\NuGet\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
@@ -222,6 +234,12 @@
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
+    <Reference Include="Xceed.Document.NET, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <HintPath>F:\NuGet\packages\DocX.2.5.0\lib\net40\Xceed.Document.NET.dll</HintPath>
+    </Reference>
+    <Reference Include="Xceed.Words.NET, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <HintPath>F:\NuGet\packages\DocX.2.5.0\lib\net40\Xceed.Words.NET.dll</HintPath>
+    </Reference>
     <Reference Include="zxing, Version=0.16.9.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
       <HintPath>..\packages\ZXing.Net.0.16.9\lib\net48\zxing.dll</HintPath>
     </Reference>
@@ -350,6 +368,7 @@
     <Content Include="Images\favicon.ico" />
     <Content Include="Images\二维码.png" />
     <Content Include="Images\作图题.png" />
+    <Content Include="Images\共享数据.png" />
     <Content Include="Images\分析.png" />
     <Content Include="Images\创造.png" />
     <Content Include="Images\判断题.png" />
@@ -360,6 +379,7 @@
     <Content Include="Images\多选题.png" />
     <Content Include="Images\学校.png" />
     <Content Include="Images\学科.png" />
+    <Content Include="Images\学科网.png" />
     <Content Include="Images\应用.png" />
     <Content Include="Images\改错题.png" />
     <Content Include="Images\教师.png" />

BIN
HTEXMark/Images/共享数据.png


BIN
HTEXMark/Images/学科网.png


+ 51 - 39
HTEXMark/MarkRibbon.Designer.cs

@@ -39,9 +39,6 @@ namespace HTEXMark
         { 
             this.item_mark_tab = this.Factory.CreateRibbonTab();
             this.item_type = this.Factory.CreateRibbonGroup();
-            this.item_taxonomy = this.Factory.CreateRibbonGroup();
-            this.item_tool = this.Factory.CreateRibbonGroup();
-            this.item_user = this.Factory.CreateRibbonGroup();
             this.single = this.Factory.CreateRibbonButton();
             this.multiple = this.Factory.CreateRibbonButton();
             this.judge = this.Factory.CreateRibbonButton();
@@ -52,6 +49,7 @@ namespace HTEXMark
             this.draw = this.Factory.CreateRibbonButton();
             this.compose = this.Factory.CreateRibbonButton();
             this.sortmultiple = this.Factory.CreateRibbonButton();
+            this.item_taxonomy = this.Factory.CreateRibbonGroup();
             this.remember = this.Factory.CreateRibbonButton();
             this.understand = this.Factory.CreateRibbonButton();
             this.apply = this.Factory.CreateRibbonButton();
@@ -59,6 +57,7 @@ namespace HTEXMark
             this.evaluate = this.Factory.CreateRibbonButton();
             this.create = this.Factory.CreateRibbonButton();
             this.taxonomy = this.Factory.CreateRibbonButton();
+            this.item_tool = this.Factory.CreateRibbonGroup();
             this.answer = this.Factory.CreateRibbonButton();
             this.analysis = this.Factory.CreateRibbonButton();
             this.score = this.Factory.CreateRibbonButton();
@@ -68,11 +67,13 @@ namespace HTEXMark
             this.ended = this.Factory.CreateRibbonButton();
             this.level = this.Factory.CreateRibbonButton();
             this.count = this.Factory.CreateRibbonButton();
+            this.item_user = this.Factory.CreateRibbonGroup();
             this.qrcode = this.Factory.CreateRibbonButton();
             this.user = this.Factory.CreateRibbonButton();
             this.schoolDropDown = this.Factory.CreateRibbonDropDown();
             this.subjectDropDown = this.Factory.CreateRibbonDropDown();
             this.dataCenter = this.Factory.CreateRibbonDropDown();
+            this.xkw = this.Factory.CreateRibbonButton();
             this.item_mark_tab.SuspendLayout();
             this.item_type.SuspendLayout();
             this.item_taxonomy.SuspendLayout();
@@ -104,42 +105,6 @@ namespace HTEXMark
             this.item_type.Label = "题目类型";
             this.item_type.Name = "item_type";
             // 
-            // item_taxonomy
-            // 
-            this.item_taxonomy.Items.Add(this.remember);
-            this.item_taxonomy.Items.Add(this.understand);
-            this.item_taxonomy.Items.Add(this.apply);
-            this.item_taxonomy.Items.Add(this.analyze);
-            this.item_taxonomy.Items.Add(this.evaluate);
-            this.item_taxonomy.Items.Add(this.create);
-            this.item_taxonomy.Items.Add(this.taxonomy);
-            this.item_taxonomy.Label = "认知层次";
-            this.item_taxonomy.Name = "item_taxonomy";
-            // 
-            // item_tool
-            // 
-            this.item_tool.Items.Add(this.answer);
-            this.item_tool.Items.Add(this.analysis);
-            this.item_tool.Items.Add(this.score);
-            this.item_tool.Items.Add(this.point);
-            this.item_tool.Items.Add(this.itrue);
-            this.item_tool.Items.Add(this.ifalse);
-            this.item_tool.Items.Add(this.ended);
-            this.item_tool.Items.Add(this.level);
-            this.item_tool.Items.Add(this.count);
-            this.item_tool.Label = "其他标记";
-            this.item_tool.Name = "item_tool";
-            // 
-            // item_user
-            // 
-            this.item_user.Items.Add(this.qrcode);
-            this.item_user.Items.Add(this.user);
-            this.item_user.Items.Add(this.schoolDropDown);
-            this.item_user.Items.Add(this.subjectDropDown);
-            this.item_user.Items.Add(this.dataCenter);
-            this.item_user.Label = "用户信息";
-            this.item_user.Name = "item_user";
-            // 
             // single
             // 
             this.single.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
@@ -230,6 +195,18 @@ namespace HTEXMark
             this.sortmultiple.ShowImage = true;
             this.sortmultiple.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
+            // item_taxonomy
+            // 
+            this.item_taxonomy.Items.Add(this.remember);
+            this.item_taxonomy.Items.Add(this.understand);
+            this.item_taxonomy.Items.Add(this.apply);
+            this.item_taxonomy.Items.Add(this.analyze);
+            this.item_taxonomy.Items.Add(this.evaluate);
+            this.item_taxonomy.Items.Add(this.create);
+            this.item_taxonomy.Items.Add(this.taxonomy);
+            this.item_taxonomy.Label = "认知层次";
+            this.item_taxonomy.Name = "item_taxonomy";
+            // 
             // remember
             // 
             this.remember.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
@@ -293,6 +270,20 @@ namespace HTEXMark
             this.taxonomy.ShowImage = true;
             this.taxonomy.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
+            // item_tool
+            // 
+            this.item_tool.Items.Add(this.answer);
+            this.item_tool.Items.Add(this.analysis);
+            this.item_tool.Items.Add(this.score);
+            this.item_tool.Items.Add(this.point);
+            this.item_tool.Items.Add(this.itrue);
+            this.item_tool.Items.Add(this.ifalse);
+            this.item_tool.Items.Add(this.ended);
+            this.item_tool.Items.Add(this.level);
+            this.item_tool.Items.Add(this.count);
+            this.item_tool.Label = "其他标记";
+            this.item_tool.Name = "item_tool";
+            // 
             // answer
             // 
             this.answer.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
@@ -374,6 +365,17 @@ namespace HTEXMark
             this.count.ShowImage = true;
             this.count.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
+            // item_user
+            // 
+            this.item_user.Items.Add(this.qrcode);
+            this.item_user.Items.Add(this.user);
+            this.item_user.Items.Add(this.schoolDropDown);
+            this.item_user.Items.Add(this.subjectDropDown);
+            this.item_user.Items.Add(this.dataCenter);
+            this.item_user.Items.Add(this.xkw);
+            this.item_user.Label = "用户信息";
+            this.item_user.Name = "item_user";
+            // 
             // qrcode
             // 
             this.qrcode.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
@@ -415,6 +417,15 @@ namespace HTEXMark
             this.dataCenter.Name = "dataCenter";
             this.dataCenter.ShowImage = true;
             // 
+            // xkw
+            // 
+            this.xkw.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
+            this.xkw.Image = global::HTEXMark.Properties.Resources.共享数据;
+            this.xkw.Label = "学科网";
+            this.xkw.Name = "xkw";
+            this.xkw.ShowImage = true;
+            this.xkw.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.XKW_Click);
+            // 
             // MarkRibbon
             // 
             this.Name = "MarkRibbon";
@@ -473,6 +484,7 @@ namespace HTEXMark
         internal Microsoft.Office.Tools.Ribbon.RibbonDropDown schoolDropDown;
         internal Microsoft.Office.Tools.Ribbon.RibbonDropDown subjectDropDown;
         internal Microsoft.Office.Tools.Ribbon.RibbonDropDown dataCenter;
+        internal Microsoft.Office.Tools.Ribbon.RibbonButton xkw;
     }
 
     partial class ThisRibbonCollection

+ 99 - 1
HTEXMark/MarkRibbon.cs

@@ -2,20 +2,26 @@
 using Microsoft.Office.Interop.Word;
 using Microsoft.Office.Tools.Ribbon;
 using Microsoft.Office.Tools.Word;
+using PdfSharp.Pdf;
+using PdfSharp;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using System.Net;
 using System.Net.Http;
 using System.Reflection;
 using System.Text;
 using System.Text.Json;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using static HTEXMark.QRCodeForm;
-using static ZXing.QrCode.Internal.Version;
 using Task = System.Threading.Tasks.Task;
+using TheArtOfDev.HtmlRenderer.WinForms;
+using Xceed.Words.NET;
+
 namespace HTEXMark
 {
     public partial class MarkRibbon
@@ -432,5 +438,97 @@ namespace HTEXMark
                 }
             }
         }
+
+        private void XKW_Click(object sender, RibbonControlEventArgs e)
+        {
+            string html = "<html><body><h1>Hello, World!</h1></body></html>";
+            // 处理远程图片并将HTML内容放入剪贴板
+            string processedHtml = ProcessRemoteImages(html);
+
+           
+
+            Microsoft.Office.Interop.Word.Application wordApp = Globals.ThisAddIn.Application;
+
+            InsertHtmlIntoWord(wordApp, processedHtml);
+            // 在Word中粘贴HTML内容
+
+        }
+     
+        private string ConvertHtmlToDocx(string htmlContent)
+        {
+            using (DocX document = DocX.Create(new MemoryStream()))
+            {
+                document.InsertParagraph(htmlContent);
+
+                // Save DOCX content to string
+                string docxContent = document.Xml.ToString();
+                return docxContent;
+            }
+        }
+        private void InsertHtmlIntoWord(Microsoft.Office.Interop.Word.Application wordApp, string htmlContent)
+        {
+            // 获取当前光标位置的 Range 对象
+             Range range = wordApp.Selection.Range;
+            // 将HTML文本放入剪贴板
+            //Clipboard.SetText(htmlContent, TextDataFormat.Html);
+            
+            string rtfContent = "{\\rtf1\\ansi\\ansicpg1252\\uc1\\htmautsp\\deff2{\\fonttbl{\\f0\\fcharset0 Times New Roman;}{\\f2\\fcharset0 Microsoft YaHei UI;}}{\\colortbl\\red0\\green0\\blue0;\\red255\\green255\\blue255;}\\loch\\hich\\dbch\\pard\\plain\\ltrpar\\itap0{\\lang1033\\fs43\\f2\\cf0 \\cf0\\ql{\\f2 {\\ltrch Hello, World!}\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}\r\n}\r\n}";
+            // 使用 Clipboard 将 HTML 内容转换为 RTF 格式
+            System.Windows.Forms.Clipboard.SetText(rtfContent, TextDataFormat.Rtf);
+            // 检查剪贴板是否包含文本
+          
+            // Create a range at the end of the document
+          
+            // Paste HTML from clipboard into the range
+            wordApp.ActiveDocument.Application.Selection.Range.PasteSpecial(DataType: WdPasteDataType.wdPasteRTF);
+            // 清除 Clipboard 内容
+            System.Windows.Forms.Clipboard.Clear();
+        }
+
+        private string ConvertPdfToRtf(string htmlContent)
+        {
+            using (RichTextBox richTextBox = new RichTextBox())
+            {
+                // Load HTML into RichTextBox
+                richTextBox.Rtf = null;
+
+                // Get RTF content
+                string rtfContent = richTextBox.Rtf;
+
+                return rtfContent;
+            }
+        }
+
+        private string ProcessRemoteImages(string htmlContent)
+        {
+            // 匹配HTML中的img标签
+            Regex imgRegex = new Regex("<img.*?src=['\"](.*?)['\"].*?>", RegexOptions.IgnoreCase);
+
+            // 替换img标签中的远程图片链接
+            string processedHtml = imgRegex.Replace(htmlContent,   match =>
+            {
+                string imageUrl = match.Groups[1].Value;
+
+                // 下载远程图片并转为Base64
+                string base64Image = Task.Run(async () => await DownloadAndConvertToBase64(imageUrl)).Result;
+
+                // 返回Base64编码的图片数据作为替换
+                return $"<img src='data:image/jpeg;base64,{base64Image}' alt='Remote Image'>";
+            });
+
+            return processedHtml;
+        }
+        private async Task<string> DownloadAndConvertToBase64(string imageUrl)
+        {  // 设置支持 TLS 1.2
+            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+
+            // 下载远程图片的字节数组
+            byte[] imageBytes = await httpClient.GetByteArrayAsync(imageUrl);
+
+            // 转为Base64编码
+            string base64Image = Convert.ToBase64String(imageBytes);
+
+            return base64Image;
+        }
     }
 }

+ 20 - 0
HTEXMark/Properties/Resources.Designer.cs

@@ -80,6 +80,16 @@ namespace HTEXMark.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap 共享数据 {
+            get {
+                object obj = ResourceManager.GetObject("共享数据", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>
@@ -170,6 +180,16 @@ namespace HTEXMark.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap 学科网 {
+            get {
+                object obj = ResourceManager.GetObject("学科网", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>

+ 8 - 2
HTEXMark/Properties/Resources.resx

@@ -118,6 +118,9 @@
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  <data name="学科网" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Images\学科网.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
   <data name="作图题" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Images\作图题.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
@@ -196,6 +199,9 @@
   <data name="有序多选题" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Images\有序多选题.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="数据中心" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Images\数据中心.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
   <data name="知识点" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Images\知识点.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
@@ -208,7 +214,7 @@
   <data name="难度" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Images\难度.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
-  <data name="数据中心" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Images\数据中心.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  <data name="共享数据" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Images\共享数据.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
 </root>

+ 4 - 0
HTEXMark/app.config

@@ -14,6 +14,10 @@
         <assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
         <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
       </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
+      </dependentAssembly>
     </assemblyBinding>
   </runtime>
 </configuration>

+ 4 - 0
HTEXMark/packages.config

@@ -1,10 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="DocX" version="2.5.0" targetFramework="net48" />
+  <package id="HtmlRenderer.Core" version="1.5.1-beta1" targetFramework="net48" />
+  <package id="HtmlRenderer.WinForms" version="1.5.1-beta1" targetFramework="net48" />
   <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
   <package id="Microsoft.IdentityModel.Abstractions" version="7.2.0" targetFramework="net48" />
   <package id="Microsoft.IdentityModel.JsonWebTokens" version="7.2.0" targetFramework="net48" />
   <package id="Microsoft.IdentityModel.Logging" version="7.2.0" targetFramework="net48" />
   <package id="Microsoft.IdentityModel.Tokens" version="7.2.0" targetFramework="net48" />
+  <package id="PDFsharp" version="1.50.4000-beta3b" targetFramework="net48" />
   <package id="System.Buffers" version="4.5.1" targetFramework="net48" />
   <package id="System.IdentityModel.Tokens.Jwt" version="7.2.0" targetFramework="net48" />
   <package id="System.IO" version="4.3.0" targetFramework="net48" />