Skip to content

Commit bf7fc01

Browse files
committed
Updated code.
1 parent 68877bf commit bf7fc01

11 files changed

Lines changed: 35 additions & 188 deletions

File tree

src/Aneejian.PowerPoint.Downsizer.AddIn/AboutBox.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
using System;
22
using System.Threading.Tasks;
33
using System.Windows.Forms;
4+
using appInfo = Aneejian.PowerPoint.Downsizer.AddIn.Fickles.AppInfo;
45

56
namespace Aneejian.PowerPoint.Downsizer.AddIn
67
{
78
public partial class AboutBox : Form
89
{
9-
private readonly Properties.Settings _settings = Properties.Settings.Default;
10-
1110
public AboutBox()
1211
{
1312
InitializeComponent();
14-
Text = string.Format("About {0}", _settings.App_Name);
15-
labelProductName.Text = _settings.App_Name;
16-
labelVersion.Text = string.Format("Version {0}", _settings.App_Version.Replace("v", ""));
17-
labelCopyright.Text = _settings.App_Copyright;
18-
labelCompanyName.Text = _settings.App_Company;
13+
Text = string.Format("About {0}", appInfo.Title);
14+
labelProductName.Text = appInfo.Product;
15+
labelVersion.Text = string.Format("Version {0}", appInfo.Version.Replace("v", ""));
16+
labelCopyright.Text = appInfo.Copyright;
17+
labelCompanyName.Text = appInfo.Company;
1918
rtbUsageStats.Text = new UsageStats().ToString();
2019
}
2120

src/Aneejian.PowerPoint.Downsizer.AddIn/Aneejian.PowerPoint.Downsizer.AddIn.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
3030
<DefineConstants>VSTO40</DefineConstants>
3131
<IsWebBootstrapper>False</IsWebBootstrapper>
32+
<TargetFrameworkProfile />
3233
<BootstrapperEnabled>true</BootstrapperEnabled>
3334
<PublishUrl>publish\</PublishUrl>
3435
<InstallUrl />
@@ -44,9 +45,13 @@
4445
<FriendlyName>Aneejian.PowerPoint.Downsizer.AddIn</FriendlyName>
4546
<OfficeApplicationDescription />
4647
<LoadBehavior>3</LoadBehavior>
47-
<TargetFrameworkProfile />
4848
</PropertyGroup>
4949
<ItemGroup>
50+
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
51+
<Visible>False</Visible>
52+
<ProductName>Microsoft .NET Framework 4.6 %28x86 and x64%29</ProductName>
53+
<Install>true</Install>
54+
</BootstrapperPackage>
5055
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
5156
<Visible>False</Visible>
5257
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
@@ -189,6 +194,7 @@
189194
</Compile>
190195
<Compile Include="Enums.cs" />
191196
<Compile Include="Extensions.cs" />
197+
<Compile Include="Fickles.cs" />
192198
<Compile Include="IUsageStats.cs" />
193199
<Compile Include="Performer.cs" />
194200
<Compile Include="Properties\AssemblyInfo.cs">

src/Aneejian.PowerPoint.Downsizer.AddIn/Fickles.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Aneejian.PowerPoint.Downsizer.AddIn
1+
namespace Aneejian.PowerPoint.Downsizer.AddIn
82
{
93
internal static class Fickles
104
{
@@ -14,6 +8,7 @@ internal static class Fickles
148
internal const string RepositoryUrl = "https://kannansuresh.github.io/PowerPoint-Downsizer/";
159
internal const string BlogPostUrl = "https://kannansuresh.github.io/PowerPoint-Downsizer/";
1610
internal const string CheckUpdateUrl = "https://kannansuresh.github.io/PowerPoint-Downsizer/update-info.txt";
11+
internal const string HelpUrl = BlogPostUrl;
1712

1813
// Coffee
1914

src/Aneejian.PowerPoint.Downsizer.AddIn/Performer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal static async Task GetPotential()
3131

3232
internal static async Task Help()
3333
{
34-
await Task.FromResult(Process.Start(_settings.App_Help)).ConfigureAwait(false);
34+
await Task.FromResult(Process.Start(Fickles.HelpUrl)).ConfigureAwait(false);
3535
}
3636

3737
internal static async Task Update()
@@ -41,12 +41,12 @@ internal static async Task Update()
4141

4242
internal static async Task Coffee()
4343
{
44-
await Task.FromResult(Process.Start(_settings.Coffee_Url)).ConfigureAwait(false);
44+
await Task.FromResult(Process.Start(Fickles.CoffeeUrl)).ConfigureAwait(false);
4545
}
4646

4747
internal static async Task HomePage()
4848
{
49-
await Task.FromResult(Process.Start(_settings.App_Homepage)).ConfigureAwait(false);
49+
await Task.FromResult(Process.Start(Fickles.CompanyUrl)).ConfigureAwait(false);
5050
}
5151

5252
internal static object GetProperty(string tag, ControlProperties property)

src/Aneejian.PowerPoint.Downsizer.AddIn/Properties/Settings.Designer.cs

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

src/Aneejian.PowerPoint.Downsizer.AddIn/Properties/Settings.settings

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
<Setting Name="Stat_UsageCounter" Type="System.UInt64" Scope="User">
1212
<Value Profile="(Default)">0</Value>
1313
</Setting>
14-
<Setting Name="Coffee_ButtonRevealThreshold" Type="System.Int32" Scope="Application">
15-
<Value Profile="(Default)">10</Value>
16-
</Setting>
1714
<Setting Name="Coffee_AlreadyBought" Type="System.Boolean" Scope="User">
1815
<Value Profile="(Default)">False</Value>
1916
</Setting>
@@ -26,42 +23,9 @@
2623
<Setting Name="Ribbon_ShowUpdateButton" Type="System.Boolean" Scope="User">
2724
<Value Profile="(Default)">False</Value>
2825
</Setting>
29-
<Setting Name="App_Version" Type="System.String" Scope="Application">
30-
<Value Profile="(Default)">v1.0.0</Value>
31-
</Setting>
32-
<Setting Name="Update_CheckUrl" Type="System.String" Scope="Application">
33-
<Value Profile="(Default)">https://kannansuresh.github.io/PowerPoint-Downsizer/update-info.txt</Value>
34-
</Setting>
3526
<Setting Name="Update_FilePath" Type="System.String" Scope="User">
3627
<Value Profile="(Default)" />
3728
</Setting>
38-
<Setting Name="App_Name" Type="System.String" Scope="Application">
39-
<Value Profile="(Default)">PowerPoint Downsizer Add-In</Value>
40-
</Setting>
41-
<Setting Name="App_Copyright" Type="System.String" Scope="Application">
42-
<Value Profile="(Default)">Copyright © Aneejian 2021</Value>
43-
</Setting>
44-
<Setting Name="App_Company" Type="System.String" Scope="Application">
45-
<Value Profile="(Default)">Aneejian</Value>
46-
</Setting>
47-
<Setting Name="App_Description" Type="System.String" Scope="Application">
48-
<Value Profile="(Default)">Add-In to downsize PowerPoint presentations by removing unused layouts and master slides.</Value>
49-
</Setting>
50-
<Setting Name="App_Homepage" Type="System.String" Scope="Application">
51-
<Value Profile="(Default)">https://aneejian.com</Value>
52-
</Setting>
53-
<Setting Name="Coffee_Url" Type="System.String" Scope="Application">
54-
<Value Profile="(Default)">https://www.buymeacoffee.com/aneejian</Value>
55-
</Setting>
56-
<Setting Name="App_Page" Type="System.String" Scope="Application">
57-
<Value Profile="(Default)">https://kannansuresh.github.io/PowerPoint-Downsizer/</Value>
58-
</Setting>
59-
<Setting Name="App_Github" Type="System.String" Scope="User">
60-
<Value Profile="(Default)">https://kannansuresh.github.io/PowerPoint-Downsizer/</Value>
61-
</Setting>
62-
<Setting Name="App_Help" Type="System.String" Scope="User">
63-
<Value Profile="(Default)">https://kannansuresh.github.io/PowerPoint-Downsizer/</Value>
64-
</Setting>
6529
<Setting Name="Stat_LayoutsDeleted" Type="System.UInt64" Scope="User">
6630
<Value Profile="(Default)">0</Value>
6731
</Setting>

src/Aneejian.PowerPoint.Downsizer.AddIn/Reporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ namespace Aneejian.PowerPoint.Downsizer.AddIn
77
{
88
internal static class Reporter
99
{
10-
private const string caption = Constants.AddInName;
10+
private const string caption = Fickles.AppInfo.Product;
1111
private static readonly string nl = Environment.NewLine;
12-
private static readonly Properties.Settings settings = Properties.Settings.Default;
1312

1413
internal static async Task ReportDownsizeStatus(IDownsizeResponse response)
1514
{
@@ -64,9 +63,10 @@ internal static async Task ReportUsageStats()
6463

6564
internal static async Task ReportHideCoffee()
6665
{
66+
var settings = Properties.Settings.Default;
6767
var message = $"Already bought a coffee? {nl}{nl}";
6868

69-
message += string.Format("You have used this add-in {2} times.{0}Consider buying a coffee if you liked it.{0}{0}Click 'Yes' if you have already bought a coffee? {0}{0}If you haven't bought a coffee yet, the 'Buy a Coffee!' button will reveal itself after you have used this add-in {1} more times after clicking 'No'.", nl, settings.Coffee_ButtonRevealThreshold * (settings.Coffee_HideCounter + 1), settings.Stat_UsageCounter);
69+
message += string.Format("You have used this add-in {2} times.{0}Consider buying a coffee if you liked it.{0}{0}Click 'Yes' if you have already bought a coffee? {0}{0}If you haven't bought a coffee yet, the 'Buy a Coffee!' button will reveal itself after you have used this add-in {1} more times after clicking 'No'.", nl, Fickles.CoffeeRevealThreshold * (settings.Coffee_HideCounter + 1), settings.Stat_UsageCounter);
7070

7171
var hide = await Task.FromResult(MessageBox.Show(message, caption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3)).ConfigureAwait(false);
7272

src/Aneejian.PowerPoint.Downsizer.AddIn/RibbonControlValues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static RibbonControlProperty GetHideCoffeeProperties()
7373
(
7474
label: "Hide Buy a Coffee button",
7575
description: "Already donated? Click to hide.",
76-
supertip: string.Format("You have used this add-in {2} times.{0}Consider buying a coffee if you liked it.{0}{0}Already bought a coffee or annoyed by this button? Click to hide it from everywhere. {0}{0}If you haven't donated, 'Buy a Coffee!' button will reveal itself after you have used this add-in {1} more times.", Environment.NewLine, settings.Coffee_ButtonRevealThreshold * (settings.Coffee_HideCounter + 1), settings.Stat_UsageCounter),
76+
supertip: string.Format("You have used this add-in {2} times.{0}Consider buying a coffee if you liked it.{0}{0}Already bought a coffee or annoyed by this button? Click to hide it from everywhere. {0}{0}If you haven't donated, 'Buy a Coffee!' button will reveal itself after you have used this add-in {1} more times.", Environment.NewLine, Fickles.CoffeeRevealThreshold * (settings.Coffee_HideCounter + 1), settings.Stat_UsageCounter),
7777
image: "WindowMinimize"
7878
);
7979
}

src/Aneejian.PowerPoint.Downsizer.AddIn/StatsManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static void UpdateStats(IDownsizeResponse downsizeResponse = null)
1919
_settings.Stat_MastersDeleted += Convert.ToUInt64(downsizeResponse.MasterSlidesDeleted);
2020
}
2121

22-
if (!_settings.Coffee_AlreadyBought && _settings.Coffee_HiddenSinceCounter >= _settings.Coffee_ButtonRevealThreshold * _settings.Coffee_HideCounter)
22+
if (!_settings.Coffee_AlreadyBought && _settings.Coffee_HiddenSinceCounter >= Fickles.CoffeeRevealThreshold * _settings.Coffee_HideCounter)
2323
{
2424
_settings.Ribbon_ShowCoffeeButton = true;
2525
_settings.Coffee_HiddenSinceCounter = 0;

src/Aneejian.PowerPoint.Downsizer.AddIn/UpdateManager.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,28 @@ namespace Aneejian.PowerPoint.Downsizer.AddIn
77
{
88
internal class UpdateManager
99
{
10-
private static readonly Properties.Settings _settings = Properties.Settings.Default;
11-
private readonly string _currentVersion = _settings.App_Version;
12-
private readonly string _upateInfoUrl = _settings.Update_CheckUrl;
13-
1410
internal async Task CheckForUpdates()
1511
{
12+
var settings = Properties.Settings.Default;
13+
1614
try
1715
{
18-
var releaseInfo = await GetWebsiteDataAsync(_upateInfoUrl).ConfigureAwait(false);
16+
var releaseInfo = await GetWebsiteDataAsync(Fickles.CheckUpdateUrl).ConfigureAwait(false);
1917

2018
if (!string.IsNullOrWhiteSpace(releaseInfo))
2119
{
2220
var updateInfo = releaseInfo.Split(new[] { "\n", "\r", "\n\r" }, StringSplitOptions.RemoveEmptyEntries);
23-
var updateAvailable = updateInfo[0].ToNumber() > _currentVersion.ToNumber();
24-
if (updateAvailable) _settings.Ribbon_ShowDownsizerTab = true;
25-
_settings.Ribbon_ShowUpdateButton = updateAvailable;
26-
_settings.Update_FilePath = updateInfo[1];
27-
_settings.Save();
21+
var updateAvailable = updateInfo[0].ToNumber() > Fickles.AppInfo.Version.ToNumber();
22+
if (updateAvailable) settings.Ribbon_ShowDownsizerTab = true;
23+
settings.Ribbon_ShowUpdateButton = updateAvailable;
24+
settings.Update_FilePath = updateInfo[1];
25+
settings.Save();
2826
}
2927
}
3028
catch (Exception)
3129
{
32-
_settings.Ribbon_ShowUpdateButton = false;
33-
_settings.Save();
30+
settings.Ribbon_ShowUpdateButton = false;
31+
settings.Save();
3432
}
3533
}
3634

@@ -45,7 +43,7 @@ private static async Task<string> GetWebsiteDataAsync(string url)
4543
{
4644
var uri = new Uri(url);
4745
var client = new HttpClient();
48-
client.DefaultRequestHeaders.Add("User-Agent", "PowerPoint Downsizer Add-In");
46+
client.DefaultRequestHeaders.Add("User-Agent", Fickles.AppInfo.Product);
4947
var response = await client.GetAsync(uri).ConfigureAwait(false);
5048
return await response.Content.ReadAsStringAsync().ConfigureAwait(false);
5149
}

0 commit comments

Comments
 (0)