-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
148 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using Livet; | ||
using System.Windows; | ||
|
||
using Livet; | ||
|
||
namespace Updater { | ||
/// <summary> | ||
/// App.xaml の相互作用ロジック | ||
/// </summary> | ||
public partial class App : Application { | ||
private void Application_Startup(object sender, StartupEventArgs e) { | ||
DispatcherHelper.UIDispatcher = Dispatcher; | ||
//AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); | ||
} | ||
|
||
//集約エラーハンドラ | ||
//private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | ||
//{ | ||
// //TODO:ロギング処理など | ||
// MessageBox.Show( | ||
// "不明なエラーが発生しました。アプリケーションを終了します。", | ||
// "エラー", | ||
// MessageBoxButton.OK, | ||
// MessageBoxImage.Error); | ||
// | ||
// Environment.Exit(1); | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using Updater.ViewModels; | ||
using Microsoft.Win32; | ||
using System; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
namespace Updater.Models { | ||
public class InstallProcess { | ||
|
||
private readonly MainWindowViewModel Owner; | ||
|
||
public InstallProcess(MainWindowViewModel vm) { | ||
|
||
Owner = vm; | ||
} | ||
|
||
public async Task InstallAsync() { | ||
|
||
Owner.Status = "レジストリ登録中"; | ||
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", "SRNicoNico.exe", 0x00002AF8, RegistryValueKind.DWord); | ||
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING", "SRNicoNico.exe", 0x00000001, RegistryValueKind.DWord); | ||
|
||
var location = Owner.InstallLocation; | ||
|
||
var settings = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SRNicoNico"); | ||
|
||
if (Directory.Exists(location)) { | ||
|
||
Owner.Status = "元ファイルバックアップ中"; | ||
if (File.Exists(Path.Combine(settings, "backup.zip"))) { | ||
|
||
Owner.Status = "古いバックアップファイルを削除中"; | ||
File.Delete(Path.Combine(settings, "backup.zip")); | ||
} | ||
|
||
ZipFile.CreateFromDirectory(location, Path.Combine(settings, "backup.zip"), CompressionLevel.Optimal, true); | ||
} | ||
|
||
Owner.Status = "ディレクトリ作成中"; | ||
Directory.CreateDirectory(location); | ||
Directory.CreateDirectory(Path.Combine(location, "tmp")); | ||
Directory.CreateDirectory(settings); | ||
|
||
using (var wc = new WebClient()) { | ||
|
||
Owner.Status = "本体ダウンロード中"; | ||
await wc.DownloadFileTaskAsync(await UpdateChecker.GetLatestBinaryUrl(wc), Path.Combine(location, @"tmp\data")); | ||
} | ||
|
||
Owner.Status = "解凍中"; | ||
using (var archive = ZipFile.OpenRead(Path.Combine(location, @"tmp\data"))) { | ||
|
||
retry: | ||
try { | ||
foreach (var entry in archive.Entries) { | ||
|
||
var fullname = Path.Combine(location, entry.FullName); | ||
var dir = Path.GetDirectoryName(fullname); | ||
if (!Directory.Exists(fullname)) { | ||
|
||
Directory.CreateDirectory(dir); | ||
} | ||
if (!string.IsNullOrEmpty(Path.GetFileName(fullname))) { | ||
|
||
entry.ExtractToFile(fullname, true); | ||
} | ||
} | ||
} catch(Exception) { | ||
|
||
Thread.Sleep(100); | ||
goto retry; | ||
} | ||
|
||
} | ||
Owner.Status = "OKOK"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.