Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
livewing committed Jun 7, 2016
2 parents 9d759d5 + c6554d3 commit eed974d
Show file tree
Hide file tree
Showing 32 changed files with 755 additions and 980 deletions.
13 changes: 4 additions & 9 deletions CtrlLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using Livet;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;

using Livet;

namespace CtrlLauncher
{
/// <summary>
Expand All @@ -20,11 +15,11 @@ public partial class App : Application
private void Application_Startup(object sender, StartupEventArgs e)
{
DispatcherHelper.UIDispatcher = Dispatcher;
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}

// 集約エラーハンドラ
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
Expand Down
4 changes: 0 additions & 4 deletions CtrlLauncher/Behaviors/AvalonEditBindingBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using ICSharpCode.AvalonEdit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interactivity;

Expand Down
16 changes: 14 additions & 2 deletions CtrlLauncher/CtrlLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,24 @@
<Compile Include="Models\AppInfo.cs" />
<Compile Include="Models\FileEntry.cs" />
<Compile Include="Models\LauncherCore.cs" />
<Compile Include="Utils.cs" />
<Compile Include="Models\Settings.cs" />
<Compile Include="Utils\BindableBase.cs" />
<Compile Include="Utils\Utils.cs" />
<Compile Include="Utils\ViewModelBase.cs" />
<Compile Include="ViewModels\AppInfoViewModel.cs" />
<Compile Include="ViewModels\AppSpecViewModel.cs" />
<Compile Include="ViewModels\FileEntryViewModel.cs" />
<Compile Include="ViewModels\LauncherCoreViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\SettingsWindowViewModel.cs" />
<Compile Include="ViewModels\SourceCodeContentViewModel.cs" />
<Compile Include="Views\SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SourceCodeContent.xaml.cs">
<DependentUpon>SourceCodeContent.xaml</DependentUpon>
</Compile>
<Compile Include="Win32.cs" />
<Compile Include="Utils\Win32.cs" />
<Page Include="Views\AboutContent.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -161,6 +169,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Views\SettingsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SourceCodeContent.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
19 changes: 5 additions & 14 deletions CtrlLauncher/Models/About.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

using Livet;
using System.IO;

namespace CtrlLauncher.Models
{
public class About : NotificationObject
public class About
{
public string Version { get; private set; }
public string Version => Assembly.GetExecutingAssembly().GetName().Version.ToString(3);

public IEnumerable<Tuple<string, string, string>> Licenses { get; private set; }
public IEnumerable<Tuple<string, string, string>> Licenses { get; }

public void OpenUri(string uriString)
{
Process.Start(uriString);
}
public void OpenUri(string uriString) => Process.Start(uriString);

public About()
{
// バージョンを取得
Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(3);

// 埋め込まれたライセンス条項ファイルの読み込み
var asm = Assembly.GetExecutingAssembly();
var licenses = asm.GetManifestResourceNames().Where(n => n.StartsWith("CtrlLauncher.Resources.Licenses."));
Expand Down
42 changes: 26 additions & 16 deletions CtrlLauncher/Models/AppInfo.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Reactive.Linq;
using System.Windows.Media.Imaging;

using Livet;

namespace CtrlLauncher.Models
{
public class AppInfo : NotificationObject
public class AppInfo : BindableBase
{
private LauncherCore core;

public AppSpec AppSpec { get; private set; }
public AppSpec AppSpec { get; }

public string Path { get; private set; }
public string Path { get; }

public BitmapImage ScreenshotImage { get; private set; }
public BitmapImage ScreenshotImage { get; }

public int StartCount { get { return core.GetCount(this); } }
public int StartCount => core.GetCount(this);

public string SourceAbsolutePath { get { return toAbsolutePath(AppSpec.SourcePath); } }
public string SourceAbsolutePath => toAbsolutePath(AppSpec.SourcePath);

public AppInfo(LauncherCore core, AppSpec spec, string path)
{
Expand Down Expand Up @@ -51,7 +47,24 @@ public void Start(Action timeoutHandler)
core.SetCount(this, core.GetCount(this) + 1);
RaisePropertyChanged(nameof(StartCount));

if (AppSpec.TimeLimit > TimeSpan.Zero)
TimeSpan timeLimit;
switch (core.Settings.GlobalTimeLimitMode)
{
case Settings.TimeLimitMode.Default:
timeLimit = (AppSpec.TimeLimit == TimeSpan.Zero) ? core.Settings.GlobalTimeLimit : AppSpec.TimeLimit;
break;
case Settings.TimeLimitMode.Enabled:
timeLimit = (AppSpec.TimeLimit == TimeSpan.Zero || AppSpec.TimeLimit > core.Settings.GlobalTimeLimit) ? core.Settings.GlobalTimeLimit : AppSpec.TimeLimit;
break;
case Settings.TimeLimitMode.Forced:
timeLimit = core.Settings.GlobalTimeLimit;
break;
default:
timeLimit = AppSpec.TimeLimit;
break;
}

if (timeLimit > TimeSpan.Zero)
{
IDisposable d = null;
var s = Observable.Interval(TimeSpan.FromMilliseconds(100)).Where(_ =>
Expand All @@ -69,7 +82,7 @@ public void Start(Action timeoutHandler)
});
d = s.Subscribe(_ =>
{
var remaining = AppSpec.TimeLimit - (DateTime.Now - process.StartTime);
var remaining = timeLimit - (DateTime.Now - process.StartTime);
if (remaining < TimeSpan.Zero)
{
process.Kill();
Expand Down Expand Up @@ -107,9 +120,6 @@ public void OpenDirectory()
catch { }
}

private string toAbsolutePath(string relative)
{
return new Uri(new Uri(Path + "\\"), relative).LocalPath;
}
private string toAbsolutePath(string relative) => new Uri(new Uri(Path + "\\"), relative).LocalPath;
}
}
15 changes: 5 additions & 10 deletions CtrlLauncher/Models/AppSpec.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;

using Livet;
using YamlDotNet.Serialization;
using System.IO;

namespace CtrlLauncher.Models
{
public class AppSpec : NotificationObject
public class AppSpec
{
public string Id { get; set; }

public string Title { get; set; }

public string Genre { get; set; }
Expand All @@ -28,10 +26,7 @@ public class AppSpec : NotificationObject

public string Description { get; set; }

public AppSpec()
{

}
public bool IsLate { get; set; } = false;

public static async Task<AppSpec> LoadAsync(string path)
{
Expand Down
18 changes: 5 additions & 13 deletions CtrlLauncher/Models/FileEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
Expand All @@ -11,20 +10,13 @@ namespace CtrlLauncher.Models
{
public class FileEntry
{
public string Name { get; private set; }
public string Name { get; }

public string Path { get; private set; }
public string Path { get; }

public bool IsDirectory { get; private set; }
public bool IsDirectory { get; }

public long Size
{
get
{
if (IsDirectory) return 0;
return new FileInfo(Path).Length;
}
}
public long Size => IsDirectory ? 0 : new FileInfo(Path).Length;

#region Childrenプロパティ
private IEnumerable<FileEntry> _Children = null;
Expand All @@ -34,7 +26,7 @@ public IEnumerable<FileEntry> Children
{
if (_Children != null)
return _Children;
else if (Directory.Exists(Path))
if (Directory.Exists(Path))
{
IEnumerable<string> dirs = Enumerable.Empty<string>();
IEnumerable<string> files = Enumerable.Empty<string>();
Expand Down
Loading

0 comments on commit eed974d

Please sign in to comment.