黄贺彬 1 year ago
parent
commit
8d1f503161
4 changed files with 94 additions and 22 deletions
  1. 3 1
      HTEXLabel/LableRibbon.cs
  2. 5 5
      HTEXMark/HTEXMark.csproj
  3. 31 1
      HTEXMark/MarkRibbon.Designer.cs
  4. 55 15
      HTEXMark/MarkRibbon.cs

+ 3 - 1
HTEXLabel/LableRibbon.cs

@@ -149,7 +149,9 @@ namespace HTEXLabel
                         break;
                 }
             }
-            else {
+           
+            else
+            {
                 selection.TypeText("{" + buttonTag + "}");
             }
         }

+ 5 - 5
HTEXMark/HTEXMark.csproj

@@ -101,7 +101,7 @@
   <ItemGroup>
     <Reference Include="Accessibility" />
     <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>F:\NuGet\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
+      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@@ -120,10 +120,10 @@
       <HintPath>F:\NuGet\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
     </Reference>
     <Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>F:\NuGet\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
+      <HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
     </Reference>
     <Reference Include="System.Text.Json, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>F:\NuGet\packages\System.Text.Json.8.0.1\lib\net462\System.Text.Json.dll</HintPath>
+      <HintPath>..\packages\System.Text.Json.8.0.1\lib\net462\System.Text.Json.dll</HintPath>
     </Reference>
     <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>F:\NuGet\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
@@ -138,10 +138,10 @@
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="zxing, Version=0.16.9.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
-      <HintPath>F:\NuGet\packages\ZXing.Net.0.16.9\lib\net48\zxing.dll</HintPath>
+      <HintPath>..\packages\ZXing.Net.0.16.9\lib\net48\zxing.dll</HintPath>
     </Reference>
     <Reference Include="zxing.presentation, Version=0.16.9.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
-      <HintPath>F:\NuGet\packages\ZXing.Net.0.16.9\lib\net48\zxing.presentation.dll</HintPath>
+      <HintPath>..\packages\ZXing.Net.0.16.9\lib\net48\zxing.presentation.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup>

+ 31 - 1
HTEXMark/MarkRibbon.Designer.cs

@@ -108,6 +108,7 @@ namespace HTEXMark
             this.single.Label = "单选题\n";
             this.single.Name = "single";
             this.single.ShowImage = true;
+            this.single.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // multiple
             // 
@@ -116,6 +117,7 @@ namespace HTEXMark
             this.multiple.Label = "多选题\n";
             this.multiple.Name = "multiple";
             this.multiple.ShowImage = true;
+            this.multiple.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // judge
             // 
@@ -124,6 +126,7 @@ namespace HTEXMark
             this.judge.Label = "判断题\n";
             this.judge.Name = "judge";
             this.judge.ShowImage = true;
+            this.judge.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // complete
             // 
@@ -132,6 +135,7 @@ namespace HTEXMark
             this.complete.Label = "填空题\n";
             this.complete.Name = "complete";
             this.complete.ShowImage = true;
+            this.complete.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // subjective
             // 
@@ -140,6 +144,7 @@ namespace HTEXMark
             this.subjective.Label = "问答题\n";
             this.subjective.Name = "subjective";
             this.subjective.ShowImage = true;
+            this.subjective.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // connector
             // 
@@ -148,6 +153,7 @@ namespace HTEXMark
             this.connector.Label = "连线题\n";
             this.connector.Name = "connector";
             this.connector.ShowImage = true;
+            this.connector.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // correct
             // 
@@ -156,6 +162,7 @@ namespace HTEXMark
             this.correct.Label = "改错题\n";
             this.correct.Name = "correct";
             this.correct.ShowImage = true;
+            this.correct.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // draw
             // 
@@ -164,6 +171,7 @@ namespace HTEXMark
             this.draw.Label = "作图题\n";
             this.draw.Name = "draw";
             this.draw.ShowImage = true;
+            this.draw.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // compose
             // 
@@ -172,6 +180,7 @@ namespace HTEXMark
             this.compose.Label = "综合题\n";
             this.compose.Name = "compose";
             this.compose.ShowImage = true;
+            this.compose.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // sortmultiple
             // 
@@ -180,6 +189,7 @@ namespace HTEXMark
             this.sortmultiple.Label = "有序多选题\n";
             this.sortmultiple.Name = "sortmultiple";
             this.sortmultiple.ShowImage = true;
+            this.sortmultiple.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // item_taxonomy
             // 
@@ -192,6 +202,7 @@ namespace HTEXMark
             this.item_taxonomy.Items.Add(this.taxonomy);
             this.item_taxonomy.Label = "认知层次";
             this.item_taxonomy.Name = "item_taxonomy";
+           
             // 
             // remember
             // 
@@ -200,6 +211,7 @@ namespace HTEXMark
             this.remember.Label = "记忆\n";
             this.remember.Name = "remember";
             this.remember.ShowImage = true;
+            this.remember.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // understand
             // 
@@ -208,6 +220,7 @@ namespace HTEXMark
             this.understand.Label = "理解\n";
             this.understand.Name = "understand";
             this.understand.ShowImage = true;
+            this.understand.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // apply
             // 
@@ -216,6 +229,7 @@ namespace HTEXMark
             this.apply.Label = "应用\n";
             this.apply.Name = "apply";
             this.apply.ShowImage = true;
+            this.apply.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // analyze
             // 
@@ -224,6 +238,7 @@ namespace HTEXMark
             this.analyze.Label = "分析\n";
             this.analyze.Name = "analyze";
             this.analyze.ShowImage = true;
+            this.analyze.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // evaluate
             // 
@@ -232,6 +247,7 @@ namespace HTEXMark
             this.evaluate.Label = "评价\n";
             this.evaluate.Name = "evaluate";
             this.evaluate.ShowImage = true;
+            this.evaluate.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // create
             // 
@@ -240,6 +256,7 @@ namespace HTEXMark
             this.create.Label = "创造\n";
             this.create.Name = "create";
             this.create.ShowImage = true;
+            this.create.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // taxonomy
             // 
@@ -248,6 +265,7 @@ namespace HTEXMark
             this.taxonomy.Label = "认知层次\n";
             this.taxonomy.Name = "taxonomy";
             this.taxonomy.ShowImage = true;
+            this.taxonomy.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // item_tool
             // 
@@ -270,6 +288,7 @@ namespace HTEXMark
             this.answer.Label = "答案\n";
             this.answer.Name = "answer";
             this.answer.ShowImage = true;
+            this.answer.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // analysis
             // 
@@ -278,6 +297,7 @@ namespace HTEXMark
             this.analysis.Label = "解析\n";
             this.analysis.Name = "analysis";
             this.analysis.ShowImage = true;
+            this.analysis.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // score
             // 
@@ -286,6 +306,7 @@ namespace HTEXMark
             this.score.Label = "配分\n";
             this.score.Name = "score";
             this.score.ShowImage = true;
+            this.score.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // point
             // 
@@ -294,6 +315,7 @@ namespace HTEXMark
             this.point.Label = "知识点\n";
             this.point.Name = "point";
             this.point.ShowImage = true;
+            this.point.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // itrue
             // 
@@ -302,6 +324,7 @@ namespace HTEXMark
             this.itrue.Label = "对\n";
             this.itrue.Name = "itrue";
             this.itrue.ShowImage = true;
+            this.itrue.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // ifalse
             // 
@@ -310,6 +333,7 @@ namespace HTEXMark
             this.ifalse.Label = "错\n";
             this.ifalse.Name = "ifalse";
             this.ifalse.ShowImage = true;
+            this.ifalse.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // ended
             // 
@@ -318,6 +342,7 @@ namespace HTEXMark
             this.ended.Label = "结束\n";
             this.ended.Name = "ended";
             this.ended.ShowImage = true;
+            this.ended.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // level
             // 
@@ -326,6 +351,7 @@ namespace HTEXMark
             this.level.Label = "难度\n";
             this.level.Name = "level";
             this.level.ShowImage = true;
+            this.level.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // count
             // 
@@ -334,6 +360,7 @@ namespace HTEXMark
             this.count.Label = "填空数\n";
             this.count.Name = "count";
             this.count.ShowImage = true;
+            this.count.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // item_user
             // 
@@ -341,6 +368,7 @@ namespace HTEXMark
             this.item_user.Items.Add(this.user);
             this.item_user.Label = "用户信息";
             this.item_user.Name = "item_user";
+           
             // 
             // qrcode
             // 
@@ -349,6 +377,7 @@ namespace HTEXMark
             this.qrcode.Label = "登录\n";
             this.qrcode.Name = "qrcode";
             this.qrcode.ShowImage = true;
+            this.qrcode.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // user
             // 
@@ -356,8 +385,9 @@ namespace HTEXMark
             this.user.Image = global::HTEXMark.Properties.Resources.教师;
             this.user.Label = "用户\n";
             this.user.Name = "user";
-            this.user.Visible=false;
             this.user.ShowImage = true;
+            this.user.Visible = false;
+            this.user.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.MarkTags_Click);
             // 
             // MarkRibbon
             // 

+ 55 - 15
HTEXMark/MarkRibbon.cs

@@ -8,6 +8,7 @@ using System.Linq;
 using System.Reflection;
 using System.Text;
 using System.Text.Json;
+using System.Windows.Forms;
 namespace HTEXMark
 {
     public partial class MarkRibbon
@@ -133,26 +134,65 @@ namespace HTEXMark
 
 
         }
-        private static string GetResourceText(string resourceName)
-        {
+     
 
-            Assembly asm = Assembly.GetExecutingAssembly();
-            string[] resourceNames = asm.GetManifestResourceNames();
-            for (int i = 0; i < resourceNames.Length; ++i)
+        private void MarkTags_Click(object sender, RibbonControlEventArgs e)
+        {  // 在这里根据按钮的标识执行相应的操作
+            var button = sender as  RibbonButton;
+            string buttonId = button.Id;
+            string buttonTag = button.Tag.ToString();
+            Microsoft.Office.Interop.Word.Selection selection = Globals.ThisAddIn.Application.Selection;
+            if (buttonId.Equals("compose"))
             {
-                if (string.Compare(resourceName, resourceNames[i], StringComparison.OrdinalIgnoreCase) == 0)
+                // 获取 Office 应用程序的语言设置
+                LanguageSettings languageSettings = Globals.ThisAddIn.Application.LanguageSettings;
+                // 获取主语言 ID
+                int languageId = languageSettings.get_LanguageID(MsoAppLanguageID.msoLanguageIDUI);
+                // 判断语言版本
+                switch (languageId)
                 {
-                    using (StreamReader resourceReader = new StreamReader(asm.GetManifestResourceStream(resourceNames[i])))
-                    {
-                        if (resourceReader != null)
-                        {
-                            return resourceReader.ReadToEnd();
-                        }
-                    }
+                    case 2052:
+                        // 2052 是简体中文的语言 ID
+                        selection.TypeText("{" + buttonTag + "}{综合题结束}"); break;
+                    case 1028:
+                        // 1028 是繁体中文的语言 ID
+                        selection.TypeText("{" + buttonTag + "}{題組題結束}"); break;
+                    case 1033:
+                        // 1033 是英语的语言 ID
+                        selection.TypeText("{" + buttonTag + "}{QuestionGroupEnded}"); break;
+                    default:
+                        // System.Windows.Forms.MessageBox.Show("未知的 Office 语言版本:" + languageId.ToString());
+                        selection.TypeText("{" + buttonTag + "}");
+                        break;
                 }
             }
-            return null;
+            else if (buttonId.Equals("ended")) {
+                // 获取 Office 应用程序的语言设置
+                LanguageSettings languageSettings = Globals.ThisAddIn.Application.LanguageSettings;
+                // 获取主语言 ID
+                int languageId = languageSettings.get_LanguageID(MsoAppLanguageID.msoLanguageIDUI);
+                // 判断语言版本
+                switch (languageId)
+                {
+                    case 2052:
+                        // 2052 是简体中文的语言 ID
+                        selection.TypeText("{综合题结束}"); break;
+                    case 1028:
+                        // 1028 是繁体中文的语言 ID
+                        selection.TypeText("{題組題結束}"); break;
+                    case 1033:
+                        // 1033 是英语的语言 ID
+                        selection.TypeText("{QuestionGroupEnded}"); break;
+                    default:
+                        // System.Windows.Forms.MessageBox.Show("未知的 Office 语言版本:" + languageId.ToString());
+                        selection.TypeText("{QuestionGroupEnded}");
+                        break;
+                }
+            }
+            else
+            {
+                selection.TypeText("{" + buttonTag + "}");
+            }
         }
-
     }
 }