diff --git a/ExcelAddIn_TableOfContents.csproj b/ExcelAddIn_TableOfContents.csproj
index 84b373b..db2343e 100644
--- a/ExcelAddIn_TableOfContents.csproj
+++ b/ExcelAddIn_TableOfContents.csproj
@@ -33,7 +33,7 @@
\\asyn\web\PlugIn\Excel\
de
- 1.0.0.3
+ 1.0.0.4
true
true
0
@@ -268,7 +268,7 @@
-
+
diff --git a/GlobalFunction.cs b/GlobalFunction.cs
index b615f21..34f4663 100644
--- a/GlobalFunction.cs
+++ b/GlobalFunction.cs
@@ -15,14 +15,6 @@ class GlobalFunction
{
- // 'check whether Excel-GUI is german or not
- public static bool isGermanGUI() {
- return true;
- //ToDo: Sprache ermitteln...
- }
-
-
-
//'Does the sheet exists in specific workbook?
public static bool worksheetExists(Excel.Workbook WB, String sheetToFind ) {
foreach (Excel.Worksheet Sheet in WB.Worksheets) {
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 756d73d..187d1da 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -85,7 +85,7 @@ public string TocStyle {
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("https://github.com/ahaenggli/ExcelAddIn_TableOfContents/releases/download/latest/" +
+ [global::System.Configuration.DefaultSettingValueAttribute("https://github.com/ahaenggli/ExcelAddIn_TableOfContents/releases/latest/download/" +
"ExcelAddIn_TableOfContents.zip")]
public string UpdateUrl {
get {
@@ -103,5 +103,15 @@ public string UpdateUrl {
this["LastUpdateCheck"] = value;
}
}
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("https://api.github.com/repos/ahaenggli/ExcelAddIn_TableOfContents/releases/latest" +
+ "")]
+ public string VersionUrl {
+ get {
+ return ((string)(this["VersionUrl"]));
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 0f91125..6ed8e40 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -18,10 +18,13 @@
TableStyleMedium15
- https://github.com/ahaenggli/ExcelAddIn_TableOfContents/releases/download/latest/ExcelAddIn_TableOfContents.zip
+ https://github.com/ahaenggli/ExcelAddIn_TableOfContents/releases/latest/download/ExcelAddIn_TableOfContents.zip
+
+ https://api.github.com/repos/ahaenggli/ExcelAddIn_TableOfContents/releases/latest
+
\ No newline at end of file
diff --git a/ThisAddIn.cs b/ThisAddIn.cs
index da81706..67c2525 100644
--- a/ThisAddIn.cs
+++ b/ThisAddIn.cs
@@ -8,6 +8,9 @@
using System.Net;
using System.Threading;
using System.IO.Compression;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Reflection;
namespace ExcelAddIn_TableOfContents
{
@@ -24,10 +27,6 @@ private void ThisAddIn_Startup(object sender, System.EventArgs e)
//event and property do have the same name ....
((Excel.AppEvents_Event)this.Application).NewWorkbook += Application_NewWorkbook;
- //event for changes in TOC-Sheet
- this.Application.SheetChange += Application_SheetChange;
-
-
Thread worker = new Thread(Update);
worker.IsBackground = true;
worker.Start();
@@ -86,12 +85,13 @@ private void Application_SheetChange(object Sh, Range Target)
string str_arrTblCols = String.Join(";", arrTblCols);
string str_newCusProp = String.Join(";", newCusProp);
+
PropertyExtension.setProperty(ws, "TocColumns", str_arrTblCols);
PropertyExtension.setProperty(ws, "TocCustomProperties", str_newCusProp);
}
- public string Selector(Excel.Range cell)
+ private string Selector(Excel.Range cell)
{
if (cell.Value2 == null)
return "";
@@ -106,8 +106,6 @@ private void Application_NewWorkbook(Excel.Workbook Wb)
PropertyExtension.setProperty(Wb.Sheets[1], "isToc", "0");
}
-
-
private void Application_WorkbookNewSheet(Excel.Workbook Wb, object Sh)
{
if (!(Sh is Excel.Worksheet)) return;
@@ -121,63 +119,18 @@ private void Application_SheetActivate(object Sh)
if (!(Sh is Excel.Worksheet)) return;
if (((Excel.Worksheet)Sh).Name.Equals(TocSheetExtension.getTocSheetName()))
+ {
TocSheetExtension.generateTocWorksheet();
-
+ //event for changes in TOC-Sheet
+ this.Application.SheetChange += Application_SheetChange;
+ } else this.Application.SheetChange -= Application_SheetChange;
}
- private void ThisAddIn_Shutdown(object sender, EventArgs e)
- {
-
- }
-
-
- /*
-
-Option Explicit
-
-'event handler for application
-Private TocSheetExtension_AppEventHandler As TocSheetAppEventHandler
-
-' Sub is called whenever AddIn is loaded
-Private Sub Workbook_Open()
- 'To combine keys with Precede the key code by
- 'SHIFT + (plus sign)
- 'CTRL ^ (caret)
- 'ALT % (percent sign)
-
- '' CTRL + Shift + A
- 'Application.OnKey "^+{A}", "tstBox"
- Application.OnKey "{F5}", "handleF5Click"
- isF5 = False
- 'init application wide event handler
- Set TocSheetExtension_AppEventHandler = New TocSheetAppEventHandler
-
-End Sub
-
- */
- // handles click on F5-Key
- private void handleF5Click()
+ private void ThisAddIn_Shutdown(object sender, EventArgs e)
{
- Excel.Workbook ActiveWorkbook = Globals.ThisAddIn.Application.ActiveWorkbook;
-
- if (ActiveWorkbook == null) return;
-
-
- if (!ActiveWorkbook.ActiveSheet.Name.Equals(TocSheetExtension.getTocSheetName()))
- {
- Form frm = new frmPropertyExtension();
- frm.Show();
- }
- else
- TocSheetExtension.generateTocWorksheet();
-
-
-
}
-
-
private void Update()
{
try
@@ -188,45 +141,67 @@ private void Update()
Properties.Settings.Default.Save();
}
+ Version a = Assembly.GetExecutingAssembly().GetName().Version;
+ Version b = a;
+
// once a day should be enougth....
- if (Settings.Default.LastUpdateCheck.AddMinutes(60) <= DateTime.Now)
+ if (Settings.Default.LastUpdateCheck.AddHours(1) <= DateTime.Now)
{
-
- string ProgramData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\haenggli.NET\";
- string AddInData = ProgramData + @"ExcelAddIn_TableOfContents\";
- string StartFile = AddInData + @"ExcelAddIn_TableOfContents.vsto";
- string localFile = AddInData + @"ExcelAddIn_TableOfContents.zip";
- string DownloadUrl = Environment.GetEnvironmentVariable("TableOfContents_DownloadUrl", EnvironmentVariableTarget.Machine) ?? Settings.Default.UpdateUrl;
-
- if (DownloadUrl.Equals("---"))
+ System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
+ HttpWebRequest wr = (HttpWebRequest )WebRequest.Create(Settings.Default.VersionUrl);
+ wr.UserAgent = "ahaenggli/ExcelAddIn_TableOfContents";
+ var x = wr.GetResponse(); ;
+
+ using (var reader = new System.IO.StreamReader(x.GetResponseStream()))
{
- Settings.Default.LastUpdateCheck = DateTime.Now;
- Properties.Settings.Default.Save();
- return;
+ string json = reader.ReadToEnd();
+ if (json.Contains("tag_name"))
+ {
+ Regex pattern = new Regex("\"tag_name\":\"v\\d+(\\.\\d+){2,}\",");
+ Match m = pattern.Match(json);
+ b = new Version(m.Value.Replace("\"", "").Replace("tag_name:v", "").Replace(",", ""));
+ }
}
- if (!Directory.Exists(AddInData)) Directory.CreateDirectory(AddInData);
- foreach (System.IO.FileInfo file in new DirectoryInfo(AddInData).GetFiles()) file.Delete();
- foreach (System.IO.DirectoryInfo subDirectory in new DirectoryInfo(AddInData).GetDirectories()) subDirectory.Delete(true);
-
- if (DownloadUrl.StartsWith("http"))
+ if (b > a)
{
- System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
- WebClient webClient = new WebClient();
- webClient.DownloadFile(DownloadUrl, localFile);
- webClient.Dispose();
- DownloadUrl = localFile;
- }
-
- ZipFile.ExtractToDirectory(DownloadUrl, AddInData);
+ string ProgramData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\haenggli.NET\";
+ string AddInData = ProgramData + @"ExcelAddIn_TableOfContents\";
+ string StartFile = AddInData + @"ExcelAddIn_TableOfContents.vsto";
+ string localFile = AddInData + @"ExcelAddIn_TableOfContents.zip";
+ string DownloadUrl = Environment.GetEnvironmentVariable("TableOfContents_DownloadUrl", EnvironmentVariableTarget.Machine) ?? Settings.Default.UpdateUrl;
+
+ if (DownloadUrl.Equals("---"))
+ {
+ Settings.Default.LastUpdateCheck = DateTime.Now;
+ Properties.Settings.Default.Save();
+ return;
+ }
+
+ if (!Directory.Exists(AddInData)) Directory.CreateDirectory(AddInData);
+ foreach (System.IO.FileInfo file in new DirectoryInfo(AddInData).GetFiles()) file.Delete();
+ foreach (System.IO.DirectoryInfo subDirectory in new DirectoryInfo(AddInData).GetDirectories()) subDirectory.Delete(true);
+
+ if (DownloadUrl.StartsWith("http"))
+ {
+
+ WebClient webClient = new WebClient();
+ webClient.DownloadFile(DownloadUrl, localFile);
+ webClient.Dispose();
+ DownloadUrl = localFile;
+ }
+
+ ZipFile.ExtractToDirectory(DownloadUrl, AddInData);
+ }
Settings.Default.LastUpdateCheck = DateTime.Now;
Properties.Settings.Default.Save();
}
}
catch (System.Exception Ex)
{
- MessageBox.Show(Ex.Message);
+ if(!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("TableOfContents_DownloadUrl", EnvironmentVariableTarget.Machine)))
+ MessageBox.Show(Ex.Message);
}
}
diff --git a/TocSheetExtension.cs b/TocSheetExtension.cs
index 9cc3726..85d906f 100644
--- a/TocSheetExtension.cs
+++ b/TocSheetExtension.cs
@@ -152,8 +152,8 @@ public static String getWorksheetCreatedDatePropName()
try
{
if (String.IsNullOrWhiteSpace(prop)) prop = PropertyExtension.getProperty(getTocSheet(), "WorksheetCreatedDatePropName") ?? Settings.Default.WorksheetCreatedDatePropName;
- if (String.IsNullOrWhiteSpace(prop) && GlobalFunction.isGermanGUI()) prop = "Datum";
- if (String.IsNullOrWhiteSpace(prop) && !GlobalFunction.isGermanGUI()) prop = "Created";
+ if (String.IsNullOrWhiteSpace(prop)) prop = "Datum";
+ //if (String.IsNullOrWhiteSpace(prop) && !GlobalFunction.isGermanGUI()) prop = "Created";
}
catch (System.Exception e)
{
@@ -173,8 +173,8 @@ public static string[] getTocColumns()
{
if (String.IsNullOrWhiteSpace(props)) props = PropertyExtension.getProperty(getTocSheet(), "TocColumns") ?? Settings.Default.TocColumns;
- if (String.IsNullOrWhiteSpace(props) && GlobalFunction.isGermanGUI()) props = "Blatt;Datum;Beschreibung;Verantwortlich;ToDo;Status;Info";
- if (String.IsNullOrWhiteSpace(props) && !GlobalFunction.isGermanGUI()) props = "Worksheet;Created;Description;Responsible;ToDo;Status;Info";
+ if (String.IsNullOrWhiteSpace(props)) props = "Blatt;Datum;Beschreibung;Verantwortlich;ToDo;Status;Info";
+ //if (String.IsNullOrWhiteSpace(props) && !GlobalFunction.isGermanGUI()) props = "Worksheet;Created;Description;Responsible;ToDo;Status;Info";
}
catch (System.Exception e)
@@ -203,8 +203,8 @@ public static string[] getTocCustomProperties()
{
if (String.IsNullOrWhiteSpace(props)) props = PropertyExtension.getProperty(getTocSheet(), "TocCustomProperties") ?? Settings.Default.TocCustomProperties;
- if (String.IsNullOrWhiteSpace(props) && GlobalFunction.isGermanGUI()) props = "Beschreibung;Verantwortlich;ToDo;Status;Info;Datum";
- if (String.IsNullOrWhiteSpace(props) && !GlobalFunction.isGermanGUI()) props = "Description;Responsible;ToDo;Status;Info;Created";
+ if (String.IsNullOrWhiteSpace(props)) props = "Beschreibung;Verantwortlich;ToDo;Status;Info;Datum";
+ //if (String.IsNullOrWhiteSpace(props) && !GlobalFunction.isGermanGUI()) props = "Description;Responsible;ToDo;Status;Info;Created";
}
catch (System.Exception e)
@@ -249,8 +249,8 @@ public static String getTocSheetName()
}
if (String.IsNullOrWhiteSpace(sumsheet)) sumsheet = Settings.Default.TocWorksheetName;
- if (String.IsNullOrWhiteSpace(sumsheet) && GlobalFunction.isGermanGUI()) sumsheet = "Uebersicht";
- if (String.IsNullOrWhiteSpace(sumsheet) && !GlobalFunction.isGermanGUI()) sumsheet = "Toc";
+ if (String.IsNullOrWhiteSpace(sumsheet)) sumsheet = "Uebersicht";
+ //if (String.IsNullOrWhiteSpace(sumsheet) && !GlobalFunction.isGermanGUI()) sumsheet = "Toc";
return sumsheet;
}
diff --git a/_RibbonBar.Designer.cs b/_RibbonBar.Designer.cs
index cbfd770..381c629 100644
--- a/_RibbonBar.Designer.cs
+++ b/_RibbonBar.Designer.cs
@@ -34,22 +34,22 @@ protected override void Dispose(bool disposing)
///
private void InitializeComponent()
{
- this.tab1 = this.Factory.CreateRibbonTab();
+ this.TabAddIns = this.Factory.CreateRibbonTab();
this.group1 = this.Factory.CreateRibbonGroup();
this.button2 = this.Factory.CreateRibbonButton();
this.button1 = this.Factory.CreateRibbonButton();
this.button3 = this.Factory.CreateRibbonButton();
- this.tab1.SuspendLayout();
+ this.TabAddIns.SuspendLayout();
this.group1.SuspendLayout();
this.SuspendLayout();
//
- // tab1
+ // TabAddIns
//
- this.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
- this.tab1.Groups.Add(this.group1);
- this.tab1.KeyTip = "T";
- this.tab1.Label = "TabAddIns";
- this.tab1.Name = "tab1";
+ this.TabAddIns.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
+ this.TabAddIns.Groups.Add(this.group1);
+ this.TabAddIns.KeyTip = "T";
+ this.TabAddIns.Label = "TabAddIns";
+ this.TabAddIns.Name = "TabAddIns";
//
// group1
//
@@ -84,10 +84,10 @@ private void InitializeComponent()
//
this.Name = "_RibbonBar";
this.RibbonType = "Microsoft.Excel.Workbook";
- this.Tabs.Add(this.tab1);
+ this.Tabs.Add(this.TabAddIns);
this.Load += new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.Ribbon1_Load);
- this.tab1.ResumeLayout(false);
- this.tab1.PerformLayout();
+ this.TabAddIns.ResumeLayout(false);
+ this.TabAddIns.PerformLayout();
this.group1.ResumeLayout(false);
this.group1.PerformLayout();
this.ResumeLayout(false);
@@ -96,7 +96,7 @@ private void InitializeComponent()
#endregion
- internal Microsoft.Office.Tools.Ribbon.RibbonTab tab1;
+ internal Microsoft.Office.Tools.Ribbon.RibbonTab TabAddIns;
internal Microsoft.Office.Tools.Ribbon.RibbonGroup group1;
internal Microsoft.Office.Tools.Ribbon.RibbonButton button1;
internal Microsoft.Office.Tools.Ribbon.RibbonButton button2;
diff --git a/app.config b/app.config
index 25e5b42..ec15b60 100644
--- a/app.config
+++ b/app.config
@@ -33,7 +33,10 @@
- https://github.com/ahaenggli/ExcelAddIn_TableOfContents/releases/download/latest/ExcelAddIn_TableOfContents.zip
+ https://github.com/ahaenggli/ExcelAddIn_TableOfContents/releases/latest/download/ExcelAddIn_TableOfContents.zip
+
+
+ https://api.github.com/repos/ahaenggli/ExcelAddIn_TableOfContents/releases/latest