Skip to content

Commit 9884ce4

Browse files
committed
Initial upload
0 parents  commit 9884ce4

12 files changed

+586
-0
lines changed

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
[Dd]ebug/
46+
[Rr]elease/
47+
*_i.c
48+
*_p.c
49+
*.ilk
50+
*.meta
51+
*.obj
52+
*.pch
53+
*.pdb
54+
*.pgc
55+
*.pgd
56+
*.rsp
57+
*.sbr
58+
*.tlb
59+
*.tli
60+
*.tlh
61+
*.tmp
62+
*.vspscc
63+
.builds
64+
*.dotCover
65+
66+
## TODO: If you have NuGet Package Restore enabled, uncomment this
67+
#packages/
68+
69+
# Visual C++ cache files
70+
ipch/
71+
*.aps
72+
*.ncb
73+
*.opensdf
74+
*.sdf
75+
76+
# Visual Studio profiler
77+
*.psess
78+
*.vsp
79+
80+
# ReSharper is a .NET coding add-in
81+
_ReSharper*
82+
83+
# Installshield output folder
84+
[Ee]xpress
85+
86+
# DocProject is a documentation generator add-in
87+
DocProject/buildhelp/
88+
DocProject/Help/*.HxT
89+
DocProject/Help/*.HxC
90+
DocProject/Help/*.hhc
91+
DocProject/Help/*.hhk
92+
DocProject/Help/*.hhp
93+
DocProject/Help/Html2
94+
DocProject/Help/html
95+
96+
# Click-Once directory
97+
publish
98+
99+
# Others
100+
[Bb]in
101+
[Oo]bj
102+
sql
103+
TestResults
104+
*.Cache
105+
ClientBin
106+
stylecop.*
107+
~$*
108+
*.dbmdl
109+
Generated_Code #added for RIA/Silverlight projects
110+
111+
# Backup & report files from converting an old project file to a newer
112+
# Visual Studio version. Backup files are not needed, because we have git ;-)
113+
_UpgradeReport_Files/
114+
Backup*/
115+
UpgradeLog*.XML
116+
117+
118+
119+
############
120+
## Windows
121+
############
122+
123+
# Windows image file caches
124+
Thumbs.db
125+
126+
# Folder config file
127+
Desktop.ini
128+
129+
130+
#############
131+
## Python
132+
#############
133+
134+
*.py[co]
135+
136+
# Packages
137+
*.egg
138+
*.egg-info
139+
dist
140+
build
141+
eggs
142+
parts
143+
bin
144+
var
145+
sdist
146+
develop-eggs
147+
.installed.cfg
148+
149+
# Installer logs
150+
pip-log.txt
151+
152+
# Unit test / coverage reports
153+
.coverage
154+
.tox
155+
156+
#Translations
157+
*.mo
158+
159+
#Mr Developer
160+
.mr.developer.cfg
161+
162+
# Mac crap
163+
.DS_Store

AppUpdateReminder.cs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
using Microsoft.Phone.Tasks;
2+
using System;
3+
using System.Windows;
4+
5+
namespace Hedgehog.UpdateReminder
6+
{
7+
public class AppUpdateReminder
8+
{
9+
/// <summary>
10+
/// Caption of the message box shwon, when reminded of available update
11+
/// </summary>
12+
public string MessageBoxCaption { get; set; }
13+
/// <summary>
14+
/// Body of the message box shown, when reminded of available update
15+
/// </summary>
16+
public string MessageBoxMessage { get; set; }
17+
/// <summary>
18+
/// Specifies how often the app checks for available updates;
19+
/// E.g. by setting RecurrencePerUsageCount = 5 every 5 times a user opens the app it'll check for an update
20+
/// </summary>
21+
public int? RecurrencePerUsageCount { get; set; }
22+
/// <summary>
23+
/// Specifies the current version of the running app
24+
/// </summary>
25+
public string CurrentVersion { get; set; }
26+
/// <summary>
27+
/// Implemention of the actual validator
28+
/// </summary>
29+
public IUpdateValidator UpdateValidator { get; set; }
30+
31+
/// <summary>
32+
/// Provider to persist the data, e.g. custom xml, database
33+
/// </summary>
34+
protected ReminderDataPersistenceFileProvider<AppUpdateReminderData> PersistenceProvider { get; set; }
35+
36+
int? _numberOfUsagesAfterLastReminder;
37+
protected int NumberOfUsagesAfterLastReminder
38+
{
39+
get
40+
{
41+
if (_numberOfUsagesAfterLastReminder == null)
42+
{
43+
var data = PersistenceProvider.LoadData();
44+
_numberOfUsagesAfterLastReminder = data.NumberOfAppRunsAfterLastReminder;
45+
}
46+
return _numberOfUsagesAfterLastReminder.GetValueOrDefault(0);
47+
}
48+
set
49+
{
50+
this._numberOfUsagesAfterLastReminder = value;
51+
PersistenceProvider.SaveData(new AppUpdateReminderData { NumberOfAppRunsAfterLastReminder = value });
52+
}
53+
}
54+
55+
public AppUpdateReminder()
56+
{
57+
PersistenceProvider = new ReminderDataPersistenceFileProvider<AppUpdateReminderData>()
58+
{
59+
FilePath = "AppUpdateReminderData.xml"
60+
};
61+
PersistenceProvider.EnsureFileExistence(new AppUpdateReminderData { NumberOfAppRunsAfterLastReminder = _numberOfUsagesAfterLastReminder.GetValueOrDefault(0) });
62+
63+
this.MessageBoxCaption = "Update available";
64+
this.MessageBoxMessage = "Good news: A new version of the app is available to download. Do you want to update straight away?";
65+
}
66+
67+
public void Init()
68+
{
69+
if (this.UpdateValidator == null)
70+
throw new ArgumentNullException("UpdateValidator");
71+
72+
NumberOfUsagesAfterLastReminder++;
73+
74+
if (NumberOfUsagesAfterLastReminder >= RecurrencePerUsageCount.GetValueOrDefault(0))
75+
{
76+
NumberOfUsagesAfterLastReminder = 0;
77+
UpdateValidator.CurrentVersion = this.CurrentVersion;
78+
UpdateValidator.IsUpdateAvailableCompleted += UpdateValidator_IsUpdateAvailableCompleted;
79+
UpdateValidator.IsUpdateAvailableAsync();
80+
}
81+
}
82+
83+
void UpdateValidator_IsUpdateAvailableCompleted(object sender, IsUpdateAvailableCompletedEventArgs e)
84+
{
85+
if (e.IsUpdateAvailable)
86+
{
87+
var result = MessageBox.Show(MessageBoxMessage, MessageBoxCaption, MessageBoxButton.OKCancel);
88+
if (result == MessageBoxResult.OK)
89+
{
90+
MarketplaceDetailTask task = new MarketplaceDetailTask();
91+
task.Show();
92+
}
93+
}
94+
}
95+
}
96+
}

AppUpdateReminderData.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Xml.Serialization;
6+
7+
namespace Hedgehog.UpdateReminder
8+
{
9+
[XmlRoot]
10+
public class AppUpdateReminderData
11+
{
12+
[XmlElement]
13+
public int NumberOfAppRunsAfterLastReminder { get; set; }
14+
}
15+
}

AppUsageProvider.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace Hedgehog.UpdateReminder
7+
{
8+
public class AppUsageProvider
9+
{
10+
public int NumberOfUsagesAfterLastReminder { get; set; }
11+
}
12+
}

Hedgehog.UpdateReminder.csproj

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>10.0.20506</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{D9DA0A67-803E-495F-A78E-BF973524B4C6}</ProjectGuid>
9+
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
10+
<OutputType>Library</OutputType>
11+
<AppDesignerFolder>Properties</AppDesignerFolder>
12+
<RootNamespace>Hedgehog.UpdateReminder</RootNamespace>
13+
<AssemblyName>Hedgehog.UpdateReminder</AssemblyName>
14+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
15+
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
16+
<TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
17+
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
18+
<SilverlightApplication>false</SilverlightApplication>
19+
<ValidateXaml>true</ValidateXaml>
20+
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
23+
<DebugSymbols>true</DebugSymbols>
24+
<DebugType>full</DebugType>
25+
<Optimize>false</Optimize>
26+
<OutputPath>Bin\Debug</OutputPath>
27+
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
28+
<NoStdLib>true</NoStdLib>
29+
<NoConfig>true</NoConfig>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
34+
<DebugType>pdbonly</DebugType>
35+
<Optimize>true</Optimize>
36+
<OutputPath>Bin\Release</OutputPath>
37+
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
38+
<NoStdLib>true</NoStdLib>
39+
<NoConfig>true</NoConfig>
40+
<ErrorReport>prompt</ErrorReport>
41+
<WarningLevel>4</WarningLevel>
42+
</PropertyGroup>
43+
<ItemGroup>
44+
<Reference Include="Microsoft.Phone" />
45+
<Reference Include="System.Windows" />
46+
<Reference Include="system" />
47+
<Reference Include="System.Core" />
48+
<Reference Include="System.Xml" />
49+
<Reference Include="System.Net" />
50+
<Reference Include="mscorlib.extensions" />
51+
<Reference Include="System.Xml.Serialization" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Compile Include="AppUpdateReminder.cs" />
55+
<Compile Include="AppUpdateReminderData.cs" />
56+
<Compile Include="AppUsageProvider.cs" />
57+
<Compile Include="UpdateValidator\FileUpdateValidator.cs" />
58+
<Compile Include="IsUpdateAvailableCompletedEventArgs.cs" />
59+
<Compile Include="IUpdateValidator.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
<Compile Include="ReminderDataPersistenceFileProvider.cs" />
62+
</ItemGroup>
63+
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
64+
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
65+
<ProjectExtensions />
66+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
67+
Other similar extension points exist, see Microsoft.Common.targets.
68+
<Target Name="BeforeBuild">
69+
</Target>
70+
<Target Name="AfterBuild">
71+
</Target>
72+
-->
73+
</Project>

0 commit comments

Comments
 (0)