first commit
This commit is contained in:
commit
9b55e8b683
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/node_modules/
|
||||||
|
bin
|
BIN
.vs/ProjectEvaluation/testwordaddin1.metadata.v7.bin
Normal file
BIN
.vs/ProjectEvaluation/testwordaddin1.metadata.v7.bin
Normal file
Binary file not shown.
BIN
.vs/ProjectEvaluation/testwordaddin1.projects.v7.bin
Normal file
BIN
.vs/ProjectEvaluation/testwordaddin1.projects.v7.bin
Normal file
Binary file not shown.
BIN
.vs/TestWordAddIn1/DesignTimeBuild/.dtbcache.v2
Normal file
BIN
.vs/TestWordAddIn1/DesignTimeBuild/.dtbcache.v2
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.vs/TestWordAddIn1/v17/.futdcache.v2
Normal file
BIN
.vs/TestWordAddIn1/v17/.futdcache.v2
Normal file
Binary file not shown.
BIN
.vs/TestWordAddIn1/v17/.suo
Normal file
BIN
.vs/TestWordAddIn1/v17/.suo
Normal file
Binary file not shown.
37
TestWordAddIn1.sln
Normal file
37
TestWordAddIn1.sln
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.5.33516.290
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWordAddIn1", "TestWordAddIn1\TestWordAddIn1.csproj", "{E12FB108-CC54-49E3-B606-872B9805F9FA}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Webview2WinFormsApp", "Webview2WinFormsApp\Webview2WinFormsApp.csproj", "{283CE9EF-73B6-478A-B177-1B9174220C35}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UtilLib", "UtilLib\UtilLib.csproj", "{724D79C5-93B5-4BD7-9964-A05CCEFD3BFA}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E12FB108-CC54-49E3-B606-872B9805F9FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E12FB108-CC54-49E3-B606-872B9805F9FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E12FB108-CC54-49E3-B606-872B9805F9FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E12FB108-CC54-49E3-B606-872B9805F9FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{283CE9EF-73B6-478A-B177-1B9174220C35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{283CE9EF-73B6-478A-B177-1B9174220C35}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{283CE9EF-73B6-478A-B177-1B9174220C35}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{283CE9EF-73B6-478A-B177-1B9174220C35}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{724D79C5-93B5-4BD7-9964-A05CCEFD3BFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{724D79C5-93B5-4BD7-9964-A05CCEFD3BFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{724D79C5-93B5-4BD7-9964-A05CCEFD3BFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{724D79C5-93B5-4BD7-9964-A05CCEFD3BFA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {7C87838C-07BB-41AF-9F47-1F995065934E}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
13
TestWordAddIn1/AppConfig.cs
Normal file
13
TestWordAddIn1/AppConfig.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public class AppConfig
|
||||||
|
{
|
||||||
|
public static readonly string PanelName = "校对王";
|
||||||
|
}
|
||||||
|
}
|
16
TestWordAddIn1/Bridge.cs
Normal file
16
TestWordAddIn1/Bridge.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public class Bridge
|
||||||
|
{
|
||||||
|
public void Test()
|
||||||
|
{
|
||||||
|
System.Windows.Forms.MessageBox.Show("Test on C# Bridge!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
TestWordAddIn1/Enums.cs
Normal file
17
TestWordAddIn1/Enums.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public enum OfficeType
|
||||||
|
{
|
||||||
|
Word,
|
||||||
|
WPS
|
||||||
|
}
|
||||||
|
internal class Enums
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
92
TestWordAddIn1/Form1.Designer.cs
generated
Normal file
92
TestWordAddIn1/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
|
this.panel1 = new System.Windows.Forms.Panel();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
|
this.panel1.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBox1
|
||||||
|
//
|
||||||
|
this.pictureBox1.BackgroundImage = global::TestWordAddIn1.Properties.Resources.android_chrome_192x192;
|
||||||
|
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||||
|
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
|
this.pictureBox1.Size = new System.Drawing.Size(800, 200);
|
||||||
|
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
this.pictureBox1.TabIndex = 0;
|
||||||
|
this.pictureBox1.TabStop = false;
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
this.panel1.Controls.Add(this.button1);
|
||||||
|
this.panel1.Controls.Add(this.pictureBox1);
|
||||||
|
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.panel1.Name = "panel1";
|
||||||
|
this.panel1.Size = new System.Drawing.Size(800, 450);
|
||||||
|
this.panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Font = new System.Drawing.Font("微软雅黑", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.button1.Location = new System.Drawing.Point(307, 206);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(181, 62);
|
||||||
|
this.button1.TabIndex = 1;
|
||||||
|
this.button1.Text = "button1";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.panel1);
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
|
this.panel1.ResumeLayout(false);
|
||||||
|
this.panel1.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.PictureBox pictureBox1;
|
||||||
|
private System.Windows.Forms.Panel panel1;
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
}
|
||||||
|
}
|
25
TestWordAddIn1/Form1.cs
Normal file
25
TestWordAddIn1/Form1.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Test");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TestWordAddIn1/Form1.resx
Normal file
120
TestWordAddIn1/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
23
TestWordAddIn1/Http.cs
Normal file
23
TestWordAddIn1/Http.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
internal class Http
|
||||||
|
{
|
||||||
|
public static String Get(string url)
|
||||||
|
{
|
||||||
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
var res = req.GetResponse();
|
||||||
|
using (var reader = new StreamReader(res.GetResponseStream()))
|
||||||
|
{
|
||||||
|
return reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
145
TestWordAddIn1/ProofreadItem.cs
Normal file
145
TestWordAddIn1/ProofreadItem.cs
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
using Microsoft.Office.Interop.Word;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using UtilLib;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public partial class ProofreadItem : UserControl
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly Color BG_NORMAL = Color.WhiteSmoke;
|
||||||
|
private readonly Color BG_HOVER = Color.AliceBlue;
|
||||||
|
private readonly Color BG_ACTIVE = Color.AliceBlue;
|
||||||
|
private DiffItem diffItem;
|
||||||
|
private int currentStart;
|
||||||
|
private Document document;
|
||||||
|
private Bookmark bookmark;
|
||||||
|
private bool processed = false;
|
||||||
|
|
||||||
|
public ProofreadItem()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.BackColor = BG_NORMAL;
|
||||||
|
this.document = Globals.ThisAddIn.Application.ActiveDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProofreadItem_MouseEnter(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.BackColor = BG_HOVER;
|
||||||
|
Console.WriteLine("ProofreadItem_MouseEnter");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProofreadItem_MouseLeave(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.BackColor = BG_NORMAL;
|
||||||
|
Console.WriteLine("ProofreadItem_MouseLeave");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProofreadItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.BackColor = BG_ACTIVE;
|
||||||
|
Console.WriteLine("ProofreadItem_Click");
|
||||||
|
}
|
||||||
|
private void AddBookmark(Color color)
|
||||||
|
{
|
||||||
|
int rangeStart = this.currentStart + this.diffItem.Start,
|
||||||
|
rangeEnd = this.currentStart + this.diffItem.End;
|
||||||
|
|
||||||
|
Range r = this.document.Range(rangeStart, rangeEnd);
|
||||||
|
|
||||||
|
this.bookmark = this.document.Bookmarks.Add("mark_" + this.diffItem.Id, r);
|
||||||
|
if (this.diffItem.Tag != "i")
|
||||||
|
{
|
||||||
|
r.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProofreadItem(DiffItem it, int start)
|
||||||
|
{
|
||||||
|
this.diffItem = it;
|
||||||
|
this.currentStart = start;
|
||||||
|
this.ProcessView();
|
||||||
|
|
||||||
|
var typeConfig = TypeConfig.Get(it.Type);
|
||||||
|
type.Text = typeConfig.Text;
|
||||||
|
type.Visible = false;
|
||||||
|
var c = Colors.FromHex(typeConfig.Color);
|
||||||
|
typePanel.BackColor = c;
|
||||||
|
//if (it.Tag != "i")
|
||||||
|
//{
|
||||||
|
AddBookmark(c);
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (it.Type == ProofreadType.blackWord
|
||||||
|
|| it.Type == ProofreadType.blackWordBlock
|
||||||
|
|| it.Type == ProofreadType.sensitive)
|
||||||
|
{
|
||||||
|
description.Text = "【敏感词】建议查看";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (it.Tag == "r")
|
||||||
|
{
|
||||||
|
origin.Text = it.Origin + ">" + it.Text;
|
||||||
|
description.Text = string.Format("【{0}】建议选用“{1}”", typeConfig.Text, it.Text);
|
||||||
|
}
|
||||||
|
else if (it.Tag == "i")
|
||||||
|
{
|
||||||
|
origin.Text = it.Text + " 新增";
|
||||||
|
description.Text = string.Format("【{0}】建议新增", typeConfig.Text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
origin.Text = it.Origin + " 删除";
|
||||||
|
description.Text = string.Format("【{0}】建议删除", typeConfig.Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessView()
|
||||||
|
{
|
||||||
|
var showBtn = this.diffItem.IsAccept == AcceptEnum.Default;
|
||||||
|
btnAccept.Visible = showBtn;
|
||||||
|
btnIgnore.Visible = showBtn;
|
||||||
|
processStatus.Visible = !showBtn;
|
||||||
|
if (!showBtn)
|
||||||
|
{
|
||||||
|
processStatus.Text = (this.diffItem.IsAccept == AcceptEnum.Accept) ? "已采纳" : "已忽略";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProofreadItem_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnIgnore_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.diffItem.IsAccept != AcceptEnum.Default) return;
|
||||||
|
this.diffItem.IsAccept = AcceptEnum.Ignore;
|
||||||
|
this.bookmark.Range.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic;
|
||||||
|
MessageBox.Show("忽略" + this.currentStart + this.diffItem.Text);
|
||||||
|
this.ProcessView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnAccept_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.diffItem.IsAccept != AcceptEnum.Default) return;
|
||||||
|
this.diffItem.IsAccept = AcceptEnum.Accept;
|
||||||
|
var rng = this.bookmark.Range;
|
||||||
|
rng.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic;
|
||||||
|
if (this.diffItem.Tag == "d")
|
||||||
|
{
|
||||||
|
rng.Delete();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rng.Text = this.diffItem.Text;
|
||||||
|
}
|
||||||
|
this.ProcessView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
147
TestWordAddIn1/ProofreadItem.designer.cs
generated
Normal file
147
TestWordAddIn1/ProofreadItem.designer.cs
generated
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
partial class ProofreadItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.origin = new System.Windows.Forms.Label();
|
||||||
|
this.type = new System.Windows.Forms.Label();
|
||||||
|
this.description = new System.Windows.Forms.Label();
|
||||||
|
this.btnAccept = new System.Windows.Forms.Button();
|
||||||
|
this.btnIgnore = new System.Windows.Forms.Button();
|
||||||
|
this.typePanel = new System.Windows.Forms.Panel();
|
||||||
|
this.processStatus = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// origin
|
||||||
|
//
|
||||||
|
this.origin.AutoSize = true;
|
||||||
|
this.origin.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.origin.Location = new System.Drawing.Point(18, 10);
|
||||||
|
this.origin.Name = "origin";
|
||||||
|
this.origin.Size = new System.Drawing.Size(49, 20);
|
||||||
|
this.origin.TabIndex = 0;
|
||||||
|
this.origin.Text = "origin";
|
||||||
|
//
|
||||||
|
// type
|
||||||
|
//
|
||||||
|
this.type.AutoSize = true;
|
||||||
|
this.type.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.type.Location = new System.Drawing.Point(69, 11);
|
||||||
|
this.type.Name = "type";
|
||||||
|
this.type.Size = new System.Drawing.Size(38, 20);
|
||||||
|
this.type.TabIndex = 1;
|
||||||
|
this.type.Text = "type";
|
||||||
|
//
|
||||||
|
// description
|
||||||
|
//
|
||||||
|
this.description.AutoSize = true;
|
||||||
|
this.description.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.description.Location = new System.Drawing.Point(12, 36);
|
||||||
|
this.description.Name = "description";
|
||||||
|
this.description.Size = new System.Drawing.Size(84, 20);
|
||||||
|
this.description.TabIndex = 2;
|
||||||
|
this.description.Text = "description";
|
||||||
|
//
|
||||||
|
// btnAccept
|
||||||
|
//
|
||||||
|
this.btnAccept.BackgroundImage = global::TestWordAddIn1.Properties.Resources.check;
|
||||||
|
this.btnAccept.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.btnAccept.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btnAccept.Location = new System.Drawing.Point(222, 13);
|
||||||
|
this.btnAccept.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.btnAccept.Name = "btnAccept";
|
||||||
|
this.btnAccept.Size = new System.Drawing.Size(26, 26);
|
||||||
|
this.btnAccept.TabIndex = 3;
|
||||||
|
this.btnAccept.UseVisualStyleBackColor = true;
|
||||||
|
this.btnAccept.Click += new System.EventHandler(this.btnAccept_Click);
|
||||||
|
//
|
||||||
|
// btnIgnore
|
||||||
|
//
|
||||||
|
this.btnIgnore.BackgroundImage = global::TestWordAddIn1.Properties.Resources.minus_bold;
|
||||||
|
this.btnIgnore.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.btnIgnore.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btnIgnore.Location = new System.Drawing.Point(258, 13);
|
||||||
|
this.btnIgnore.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.btnIgnore.Name = "btnIgnore";
|
||||||
|
this.btnIgnore.Size = new System.Drawing.Size(26, 26);
|
||||||
|
this.btnIgnore.TabIndex = 4;
|
||||||
|
this.btnIgnore.UseVisualStyleBackColor = true;
|
||||||
|
this.btnIgnore.Click += new System.EventHandler(this.btnIgnore_Click);
|
||||||
|
//
|
||||||
|
// typePanel
|
||||||
|
//
|
||||||
|
this.typePanel.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.typePanel.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.typePanel.Name = "typePanel";
|
||||||
|
this.typePanel.Size = new System.Drawing.Size(4, 70);
|
||||||
|
this.typePanel.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// processStatus
|
||||||
|
//
|
||||||
|
this.processStatus.AutoSize = true;
|
||||||
|
this.processStatus.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.processStatus.Location = new System.Drawing.Point(222, 18);
|
||||||
|
this.processStatus.Name = "processStatus";
|
||||||
|
this.processStatus.Size = new System.Drawing.Size(50, 20);
|
||||||
|
this.processStatus.TabIndex = 6;
|
||||||
|
this.processStatus.Text = "label1";
|
||||||
|
//
|
||||||
|
// ProofreadItem
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||||
|
this.Controls.Add(this.processStatus);
|
||||||
|
this.Controls.Add(this.typePanel);
|
||||||
|
this.Controls.Add(this.btnIgnore);
|
||||||
|
this.Controls.Add(this.btnAccept);
|
||||||
|
this.Controls.Add(this.description);
|
||||||
|
this.Controls.Add(this.type);
|
||||||
|
this.Controls.Add(this.origin);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.Name = "ProofreadItem";
|
||||||
|
this.Size = new System.Drawing.Size(300, 70);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label origin;
|
||||||
|
private Label type;
|
||||||
|
private Label description;
|
||||||
|
private Button btnAccept;
|
||||||
|
private Button btnIgnore;
|
||||||
|
private Panel typePanel;
|
||||||
|
private Label processStatus;
|
||||||
|
}
|
||||||
|
}
|
120
TestWordAddIn1/ProofreadItem.resx
Normal file
120
TestWordAddIn1/ProofreadItem.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
79
TestWordAddIn1/ProofreadPanel.Designer.cs
generated
Normal file
79
TestWordAddIn1/ProofreadPanel.Designer.cs
generated
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
partial class ProofreadPanel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.panel1 = new System.Windows.Forms.Panel();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.BackColor = System.Drawing.SystemColors.HotTrack;
|
||||||
|
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.button1.ForeColor = System.Drawing.Color.White;
|
||||||
|
this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
this.button1.Location = new System.Drawing.Point(16, 14);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(117, 31);
|
||||||
|
this.button1.TabIndex = 0;
|
||||||
|
this.button1.Text = "开始校对";
|
||||||
|
this.button1.UseVisualStyleBackColor = false;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.panel1.AutoScroll = true;
|
||||||
|
this.panel1.Location = new System.Drawing.Point(16, 61);
|
||||||
|
this.panel1.Name = "panel1";
|
||||||
|
this.panel1.Size = new System.Drawing.Size(304, 606);
|
||||||
|
this.panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// ProofreadPanel
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.BackColor = System.Drawing.Color.White;
|
||||||
|
this.Controls.Add(this.panel1);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Name = "ProofreadPanel";
|
||||||
|
this.Size = new System.Drawing.Size(340, 686);
|
||||||
|
this.Load += new System.EventHandler(this.ProofreadPanel_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
private System.Windows.Forms.Panel panel1;
|
||||||
|
}
|
||||||
|
}
|
131
TestWordAddIn1/ProofreadPanel.cs
Normal file
131
TestWordAddIn1/ProofreadPanel.cs
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
using Microsoft.Office.Interop.Word;
|
||||||
|
using Microsoft.Web.WebView2.Core;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.ConstrainedExecution;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using UtilLib;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public partial class ProofreadPanel : UserControl
|
||||||
|
{
|
||||||
|
private CoreWebView2Environment env;
|
||||||
|
|
||||||
|
private readonly int ItemHeight = 75;
|
||||||
|
private readonly List<ProofreadItem> Items = new List<ProofreadItem>();
|
||||||
|
public ProofreadPanel()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProofreadPanel_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//InitWebview();
|
||||||
|
}
|
||||||
|
public void SendMessage(string action, object data)
|
||||||
|
{
|
||||||
|
//string json = JsonConvert.SerializeObject(new WebActionMessage(action, data));
|
||||||
|
//webView21.CoreWebView2.PostWebMessageAsJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public async void InitWebview()
|
||||||
|
//{
|
||||||
|
//if (env == null)
|
||||||
|
//{
|
||||||
|
// // 自定义环境位置
|
||||||
|
// env = await CoreWebView2Environment.CreateAsync(null, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/web/user_data");
|
||||||
|
// webView21.CoreWebView2InitializationCompleted += WebView21_CoreWebView2InitializationCompleted;
|
||||||
|
// await webView21.EnsureCoreWebView2Async(env);
|
||||||
|
//}
|
||||||
|
//webView21.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\web\\index.html");
|
||||||
|
////
|
||||||
|
//webView21.CoreWebView2.AddHostObjectToScript("bridge", new Bridge());
|
||||||
|
//}
|
||||||
|
|
||||||
|
private void WebView21_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void webView21_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var app = Globals.ThisAddIn.Application;
|
||||||
|
var doc = app.ActiveDocument;
|
||||||
|
var content = doc.Content.Text.Trim();
|
||||||
|
if (content.Length > 0)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("将会清空文档内容并加载示例内容,确定继续操作?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// doc.Select();
|
||||||
|
var rng = doc.Range(0, content.Length);
|
||||||
|
rng.Delete();
|
||||||
|
}
|
||||||
|
var result = API.GetProofreadResult();
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("加载数据失败,请重试");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var cur = app.Selection;
|
||||||
|
if (app.Options.Overtype)
|
||||||
|
{
|
||||||
|
// 禁用
|
||||||
|
app.Options.Overtype = false;
|
||||||
|
}
|
||||||
|
if (cur.Type != WdSelectionType.wdSelectionIP)
|
||||||
|
{
|
||||||
|
MessageBox.Show("异常");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
InitDocument(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitDocument(ProofreadResult result)
|
||||||
|
{
|
||||||
|
var app = Globals.ThisAddIn.Application;
|
||||||
|
var cur = app.Selection;
|
||||||
|
var doc = app.ActiveDocument;
|
||||||
|
int index = 0;
|
||||||
|
foreach (var correct in result.CorrectedSet)
|
||||||
|
{
|
||||||
|
cur.TypeText(correct.Insert);
|
||||||
|
var rng = cur.Range;
|
||||||
|
if (correct.Diffs != null)
|
||||||
|
{
|
||||||
|
foreach (var it in correct.Diffs)
|
||||||
|
{
|
||||||
|
ProofreadItem item = new ProofreadItem();
|
||||||
|
item.SetProofreadItem(it, correct.Offset);
|
||||||
|
Items.Add(item);
|
||||||
|
if (it.Tag == "d")
|
||||||
|
{
|
||||||
|
var curg = doc.Range(correct.Offset + it.Start, correct.Offset + it.End);
|
||||||
|
// 设置玄宗效果
|
||||||
|
}
|
||||||
|
item.Location = new System.Drawing.Point(10, (ItemHeight + 10) * index);
|
||||||
|
panel1.Controls.Add(item);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TestWordAddIn1/ProofreadPanel.resx
Normal file
120
TestWordAddIn1/ProofreadPanel.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
38
TestWordAddIn1/Properties/AssemblyInfo.cs
Normal file
38
TestWordAddIn1/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security;
|
||||||
|
|
||||||
|
// 有关程序集的一般信息由以下
|
||||||
|
// 控制。更改这些特性值可修改
|
||||||
|
// 与程序集关联的信息。
|
||||||
|
[assembly: AssemblyTitle("TestWordAddIn1")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("TestWordAddIn1")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
//将 ComVisible 设置为 false 将使此程序集中的类型
|
||||||
|
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
||||||
|
//请将此类型的 ComVisible 特性设置为 true。
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||||
|
[assembly: Guid("1fa7f1e1-a05f-4129-a40d-62134d43270d")]
|
||||||
|
|
||||||
|
// 程序集的版本信息由下列四个值组成:
|
||||||
|
//
|
||||||
|
// 主版本
|
||||||
|
// 次版本
|
||||||
|
// 生成号
|
||||||
|
// 修订号
|
||||||
|
//
|
||||||
|
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||||
|
// 方法是按如下所示使用“*”: :
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
123
TestWordAddIn1/Properties/Resources.Designer.cs
generated
Normal file
123
TestWordAddIn1/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// 此代码由工具生成。
|
||||||
|
// 运行时版本:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||||
|
// 重新生成代码,这些更改将会丢失。
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace TestWordAddIn1.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||||
|
/// </summary>
|
||||||
|
// 此类是由 StronglyTypedResourceBuilder
|
||||||
|
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||||
|
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||||
|
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestWordAddIn1.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||||
|
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap android_chrome_192x192 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("android-chrome-192x192", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap check {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("check", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap favicon {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("favicon", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap minus_bold {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("minus-bold", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap search_check {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("search-check", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap search_proofread {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("search-proofread", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
139
TestWordAddIn1/Properties/Resources.resx
Normal file
139
TestWordAddIn1/Properties/Resources.resx
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<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="search-proofread" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\search-proofread.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="minus-bold" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\minus-bold.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="favicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\favicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="check" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\check.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="android-chrome-192x192" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\android-chrome-192x192.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="search-check" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\search-check.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
26
TestWordAddIn1/Properties/Settings.Designer.cs
generated
Normal file
26
TestWordAddIn1/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace TestWordAddIn1.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
TestWordAddIn1/Properties/Settings.settings
Normal file
7
TestWordAddIn1/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
BIN
TestWordAddIn1/Resources/android-chrome-192x192.png
Normal file
BIN
TestWordAddIn1/Resources/android-chrome-192x192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
TestWordAddIn1/Resources/check.png
Normal file
BIN
TestWordAddIn1/Resources/check.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
TestWordAddIn1/Resources/favicon.png
Normal file
BIN
TestWordAddIn1/Resources/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
TestWordAddIn1/Resources/minus-bold.png
Normal file
BIN
TestWordAddIn1/Resources/minus-bold.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 173 B |
BIN
TestWordAddIn1/Resources/search-check.png
Normal file
BIN
TestWordAddIn1/Resources/search-check.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 617 B |
BIN
TestWordAddIn1/Resources/search-proofread.png
Normal file
BIN
TestWordAddIn1/Resources/search-proofread.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
161
TestWordAddIn1/Ribbon1.Designer.cs
generated
Normal file
161
TestWordAddIn1/Ribbon1.Designer.cs
generated
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
partial class Ribbon1 : Microsoft.Office.Tools.Ribbon.RibbonBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
public Ribbon1()
|
||||||
|
: base(Globals.Factory.GetRibbonFactory())
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.tab1 = this.Factory.CreateRibbonTab();
|
||||||
|
this.group1 = this.Factory.CreateRibbonGroup();
|
||||||
|
this.button1 = this.Factory.CreateRibbonButton();
|
||||||
|
this.btnLoadDocument = this.Factory.CreateRibbonButton();
|
||||||
|
this.button3 = this.Factory.CreateRibbonButton();
|
||||||
|
this.group2 = this.Factory.CreateRibbonGroup();
|
||||||
|
this.btnProofread = this.Factory.CreateRibbonButton();
|
||||||
|
this.btnOpenForm = this.Factory.CreateRibbonButton();
|
||||||
|
this.button8 = this.Factory.CreateRibbonButton();
|
||||||
|
this.button6 = this.Factory.CreateRibbonButton();
|
||||||
|
this.tab1.SuspendLayout();
|
||||||
|
this.group1.SuspendLayout();
|
||||||
|
this.group2.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// tab1
|
||||||
|
//
|
||||||
|
this.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
|
||||||
|
this.tab1.Groups.Add(this.group1);
|
||||||
|
this.tab1.Groups.Add(this.group2);
|
||||||
|
this.tab1.Label = "测试加载项";
|
||||||
|
this.tab1.Name = "tab1";
|
||||||
|
//
|
||||||
|
// group1
|
||||||
|
//
|
||||||
|
this.group1.Items.Add(this.button1);
|
||||||
|
this.group1.Items.Add(this.btnLoadDocument);
|
||||||
|
this.group1.Items.Add(this.button3);
|
||||||
|
this.group1.Label = "分组1";
|
||||||
|
this.group1.Name = "group1";
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Label = "获取当前文本";
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// btnLoadDocument
|
||||||
|
//
|
||||||
|
this.btnLoadDocument.Label = "加载文档";
|
||||||
|
this.btnLoadDocument.Name = "btnLoadDocument";
|
||||||
|
this.btnLoadDocument.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button2_Click);
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
this.button3.Label = "插入";
|
||||||
|
this.button3.Name = "button3";
|
||||||
|
this.button3.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button3_Click);
|
||||||
|
//
|
||||||
|
// group2
|
||||||
|
//
|
||||||
|
this.group2.Items.Add(this.btnProofread);
|
||||||
|
this.group2.Items.Add(this.btnOpenForm);
|
||||||
|
this.group2.Items.Add(this.button8);
|
||||||
|
this.group2.Items.Add(this.button6);
|
||||||
|
this.group2.Label = "分组2";
|
||||||
|
this.group2.Name = "group2";
|
||||||
|
//
|
||||||
|
// btnProofread
|
||||||
|
//
|
||||||
|
this.btnProofread.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
|
this.btnProofread.Image = global::TestWordAddIn1.Properties.Resources.search_proofread;
|
||||||
|
this.btnProofread.Label = "开始校验";
|
||||||
|
this.btnProofread.Name = "btnProofread";
|
||||||
|
this.btnProofread.ShowImage = true;
|
||||||
|
this.btnProofread.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button4_Click);
|
||||||
|
//
|
||||||
|
// btnOpenForm
|
||||||
|
//
|
||||||
|
this.btnOpenForm.Image = global::TestWordAddIn1.Properties.Resources.favicon;
|
||||||
|
this.btnOpenForm.Label = "打开原生窗口";
|
||||||
|
this.btnOpenForm.Name = "btnOpenForm";
|
||||||
|
this.btnOpenForm.ShowImage = true;
|
||||||
|
this.btnOpenForm.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnOpenForm_Click);
|
||||||
|
//
|
||||||
|
// button8
|
||||||
|
//
|
||||||
|
this.button8.Label = "测试3";
|
||||||
|
this.button8.Name = "button8";
|
||||||
|
this.button8.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button8_Click);
|
||||||
|
//
|
||||||
|
// button6
|
||||||
|
//
|
||||||
|
this.button6.Label = "保存文档";
|
||||||
|
this.button6.Name = "button6";
|
||||||
|
this.button6.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button6_Click);
|
||||||
|
//
|
||||||
|
// Ribbon1
|
||||||
|
//
|
||||||
|
this.Name = "Ribbon1";
|
||||||
|
this.RibbonType = "Microsoft.Word.Document";
|
||||||
|
this.Tabs.Add(this.tab1);
|
||||||
|
this.Load += new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.Ribbon1_Load);
|
||||||
|
this.tab1.ResumeLayout(false);
|
||||||
|
this.tab1.PerformLayout();
|
||||||
|
this.group1.ResumeLayout(false);
|
||||||
|
this.group1.PerformLayout();
|
||||||
|
this.group2.ResumeLayout(false);
|
||||||
|
this.group2.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonTab tab1;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonGroup group1;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton button1;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnLoadDocument;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton button3;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonGroup group2;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnProofread;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnOpenForm;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton button8;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton button6;
|
||||||
|
}
|
||||||
|
|
||||||
|
partial class ThisRibbonCollection
|
||||||
|
{
|
||||||
|
internal Ribbon1 Ribbon1
|
||||||
|
{
|
||||||
|
get { return this.GetRibbon<Ribbon1>(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
175
TestWordAddIn1/Ribbon1.cs
Normal file
175
TestWordAddIn1/Ribbon1.cs
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
using Microsoft.Office.Interop.Word;
|
||||||
|
using Microsoft.Office.Tools.Ribbon;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using UtilLib;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public partial class Ribbon1
|
||||||
|
{
|
||||||
|
private Microsoft.Office.Interop.Word.Application wordApp;
|
||||||
|
private Document document;
|
||||||
|
|
||||||
|
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
|
||||||
|
{
|
||||||
|
wordApp = Globals.ThisAddIn.Application;
|
||||||
|
Console.WriteLine("插件加载完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void button1_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
var currentText = wordApp.ActiveDocument.Range().Text;
|
||||||
|
Debug.WriteLine(currentText);
|
||||||
|
|
||||||
|
System.Windows.Forms.MessageBox.Show("Test:" + currentText);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button4_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
// 开始校对
|
||||||
|
//var doc = wordApp.ActiveDocument;
|
||||||
|
//var content = doc.Content.Text.Trim();
|
||||||
|
//if (content.Length == 0)
|
||||||
|
//{
|
||||||
|
// System.Windows.Forms.MessageBox.Show("内容为空");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
Globals.ThisAddIn.SetPanelVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addMarks()
|
||||||
|
{
|
||||||
|
document = wordApp.ActiveDocument;
|
||||||
|
Range rng = document.Range(2, 4);
|
||||||
|
document.Bookmarks.Add("s24", rng);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnOpenForm_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
Form1 f1 = new Form1();
|
||||||
|
f1.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button8_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
//var paragrahs = wordApp.ActiveDocument.Paragraphs;
|
||||||
|
Document doc = wordApp.ActiveDocument;
|
||||||
|
object start = 0;
|
||||||
|
object end = 4;
|
||||||
|
System.Windows.Forms.MessageBox.Show("选择0,4");
|
||||||
|
// 设置区域位置
|
||||||
|
Range range = doc.Range(ref start, ref end); // 从 start(索引从0开始)到end前一个字符(不包含end)
|
||||||
|
range.Select(); // 选中区域
|
||||||
|
System.Windows.Forms.MessageBox.Show("即将全选");
|
||||||
|
wordApp.ActiveDocument.Select(); // 全选
|
||||||
|
var sentences = doc.Sentences;
|
||||||
|
System.Windows.Forms.MessageBox.Show("句子总计:" + sentences.Count);
|
||||||
|
if (sentences.Count >= 2)
|
||||||
|
{
|
||||||
|
System.Windows.Forms.MessageBox.Show("选中第2个句子");
|
||||||
|
var s2 = sentences[2]; // 句子的索引从1开始
|
||||||
|
doc.Range(s2.Start, s2.End).Select();
|
||||||
|
}
|
||||||
|
System.Windows.Forms.MessageBox.Show("选择2,5");
|
||||||
|
// 设置区域位置
|
||||||
|
Range rng = doc.Range(2, 5);
|
||||||
|
rng.Select(); //
|
||||||
|
System.Windows.Forms.MessageBox.Show("向后选择多2个字符");
|
||||||
|
// 按字符向后移动
|
||||||
|
rng.MoveEnd(WdUnits.wdCharacter, 2);
|
||||||
|
// 字符向前移动
|
||||||
|
//rng.MoveStart(WdUnits.wdCharacter, 2);
|
||||||
|
rng.Select();
|
||||||
|
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
// 选择第1段
|
||||||
|
rng = doc.Paragraphs[1].Range;
|
||||||
|
rng.Select();
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
rng.Collapse(WdCollapseDirection.wdCollapseEnd); // 折叠(wdCollapseEnd:向后,wdCollapseStart:向前)
|
||||||
|
System.Windows.Forms.MessageBox.Show("插入新字符");
|
||||||
|
rng.Text = "插入新字符";
|
||||||
|
rng.Select();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button6_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
wordApp.ActiveDocument.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button3_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
document = wordApp.ActiveDocument;
|
||||||
|
var txt = "在文档开头指定一个范围,并插入文本 New Text。\n再说一下这个问题哈";
|
||||||
|
Selection cur = wordApp.Selection;
|
||||||
|
if (cur.Type != WdSelectionType.wdSelectionIP)
|
||||||
|
{
|
||||||
|
MessageBox.Show("异常");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cur.TypeText(txt);
|
||||||
|
AddBookmark(1, 3, "#ff0000");
|
||||||
|
AddBookmark(4, 6, "#00ff00");
|
||||||
|
|
||||||
|
}
|
||||||
|
private Bookmark AddBookmark(int rangeStart, int rangeEnd,string color)
|
||||||
|
{
|
||||||
|
var doc = wordApp.ActiveDocument;
|
||||||
|
Range r = doc.Range(rangeStart, rangeEnd);
|
||||||
|
|
||||||
|
var mark = doc.Bookmarks.Add("mark_" + rangeStart + "_" + rangeEnd, r);
|
||||||
|
r.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(color));
|
||||||
|
return mark;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ProofreadResult GetSource()
|
||||||
|
{
|
||||||
|
|
||||||
|
var content = Http.Get("http://test.wx.wm-app.xyz/proofread.json");
|
||||||
|
var result = JsonConvert.DeserializeObject<Response<ProofreadResult>>(content);
|
||||||
|
return result.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载文档
|
||||||
|
private void button2_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
document = wordApp.ActiveDocument;
|
||||||
|
|
||||||
|
var cur = wordApp.Selection;
|
||||||
|
|
||||||
|
if (wordApp.Options.Overtype)
|
||||||
|
{
|
||||||
|
// 禁用
|
||||||
|
wordApp.Options.Overtype = false;
|
||||||
|
}
|
||||||
|
if (cur.Type != WdSelectionType.wdSelectionIP)
|
||||||
|
{
|
||||||
|
System.Windows.Forms.MessageBox.Show("异常");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var result = GetSource();
|
||||||
|
result.CorrectedSet.ForEach(it =>
|
||||||
|
{
|
||||||
|
cur.TypeText(it.Insert);
|
||||||
|
});
|
||||||
|
|
||||||
|
//for (int i = 0; i < 20; i++)
|
||||||
|
//{
|
||||||
|
// cur.TypeText("-->" + i);
|
||||||
|
// cur.TypeParagraph();
|
||||||
|
// Thread.Sleep(1000);
|
||||||
|
//}
|
||||||
|
//cur.TypeText("在文档开头指定一个范围,并插入文本 New Text。\n下面的代码示例可用于文档级自定义项。");
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TestWordAddIn1/Ribbon1.resx
Normal file
120
TestWordAddIn1/Ribbon1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
305
TestWordAddIn1/TestWordAddIn1.csproj
Normal file
305
TestWordAddIn1/TestWordAddIn1.csproj
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
<Project ToolsVersion="17.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<!--
|
||||||
|
This section defines project-level properties.
|
||||||
|
|
||||||
|
AssemblyName
|
||||||
|
Name of the output assembly.
|
||||||
|
Configuration
|
||||||
|
Specifies a default value for debug.
|
||||||
|
OutputType
|
||||||
|
Must be "Library" for VSTO.
|
||||||
|
Platform
|
||||||
|
Specifies what CPU the output of this project can run on.
|
||||||
|
NoStandardLibraries
|
||||||
|
Set to "false" for VSTO.
|
||||||
|
RootNamespace
|
||||||
|
In C#, this specifies the namespace given to new files. In VB, all objects are
|
||||||
|
wrapped in this namespace at runtime.
|
||||||
|
-->
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectTypeGuids>{BAA0C2D2-18E2-41B9-852F-F413020CAA33};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{E12FB108-CC54-49E3-B606-872B9805F9FA}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<NoStandardLibraries>false</NoStandardLibraries>
|
||||||
|
<RootNamespace>TestWordAddIn1</RootNamespace>
|
||||||
|
<AssemblyName>TestWordAddIn1</AssemblyName>
|
||||||
|
<LoadBehavior>3</LoadBehavior>
|
||||||
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
|
<DefineConstants>VSTO40</DefineConstants>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
<BootstrapperComponentsLocation>HomeSite</BootstrapperComponentsLocation>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.VSTORuntime.4.0">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Microsoft Visual Studio 2010 Tools for Office Runtime %28x86 and x64%29</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<!--
|
||||||
|
OfficeApplication
|
||||||
|
Add-in host application
|
||||||
|
-->
|
||||||
|
<OfficeApplication>Word</OfficeApplication>
|
||||||
|
</PropertyGroup>
|
||||||
|
<!--
|
||||||
|
This section defines properties that are set when the "Debug" configuration is selected.
|
||||||
|
|
||||||
|
DebugSymbols
|
||||||
|
If "true", create symbols (.pdb). If "false", do not create symbols.
|
||||||
|
DefineConstants
|
||||||
|
Constants defined for the preprocessor.
|
||||||
|
EnableUnmanagedDebugging
|
||||||
|
If "true", starting the debugger will attach both managed and unmanaged debuggers.
|
||||||
|
Optimize
|
||||||
|
If "true", optimize the build output. If "false", do not optimize.
|
||||||
|
OutputPath
|
||||||
|
Output path of project relative to the project file.
|
||||||
|
WarningLevel
|
||||||
|
Warning level for the compiler.
|
||||||
|
-->
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||||
|
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<!--
|
||||||
|
This section defines properties that are set when the "Release" configuration is selected.
|
||||||
|
|
||||||
|
DebugSymbols
|
||||||
|
If "true", create symbols (.pdb). If "false", do not create symbols.
|
||||||
|
DefineConstants
|
||||||
|
Constants defined for the preprocessor.
|
||||||
|
EnableUnmanagedDebugging
|
||||||
|
If "true", starting the debugger will attach both managed and unmanaged debuggers.
|
||||||
|
Optimize
|
||||||
|
If "true", optimize the build output. If "false", do not optimize.
|
||||||
|
OutputPath
|
||||||
|
Output path of project relative to the project file.
|
||||||
|
WarningLevel
|
||||||
|
Warning level for the compiler.
|
||||||
|
-->
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||||
|
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<!--
|
||||||
|
This section specifies references for the project.
|
||||||
|
-->
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Accessibility" />
|
||||||
|
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.2151.40, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.2151.40\lib\net45\Microsoft.Web.WebView2.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Web.WebView2.WinForms, Version=1.0.2151.40, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.2151.40\lib\net45\Microsoft.Web.WebView2.WinForms.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.2151.40, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.2151.40\lib\net45\Microsoft.Web.WebView2.Wpf.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Office.Tools.v4.0.Framework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.Tools.Applications.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Office.Tools, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Office.Tools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Office.Tools.Common.v4.0.Utilities, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
|
||||||
|
<Private>False</Private>
|
||||||
|
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
|
||||||
|
<Private>False</Private>
|
||||||
|
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<!--
|
||||||
|
This section defines the user source files that are part of the project.
|
||||||
|
|
||||||
|
A "Compile" element specifies a source file to compile.
|
||||||
|
An "EmbeddedResource" element specifies an .resx file for embedded resources.
|
||||||
|
A "None" element specifies a file that is not to be passed to the compiler (for instance,
|
||||||
|
a text file or XML file).
|
||||||
|
The "AppDesigner" element specifies the directory where the application properties files
|
||||||
|
can be found.
|
||||||
|
-->
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="AppConfig.cs" />
|
||||||
|
<Compile Include="Bridge.cs" />
|
||||||
|
<Compile Include="Enums.cs" />
|
||||||
|
<Compile Include="Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.cs">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Http.cs" />
|
||||||
|
<Compile Include="ProofreadItem.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ProofreadItem.designer.cs">
|
||||||
|
<DependentUpon>ProofreadItem.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ProofreadPanel.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ProofreadPanel.Designer.cs">
|
||||||
|
<DependentUpon>ProofreadPanel.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="ProofreadItem.resx">
|
||||||
|
<DependentUpon>ProofreadItem.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="ProofreadPanel.resx">
|
||||||
|
<DependentUpon>ProofreadPanel.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="Ribbon1.resx">
|
||||||
|
<DependentUpon>Ribbon1.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Ribbon1.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Ribbon1.Designer.cs">
|
||||||
|
<DependentUpon>Ribbon1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ThisAddIn.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<None Include="TestWordAddIn1_TemporaryKey.pfx" />
|
||||||
|
<None Include="ThisAddIn.Designer.xml">
|
||||||
|
<DependentUpon>ThisAddIn.cs</DependentUpon>
|
||||||
|
</None>
|
||||||
|
<Compile Include="ThisAddIn.Designer.cs">
|
||||||
|
<DependentUpon>ThisAddIn.Designer.xml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<AppDesigner Include="Properties\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\favicon.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\android-chrome-192x192.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\search-proofread.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UtilLib\UtilLib.csproj">
|
||||||
|
<Project>{724d79c5-93b5-4bd7-9964-a05ccefd3bfa}</Project>
|
||||||
|
<Name>UtilLib</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\minus-bold.png" />
|
||||||
|
<None Include="Resources\check.png" />
|
||||||
|
<None Include="Resources\search-check.png" />
|
||||||
|
<Content Include="web\index.html">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SignManifests>true</SignManifests>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ManifestKeyFile>TestWordAddIn1_TemporaryKey.pfx</ManifestKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ManifestCertificateThumbprint>0618754C31A0C743191F0D2976885003BA3EB202</ManifestCertificateThumbprint>
|
||||||
|
</PropertyGroup>
|
||||||
|
<!-- Include the build rules for a C# project. -->
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- Include additional build rules for an Office application add-in. -->
|
||||||
|
<Import Project="$(VSToolsPath)\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<!-- This section defines VSTO properties that describe the host-changeable project properties. -->
|
||||||
|
<ProjectExtensions>
|
||||||
|
<VisualStudio>
|
||||||
|
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
|
||||||
|
<ProjectProperties HostName="Word" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\16.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
|
||||||
|
<Host Name="Word" GeneratedCodeNamespace="TestWordAddIn1" IconIndex="0">
|
||||||
|
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
|
||||||
|
</Host>
|
||||||
|
</FlavorProperties>
|
||||||
|
</VisualStudio>
|
||||||
|
</ProjectExtensions>
|
||||||
|
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\Microsoft.Web.WebView2.targets')" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2151.40\build\Microsoft.Web.WebView2.targets'))" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
BIN
TestWordAddIn1/TestWordAddIn1_TemporaryKey.pfx
Normal file
BIN
TestWordAddIn1/TestWordAddIn1_TemporaryKey.pfx
Normal file
Binary file not shown.
237
TestWordAddIn1/ThisAddIn.Designer.cs
generated
Normal file
237
TestWordAddIn1/ThisAddIn.Designer.cs
generated
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma warning disable 414
|
||||||
|
namespace TestWordAddIn1 {
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
[Microsoft.VisualStudio.Tools.Applications.Runtime.StartupObjectAttribute(0)]
|
||||||
|
[global::System.Security.Permissions.PermissionSetAttribute(global::System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
|
||||||
|
public sealed partial class ThisAddIn : Microsoft.Office.Tools.AddInBase {
|
||||||
|
|
||||||
|
internal Microsoft.Office.Tools.CustomTaskPaneCollection CustomTaskPanes;
|
||||||
|
|
||||||
|
internal Microsoft.Office.Tools.SmartTagCollection VstoSmartTags;
|
||||||
|
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
private global::System.Object missing = global::System.Type.Missing;
|
||||||
|
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
internal Microsoft.Office.Interop.Word.Application Application;
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
public ThisAddIn(global::Microsoft.Office.Tools.Word.ApplicationFactory factory, global::System.IServiceProvider serviceProvider) :
|
||||||
|
base(factory, serviceProvider, "AddIn", "ThisAddIn") {
|
||||||
|
Globals.Factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
protected override void Initialize() {
|
||||||
|
base.Initialize();
|
||||||
|
this.Application = this.GetHostItem<Microsoft.Office.Interop.Word.Application>(typeof(Microsoft.Office.Interop.Word.Application), "Application");
|
||||||
|
Globals.ThisAddIn = this;
|
||||||
|
global::System.Windows.Forms.Application.EnableVisualStyles();
|
||||||
|
this.InitializeCachedData();
|
||||||
|
this.InitializeControls();
|
||||||
|
this.InitializeComponents();
|
||||||
|
this.InitializeData();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
protected override void FinishInitialization() {
|
||||||
|
this.InternalStartup();
|
||||||
|
this.OnStartup();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
protected override void InitializeDataBindings() {
|
||||||
|
this.BeginInitialization();
|
||||||
|
this.BindToData();
|
||||||
|
this.EndInitialization();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
private void InitializeCachedData() {
|
||||||
|
if ((this.DataHost == null)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.DataHost.IsCacheInitialized) {
|
||||||
|
this.DataHost.FillCachedData(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
private void InitializeData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
private void BindToData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
private void StartCaching(string MemberName) {
|
||||||
|
this.DataHost.StartCaching(this, MemberName);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
private void StopCaching(string MemberName) {
|
||||||
|
this.DataHost.StopCaching(this, MemberName);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
private bool IsCached(string MemberName) {
|
||||||
|
return this.DataHost.IsCached(this, MemberName);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
private void BeginInitialization() {
|
||||||
|
this.BeginInit();
|
||||||
|
this.CustomTaskPanes.BeginInit();
|
||||||
|
this.VstoSmartTags.BeginInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
private void EndInitialization() {
|
||||||
|
this.VstoSmartTags.EndInit();
|
||||||
|
this.CustomTaskPanes.EndInit();
|
||||||
|
this.EndInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
private void InitializeControls() {
|
||||||
|
this.CustomTaskPanes = Globals.Factory.CreateCustomTaskPaneCollection(null, null, "CustomTaskPanes", "CustomTaskPanes", this);
|
||||||
|
this.VstoSmartTags = Globals.Factory.CreateSmartTagCollection(null, null, "VstoSmartTags", "VstoSmartTags", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
private void InitializeComponents() {
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
private bool NeedsFill(string MemberName) {
|
||||||
|
return this.DataHost.NeedsFill(this, MemberName);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
|
protected override void OnShutdown() {
|
||||||
|
this.VstoSmartTags.Dispose();
|
||||||
|
this.CustomTaskPanes.Dispose();
|
||||||
|
base.OnShutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
internal sealed partial class Globals {
|
||||||
|
|
||||||
|
///
|
||||||
|
private Globals() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ThisAddIn _ThisAddIn;
|
||||||
|
|
||||||
|
private static global::Microsoft.Office.Tools.Word.ApplicationFactory _factory;
|
||||||
|
|
||||||
|
private static ThisRibbonCollection _ThisRibbonCollection;
|
||||||
|
|
||||||
|
internal static ThisAddIn ThisAddIn {
|
||||||
|
get {
|
||||||
|
return _ThisAddIn;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if ((_ThisAddIn == null)) {
|
||||||
|
_ThisAddIn = value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new System.NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static global::Microsoft.Office.Tools.Word.ApplicationFactory Factory {
|
||||||
|
get {
|
||||||
|
return _factory;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if ((_factory == null)) {
|
||||||
|
_factory = value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new System.NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static ThisRibbonCollection Ribbons {
|
||||||
|
get {
|
||||||
|
if ((_ThisRibbonCollection == null)) {
|
||||||
|
_ThisRibbonCollection = new ThisRibbonCollection(_factory.GetRibbonFactory());
|
||||||
|
}
|
||||||
|
return _ThisRibbonCollection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "17.0.0.0")]
|
||||||
|
internal sealed partial class ThisRibbonCollection : Microsoft.Office.Tools.Ribbon.RibbonCollectionBase {
|
||||||
|
|
||||||
|
///
|
||||||
|
internal ThisRibbonCollection(global::Microsoft.Office.Tools.Ribbon.RibbonFactory factory) :
|
||||||
|
base(factory) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
TestWordAddIn1/ThisAddIn.Designer.xml
Normal file
5
TestWordAddIn1/ThisAddIn.Designer.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<hostitem:hostItem hostitem:baseType="Microsoft.Office.Tools.AddInBase" hostitem:namespace="TestWordAddIn1" hostitem:className="ThisAddIn" hostitem:identifier="ThisAddIn" hostitem:primaryCookie="AddIn" hostitem:master="true" hostitem:factoryType="Microsoft.Office.Tools.Word.ApplicationFactory" hostitem:startupIndex="0" xmlns:hostitem="http://schemas.microsoft.com/2004/VisualStudio/Tools/Applications/HostItem.xsd">
|
||||||
|
<hostitem:hostObject hostitem:name="Application" hostitem:identifier="Application" hostitem:type="Microsoft.Office.Interop.Word.Application" hostitem:cookie="Application" hostitem:modifier="Internal" />
|
||||||
|
<hostitem:hostControl hostitem:name="CustomTaskPanes" hostitem:identifier="CustomTaskPanes" hostitem:type="Microsoft.Office.Tools.CustomTaskPaneCollection" hostitem:primaryCookie="CustomTaskPanes" hostitem:modifier="Internal" />
|
||||||
|
<hostitem:hostControl hostitem:name="VstoSmartTags" hostitem:identifier="VstoSmartTags" hostitem:type="Microsoft.Office.Tools.SmartTagCollection" hostitem:primaryCookie="VstoSmartTags" hostitem:modifier="Internal" />
|
||||||
|
</hostitem:hostItem>
|
215
TestWordAddIn1/ThisAddIn.cs
Normal file
215
TestWordAddIn1/ThisAddIn.cs
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using Microsoft.Office.Interop.Word;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CustomTaskPane = Microsoft.Office.Tools.CustomTaskPane;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TestWordAddIn1
|
||||||
|
{
|
||||||
|
public partial class ThisAddIn
|
||||||
|
{
|
||||||
|
|
||||||
|
public OfficeType officeType = OfficeType.Word;
|
||||||
|
public string applicationStartupPath;
|
||||||
|
public bool proofreadPanelOpen;
|
||||||
|
private ProofreadPanel proofreadPanel;
|
||||||
|
private Dictionary<Document, CustomTaskPane> myTaskPanes;
|
||||||
|
private CustomTaskPane myCustomTaskPane;
|
||||||
|
|
||||||
|
private void ThisAddIn_Startup(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
this.applicationStartupPath = System.Windows.Forms.Application.ProductName;
|
||||||
|
|
||||||
|
if (applicationStartupPath.Contains("WPS"))
|
||||||
|
{
|
||||||
|
this.officeType = OfficeType.WPS;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var eventInfo = new ComAwareEventInfo(typeof(ApplicationEvents4_Event), "DocumentOpen");
|
||||||
|
var handler = new ApplicationEvents4_DocumentOpenEventHandler(Application_DocumentOpen);
|
||||||
|
|
||||||
|
// 监听文档相关操作
|
||||||
|
//eventInfo.AddEventHandler(this, handler);
|
||||||
|
//new ComAwareEventInfo(typeof(ApplicationEvents4_Event), "NewDocument").AddEventHandler(Application, new ApplicationEvents4_NewDocumentEventHandler(Application_NewDocument));
|
||||||
|
//new ComAwareEventInfo(typeof(ApplicationEvents4_Event), "WindowActivate").AddEventHandler(Application, new ApplicationEvents4_WindowActivateEventHandler(Application_WindowActivate));
|
||||||
|
//new ComAwareEventInfo(typeof(ApplicationEvents4_Event), "WindowDeactivate").AddEventHandler(Application, new ApplicationEvents4_WindowDeactivateEventHandler(Application_WindowDeactivate));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 隐藏所有的面板
|
||||||
|
/// </summary>
|
||||||
|
void HideAllPane()
|
||||||
|
{
|
||||||
|
foreach (CustomTaskPane customTaskPane in CustomTaskPanes)
|
||||||
|
{
|
||||||
|
customTaskPane.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Application_NewDocument(Document doc)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Application_NewDocument");
|
||||||
|
InitProofreadPanel();
|
||||||
|
HideAllPane();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Application_DocumentOpen(Document doc)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Application_DocumentOpen");
|
||||||
|
InitProofreadPanel();
|
||||||
|
HideAllPane();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Application_DocumentChange()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Application_DocumentChange");
|
||||||
|
ShowTaskPaneForActiveDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowTaskPaneForActiveDocument()
|
||||||
|
{
|
||||||
|
// 获取当前文档
|
||||||
|
Document activeDocument = Application.ActiveDocument;
|
||||||
|
// 如果现有任务不包含文档则直接返回
|
||||||
|
if (!myTaskPanes.ContainsKey(activeDocument))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 显示当前文档panel隐藏其他文档panel
|
||||||
|
foreach (var item in myTaskPanes)
|
||||||
|
{
|
||||||
|
if (item.Key == activeDocument)
|
||||||
|
{
|
||||||
|
item.Value.Visible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.Value.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Application_WindowActivate_WPS(Document document, Window window)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Application_WindowActivate_WPS");
|
||||||
|
if (myCustomTaskPane == null)
|
||||||
|
{
|
||||||
|
InitProofreadPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Application_WindowActivate(Document document, Window window)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Application_WindowActivate");
|
||||||
|
//bool flag = true;
|
||||||
|
//if (myTaskPanes != null)
|
||||||
|
//{
|
||||||
|
// foreach (KeyValuePair<Document,CustomTaskPane> customTaskPane in myTaskPanes)
|
||||||
|
// {
|
||||||
|
// if (customTaskPane.Key == Application.ActiveDocument)
|
||||||
|
// {
|
||||||
|
// flag = false;
|
||||||
|
// myCustomTaskPane = customTaskPane.Value;
|
||||||
|
// proofreadPanel = userControls[Application.ActiveDocument];
|
||||||
|
// myCustomTaskPane.Visible = customTaskPanesVisible[Application.ActiveDocument];
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (flag)
|
||||||
|
// {
|
||||||
|
// NewCustomTaskPane();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// NewCustomTaskPane();
|
||||||
|
//}
|
||||||
|
//Globals.Ribbons.Ribbon.button_viewOn.Visible = !myCustomTaskPane.Visible;
|
||||||
|
//Globals.Ribbons.Ribbon.button_viewOff.Visible = myCustomTaskPane.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Application_WindowDeactivate(Document document, Window window)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Application_WindowDeactivate");
|
||||||
|
//if (customTaskPanesVisible.ContainsKey(document))
|
||||||
|
//{
|
||||||
|
// customTaskPanesVisible[document] = myCustomTaskPane.Visible;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// customTaskPanesVisible.Add(document, myCustomTaskPane.Visible);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 面板最小宽度
|
||||||
|
/// </summary>
|
||||||
|
private static readonly int MIN_WIDTH = 380;
|
||||||
|
|
||||||
|
void InitProofreadPanel()
|
||||||
|
{
|
||||||
|
if(this.myCustomTaskPane == null)
|
||||||
|
{
|
||||||
|
// 创建
|
||||||
|
proofreadPanel = new ProofreadPanel();
|
||||||
|
// 添加到panes
|
||||||
|
this.myCustomTaskPane = CustomTaskPanes.Add(proofreadPanel, AppConfig.PanelName);
|
||||||
|
// 先隐藏
|
||||||
|
this.myCustomTaskPane.Visible = false;
|
||||||
|
myCustomTaskPane.Width = MIN_WIDTH;
|
||||||
|
this.myCustomTaskPane.VisibleChanged += OnProofreadPanel_VisibleChange;
|
||||||
|
// 添加到集合
|
||||||
|
//this.myTaskPanes.Add(Application.ActiveDocument, this.myCustomTaskPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当面板的显示变化时
|
||||||
|
private void OnProofreadPanel_VisibleChange(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(this.myCustomTaskPane != null && myCustomTaskPane.Width < MIN_WIDTH)
|
||||||
|
{
|
||||||
|
this.myCustomTaskPane.Width = MIN_WIDTH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPanelVisible(bool open)
|
||||||
|
{
|
||||||
|
if (this.proofreadPanelOpen == open) return;
|
||||||
|
|
||||||
|
this.InitProofreadPanel();
|
||||||
|
this.proofreadPanelOpen = open;
|
||||||
|
this.myCustomTaskPane.Visible = this.proofreadPanelOpen;
|
||||||
|
}
|
||||||
|
public bool TogglePanelVisible()
|
||||||
|
{
|
||||||
|
this.proofreadPanelOpen = !this.proofreadPanelOpen;
|
||||||
|
this.myCustomTaskPane.Visible = this.proofreadPanelOpen;
|
||||||
|
return this.proofreadPanelOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region VSTO 生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InternalStartup()
|
||||||
|
{
|
||||||
|
this.Startup += new System.EventHandler(ThisAddIn_Startup);
|
||||||
|
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.Form1.resources
Normal file
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.Form1.resources
Normal file
Binary file not shown.
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.ProofreadItem.resources
Normal file
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.ProofreadItem.resources
Normal file
Binary file not shown.
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.ProofreadPanel.resources
Normal file
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.ProofreadPanel.resources
Normal file
Binary file not shown.
Binary file not shown.
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.Ribbon1.resources
Normal file
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.Ribbon1.resources
Normal file
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
46fabd4c02277f5287e9e4cc8a8baf270df54dfc
|
@ -0,0 +1,31 @@
|
|||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\TestWordAddIn1.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\TestWordAddIn1.pdb
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\TestWordAddIn1.dll.manifest
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\TestWordAddIn1.vsto
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Microsoft.Office.Tools.Common.v4.0.Utilities.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.csproj.AssemblyReference.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.Properties.Resources.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.Ribbon1.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.csproj.GenerateResource.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.csproj.CopyComplete
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.pdb
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.Form1.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Newtonsoft.Json.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Newtonsoft.Json.xml
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.ProofreadPanel.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\runtimes\win-x86\native\WebView2Loader.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\runtimes\win-x64\native\WebView2Loader.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\runtimes\win-arm64\native\WebView2Loader.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Microsoft.Web.WebView2.Core.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Microsoft.Web.WebView2.WinForms.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Microsoft.Web.WebView2.Wpf.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Microsoft.Web.WebView2.Core.xml
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Microsoft.Web.WebView2.WinForms.xml
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\Microsoft.Web.WebView2.Wpf.xml
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\web\index.html
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Debug\TestWordAddIn1.ProofreadItem.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\UtilLib.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\UtilLib.pdb
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Debug\UtilLib.dll.config
|
Binary file not shown.
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.dll
Normal file
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.dll
Normal file
Binary file not shown.
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.pdb
Normal file
BIN
TestWordAddIn1/obj/Debug/TestWordAddIn1.pdb
Normal file
Binary file not shown.
@ -0,0 +1,4 @@
|
|||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.Form1.resources
Normal file
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.Form1.resources
Normal file
Binary file not shown.
Binary file not shown.
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.Ribbon1.resources
Normal file
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.Ribbon1.resources
Normal file
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
487d1bb5458f1f46fd33ce520a82e0b8d2655794
|
@ -0,0 +1,14 @@
|
|||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Release\TestWordAddIn1.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Release\TestWordAddIn1.pdb
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Release\TestWordAddIn1.dll.manifest
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Release\TestWordAddIn1.vsto
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\bin\Release\Microsoft.Office.Tools.Common.v4.0.Utilities.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.csproj.AssemblyReference.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.Form1.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.Properties.Resources.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.Ribbon1.resources
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.csproj.GenerateResource.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.csproj.CopyComplete
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\TestWordAddIn1\obj\Release\TestWordAddIn1.pdb
|
Binary file not shown.
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.dll
Normal file
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.dll
Normal file
Binary file not shown.
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.pdb
Normal file
BIN
TestWordAddIn1/obj/Release/TestWordAddIn1.pdb
Normal file
Binary file not shown.
5
TestWordAddIn1/packages.config
Normal file
5
TestWordAddIn1/packages.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.Web.WebView2" version="1.0.2151.40" targetFramework="net462" />
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
|
||||||
|
</packages>
|
24
TestWordAddIn1/web/index.html
Normal file
24
TestWordAddIn1/web/index.html
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button onclick="sendToBehavior()">xxx</button>
|
||||||
|
<button onclick="testBridge()">xxx</button>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function sendToBehavior() {
|
||||||
|
window.postMessage(JSON.stringify({
|
||||||
|
code: 1, message: 'from web'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
function testBridge() {
|
||||||
|
console.log(window.bridge)
|
||||||
|
}
|
||||||
|
window.addEventListener('message', e => {
|
||||||
|
console.log('on-message', e)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
20
UtilLib/API.cs
Normal file
20
UtilLib/API.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class API
|
||||||
|
{
|
||||||
|
private static readonly string API_URL = "http://test.wx.wm-app.xyz/proofread.json";
|
||||||
|
public static ProofreadResult GetProofreadResult()
|
||||||
|
{
|
||||||
|
var content = Http.Get(API_URL);
|
||||||
|
var result = JsonConvert.DeserializeObject<Response<ProofreadResult>>(content);
|
||||||
|
return result.Data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
UtilLib/AcceptEnum.cs
Normal file
28
UtilLib/AcceptEnum.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public enum AcceptEnum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 默认(未处理)
|
||||||
|
/// </summary>
|
||||||
|
Default = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// 复核
|
||||||
|
/// </summary>
|
||||||
|
Review = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 采纳
|
||||||
|
/// </summary>
|
||||||
|
Accept = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 忽略
|
||||||
|
/// </summary>
|
||||||
|
Ignore = 3
|
||||||
|
}
|
||||||
|
}
|
6
UtilLib/App.config
Normal file
6
UtilLib/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
26
UtilLib/Colors.cs
Normal file
26
UtilLib/Colors.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class Colors
|
||||||
|
{
|
||||||
|
public static Color FromHex(string hex)
|
||||||
|
{
|
||||||
|
hex = hex.TrimStart('#');
|
||||||
|
int hexValue = Convert.ToInt32(hex, 16);
|
||||||
|
byte red = (byte)((hexValue >> 16) & 0xFF);
|
||||||
|
byte green = (byte)((hexValue >> 8) & 0xFF);
|
||||||
|
byte blue = (byte)(hexValue & 0xFF);
|
||||||
|
return FromRGB(red, green, blue);
|
||||||
|
}
|
||||||
|
public static Color FromRGB(byte red, byte green, byte blue)
|
||||||
|
{
|
||||||
|
return Color.FromArgb(red, green, blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
UtilLib/Correct.cs
Normal file
19
UtilLib/Correct.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class Correct
|
||||||
|
{
|
||||||
|
public string Key { get; set; }
|
||||||
|
public int Offset { get; set; }
|
||||||
|
public string New_text { get; set; }
|
||||||
|
public string Insert { get; set; }
|
||||||
|
public int Insert_len { get; set; }
|
||||||
|
|
||||||
|
public List<DiffItem> Diffs { get; set; }
|
||||||
|
}
|
||||||
|
}
|
21
UtilLib/DiffItem.cs
Normal file
21
UtilLib/DiffItem.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class DiffItem
|
||||||
|
{
|
||||||
|
public string Tag { get; set; }
|
||||||
|
public string Origin { get; set; }
|
||||||
|
public string Text { get; set; }
|
||||||
|
public int Start { get; set; }
|
||||||
|
public int End { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Idx { get; set; }
|
||||||
|
public AcceptEnum IsAccept { get; set; }
|
||||||
|
public ProofreadType Type { get; set; }
|
||||||
|
}
|
||||||
|
}
|
19
UtilLib/Http.cs
Normal file
19
UtilLib/Http.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
internal class Http
|
||||||
|
{
|
||||||
|
public static String Get(string url)
|
||||||
|
{
|
||||||
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
var res = req.GetResponse();
|
||||||
|
using (var reader = new StreamReader(res.GetResponseStream()))
|
||||||
|
{
|
||||||
|
return reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
UtilLib/ProofreadResult.cs
Normal file
30
UtilLib/ProofreadResult.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class ProofreadResult
|
||||||
|
{
|
||||||
|
public object AbnormalCount { get; set; }
|
||||||
|
public List<Correct> CorrectedSet { get; set; }
|
||||||
|
public object History { get; set; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
"id": 1326,
|
||||||
|
"isBlackWord": true,
|
||||||
|
"isOrigin": 2,
|
||||||
|
"isWhiteWord": true,
|
||||||
|
"name": "失业在家的日子-最新",
|
||||||
|
"status": 3
|
||||||
|
*/
|
||||||
|
public int Id { get; set; }
|
||||||
|
public bool IsBlackWord { get; set; }
|
||||||
|
public int IsOrigin { get; set; }
|
||||||
|
public bool IsWhiteWord { get; set; }
|
||||||
|
public int Status { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
72
UtilLib/ProofreadType.cs
Normal file
72
UtilLib/ProofreadType.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public enum ProofreadType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 未知
|
||||||
|
/// </summary>
|
||||||
|
unknown,
|
||||||
|
/// <summary>
|
||||||
|
/// 黑名单
|
||||||
|
/// </summary>
|
||||||
|
blackWord,
|
||||||
|
/**
|
||||||
|
* 字错
|
||||||
|
*/
|
||||||
|
characterError,
|
||||||
|
/**
|
||||||
|
* 词错
|
||||||
|
*/
|
||||||
|
wordError,
|
||||||
|
/**
|
||||||
|
* 数字错
|
||||||
|
*/
|
||||||
|
numberError,
|
||||||
|
/**
|
||||||
|
* 计量单位错
|
||||||
|
*/
|
||||||
|
unitsError,
|
||||||
|
/**
|
||||||
|
* 标点错
|
||||||
|
*/
|
||||||
|
punctuationError,
|
||||||
|
/**
|
||||||
|
* 语法错
|
||||||
|
*/
|
||||||
|
grammarError,
|
||||||
|
/**
|
||||||
|
* 知识性差错
|
||||||
|
*/
|
||||||
|
knowledgeableError,
|
||||||
|
/**
|
||||||
|
* 倾向性差错
|
||||||
|
*/
|
||||||
|
tendentiousError,
|
||||||
|
/**
|
||||||
|
* 不⼀致
|
||||||
|
*/
|
||||||
|
inconsistentError,
|
||||||
|
/**
|
||||||
|
* 格式错
|
||||||
|
*/
|
||||||
|
formatError,
|
||||||
|
/// <summary>
|
||||||
|
/// 敏感词
|
||||||
|
/// </summary>
|
||||||
|
sensitive,
|
||||||
|
/// <summary>
|
||||||
|
/// 黑名单-替换
|
||||||
|
/// </summary>
|
||||||
|
blackWordReplace = 14,
|
||||||
|
/// <summary>
|
||||||
|
/// 黑名单-拦截
|
||||||
|
/// </summary>
|
||||||
|
blackWordBlock = 15,
|
||||||
|
}
|
||||||
|
}
|
16
UtilLib/Response.cs
Normal file
16
UtilLib/Response.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class Response<T>
|
||||||
|
{
|
||||||
|
public int Code { get; set; }
|
||||||
|
public string Msg { get; set; }
|
||||||
|
public T Data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
83
UtilLib/TypeConfig.cs
Normal file
83
UtilLib/TypeConfig.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class TypeConfig
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
{id:[ProofreadTypeEnum.blackWord, ProofreadTypeEnum.blackWordBlock, ProofreadTypeEnum.blackWordReplace], type: 'black',acceptAll:[ProofreadTypeEnum.blackWordReplace],ignoreAll:[ProofreadTypeEnum.blackWordBlock, ProofreadTypeEnum.blackWordReplace], count: 0, text: '黑名单', color: '#2A2A2A',key:'blackWord'},
|
||||||
|
{id:ProofreadTypeEnum.characterError,type: 'char', count: 0, text: '提示', color: '#FD6643',key:'characterError'},
|
||||||
|
{ id: ProofreadTypeEnum.wordError,type: 'word', count: 0, text: '词错', color: '#29CEC0',key: 'wordError'},
|
||||||
|
{ id: ProofreadTypeEnum.numberError,type: 'number', count: 0, text: '数字错', color: '#c9c9c9',key: 'numberError'},
|
||||||
|
{ id: ProofreadTypeEnum.punctuationError,type: 'symbol', count: 0, text: '标点错', color: '#558CB7',key: 'punctuationError'},
|
||||||
|
{ id: ProofreadTypeEnum.unitsError,type: 'unit', count: 0, text: '计量单位错', color: '#77F1AE',key: 'unitsError'},
|
||||||
|
{ id: ProofreadTypeEnum.grammarError,type: 'syntax', count: 0, text: '语法错误', color: '#CDAFE5',key: 'grammarError'},
|
||||||
|
{ id: ProofreadTypeEnum.knowledgeableError,type: 'info', count: 0, text: '知识性错误', color: '#B2CCE6',key: 'knowledgeableError'},
|
||||||
|
{ id: ProofreadTypeEnum.tendentiousError,type: 'tendency', count: 0, text: '倾向性错误', color: '#E2AACA',key: 'tendentiousError'},
|
||||||
|
{ id: ProofreadTypeEnum.inconsistentError,type: 'inconsistent', count: 0, text: '不一致错误', color: '#E0AAAC',key: 'inconsistentError'},
|
||||||
|
{ id: ProofreadTypeEnum.formatError,type: 'format', count: 0, text: '格式错误', color: '#E9D0A7',key: 'formatError'},
|
||||||
|
{ id: ProofreadTypeEnum.sensitive,type: 'sensitive', count: 0, text: '敏感词', color: '#e971ba',key: 'sensitive'},
|
||||||
|
*/
|
||||||
|
public ProofreadType Type { get; set; }
|
||||||
|
public string Text { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Color { get; set; }
|
||||||
|
|
||||||
|
public static TypeConfig BlackWord = new TypeConfig(ProofreadType.blackWord, "黑名单", "black", "#2A2A2A");
|
||||||
|
public static TypeConfig BlackWordBlock = new TypeConfig(ProofreadType.blackWordBlock, "黑名单", "black", "#2A2A2A");
|
||||||
|
public static TypeConfig BlackWordReplace = new TypeConfig(ProofreadType.blackWordReplace, "黑名单", "black", "#2A2A2A");
|
||||||
|
public static TypeConfig CharacterError = new TypeConfig(ProofreadType.characterError, "提示", "characterError", "#FD6643");
|
||||||
|
public static TypeConfig WordError = new TypeConfig(ProofreadType.wordError, "词错", "wordError", "#29CEC0");
|
||||||
|
public static TypeConfig NumberError = new TypeConfig(ProofreadType.numberError, "数字错", "numberError", "#c9c9c9");
|
||||||
|
public static TypeConfig PunctuationError = new TypeConfig(ProofreadType.punctuationError, "标点错", "punctuationError", "#558CB7");
|
||||||
|
public static TypeConfig UnitsError = new TypeConfig(ProofreadType.unitsError, "计量单位错", "unitsError", "#77F1AE");
|
||||||
|
public static TypeConfig GrammarError = new TypeConfig(ProofreadType.grammarError, "语法错误", "grammarError", "#CDAFE5");
|
||||||
|
public static TypeConfig KnowledgeableError = new TypeConfig(ProofreadType.knowledgeableError, "知识性错误", "knowledgeableError", "#B2CCE6");
|
||||||
|
public static TypeConfig TendentiousError = new TypeConfig(ProofreadType.tendentiousError, "倾向性错误", "tendentiousError", "#E2AACA");
|
||||||
|
public static TypeConfig InconsistentError = new TypeConfig(ProofreadType.inconsistentError, "不一致错误", "inconsistentError", "#E0AAAC");
|
||||||
|
public static TypeConfig FormatError = new TypeConfig(ProofreadType.formatError, "格式错误", "formatError", "#E9D0A7");
|
||||||
|
public static TypeConfig Sensitive = new TypeConfig(ProofreadType.sensitive, "敏感词", "sensitive", "#e971ba");
|
||||||
|
|
||||||
|
private static Dictionary<ProofreadType, TypeConfig> AllTypeConfig = null;
|
||||||
|
|
||||||
|
public TypeConfig(ProofreadType type, string text, string name, string color)
|
||||||
|
{
|
||||||
|
this.Type = type;
|
||||||
|
this.Text = text;
|
||||||
|
this.Name = name;
|
||||||
|
this.Color = color;
|
||||||
|
}
|
||||||
|
public TypeConfig()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
static void Init()
|
||||||
|
{
|
||||||
|
if (AllTypeConfig != null) return;
|
||||||
|
AllTypeConfig = new Dictionary<ProofreadType, TypeConfig>();
|
||||||
|
AllTypeConfig.Add(ProofreadType.punctuationError, PunctuationError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.numberError, NumberError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.tendentiousError, TendentiousError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.wordError, WordError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.blackWord, BlackWord);
|
||||||
|
AllTypeConfig.Add(ProofreadType.blackWordBlock, BlackWordBlock);
|
||||||
|
AllTypeConfig.Add(ProofreadType.blackWordReplace, BlackWordReplace);
|
||||||
|
AllTypeConfig.Add(ProofreadType.characterError, CharacterError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.formatError, FormatError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.grammarError, GrammarError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.inconsistentError, InconsistentError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.knowledgeableError, KnowledgeableError);
|
||||||
|
AllTypeConfig.Add(ProofreadType.sensitive, Sensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TypeConfig Get(ProofreadType type)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
return AllTypeConfig[type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
UtilLib/UtilLib.csproj
Normal file
65
UtilLib/UtilLib.csproj
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{724D79C5-93B5-4BD7-9964-A05CCEFD3BFA}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<RootNamespace>UtilLib</RootNamespace>
|
||||||
|
<AssemblyName>UtilLib</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject />
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="AcceptEnum.cs" />
|
||||||
|
<Compile Include="API.cs" />
|
||||||
|
<Compile Include="Colors.cs" />
|
||||||
|
<Compile Include="Correct.cs" />
|
||||||
|
<Compile Include="DiffItem.cs" />
|
||||||
|
<Compile Include="Http.cs" />
|
||||||
|
<Compile Include="Response.cs" />
|
||||||
|
<Compile Include="ProofreadResult.cs" />
|
||||||
|
<Compile Include="ProofreadType.cs" />
|
||||||
|
<Compile Include="TypeConfig.cs" />
|
||||||
|
<Compile Include="WebActionMessage.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
22
UtilLib/WebActionMessage.cs
Normal file
22
UtilLib/WebActionMessage.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UtilLib
|
||||||
|
{
|
||||||
|
public class WebActionMessage
|
||||||
|
{
|
||||||
|
public WebActionMessage()
|
||||||
|
{ }
|
||||||
|
public WebActionMessage(string action, object data)
|
||||||
|
{
|
||||||
|
Action = action;
|
||||||
|
Data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Action { get; set; }
|
||||||
|
public object Data { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
|
BIN
UtilLib/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
BIN
UtilLib/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
Binary file not shown.
BIN
UtilLib/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
BIN
UtilLib/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
Binary file not shown.
BIN
UtilLib/obj/Debug/UtilLib.csproj.AssemblyReference.cache
Normal file
BIN
UtilLib/obj/Debug/UtilLib.csproj.AssemblyReference.cache
Normal file
Binary file not shown.
0
UtilLib/obj/Debug/UtilLib.csproj.CopyComplete
Normal file
0
UtilLib/obj/Debug/UtilLib.csproj.CopyComplete
Normal file
1
UtilLib/obj/Debug/UtilLib.csproj.CoreCompileInputs.cache
Normal file
1
UtilLib/obj/Debug/UtilLib.csproj.CoreCompileInputs.cache
Normal file
@ -0,0 +1 @@
|
|||||||
|
fb8f34c352a3d8044db8982ce7a7eb73c62ae6db
|
10
UtilLib/obj/Debug/UtilLib.csproj.FileListAbsolute.txt
Normal file
10
UtilLib/obj/Debug/UtilLib.csproj.FileListAbsolute.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\obj\Debug\UtilLib.csproj.AssemblyReference.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\obj\Debug\UtilLib.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\bin\Debug\UtilLib.dll.config
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\bin\Debug\UtilLib.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\bin\Debug\UtilLib.pdb
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\bin\Debug\Newtonsoft.Json.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\bin\Debug\Newtonsoft.Json.xml
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\obj\Debug\UtilLib.csproj.CopyComplete
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\obj\Debug\UtilLib.dll
|
||||||
|
C:\Users\home-dev\source\repos\TestWordAddIn1\UtilLib\obj\Debug\UtilLib.pdb
|
BIN
UtilLib/obj/Debug/UtilLib.dll
Normal file
BIN
UtilLib/obj/Debug/UtilLib.dll
Normal file
Binary file not shown.
BIN
UtilLib/obj/Debug/UtilLib.pdb
Normal file
BIN
UtilLib/obj/Debug/UtilLib.pdb
Normal file
Binary file not shown.
4
UtilLib/packages.config
Normal file
4
UtilLib/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
|
||||||
|
</packages>
|
119
Webview2WinFormsApp/AutoAdaptWindowsSize.cs
Normal file
119
Webview2WinFormsApp/AutoAdaptWindowsSize.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
//using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
|
||||||
|
namespace Webview2WinFormsApp
|
||||||
|
{
|
||||||
|
class AutoAdaptWindowsSize //窗口缩放对象
|
||||||
|
{
|
||||||
|
double formOriginalWidth;//窗体高度原始宽度
|
||||||
|
double formOriginalHeight;//窗体原始
|
||||||
|
double scaleX;//水平缩放比例
|
||||||
|
double scaleY;//垂直缩放比例
|
||||||
|
readonly Dictionary<string, string> ControlsInfo = new Dictionary<string, string>();//控件中心Left,Top,控件Width,控件Height,控件字体Size
|
||||||
|
|
||||||
|
private Form _form;
|
||||||
|
Panel Win_Panel1 = new Panel();
|
||||||
|
public AutoAdaptWindowsSize(Form form)
|
||||||
|
{
|
||||||
|
_form = form;
|
||||||
|
|
||||||
|
//代码生成一个容器panel1,添加至窗体
|
||||||
|
_form.Controls.Add(Win_Panel1);
|
||||||
|
Win_Panel1.BorderStyle = BorderStyle.None; //容器border样式
|
||||||
|
Win_Panel1.Dock = DockStyle.Fill; //设置填充,下面添加控件至容器完成后,容器会填充窗口
|
||||||
|
Win_Panel1.BackColor = Color.Transparent; // 这里默认的背景颜色是form的背景颜色,如果form页面时图片,需要将这里的颜色设置成透明,否则会被覆盖。
|
||||||
|
//将窗体所有控件添加至panel1
|
||||||
|
while (_form.Controls[0].Name.Trim() != "")
|
||||||
|
{
|
||||||
|
foreach (Control item in _form.Controls)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (item.Name.Trim() != "" && item.Name.Trim() != Win_Panel1.Name.Trim())
|
||||||
|
{
|
||||||
|
Win_Panel1.Controls.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存窗体和控件初始大小
|
||||||
|
InitControlsInfo(Win_Panel1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitControlsInfo(Control ctrlContainer)
|
||||||
|
{
|
||||||
|
if (ctrlContainer.Parent == _form)//获取窗体的高度和宽度
|
||||||
|
{
|
||||||
|
formOriginalWidth = Convert.ToDouble(ctrlContainer.Width);
|
||||||
|
formOriginalHeight = Convert.ToDouble(ctrlContainer.Height);
|
||||||
|
}
|
||||||
|
foreach (Control item in ctrlContainer.Controls)
|
||||||
|
{
|
||||||
|
if (item.Name.Trim() != "")
|
||||||
|
{
|
||||||
|
//添加信息:键值:控件名,内容:据左边距离,距顶部距离,控件宽度,控件高度,控件字体。
|
||||||
|
ControlsInfo.Add(item.Name, (item.Left + item.Width / 2) + "," + (item.Top + item.Height / 2) + "," + item.Width + "," + item.Height + "," + item.Font.Size);
|
||||||
|
}
|
||||||
|
if ((item as UserControl) == null && item.Controls.Count > 0)
|
||||||
|
{
|
||||||
|
InitControlsInfo(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void FormSizeChanged()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ControlsInfo.Count > 0)//如果字典中有数据,即窗体改变
|
||||||
|
{
|
||||||
|
ControlsZoomScale(Win_Panel1);//表示pannel控件
|
||||||
|
ControlsChange(Win_Panel1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
private void ControlsZoomScale(Control ctrlContainer)
|
||||||
|
{
|
||||||
|
scaleX = (Convert.ToDouble(ctrlContainer.Width) / formOriginalWidth);
|
||||||
|
scaleY = (Convert.ToDouble(ctrlContainer.Height) / formOriginalHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 改变控件大小
|
||||||
|
|
||||||
|
private void ControlsChange(Control ctrlContainer)
|
||||||
|
{
|
||||||
|
double[] pos = new double[5];//pos数组保存当前控件中心Left,Top,控件Width,控件Height,控件字体Size
|
||||||
|
foreach (Control item in ctrlContainer.Controls)//遍历控件
|
||||||
|
{
|
||||||
|
if (item.Name.Trim() != "")//如果控件名不是空,则执行
|
||||||
|
{
|
||||||
|
if ((item as UserControl) == null && item.Controls.Count > 0)//如果不是自定义控件
|
||||||
|
{
|
||||||
|
ControlsChange(item);//循环执行
|
||||||
|
}
|
||||||
|
string[] strs = ControlsInfo[item.Name].Split(',');//从字典中查出的数据,以‘,’分割成字符串组
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
pos[i] = Convert.ToDouble(strs[i]);//添加到临时数组
|
||||||
|
}
|
||||||
|
double itemWidth = pos[2] * scaleX; //计算控件宽度,double类型
|
||||||
|
double itemHeight = pos[3] * scaleY; //计算控件高度
|
||||||
|
item.Left = Convert.ToInt32(pos[0] * scaleX - itemWidth / 2);//计算控件距离左边距离
|
||||||
|
item.Top = Convert.ToInt32(pos[1] * scaleY - itemHeight / 2);//计算控件距离顶部距离
|
||||||
|
item.Width = Convert.ToInt32(itemWidth);//控件宽度,int类型
|
||||||
|
item.Height = Convert.ToInt32(itemHeight);//控件高度
|
||||||
|
if (float.Parse((pos[4] * Math.Min(scaleX, scaleY)).ToString()) != 0) //缩放字体大小不能为0
|
||||||
|
{ item.Font = new Font(item.Font.Name, float.Parse((pos[4] * Math.Min(scaleX, scaleY)).ToString())); } //字体
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user