Skip to content

Commit

Permalink
Merge branch 'ignore-spelling'
Browse files Browse the repository at this point in the history
  • Loading branch information
elvirbrk committed Oct 13, 2017
2 parents 092f5c2 + abbf74c commit 5121b65
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 58 deletions.
122 changes: 73 additions & 49 deletions NoteHighlightAddin/AddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,18 @@ public void OnStartupComplete(ref Array custom)
//public async Task AddInButtonClicked(IRibbonControl control)
public void AddInButtonClicked(IRibbonControl control)
{
tag = control.Tag;
try
{
tag = control.Tag;

Thread t = new Thread(new ThreadStart(ShowForm));
t.SetApartmentState(ApartmentState.STA);
t.Start();
Thread t = new Thread(new ThreadStart(ShowForm));
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
catch (Exception e)
{
MessageBox.Show("Exception from AddInButtonClicked: "+ e.ToString());
}

//t.Join(5000);

Expand All @@ -151,49 +158,56 @@ public void AddInButtonClicked(IRibbonControl control)

private void ShowForm()
{
string outFileName = Guid.NewGuid().ToString();

//try
//{
//ProcessHelper processHelper = new ProcessHelper("NoteHighLightForm.exe", new string[] { control.Tag, outFileName });
//processHelper.IsWaitForInputIdle = true;
//processHelper.ProcessStart();
try
{
string outFileName = Guid.NewGuid().ToString();

//CodeForm form = new CodeForm(tag, outFileName);
//form.ShowDialog();
//try
//{
//ProcessHelper processHelper = new ProcessHelper("NoteHighLightForm.exe", new string[] { control.Tag, outFileName });
//processHelper.IsWaitForInputIdle = true;
//processHelper.ProcessStart();

//TestForm t = new TestForm();
var pageNode = GetPageNode();
string selectedText = "";
XElement outline = null;
bool selectedTextFormated = false;
//CodeForm form = new CodeForm(tag, outFileName);
//form.ShowDialog();

if (pageNode != null)
{
var existingPageId = pageNode.Attribute("ID").Value;
selectedText = GetSelectedText(existingPageId, out selectedTextFormated);
//TestForm t = new TestForm();
var pageNode = GetPageNode();
string selectedText = "";
XElement outline = null;
bool selectedTextFormated = false;

if (selectedText.Trim() != "")
if (pageNode != null)
{
outline = GetOutline(existingPageId);
var existingPageId = pageNode.Attribute("ID").Value;
selectedText = GetSelectedText(existingPageId, out selectedTextFormated);

if (selectedText.Trim() != "")
{
outline = GetOutline(existingPageId);
}
}
}

MainForm form = new MainForm(tag, outFileName, selectedText);

System.Windows.Forms.Application.Run(form);
//}
//catch (Exception ex)
//{
// MessageBox.Show("Error executing NoteHighLightForm.exe:" + ex.Message);
// return;
//}
System.Windows.Forms.Application.Run(form);
//}
//catch (Exception ex)
//{
// MessageBox.Show("Error executing NoteHighLightForm.exe:" + ex.Message);
// return;
//}

string fileName = Path.Combine(Path.GetTempPath(), outFileName + ".html");
string fileName = Path.Combine(Path.GetTempPath(), outFileName + ".html");

if (File.Exists(fileName))
if (File.Exists(fileName))
{
InsertHighLightCodeToCurrentSide(fileName, form.Parameters, outline, selectedTextFormated);
}
}
catch (Exception e)
{
InsertHighLightCodeToCurrentSide(fileName, form.Parameters, outline, selectedTextFormated);
MessageBox.Show("Exception from ShowForm: " + e.ToString());
}
}

Expand Down Expand Up @@ -231,24 +245,31 @@ public IStream GetImage(string imageName)
/// </summary>
private void InsertHighLightCodeToCurrentSide(string fileName, HighLightParameter parameters, XElement outline, bool selectedTextFormated)
{
// Trace.TraceInformation(System.Reflection.MethodBase.GetCurrentMethod().Name);
string htmlContent = File.ReadAllText(fileName, Encoding.UTF8);
try
{
// Trace.TraceInformation(System.Reflection.MethodBase.GetCurrentMethod().Name);
string htmlContent = File.ReadAllText(fileName, Encoding.UTF8);

var pageNode = GetPageNode();
var pageNode = GetPageNode();

if (pageNode != null)
{
var existingPageId = pageNode.Attribute("ID").Value;
string[] position=null;
if (outline == null)
if (pageNode != null)
{
position = GetMousePointPosition(existingPageId);
}
var existingPageId = pageNode.Attribute("ID").Value;
string[] position = null;
if (outline == null)
{
position = GetMousePointPosition(existingPageId);
}

var page = InsertHighLightCode(htmlContent, position, parameters, outline, selectedTextFormated);
page.Root.SetAttributeValue("ID", existingPageId);
var page = InsertHighLightCode(htmlContent, position, parameters, outline, selectedTextFormated);
page.Root.SetAttributeValue("ID", existingPageId);

OneNoteApplication.UpdatePageContent(page.ToString(), DateTime.MinValue);
OneNoteApplication.UpdatePageContent(page.ToString(), DateTime.MinValue);
}
}
catch (Exception e)
{
MessageBox.Show("Exception from InsertHighLightCodeToCurrentSide: "+e.ToString());
}
}

Expand Down Expand Up @@ -402,6 +423,7 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position, High
XElement cell2 = new XElement(ns + "Cell");
cell2.Add(new XAttribute("shadingColor", colorString));


string defaultStyle = "";

var arrayLine = htmlContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
Expand All @@ -412,6 +434,8 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position, High
if(item.StartsWith("<pre"))
{
defaultStyle = item.Substring(0,item.IndexOf("<span"));
//Sets language to Latin to disable spell check
defaultStyle = defaultStyle.Insert(defaultStyle.Length - 1, " lang=la");
item = item.Substring(item.IndexOf("<span"));
}

Expand Down Expand Up @@ -452,7 +476,7 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position, High
//string s = item.Replace(@"style=""", string.Format(@"style=""font-family:{0}; ", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value));
//string s = string.Format(@"<body style=""font-family:{0}"">", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value) +
// itemLine.Replace("&apos;", "'") + "</body>";
string s = defaultStyle + itemLine.Replace("&apos;", "'") + "</body>";
string s = defaultStyle + itemLine.Replace("&apos;", "'") + "</pre>";

cell2.Add(new XElement(ns + "OEChildren",
new XElement(ns + "OE",
Expand Down
4 changes: 2 additions & 2 deletions NoteHighlightAddin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyFileVersion("3.0.*")]
[assembly: AssemblyVersion("3.1.*")]
[assembly: AssemblyFileVersion("3.1.*")]
2 changes: 1 addition & 1 deletion NoteHighlightAddin/ribbon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<button id="buttonR" label="R" size="large" screentip="Enter R Code" onAction="AddInButtonClicked" tag="r" image="Other.png" visible="false"/>
<button id="buttonBash" label="Bash" size="large" screentip="Enter Bash Code" onAction="AddInButtonClicked" tag="sh" image="Other.png" visible="false"/>
<button id="buttonSwift" label="Swift" size="large" screentip="Enter Swift Code" onAction="AddInButtonClicked" tag="swift" image="Other.png" visible="false"/>
<button id="buttonVisaulBasic" label="Visual Basic" size="large" screentip="Enter Visual Basic Code" onAction="AddInButtonClicked" tag="vb" image="Other.png" visible="false"/>
<button id="buttonVisualBasic" label="Visual Basic" size="large" screentip="Enter Visual Basic Code" onAction="AddInButtonClicked" tag="vb" image="Other.png" visible="false"/>
</group>
</tab>
</tabs>
Expand Down
6 changes: 3 additions & 3 deletions Setup/Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,15 @@
{
"Name" = "8:NoteHighlightAddin"
"ProductName" = "8:NoteHighlight2016"
"ProductCode" = "8:{765DAFF3-F505-4A51-9064-DA725395E959}"
"PackageCode" = "8:{D8D12432-A651-4151-A0DF-5EDC3C77D310}"
"ProductCode" = "8:{FB571ECB-7A79-4417-BC88-04EADC1CAEE0}"
"PackageCode" = "8:{AFFAB118-BED9-4D10-967A-1D8018F1F910}"
"UpgradeCode" = "8:{0025873C-20C5-48D6-A93A-FBD3891A9233}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:3.0"
"ProductVersion" = "8:3.1"
"Manufacturer" = "8:CodingRoad"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down
6 changes: 3 additions & 3 deletions SetupX86/SetupX86.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,15 @@
{
"Name" = "8:NoteHighlightAddin"
"ProductName" = "8:NoteHighlight2016"
"ProductCode" = "8:{455472A6-9763-40E5-B034-9760EA7F7CEB}"
"PackageCode" = "8:{D93582F6-076B-4D28-BFCC-972ACDBD422F}"
"ProductCode" = "8:{95B19903-BDE2-4560-A55D-5BDA0EF8D70C}"
"PackageCode" = "8:{8AA95C85-7AA6-44AA-8BFA-50A9071A33A5}"
"UpgradeCode" = "8:{0025873C-20C5-48D6-A93A-FBD3891A9233}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:3.0"
"ProductVersion" = "8:3.1"
"Manufacturer" = "8:CodingRoad"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down

0 comments on commit 5121b65

Please sign in to comment.