From c0a3fe297f17d1d637ac92773530d98eb00fef45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Brki=C4=87?= Date: Mon, 27 Feb 2017 11:36:04 +0100 Subject: [PATCH 1/7] Change version to 2.2 --- NoteHighlightAddin/Properties/AssemblyInfo.cs | 4 +- Setup/Setup.vdproj | 42 ++++++++++++++----- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/NoteHighlightAddin/Properties/AssemblyInfo.cs b/NoteHighlightAddin/Properties/AssemblyInfo.cs index 2fb21b8..143c88f 100644 --- a/NoteHighlightAddin/Properties/AssemblyInfo.cs +++ b/NoteHighlightAddin/Properties/AssemblyInfo.cs @@ -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("2.1.*")] -[assembly: AssemblyFileVersion("2.1.*")] +[assembly: AssemblyVersion("2.2.*")] +[assembly: AssemblyFileVersion("2.2.*")] diff --git a/Setup/Setup.vdproj b/Setup/Setup.vdproj index 297bc7e..99f2415 100644 --- a/Setup/Setup.vdproj +++ b/Setup/Setup.vdproj @@ -52,13 +52,13 @@ "Entry" { "MsmKey" = "8:_805E0317B9E0B1539EEBB800C533393B" - "OwnerKey" = "8:_692D7E391D074D36AD2530720FB8D6C4" + "OwnerKey" = "8:_7CBDA023CD2F435BB8D4D5586B86D83B" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_805E0317B9E0B1539EEBB800C533393B" - "OwnerKey" = "8:_7CBDA023CD2F435BB8D4D5586B86D83B" + "OwnerKey" = "8:_692D7E391D074D36AD2530720FB8D6C4" "MsmSig" = "8:_UNDEFINED" } "Entry" @@ -100,37 +100,37 @@ "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_805E0317B9E0B1539EEBB800C533393B" + "OwnerKey" = "8:_CBF51C0C38434D629FC3271C5390E247" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_0FFDD9474C2B804E2E2B2C7C6360577B" + "OwnerKey" = "8:_BF0DDD11259532587F856D651F450ECC" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_E4014126696E456F7FC66801CBFEEE19" + "OwnerKey" = "8:_692D7E391D074D36AD2530720FB8D6C4" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_692D7E391D074D36AD2530720FB8D6C4" + "OwnerKey" = "8:_E4014126696E456F7FC66801CBFEEE19" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_BF0DDD11259532587F856D651F450ECC" + "OwnerKey" = "8:_0FFDD9474C2B804E2E2B2C7C6360577B" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_CBF51C0C38434D629FC3271C5390E247" + "OwnerKey" = "8:_805E0317B9E0B1539EEBB800C533393B" "MsmSig" = "8:_UNDEFINED" } } @@ -287,6 +287,11 @@ "AssemblyAsmDisplayName" = "8:GenerateHighlightContent, Version=2.0.0.0, Culture=neutral, PublicKeyToken=77d9ec1ac4fb0cdc, processorArchitecture=MSIL" "ScatterAssemblies" { + "_0FFDD9474C2B804E2E2B2C7C6360577B" + { + "Name" = "8:GenerateHighlightContent.dll" + "Attributes" = "3:512" + } } "SourcePath" = "8:GenerateHighlightContent.dll" "TargetName" = "8:" @@ -333,6 +338,11 @@ "AssemblyAsmDisplayName" = "8:Helper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=609b64b0cf912098, processorArchitecture=MSIL" "ScatterAssemblies" { + "_805E0317B9E0B1539EEBB800C533393B" + { + "Name" = "8:Helper.dll" + "Attributes" = "3:512" + } } "SourcePath" = "8:Helper.dll" "TargetName" = "8:" @@ -359,6 +369,11 @@ "AssemblyAsmDisplayName" = "8:System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" "ScatterAssemblies" { + "_BF0DDD11259532587F856D651F450ECC" + { + "Name" = "8:System.Net.Http.dll" + "Attributes" = "3:512" + } } "SourcePath" = "8:System.Net.Http.dll" "TargetName" = "8:" @@ -385,6 +400,11 @@ "AssemblyAsmDisplayName" = "8:ICSharpCode.TextEditor, Version=3.0.0.3437, Culture=neutral, PublicKeyToken=4d61825e8dd49f1a, processorArchitecture=MSIL" "ScatterAssemblies" { + "_E4014126696E456F7FC66801CBFEEE19" + { + "Name" = "8:ICSharpCode.TextEditor.dll" + "Attributes" = "3:512" + } } "SourcePath" = "8:ICSharpCode.TextEditor.dll" "TargetName" = "8:" @@ -557,15 +577,15 @@ { "Name" = "8:NoteHighlightAddin" "ProductName" = "8:NoteHighlight2016" - "ProductCode" = "8:{A49EDAA1-31AD-4CAD-8990-D304D3AE2B57}" - "PackageCode" = "8:{4278A506-CDE7-4746-ABD9-2E97FBF71AFF}" + "ProductCode" = "8:{7D175A2A-59FB-42BD-AF66-FBC5608C9A80}" + "PackageCode" = "8:{E1E264E8-50A6-4D87-9C9C-28D9F29A9DA4}" "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:2.1" + "ProductVersion" = "8:2.2" "Manufacturer" = "8:CodingRoad" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" From e018c1613aa869181cc83cda691792f5e294ab20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Brki=C4=87?= Date: Mon, 27 Feb 2017 11:36:32 +0100 Subject: [PATCH 2/7] Box text to table cell --- NoteHighlightAddin/AddIn.cs | 47 +++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/NoteHighlightAddin/AddIn.cs b/NoteHighlightAddin/AddIn.cs index 0ac4fcc..f790475 100644 --- a/NoteHighlightAddin/AddIn.cs +++ b/NoteHighlightAddin/AddIn.cs @@ -258,17 +258,60 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position) { XElement children = new XElement(ns + "OEChildren"); + XElement table = new XElement(ns + "Table"); + table.Add(new XAttribute("bordersVisible", "false")); + + XElement columns = new XElement(ns + "Columns"); + XElement column1 = new XElement(ns + "Column"); + column1.Add(new XAttribute("index", "0")); + column1.Add(new XAttribute("width", "25")); + columns.Add(column1); + XElement column2 = new XElement(ns + "Column"); + column2.Add(new XAttribute("index", "1")); + column2.Add(new XAttribute("width", "100")); + columns.Add(column2); + + table.Add(columns); + + XElement row = new XElement(ns + "Row"); + XElement cell1 = new XElement(ns + "Cell"); + cell1.Add(new XAttribute("shadingColor", "#FF0000")); + XElement cell2 = new XElement(ns + "Cell"); + cell2.Add(new XAttribute("shadingColor", "#FF0000")); + var arrayLine = htmlContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (var item in arrayLine) { //string s = item.Replace(@"style=""", string.Format(@"style=""font-family:{0}; ", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value)); string s = string.Format(@"", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value) + HttpUtility.HtmlDecode(item) + ""; - children.Add(new XElement(ns + "OE", + //children.Add(new XElement(ns + "OE", + // new XElement(ns + "T", + // new XCData(s)))); + + + + cell1.Add(new XElement(ns + "OEChildren", + new XElement(ns + "OE", + new XElement(ns + "T", + new XCData("1"))))); + + cell2.Add(new XElement(ns + "OEChildren", + new XElement(ns + "OE", new XElement(ns + "T", - new XCData(s)))); + new XCData(s))))); + } + row.Add(cell1); + + row.Add(cell2); + + table.Add(row); + + children.Add(new XElement(ns + "OE", + table)); + XElement outline = new XElement(ns + "Outline"); if (position != null && position.Length == 2) From 6e7aece5766a8e96dfebd03808ad4abd96a227f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Brki=C4=87?= Date: Tue, 7 Mar 2017 09:56:57 +0100 Subject: [PATCH 3/7] Fixed unwanted text wraping --- NoteHighlightAddin/AddIn.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/NoteHighlightAddin/AddIn.cs b/NoteHighlightAddin/AddIn.cs index f790475..03648ac 100644 --- a/NoteHighlightAddin/AddIn.cs +++ b/NoteHighlightAddin/AddIn.cs @@ -264,11 +264,11 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position) XElement columns = new XElement(ns + "Columns"); XElement column1 = new XElement(ns + "Column"); column1.Add(new XAttribute("index", "0")); - column1.Add(new XAttribute("width", "25")); + column1.Add(new XAttribute("width", "40")); columns.Add(column1); XElement column2 = new XElement(ns + "Column"); column2.Add(new XAttribute("index", "1")); - column2.Add(new XAttribute("width", "100")); + column2.Add(new XAttribute("width", "1000")); columns.Add(column2); table.Add(columns); @@ -320,6 +320,11 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position) pos.Add(new XAttribute("x", position[0])); pos.Add(new XAttribute("y", position[1])); outline.Add(pos); + + XElement size = new XElement(ns + "Size"); + size.Add(new XAttribute("width", "1100")); + size.Add(new XAttribute("height", "200")); + outline.Add(size); } outline.Add(children); From f455cc01dafd97161c48c487b4c490b9ed1bfc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Brki=C4=87?= Date: Wed, 8 Mar 2017 09:36:46 +0100 Subject: [PATCH 4/7] Changed way to decode character (') because of problems with html code. --- NoteHighlightAddin/AddIn.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NoteHighlightAddin/AddIn.cs b/NoteHighlightAddin/AddIn.cs index 03648ac..f5762c6 100644 --- a/NoteHighlightAddin/AddIn.cs +++ b/NoteHighlightAddin/AddIn.cs @@ -268,7 +268,7 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position) columns.Add(column1); XElement column2 = new XElement(ns + "Column"); column2.Add(new XAttribute("index", "1")); - column2.Add(new XAttribute("width", "1000")); + column2.Add(new XAttribute("width", "1400")); columns.Add(column2); table.Add(columns); @@ -284,7 +284,7 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position) { //string s = item.Replace(@"style=""", string.Format(@"style=""font-family:{0}; ", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value)); string s = string.Format(@"", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value) + - HttpUtility.HtmlDecode(item) + ""; + item.Replace("'", "'") + ""; //children.Add(new XElement(ns + "OE", // new XElement(ns + "T", // new XCData(s)))); @@ -322,7 +322,7 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position) outline.Add(pos); XElement size = new XElement(ns + "Size"); - size.Add(new XAttribute("width", "1100")); + size.Add(new XAttribute("width", "1600")); size.Add(new XAttribute("height", "200")); outline.Add(size); } From 20007a6f4dae13b8b4774105ae0e8cdecee6daf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Brki=C4=87?= Date: Wed, 8 Mar 2017 15:37:41 +0100 Subject: [PATCH 5/7] Custom BackgroundColor selection. --- .../GenerateHighlightContent.csproj | 1 + .../IGenerateHighLight.cs | 3 +++ NoteHighlightAddin/AddIn.cs | 16 ++++++++------ NoteHighlightAddin/MainForm.Designer.cs | 17 ++++++++++++++- NoteHighlightAddin/MainForm.cs | 21 ++++++++++++++++--- NoteHighlightAddin/MainForm.resx | 6 ++++++ 6 files changed, 54 insertions(+), 10 deletions(-) diff --git a/GenerateHighlightContent/GenerateHighlightContent.csproj b/GenerateHighlightContent/GenerateHighlightContent.csproj index 77d1b13..82c033f 100644 --- a/GenerateHighlightContent/GenerateHighlightContent.csproj +++ b/GenerateHighlightContent/GenerateHighlightContent.csproj @@ -40,6 +40,7 @@ + diff --git a/GenerateHighlightContent/IGenerateHighLight.cs b/GenerateHighlightContent/IGenerateHighLight.cs index a43a595..e0251cd 100644 --- a/GenerateHighlightContent/IGenerateHighLight.cs +++ b/GenerateHighlightContent/IGenerateHighLight.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; @@ -28,5 +29,7 @@ public class HighLightParameter /// 檔案名稱 public string FileName { get; set; } + + public Color HighlightColor { get; set; } } } diff --git a/NoteHighlightAddin/AddIn.cs b/NoteHighlightAddin/AddIn.cs index f5762c6..6f7ef72 100644 --- a/NoteHighlightAddin/AddIn.cs +++ b/NoteHighlightAddin/AddIn.cs @@ -24,6 +24,7 @@ using Helper; using System.Threading; using System.Web; +using GenerateHighlightContent; #pragma warning disable CS3003 // Type is not CLS-compliant @@ -153,7 +154,7 @@ private void ShowForm() if (File.Exists(fileName)) { - InsertHighLightCodeToCurrentSide(fileName); + InsertHighLightCodeToCurrentSide(fileName, form.Parameters); } } @@ -189,7 +190,7 @@ public IStream GetImage(string imageName) /// 插入 HighLight Code 至滑鼠游標的位置 /// Insert HighLight Code To Mouse Position /// - private void InsertHighLightCodeToCurrentSide(string fileName) + private void InsertHighLightCodeToCurrentSide(string fileName, HighLightParameter parameters) { // Trace.TraceInformation(System.Reflection.MethodBase.GetCurrentMethod().Name); string htmlContent = File.ReadAllText(fileName, Encoding.UTF8); @@ -218,7 +219,7 @@ private void InsertHighLightCodeToCurrentSide(string fileName) string[] position = GetMousePointPosition(existingPageId); - var page = InsertHighLightCode(htmlContent, position); + var page = InsertHighLightCode(htmlContent, position, parameters); page.Root.SetAttributeValue("ID", existingPageId); OneNoteApplication.UpdatePageContent(page.ToString(), DateTime.MinValue); @@ -254,7 +255,7 @@ private string[] GetMousePointPosition(string pageID) /// 產生 XML 插入至 OneNote /// Generate XML Insert To OneNote /// - public XDocument InsertHighLightCode(string htmlContent, string[] position) + public XDocument InsertHighLightCode(string htmlContent, string[] position, HighLightParameter parameters) { XElement children = new XElement(ns + "OEChildren"); @@ -273,11 +274,14 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position) table.Add(columns); + Color color = parameters.HighlightColor; + string colorString = string.Format("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B); + XElement row = new XElement(ns + "Row"); XElement cell1 = new XElement(ns + "Cell"); - cell1.Add(new XAttribute("shadingColor", "#FF0000")); + cell1.Add(new XAttribute("shadingColor", colorString)); XElement cell2 = new XElement(ns + "Cell"); - cell2.Add(new XAttribute("shadingColor", "#FF0000")); + cell2.Add(new XAttribute("shadingColor", colorString)); var arrayLine = htmlContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (var item in arrayLine) diff --git a/NoteHighlightAddin/MainForm.Designer.cs b/NoteHighlightAddin/MainForm.Designer.cs index c0c1aef..edd4a8b 100644 --- a/NoteHighlightAddin/MainForm.Designer.cs +++ b/NoteHighlightAddin/MainForm.Designer.cs @@ -38,6 +38,8 @@ private void InitializeComponent() this.panel1 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel(); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.btnBackground = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.panel3.SuspendLayout(); @@ -138,6 +140,7 @@ private void InitializeComponent() // // panel2 // + this.panel2.Controls.Add(this.btnBackground); this.panel2.Controls.Add(this.btnCodeHighLight); this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel2.Location = new System.Drawing.Point(0, 534); @@ -156,7 +159,17 @@ private void InitializeComponent() this.panel3.Size = new System.Drawing.Size(689, 469); this.panel3.TabIndex = 0; // - // CodeForm + // btnBackground + // + this.btnBackground.Location = new System.Drawing.Point(12, 3); + this.btnBackground.Name = "btnBackground"; + this.btnBackground.Size = new System.Drawing.Size(105, 50); + this.btnBackground.TabIndex = 1; + this.btnBackground.Text = "Background Color"; + this.btnBackground.UseVisualStyleBackColor = true; + this.btnBackground.Click += new System.EventHandler(btnBackground_Click); + // + // MainForm // this.AcceptButton = this.btnCodeHighLight; this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -190,5 +203,7 @@ private void InitializeComponent() private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.Button btnBackground; + private System.Windows.Forms.ColorDialog colorDialog1; } } \ No newline at end of file diff --git a/NoteHighlightAddin/MainForm.cs b/NoteHighlightAddin/MainForm.cs index 01248bd..b57de33 100644 --- a/NoteHighlightAddin/MainForm.cs +++ b/NoteHighlightAddin/MainForm.cs @@ -25,6 +25,8 @@ public partial class MainForm : Form //檔案名稱 private string _fileName; + private HighLightParameter _parameters; + //要HighLight的Code private string CodeContent { get { return this.txtCode.Text; } } @@ -37,6 +39,10 @@ public partial class MainForm : Form //是否存到剪貼簿 private bool IsClipboard { get { return this.cbx_Clipboard.Checked; } } + private Color BackgroundColor { get { return this.colorDialog1.Color; } } + + public HighLightParameter Parameters { get { return _parameters; } } + #endregion #region -- Constructor -- @@ -82,18 +88,19 @@ private void btnCodeHighLight_Click(object sender, EventArgs e) string outputFileName = String.Empty; - HighLightParameter parameter = new HighLightParameter() + _parameters = new HighLightParameter() { FileName = _fileName, Content = CodeContent, CodeType = _codeType, HighLightStyle = CodeStyle, - ShowLineNumber = IsShowLineNumber + ShowLineNumber = IsShowLineNumber, + HighlightColor = BackgroundColor }; try { - outputFileName = generate.GenerateHighLightCode(parameter); + outputFileName = generate.GenerateHighLightCode(_parameters); } catch (Exception ex) { @@ -216,5 +223,13 @@ private void SaveSetting() defaultSettings.HighLightStyle = this.cbx_style.SelectedIndex; defaultSettings.Save(); } + + private void btnBackground_Click(object sender, EventArgs e) + { + if (colorDialog1.ShowDialog() == DialogResult.OK) + { + btnBackground.BackColor = colorDialog1.Color; + } + } } } diff --git a/NoteHighlightAddin/MainForm.resx b/NoteHighlightAddin/MainForm.resx index 1af7de1..a3668b3 100644 --- a/NoteHighlightAddin/MainForm.resx +++ b/NoteHighlightAddin/MainForm.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 186, 17 + \ No newline at end of file From 0b12cdcd562576b33a4faaacd6fd02e70721cb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Brki=C4=87?= Date: Wed, 8 Mar 2017 16:15:24 +0100 Subject: [PATCH 6/7] Save BackgroundColor to Settings --- NoteHighlightAddin/App.config | 3 +++ NoteHighlightAddin/MainForm.cs | 4 +++- .../Properties/Settings.Designer.cs | 15 +++++++++++++++ NoteHighlightAddin/Properties/Settings.settings | 3 +++ .../Properties/Settings1.Designer.cs | 12 ++++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/NoteHighlightAddin/App.config b/NoteHighlightAddin/App.config index 0e6c068..f6af634 100644 --- a/NoteHighlightAddin/App.config +++ b/NoteHighlightAddin/App.config @@ -17,6 +17,9 @@ 0 + + White + diff --git a/NoteHighlightAddin/MainForm.cs b/NoteHighlightAddin/MainForm.cs index b57de33..d3cb9d2 100644 --- a/NoteHighlightAddin/MainForm.cs +++ b/NoteHighlightAddin/MainForm.cs @@ -39,7 +39,7 @@ public partial class MainForm : Form //是否存到剪貼簿 private bool IsClipboard { get { return this.cbx_Clipboard.Checked; } } - private Color BackgroundColor { get { return this.colorDialog1.Color; } } + private Color BackgroundColor { get { return this.btnBackground.BackColor; } } public HighLightParameter Parameters { get { return _parameters; } } @@ -67,6 +67,7 @@ private void CodeForm_Load(object sender, EventArgs e) this.txtCode.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(CodeTypeTransform(_codeType)); this.txtCode.Encoding = Encoding.UTF8; this.cbx_style.SelectedIndex = NoteHighlightForm.Properties.Settings.Default.HighLightStyle; + this.btnBackground.BackColor = NoteHighlightForm.Properties.Settings.Default.BackgroundColor; this.TopMost = true; this.TopMost = false; } @@ -221,6 +222,7 @@ private void SaveSetting() defaultSettings.ShowLineNumber = this.cbx_lineNumber.Checked; defaultSettings.SaveOnClipboard = this.cbx_Clipboard.Checked; defaultSettings.HighLightStyle = this.cbx_style.SelectedIndex; + defaultSettings.BackgroundColor = this.btnBackground.BackColor; defaultSettings.Save(); } diff --git a/NoteHighlightAddin/Properties/Settings.Designer.cs b/NoteHighlightAddin/Properties/Settings.Designer.cs index 9fdbbb0..8b62c53 100644 --- a/NoteHighlightAddin/Properties/Settings.Designer.cs +++ b/NoteHighlightAddin/Properties/Settings.Designer.cs @@ -58,5 +58,20 @@ public int HighLightStyle { this["HighLightStyle"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("White")] + public global::System.Drawing.Color BackgroundColor + { + get + { + return ((global::System.Drawing.Color)(this["BackgroundColor"])); + } + set + { + this["BackgroundColor"] = value; + } + } } } diff --git a/NoteHighlightAddin/Properties/Settings.settings b/NoteHighlightAddin/Properties/Settings.settings index 7e385b2..ceed812 100644 --- a/NoteHighlightAddin/Properties/Settings.settings +++ b/NoteHighlightAddin/Properties/Settings.settings @@ -11,5 +11,8 @@ 0 + + White + \ No newline at end of file diff --git a/NoteHighlightAddin/Properties/Settings1.Designer.cs b/NoteHighlightAddin/Properties/Settings1.Designer.cs index 4f171fc..b649ebc 100644 --- a/NoteHighlightAddin/Properties/Settings1.Designer.cs +++ b/NoteHighlightAddin/Properties/Settings1.Designer.cs @@ -58,5 +58,17 @@ public int HighLightStyle { this["HighLightStyle"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("White")] + public global::System.Drawing.Color BackgroundColor { + get { + return ((global::System.Drawing.Color)(this["BackgroundColor"])); + } + set { + this["BackgroundColor"] = value; + } + } } } From c6536941969d5cbba6ff20cbddc6c56e7246a0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvir=20Brki=C4=87?= Date: Wed, 8 Mar 2017 16:57:59 +0100 Subject: [PATCH 7/7] Separate line numbers from code lines --- NoteHighlightAddin/AddIn.cs | 61 ++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/NoteHighlightAddin/AddIn.cs b/NoteHighlightAddin/AddIn.cs index 6f7ef72..428f37c 100644 --- a/NoteHighlightAddin/AddIn.cs +++ b/NoteHighlightAddin/AddIn.cs @@ -266,9 +266,20 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position, High XElement column1 = new XElement(ns + "Column"); column1.Add(new XAttribute("index", "0")); column1.Add(new XAttribute("width", "40")); - columns.Add(column1); + if (parameters.ShowLineNumber) + { + columns.Add(column1); + } XElement column2 = new XElement(ns + "Column"); - column2.Add(new XAttribute("index", "1")); + if (parameters.ShowLineNumber) + { + column2.Add(new XAttribute("index", "1")); + } + else + { + column2.Add(new XAttribute("index", "0")); + } + column2.Add(new XAttribute("width", "1400")); columns.Add(column2); @@ -286,19 +297,37 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position, High var arrayLine = htmlContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (var item in arrayLine) { + var itemNr = ""; + var itemLine = ""; + if (parameters.ShowLineNumber) + { + if (item.Contains("")) + { + int ind = item.IndexOf(""); + itemNr = item.Substring(0, ind + ("").Length); + itemLine = item.Substring(ind); + } + else + { + itemNr = ""; + itemLine = item; + } + + string nr = string.Format(@"", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value) + + itemNr.Replace("'", "'") + ""; + + cell1.Add(new XElement(ns + "OEChildren", + new XElement(ns + "OE", + new XElement(ns + "T", + new XCData(nr))))); + } + else + { + itemLine = item; + } //string s = item.Replace(@"style=""", string.Format(@"style=""font-family:{0}; ", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value)); string s = string.Format(@"", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value) + - item.Replace("'", "'") + ""; - //children.Add(new XElement(ns + "OE", - // new XElement(ns + "T", - // new XCData(s)))); - - - - cell1.Add(new XElement(ns + "OEChildren", - new XElement(ns + "OE", - new XElement(ns + "T", - new XCData("1"))))); + itemLine.Replace("'", "'") + ""; cell2.Add(new XElement(ns + "OEChildren", new XElement(ns + "OE", @@ -307,8 +336,10 @@ public XDocument InsertHighLightCode(string htmlContent, string[] position, High } - row.Add(cell1); - + if (parameters.ShowLineNumber) + { + row.Add(cell1); + } row.Add(cell2); table.Add(row);