Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
karoterra committed Jan 27, 2022
2 parents ccc4240 + c037cf1 commit 79df05b
Show file tree
Hide file tree
Showing 78 changed files with 3,515 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ insert_final_newline = true
[*.xml]
indent_size = 2

[.json]
[*.json]
indent_size = 2

[*.md]
charset = utf-8

[*.sln]
indent_style = tab
indent_size = 2
Expand Down
73 changes: 73 additions & 0 deletions AupInfo.Core/AupFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System.Reactive.Linq;
using Karoterra.AupDotNet;
using Reactive.Bindings;
using Reactive.Bindings.Extensions;

namespace AupInfo.Core
{
public class AupFile : DisposableBase
{
public ReadOnlyReactivePropertySlim<string?> FilePath { get; }
public ReadOnlyReactivePropertySlim<string?> FileName { get; }

public ReactivePropertySlim<EditHandle?> EditHandle { get; }
public ReactiveCollection<FilterProject> FilterProjects { get; }

public ReactiveCommand Opened { get; }

private readonly ReactivePropertySlim<string?> filepath;
private AviUtlProject? aup = null;

public AupFile()
{
filepath = new ReactivePropertySlim<string?>(null)
.AddTo(disposables);

FilePath = filepath.ToReadOnlyReactivePropertySlim()
.AddTo(disposables);
FileName = filepath
.Select(x => Path.GetFileName(x))
.ToReadOnlyReactivePropertySlim()
.AddTo(disposables);

EditHandle = new ReactivePropertySlim<EditHandle?>(null)
.AddTo(disposables);
FilterProjects = new ReactiveCollection<FilterProject>()
.AddTo(disposables);

Opened = new ReactiveCommand()
.AddTo(disposables);
}

public void Open(string path)
{
aup = new(path);
EditHandle.Value = aup.EditHandle;
filepath.Value = path;

FilterProjects.ClearOnScheduler();
FilterProjects.AddRangeOnScheduler(aup.FilterProjects);

Opened.Execute();
}

public void Close()
{
aup = null;
EditHandle.Value = null;
FilterProjects.ClearOnScheduler();
filepath.Value = null;
}

public void Save(string? path = null)
{
if (aup == null) return;
if (path == null)
path = filepath.Value!;

using var fs = File.Create(path);
using BinaryWriter bw = new(fs);
aup.Write(bw);
}
}
}
21 changes: 21 additions & 0 deletions AupInfo.Core/AupInfo.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.0</Version>
<Authors>karoterra</Authors>
<Copyright>Copyright (c) 2022 karoterra</Copyright>
<RepositoryUrl>https://github.com/karoterra/AupInfo</RepositoryUrl>
<PackageProjectUrl>https://github.com/karoterra/AupInfo</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Karoterra.AupDotNet" Version="0.1.0" />
<PackageReference Include="Prism.Core" Version="8.1.97" />
<PackageReference Include="ReactiveProperty" Version="8.0.3" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions AupInfo.Core/CoreModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Prism.Ioc;
using Prism.Modularity;

namespace AupInfo.Core
{
public class CoreModule : IModule
{
public void OnInitialized(IContainerProvider containerProvider)
{
}

public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterSingleton<AupFile>();
containerRegistry.RegisterSingleton<ExEditRepository>();
containerRegistry.RegisterSingleton<PsdToolKitRepository>();
}
}
}
33 changes: 33 additions & 0 deletions AupInfo.Core/DisposableBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Reactive.Disposables;

namespace AupInfo.Core
{
public abstract class DisposableBase : IDisposable
{
protected readonly CompositeDisposable disposables = new();

#region IDisposable

protected bool disposedValue;

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
disposables.Dispose();
}
disposedValue = true;
}
}

public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}

#endregion
}
}
26 changes: 26 additions & 0 deletions AupInfo.Core/ExEditFigure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace AupInfo.Core
{
public class ExEditFigure
{
public string Name { get; }
public string Kind { get; }

public ExEditFigure(string name, string kind)
{
Name = name;
Kind = kind;
}

public override bool Equals(object? obj)
{
return obj is ExEditFigure fig
&& Name == fig.Name
&& Kind == fig.Kind;
}

public override int GetHashCode()
{
return Name.GetHashCode() ^ Kind.GetHashCode();
}
}
}
38 changes: 38 additions & 0 deletions AupInfo.Core/ExEditFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Reactive.Bindings;
using Reactive.Bindings.Extensions;

namespace AupInfo.Core
{
public enum ExEditFileLocation
{
Path,
Project,
NotFound,
}

public class ExEditFile : DisposableBase
{
public ReactivePropertySlim<string> FilePath { get; }
public ReactivePropertySlim<string> FileType { get; }
public ReactivePropertySlim<ExEditFileLocation> Location { get; }

public ExEditFile(string path, string type, ExEditFileLocation location)
{
FilePath = new ReactivePropertySlim<string>(path).AddTo(disposables);
FileType = new ReactivePropertySlim<string>(type).AddTo(disposables);
Location = new ReactivePropertySlim<ExEditFileLocation>(location).AddTo(disposables);
}

public override bool Equals(object? obj)
{
return obj is ExEditFile file
&& FilePath.Value == file.FilePath.Value
&& FileType.Value == file.FileType.Value;
}

public override int GetHashCode()
{
return FilePath.Value.GetHashCode() ^ FileType.Value.GetHashCode();
}
}
}
Loading

0 comments on commit 79df05b

Please sign in to comment.