Skip to content

Commit e043137

Browse files
committed
Added online update check
- Logbert checks now (if not disabled in settings) for a new release on startup. - Fixed missing upgrade of previous user settings.
1 parent beb2c14 commit e043137

File tree

14 files changed

+398
-121
lines changed

14 files changed

+398
-121
lines changed

src/GuiLibrary/Controls/MenuStripEx.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#endregion
3030

3131
using System;
32+
using System.Runtime.InteropServices;
3233
using System.Windows.Forms;
3334

3435
namespace Com.Couchcoding.GuiLibrary.Controls
@@ -55,6 +56,37 @@ public sealed class MenuStripEx : MenuStrip
5556
/// </summary>
5657
private const uint MA_ACTIVATEANDEAT = 0x2;
5758

59+
/// <summary>
60+
/// Sent to a window if the mouse causes the cursor to move within a window and mouse input is not captured.
61+
/// </summary>
62+
private const int WM_SETCURSOR = 0x0020;
63+
64+
/// <summary>
65+
/// The Hand cursor.
66+
/// </summary>
67+
private const int IDC_HAND = 0x7f89;
68+
69+
#endregion
70+
71+
#region Interop Methods
72+
73+
/// <summary>
74+
/// Loads the specified cursor resource from the executable (.EXE) file associated with an application instance.
75+
/// </summary>
76+
/// <param name="hInstance">A handle to an instance of the module whose executable file contains the cursor to be loaded. </param>
77+
/// <param name="lpCursorName">The name of the cursor resource to be loaded.</param>
78+
/// <returns>If the function succeeds, the return value is the handle to the newly loaded cursor.</returns>
79+
[DllImport("user32.dll")]
80+
private static extern int LoadCursor(int hInstance, int lpCursorName);
81+
82+
/// <summary>
83+
/// Sets the cursor shape.
84+
/// </summary>
85+
/// <param name="hCursor">A handle to the cursor.</param>
86+
/// <returns>The return value is the handle to the previous cursor, if there was one. </returns>
87+
[DllImport("user32.dll")]
88+
private static extern int SetCursor(int hCursor);
89+
5890
#endregion
5991

6092
#region Overridden Methods
@@ -65,6 +97,16 @@ public sealed class MenuStripEx : MenuStrip
6597
/// <param name="m">The Windows <see cref="T:System.Windows.Forms.Message"/> to process.</param>
6698
protected override void WndProc(ref Message m)
6799
{
100+
if (m.Msg == WM_SETCURSOR && Cursor == Cursors.Hand)
101+
{
102+
// Set the systems hand cursor.
103+
SetCursor(LoadCursor(0, IDC_HAND));
104+
105+
// The message has been handled.
106+
m.Result = IntPtr.Zero;
107+
return;
108+
}
109+
68110
base.WndProc(ref m);
69111

70112
if (m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)MA_ACTIVATEANDEAT)

src/GuiLibrary/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("Couchcoding")]
1111
[assembly: AssemblyProduct("Logbert GUI Library")]
12-
[assembly: AssemblyCopyright("Copyright © 2016 Couchcoding")]
12+
[assembly: AssemblyCopyright("Copyright © 2017 Couchcoding")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.2.0.0")]
35-
[assembly: AssemblyFileVersion("1.2.0.0")]
34+
[assembly: AssemblyVersion("1.3.1.0")]
35+
[assembly: AssemblyFileVersion("1.3.1.0")]

src/Logbert/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@
375375
<setting name="LogWindowDrawGrid" serializeAs="String">
376376
<value>True</value>
377377
</setting>
378+
<setting name="FrmMainCheckForUpdateOnStartup" serializeAs="String">
379+
<value>True</value>
380+
</setting>
381+
<setting name="SettingsUpgradeRequired" serializeAs="String">
382+
<value>True</value>
383+
</setting>
378384
</Com.Couchcoding.Logbert.Properties.Settings>
379385
</userSettings>
380386
<applicationSettings>

src/Logbert/Controls/OptionPanels/OptionPanelFontColor.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Logbert/Controls/OptionPanels/OptionPanelGeneral.Designer.cs

Lines changed: 65 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Logbert/Controls/OptionPanels/OptionPanelGeneral.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public override void InitializeControl()
140140
chkAllowOnlyOneInstance.Checked = Settings.Default.FrmMainAllowOnlyOneInstance;
141141
nudMaxLogMessages.Value = Settings.Default.MaxLogMessages;
142142
chkEnableColorMap.Checked = Settings.Default.EnableColorMap;
143+
chkCheckForUpdate.Checked = Settings.Default.FrmMainCheckForUpdateOnStartup;
143144

144145
chkAnnotateTrace.Checked = ((LogLevel)Settings.Default.ColorMapAnnotation & LogLevel.Trace) == LogLevel.Trace;
145146
chkAnnotateDebug.Checked = ((LogLevel)Settings.Default.ColorMapAnnotation & LogLevel.Debug) == LogLevel.Debug;
@@ -162,6 +163,7 @@ public override void SaveSettings()
162163
Settings.Default.FrmMainAllowOnlyOneInstance = chkAllowOnlyOneInstance.Checked;
163164
Settings.Default.MaxLogMessages = (int)nudMaxLogMessages.Value;
164165
Settings.Default.EnableColorMap = chkEnableColorMap.Checked;
166+
Settings.Default.FrmMainCheckForUpdateOnStartup = chkCheckForUpdate.Checked;
165167

166168
Settings.Default.ColorMapAnnotation = 0;
167169
Settings.Default.ColorMapAnnotation |= chkAnnotateTrace.Checked ? (int)LogLevel.Trace : 0;

src/Logbert/Dialogs/FrmAbout.cs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#endregion
3030

3131
using System;
32-
using System.Diagnostics;
3332
using System.Windows.Forms;
3433

3534
using Com.Couchcoding.GuiLibrary.Dialogs;
@@ -65,38 +64,7 @@ private void LstComponentsDoubleClick(object sender, EventArgs e)
6564

6665
if (info.SubItem != null && info.SubItem.Text.StartsWith("http"))
6766
{
68-
try
69-
{
70-
Process.Start(info.SubItem.Text);
71-
}
72-
catch (Exception ex1)
73-
{
74-
// System.ComponentModel.Win32Exception is a known exception that occurs when Firefox is default browser.
75-
// It actually opens the browser but STILL throws this exception so we can just ignore it. If not this exception,
76-
// then attempt to open the URL in IE instead.
77-
if (ex1.GetType().ToString() != "System.ComponentModel.Win32Exception")
78-
{
79-
// Sometimes throws exception so we have to just ignore
80-
// this is a common .NET bug that no one online really has a great reason for so now we just need to try to open
81-
// the URL using IE if we can.
82-
try
83-
{
84-
ProcessStartInfo startInfo = new ProcessStartInfo(
85-
"IExplore.exe"
86-
, info.SubItem.Text);
87-
88-
Process.Start(startInfo);
89-
}
90-
catch (Exception ex2)
91-
{
92-
MessageBox.Show(
93-
Application.ProductName
94-
, string.Format(Resources.strErrorOpeningSystemBrowser, ex2.Message)
95-
, MessageBoxButtons.OK
96-
, MessageBoxIcon.Error);
97-
}
98-
}
99-
}
67+
Browser.Open(info.SubItem.Text, this);
10068
}
10169
}
10270

src/Logbert/Helper/Browser.cs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#region Copyright © 2017 Couchcoding
2+
3+
// File: Browser.cs
4+
// Package: Logbert
5+
// Project: Logbert
6+
//
7+
// The MIT License (MIT)
8+
//
9+
// Copyright (c) 2017 Couchcoding
10+
//
11+
// Permission is hereby granted, free of charge, to any person obtaining a copy
12+
// of this software and associated documentation files (the "Software"), to deal
13+
// in the Software without restriction, including without limitation the rights
14+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
// copies of the Software, and to permit persons to whom the Software is
16+
// furnished to do so, subject to the following conditions:
17+
//
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
20+
//
21+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
// THE SOFTWARE.
28+
29+
#endregion
30+
31+
using Com.Couchcoding.Logbert.Properties;
32+
using System;
33+
using System.Diagnostics;
34+
using System.Windows.Forms;
35+
36+
namespace Com.Couchcoding.Logbert.Helper
37+
{
38+
/// <summary>
39+
/// Implements helper methods to access the system browser.
40+
/// </summary>
41+
public static class Browser
42+
{
43+
#region Public Methods
44+
45+
/// <summary>
46+
/// Opens the system web browser with the specified URI.
47+
/// </summary>
48+
/// <param name="URI">THE URI to open in the system browser.</param>
49+
/// <param name="owner">The <see cref="IWin32Window"/> as parent for the <see cref="MessageBox"/> that is shown on error.</param>
50+
public static void Open(string URI, IWin32Window owner)
51+
{
52+
try
53+
{
54+
Process.Start(URI);
55+
}
56+
catch (Exception ex1)
57+
{
58+
// System.ComponentModel.Win32Exception is a known exception that occurs when Firefox is default browser.
59+
// It actually opens the browser but STILL throws this exception so we can just ignore it. If not this exception,
60+
// then attempt to open the URL in IE instead.
61+
if (ex1.GetType().ToString() != "System.ComponentModel.Win32Exception")
62+
{
63+
// Sometimes throws exception so we have to just ignore.
64+
// This is a common .NET issue that no one online really has a great reason for so now we just need to try to open the URL using IE if we can.
65+
try
66+
{
67+
ProcessStartInfo startInfo =
68+
new ProcessStartInfo("IExplore.exe", URI);
69+
70+
Process.Start(startInfo);
71+
}
72+
catch
73+
{
74+
MessageBox.Show(
75+
owner
76+
, string.Format(Resources.strMainUnableToOpenUri, URI)
77+
, Application.ProductName
78+
, MessageBoxButtons.OK
79+
, MessageBoxIcon.Error);
80+
}
81+
}
82+
}
83+
}
84+
85+
#endregion
86+
}
87+
}

src/Logbert/Logbert.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
<Compile Include="Dialogs\FrmOptions.Designer.cs">
257257
<DependentUpon>FrmOptions.cs</DependentUpon>
258258
</Compile>
259+
<Compile Include="Helper\Browser.cs" />
259260
<Compile Include="Helper\GdiCache.cs" />
260261
<Compile Include="Helper\Extensions.cs" />
261262
<Compile Include="Helper\FlatColorTable.cs" />

0 commit comments

Comments
 (0)