-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from Grabacr07/exp/cef
Chromium (CefSharp.Wpf) 版
- Loading branch information
Showing
51 changed files
with
960 additions
and
624 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Microsoft Corporation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
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,30 @@ | ||
// Copyright � 2010-2017 The CefSharp Authors. All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following disclaimer | ||
// in the documentation and/or other materials provided with the | ||
// distribution. | ||
// | ||
// * Neither the name of Google Inc. nor the name Chromium Embedded | ||
// Framework nor the name CefSharp nor the names of its contributors | ||
// may be used to endorse or promote products derived from this software | ||
// without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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
7 changes: 7 additions & 0 deletions
7
source/Grabacr07.KanColleViewer/Application.InstrumentationKey.cs
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,7 @@ | ||
|
||
namespace Grabacr07.KanColleViewer | ||
{ | ||
partial class Application | ||
{ | ||
} | ||
} |
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,114 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using CefSharp; | ||
using CefSharp.Wpf; | ||
using Grabacr07.KanColleViewer.Models; | ||
using Grabacr07.KanColleViewer.Models.Cef; | ||
using Grabacr07.KanColleViewer.ViewModels; | ||
using Grabacr07.KanColleWrapper; | ||
using MetroTrilithon.Desktop; | ||
using Microsoft.ApplicationInsights; | ||
using Microsoft.ApplicationInsights.DataContracts; | ||
|
||
namespace Grabacr07.KanColleViewer | ||
{ | ||
partial class Application | ||
{ | ||
static Application() | ||
{ | ||
AppDomain.CurrentDomain.UnhandledException += (sender, args) => ReportException(sender, args.ExceptionObject as Exception); | ||
|
||
TelemetryClient = new TelemetryClient(); | ||
TelemetryClient.Context.Session.Id = Guid.NewGuid().ToString(); | ||
TelemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString(); | ||
TelemetryClient.Context.Component.Version = ProductInfo.VersionString; | ||
#if DEBUG | ||
TelemetryClient.Context.User.Id = Environment.UserName; | ||
#endif | ||
SetInstrumentationKey(); | ||
} | ||
|
||
public static TelemetryClient TelemetryClient { get; } | ||
|
||
public static Application Instance => Current as Application; | ||
|
||
static partial void SetInstrumentationKey(); | ||
|
||
private static void CefInitialize() | ||
{ | ||
var cefSettings = new CefSettings() | ||
{ | ||
CachePath = CefBridge.CachePath, | ||
}; | ||
cefSettings.CefCommandLineArgs.Add("proxy-server", Models.Settings.NetworkSettings.LocalProxySettingsString); | ||
//cefSettings.CefCommandLineArgs.Add("disable-webgl", "1"); | ||
CefSharpSettings.SubprocessExitIfParentProcessClosed = true; | ||
|
||
Cef.EnableHighDPISupport(); | ||
Cef.Initialize(cefSettings); | ||
} | ||
|
||
/// <summary> | ||
/// <see cref="ProxyBootstrapper"/> を使用し、<see cref="KanColleProxy"/> を起動することを試みます。 | ||
/// 必要に応じて、ユーザーに操作を求めるダイアログを表示します。 | ||
/// </summary> | ||
/// <returns><see cref="KanColleProxy"/> の起動に成功した場合は true、それ以外の場合は false。</returns> | ||
private static bool BootstrapProxy() | ||
{ | ||
var bootstrapper = new ProxyBootstrapper(); | ||
bootstrapper.Try(); | ||
|
||
if (bootstrapper.Result == ProxyBootstrapResult.Success) | ||
{ | ||
return true; | ||
} | ||
|
||
var vmodel = new ProxyBootstrapperViewModel(bootstrapper) { Title = ProductInfo.Title, }; | ||
var window = new Views.Settings.ProxyBootstrapper { DataContext = vmodel, }; | ||
window.ShowDialog(); | ||
|
||
return vmodel.DialogResult; | ||
} | ||
|
||
private static void ReportException(object sender, Exception exception) | ||
{ | ||
var now = DateTimeOffset.Now; | ||
var path = Path.Combine( | ||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), | ||
ProductInfo.Company, | ||
ProductInfo.Product, | ||
"ErrorReports", | ||
$"ErrorReport-{now:yyyyMMdd-HHmmss}-{now.Millisecond:000}.log"); | ||
|
||
var message = $@"*** Error Report *** | ||
{ProductInfo.Product} ver.{ProductInfo.VersionString} | ||
{DateTimeOffset.Now} | ||
{new SystemEnvironment()} | ||
Sender: {sender.GetType().FullName} | ||
Exception: {exception.GetType().FullName} | ||
{exception} | ||
"; | ||
try | ||
{ | ||
// ReSharper disable once AssignNullToNotNullAttribute | ||
Directory.CreateDirectory(Path.GetDirectoryName(path)); | ||
File.AppendAllText(path, message); | ||
|
||
TelemetryClient.TrackException(exception); | ||
TelemetryClient.TrackTrace(message, SeverityLevel.Critical); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Debug.WriteLine(ex); | ||
} | ||
|
||
Current.Shutdown(); | ||
} | ||
} | ||
} |
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.