diff --git a/Class1.cs b/Class1.cs
index 7c17ab7..0dcf24f 100644
--- a/Class1.cs
+++ b/Class1.cs
@@ -14,7 +14,11 @@
using System.Xml;
using System.Xml.Linq;
using OneNote = Microsoft.Office.Interop.OneNote;
+using TextCopy;
using System.Text;
+using System.Text.RegularExpressions;
+using HtmlAgilityPack;
+
namespace litingaddin
{
@@ -1644,7 +1648,8 @@ public string GetItemID(IRibbonControl control, int index)
return "heading" + index.ToString();
}
- public void copy_chun(IRibbonControl control)
+
+ public static void get_chun(out String page_copy)
{
OneNote.Application onenoteApp = new OneNote.Application();
string xml;
@@ -1653,15 +1658,159 @@ public void copy_chun(IRibbonControl control)
XDocument doc = XDocument.Parse(xml);
XNamespace ns = doc.Root.Name.Namespace;
StringBuilder sb = new StringBuilder();
- foreach (XElement Outlines in from node in doc.Descendants(ns + "Outline").ToList() select node)
+ foreach (XElement Outlines in doc.Descendants(ns + "Outline").ToList())
{
- foreach (XElement outline in from node1 in Outlines.Descendants(ns + "T").Where(o => o.Attribute("selected").Value == "all") select node1)
+ String Outlines_selected = null;
+ Outlines_selected = Outlines.Attribute("selected").Value;
+ if (Outlines_selected != null)
{
- sb.AppendLine(outline.Value);
+ foreach (XElement Outlines_OEChilds in Outlines.Descendants(ns + "OEChildren").ToList())
+ {
+ String OEChilds_selected = null;
+ try
+ {
+ OEChilds_selected = Outlines_OEChilds.Attribute("selected").Value;
+ }
+ catch (Exception)
+ {
+
+ }
+
+ if (OEChilds_selected != null)
+ {
+ //MessageBox.Show(Outlines_OEChilds.ToString());
+ foreach (XElement Outlines_OE in Outlines_OEChilds.Descendants(ns + "OE").ToList())
+ {
+
+
+ String OE_selected = null;
+ try
+ {
+ OE_selected = Outlines_OE.Attribute("selected").Value;
+ }
+ catch (Exception)
+ {
+
+ }
+
+ if (OE_selected != null)
+ {
+ //MessageBox.Show(Outlines_OE.ToString());
+ foreach (XElement Outlines_T in Outlines_OE.Descendants(ns + "T").ToList())
+ {
+ String T_selected = null;
+ try
+ {
+ T_selected = Outlines_T.Attribute("selected").Value;
+ }
+ catch (Exception)
+ {
+
+ }
+
+ if (T_selected != null)
+ {
+ MessageBox.Show(Outlines_T.ToString());
+ sb.AppendLine(Outlines_T.Value);
+ }
+ else
+ {
+ continue;
+ }
+ }
+ }
+ else
+ {
+
+ continue;
+ }
+ }
+ }
+ else
+ {
+ continue;
+ }
+ }
+ }
+ else
+ {
+ continue;
}
+
+
}
- Clipboard.SetDataObject(sb.ToString());
+ page_copy= sb.ToString();
+ /*MessageBox.Show(sb.ToString());
+ TextCopy.ClipboardService.SetText(sb.ToString());*/
+ }
+ public static void Replace_cpan(String cpan_in,out String cpan_out)
+ {
+
+
+
+ HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
+ doc.LoadHtml(cpan_in);
+ StringBuilder sb_1 = new StringBuilder();
+ var spanNodes = doc.DocumentNode.SelectNodes("//span");
+ if (spanNodes != null)
+ {
+ foreach (var spanNode in spanNodes)
+ {
+ string content = spanNode.InnerHtml;
+ sb_1.Append(content);
+ }
+ }
+ cpan_out= sb_1.ToString();
+
+ }
+
+ public void copy_chun(IRibbonControl control)
+ {
+ OneNote.Application onenoteApp = new OneNote.Application();
+ string xml;
+ var pageid = onenoteApp.Windows.CurrentWindow.CurrentPageId;
+ onenoteApp.GetPageContent(pageid, out xml, OneNote.PageInfo.piAll);
+ XDocument doc = XDocument.Parse(xml);
+ XNamespace ns = doc.Root.Name.Namespace;
+ StringBuilder sb = new StringBuilder();
+ String page_copy;
+
+ foreach (XElement Outlines_T in doc.Descendants(ns + "T").ToList())
+ {
+ String T_selected = null;
+ try
+ {
+ T_selected = Outlines_T.Attribute("selected").Value;
+ }
+ catch (Exception)
+ {
+
+ }
+
+ if (T_selected == "all")
+ {
+ //MessageBox.Show(Outlines_T.ToString());
+ //sb.AppendLine(Outlines_T.Value);
+ if(Outlines_T.Value.Contains("span") ==true)
+ {
+ Replace_cpan(Outlines_T.Value, out page_copy);
+ sb.AppendLine(page_copy);
+ }
+ else
+ {
+ sb.AppendLine(Outlines_T.Value);
+ }
+
+ }
+ else
+ {
+ continue;
+ }
+ }
+ //MessageBox.Show(sb.ToString());
+ TextCopy.ClipboardService.SetText(sb.ToString());
+ MessageBox.Show("复制成功!");
}
diff --git a/README.md b/README.md
index 0fb1d6d..861fe85 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,9 @@ onenote项目管理插件
- 项目管理日记
> 点击后,在默认笔记本位置,生成My Project Journal笔记本。
> 如果的笔记本是联网的,也就是说,你的默认笔记本路径是在onedrve上的,按照这样的步骤操作,第一次生成My Project Journal笔记本后,关闭OneNote,等待onedirve将你的笔记本自动转化为在线笔记本,这个时间可能有点慢,你也可以继续使用,等待下次打开找不到笔记本的时候,你需要做的一件事就是,点击打开笔记本,点击onedirve,找到转化后的在线My Project Journal笔记本,完成同步后,插件可继续使用,目前技术还未解决该问题,后续再说。
-
+- 右键功能
+ - 复制为纯文本
+ > 选择内容,右键,点击复制为纯文本,将文本复制到剪切板。
## 特别说明
本工具根据个人工作需要开发,有其他需求的,可以留言。
diff --git a/app.config b/app.config
index dfcb3e1..3ef6679 100644
--- a/app.config
+++ b/app.config
@@ -1,7 +1,7 @@
-
+
-
+
@@ -21,4 +21,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/litingaddin.csproj b/litingaddin.csproj
index 10a2573..be3e2a3 100644
--- a/litingaddin.csproj
+++ b/litingaddin.csproj
@@ -35,6 +35,33 @@
True
+
+ packages\HtmlAgilityPack.NetCore.1.5.0.1\lib\net45\HtmlAgilityPack.NetCore.dll
+
+
+ packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ packages\Microsoft.Extensions.DependencyInjection.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll
+
+
+ packages\Microsoft.IdentityModel.JsonWebTokens.5.6.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll
+
+
+ packages\Microsoft.IdentityModel.Logging.5.6.0\lib\net461\Microsoft.IdentityModel.Logging.dll
+
+
+ packages\Microsoft.IdentityModel.Tokens.5.6.0\lib\net461\Microsoft.IdentityModel.Tokens.dll
+
+
+ packages\Microsoft.VisualStudio.Services.Client.16.170.0\lib\net462\Microsoft.VisualStudio.Services.Common.dll
+
+
+ packages\Microsoft.VisualStudio.Services.Client.16.170.0\lib\net462\Microsoft.VisualStudio.Services.WebApi.dll
+
+
+ packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
+
True
@@ -42,14 +69,35 @@
+
+ packages\System.IdentityModel.Tokens.Jwt.5.6.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll
+
+
+ packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll
+
+
+ packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll
+ True
+ True
+
+
+ packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
+
+ packages\TextCopy.6.2.1\lib\net462\TextCopy.dll
+
+
@@ -73,6 +121,7 @@
+
diff --git a/packages.config b/packages.config
new file mode 100644
index 0000000..a87d8eb
--- /dev/null
+++ b/packages.config
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file