Skip to content

Commit 01d08c1

Browse files
author
RandomEngy
committed
Worked around splash screen dismissing the auto-update success dialog by using a proper window. Updated the auto-update XML.
1 parent 46d4809 commit 01d08c1

8 files changed

Lines changed: 86 additions & 24 deletions

File tree

Installer/latest.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<UpdateInfo>
22
<Release>
3-
<Latest>0.9.2</Latest>
4-
<DownloadLocation>http://engy.us/VidCoder/VidCoder-0.9.2-x86.exe</DownloadLocation>
5-
<ChangelogLocation>http://vidcoder.codeplex.com/releases/view/67904</ChangelogLocation>
3+
<Latest>1.0.0</Latest>
4+
<DownloadLocation>http://engy.us/VidCoder/VidCoder-1.0.0-x86.exe</DownloadLocation>
5+
<ChangelogLocation>http://vidcoder.codeplex.com/releases/view/71622</ChangelogLocation>
66
</Release>
77
<Release-x64>
8-
<Latest>0.9.2</Latest>
9-
<DownloadLocation>http://engy.us/VidCoder/VidCoder-0.9.2-x64.exe</DownloadLocation>
10-
<ChangelogLocation>http://vidcoder.codeplex.com/releases/view/67904</ChangelogLocation>
8+
<Latest>1.0.0</Latest>
9+
<DownloadLocation>http://engy.us/VidCoder/VidCoder-1.0.0-x64.exe</DownloadLocation>
10+
<ChangelogLocation>http://vidcoder.codeplex.com/releases/view/71622</ChangelogLocation>
1111
</Release-x64>
12-
</UpdateInfo>
12+
</UpdateInfo>

VidCoder/App.xaml.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Data;
55
using System.Linq;
66
using System.Windows;
7+
using VidCoder.Properties;
8+
using VidCoder.Services;
79
using VidCoder.ViewModel;
810
using System.IO.Pipes;
911
using System.IO;
@@ -28,9 +30,30 @@ protected override void OnStartup(StartupEventArgs e)
2830
#endif
2931
base.OnStartup(e);
3032

31-
var mainVM = new MainViewModel();
32-
WindowManager.OpenWindow(mainVM);
33-
mainVM.OnLoaded();
33+
Unity.Container.RegisterInstance(this);
34+
35+
// Upgrade from previous user settings.
36+
if (Settings.Default.ApplicationVersion != Utilities.CurrentVersion)
37+
{
38+
Settings.Default.Upgrade();
39+
Settings.Default.ApplicationVersion = Utilities.CurrentVersion;
40+
Settings.Default.Save();
41+
}
42+
43+
var updater = Unity.Container.Resolve<IUpdater>();
44+
bool updateSucceeded = updater.HandlePendingUpdate();
45+
46+
if (updateSucceeded)
47+
{
48+
var updateSuccess = new UpdateSuccess();
49+
updateSuccess.Show();
50+
}
51+
else
52+
{
53+
var mainVM = new MainViewModel();
54+
WindowManager.OpenWindow(mainVM);
55+
mainVM.OnLoaded();
56+
}
3457
}
3558

3659
private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)

VidCoder/Services/Interfaces/IUpdateService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface IUpdater
1111
event EventHandler<EventArgs> UpdateDownloadCompleted;
1212

1313
void CheckUpdates();
14-
void HandlePendingUpdate();
14+
bool HandlePendingUpdate();
1515
void PromptToApplyUpdate();
1616
void HandleUpdatedSettings(bool updatesEnabled);
1717

VidCoder/Services/Updater.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void HandleUpdatedSettings(bool updatesEnabled)
120120
}
121121
}
122122

123-
public void HandlePendingUpdate()
123+
public bool HandlePendingUpdate()
124124
{
125125
// This flag signifies VidCoder is being run by the installer after an update.
126126
// In this case we report success, delete the installer, clean up the update flags and exit.
@@ -146,14 +146,12 @@ public void HandlePendingUpdate()
146146

147147
if (updateSucceeded)
148148
{
149-
MessageBox.Show("VidCoder has been successfully updated.");
150-
151149
if (Directory.Exists(Utilities.UpdatesFolder))
152150
{
153151
Directory.Delete(Utilities.UpdatesFolder, true);
154152
}
155153

156-
Environment.Exit(0);
154+
return true;
157155
}
158156
else
159157
{
@@ -163,6 +161,8 @@ public void HandlePendingUpdate()
163161
MessageBox.Show("The update was not applied. If you did not cancel it, try installing it manually.");
164162
}
165163
}
164+
165+
return false;
166166
}
167167

168168
public void CheckUpdates()

VidCoder/VidCoder.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,10 @@
382382
<SubType>Designer</SubType>
383383
<Generator>MSBuild:Compile</Generator>
384384
</Page>
385+
<Page Include="View\UpdateSuccess.xaml">
386+
<SubType>Designer</SubType>
387+
<Generator>MSBuild:Compile</Generator>
388+
</Page>
385389
</ItemGroup>
386390
<ItemGroup>
387391
<Compile Include="Constants.cs" />
@@ -490,6 +494,9 @@
490494
<Compile Include="View\Panels\VideoPanel.xaml.cs">
491495
<DependentUpon>VideoPanel.xaml</DependentUpon>
492496
</Compile>
497+
<Compile Include="View\UpdateSuccess.xaml.cs">
498+
<DependentUpon>UpdateSuccess.xaml</DependentUpon>
499+
</Compile>
493500
<Compile Include="WindowPlacement.cs" />
494501
<Compile Include="WindowPlacementWpf.cs" />
495502
<EmbeddedResource Include="Properties\Resources.resx">

VidCoder/View/UpdateSuccess.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Window x:Class="VidCoder.View.UpdateSuccess"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
Title="Success" Height="119" Width="290" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
5+
<Grid>
6+
<TextBlock Text="VidCoder has been successfully updated." HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,12,0,0" />
7+
<Button Content="OK" Height="23" HorizontalAlignment="Right" Margin="0,0,12,12" Name="button1" VerticalAlignment="Bottom" Width="75" IsDefault="True" Click="button1_Click" />
8+
</Grid>
9+
</Window>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows;
6+
using System.Windows.Controls;
7+
using System.Windows.Data;
8+
using System.Windows.Documents;
9+
using System.Windows.Input;
10+
using System.Windows.Media;
11+
using System.Windows.Media.Imaging;
12+
using System.Windows.Shapes;
13+
14+
namespace VidCoder.View
15+
{
16+
/// <summary>
17+
/// This dialog is only needed to work around a problem where a modal dialog box is dismissed by the splash screen.
18+
/// </summary>
19+
public partial class UpdateSuccess : Window
20+
{
21+
public UpdateSuccess()
22+
{
23+
InitializeComponent();
24+
}
25+
26+
private void button1_Click(object sender, RoutedEventArgs e)
27+
{
28+
this.Close();
29+
}
30+
}
31+
}

VidCoder/ViewModel/MainViewModel.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,9 @@ public MainViewModel()
141141
{
142142
Unity.Container.RegisterInstance(this);
143143

144-
// Upgrade from previous user settings.
145-
if (Settings.Default.ApplicationVersion != Utilities.CurrentVersion)
146-
{
147-
Settings.Default.Upgrade();
148-
Settings.Default.ApplicationVersion = Utilities.CurrentVersion;
149-
Settings.Default.Save();
150-
}
144+
updater.CheckUpdates();
151145

152146
this.JobCreationAvailable = false;
153-
this.updater.HandlePendingUpdate();
154-
this.updater.CheckUpdates();
155147

156148
this.sourceOptions = new ObservableCollection<SourceOptionViewModel>
157149
{

0 commit comments

Comments
 (0)