first commit
This commit is contained in:
388
.gitignore
vendored
Normal file
388
.gitignore
vendored
Normal file
@ -0,0 +1,388 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Nuget personal access tokens and Credentials
|
||||
nuget.config
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
9
App.xaml
Normal file
9
App.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Application x:Class="BallanceTASEditor.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:BallanceTASEditor"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
14
App.xaml.cs
Normal file
14
App.xaml.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
/// <summary>
|
||||
/// App.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class App : Application {
|
||||
}
|
||||
}
|
||||
104
BallanceTASEditor.csproj
Normal file
104
BallanceTASEditor.csproj
Normal file
@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3127A635-B9E5-4C78-8414-0B9B196EC25E}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>BallanceTASEditor</RootNamespace>
|
||||
<AssemblyName>BallanceTASEditor</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="zlib.net, Version=1.0.3.0, Culture=neutral, PublicKeyToken=47d7877cb3620160">
|
||||
<HintPath>packages\zlib.net.1.0.4.0\lib\zlib.net.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="StyleConverter.cs" />
|
||||
<Compile Include="TASViewer.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Core\TASFile.cs" />
|
||||
<Compile Include="Core\TASStruct.cs" />
|
||||
<Compile Include="Core\Util.cs" />
|
||||
<Compile Include="Core\ZlibUtil.cs" />
|
||||
<Compile Include="DialogUtil.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
25
BallanceTASEditor.sln
Normal file
25
BallanceTASEditor.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29418.71
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BallanceTASEditor", "BallanceTASEditor.csproj", "{3127A635-B9E5-4C78-8414-0B9B196EC25E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3127A635-B9E5-4C78-8414-0B9B196EC25E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3127A635-B9E5-4C78-8414-0B9B196EC25E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3127A635-B9E5-4C78-8414-0B9B196EC25E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3127A635-B9E5-4C78-8414-0B9B196EC25E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {ABECA811-4FBB-4394-805E-EEBC799ECC89}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
81
Core/TASFile.cs
Normal file
81
Core/TASFile.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using BallanceTASEditor.Core.TASStruct;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BallanceTASEditor.Core {
|
||||
public class TASFile {
|
||||
public TASFile(string filename) {
|
||||
mFilename = filename;
|
||||
mMem = new LinkedList<FrameData>();
|
||||
var fs = new FileStream(mFilename, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
ZlibUtil.DecompressTAS(mMem, fs);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
mPointer = mMem.First;
|
||||
}
|
||||
|
||||
public string mFilename { get; private set; }
|
||||
public long mFrameCount { get { return mMem.Count; } }
|
||||
LinkedList<FrameData> mMem;
|
||||
LinkedListNode<FrameData> mPointer;
|
||||
|
||||
public void Shift(long shiftNum) {
|
||||
if (mPointer == null) return;
|
||||
if (shiftNum == 0) return;
|
||||
var absNum = Math.Abs(shiftNum);
|
||||
if (shiftNum > 0) {
|
||||
for(long num = 0; num < absNum && mPointer.Next != null; num++) {
|
||||
mPointer = mPointer.Next;
|
||||
}
|
||||
} else {
|
||||
for (long num = 0; num < absNum && mPointer.Previous != null; num++) {
|
||||
mPointer = mPointer.Previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Get(ObservableCollection<FrameDataDisplay> container, long startIndex, int count) {
|
||||
if (mPointer == null) return 0;
|
||||
var cachePointer = mPointer;
|
||||
int i;
|
||||
for(i = 0; i < count && cachePointer != null; i++, startIndex++) {
|
||||
container[i].Reload(startIndex, cachePointer.Value);
|
||||
cachePointer = cachePointer.Next;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public void Set(FrameDataField field, long prevRange, long nextRange, bool isSet) {
|
||||
if (mPointer == null) return;
|
||||
|
||||
var cachePointer = mPointer;
|
||||
var offset = ConstValue.Mapping[field];
|
||||
for (long i = 0; i < nextRange && cachePointer != null; i++) {
|
||||
if (isSet) cachePointer.Value.SetKeyStates(offset);
|
||||
else cachePointer.Value.UnsetKeyStates(offset);
|
||||
cachePointer = cachePointer.Next;
|
||||
}
|
||||
for (long i = 0; i < prevRange && cachePointer != null; i++) {
|
||||
if (isSet) cachePointer.Value.SetKeyStates(offset);
|
||||
else cachePointer.Value.UnsetKeyStates(offset);
|
||||
cachePointer = cachePointer.Previous;
|
||||
}
|
||||
}
|
||||
|
||||
public void Save() {
|
||||
var fs = new FileStream(mFilename, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
ZlibUtil.CompressTAS(mMem, fs);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
}
|
||||
|
||||
public void SaveAs(string newfile) {
|
||||
mFilename = newfile;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
144
Core/TASStruct.cs
Normal file
144
Core/TASStruct.cs
Normal file
@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BallanceTASEditor.Core.TASStruct {
|
||||
public class FrameDataDisplay : INotifyPropertyChanged {
|
||||
public FrameDataDisplay(long index, FrameData fd) {
|
||||
Reload(index, fd);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(String propertyName) {
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void Reload(long index, FrameData fd) {
|
||||
this.index = index;
|
||||
this.deltaTime = fd.deltaTime;
|
||||
|
||||
OnPropertyChanged("index");
|
||||
OnPropertyChanged("deltaTime");
|
||||
|
||||
this.keystates = fd.keystates;
|
||||
}
|
||||
|
||||
public long index { get; set; }
|
||||
public float deltaTime { get; set; }
|
||||
public UInt32 keystates {
|
||||
get {
|
||||
UInt32 result = 0;
|
||||
if (key_enter) result |= 1; result <<= 1;
|
||||
if (key_esc) result |= 1; result <<= 1;
|
||||
if (key_q) result |= 1; result <<= 1;
|
||||
if (key_space) result |= 1; result <<= 1;
|
||||
if (key_shift) result |= 1; result <<= 1;
|
||||
if (key_right) result |= 1; result <<= 1;
|
||||
if (key_left) result |= 1; result <<= 1;
|
||||
if (key_down) result |= 1; result <<= 1;
|
||||
if (key_up) result |= 1; result <<= 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
set {
|
||||
key_up = (value & (1 << 0)).ToBool();
|
||||
key_down = (value & (1 << 1)).ToBool();
|
||||
key_left = (value & (1 << 2)).ToBool();
|
||||
key_right = (value & (1 << 3)).ToBool();
|
||||
key_shift = (value & (1 << 4)).ToBool();
|
||||
key_space = (value & (1 << 5)).ToBool();
|
||||
key_q = (value & (1 << 6)).ToBool();
|
||||
key_esc = (value & (1 << 7)).ToBool();
|
||||
key_enter = (value & (1 << 8)).ToBool();
|
||||
|
||||
OnPropertyChanged("key_up");
|
||||
OnPropertyChanged("key_down");
|
||||
OnPropertyChanged("key_left");
|
||||
OnPropertyChanged("key_right");
|
||||
OnPropertyChanged("key_shift");
|
||||
OnPropertyChanged("key_space");
|
||||
OnPropertyChanged("key_q");
|
||||
OnPropertyChanged("key_esc");
|
||||
OnPropertyChanged("key_enter");
|
||||
}
|
||||
}
|
||||
public bool key_up { get; set; }
|
||||
public bool key_down { get; set; }
|
||||
public bool key_left { get; set; }
|
||||
public bool key_right { get; set; }
|
||||
public bool key_shift { get; set; }
|
||||
public bool key_space { get; set; }
|
||||
public bool key_q { get; set; }
|
||||
public bool key_esc { get; set; }
|
||||
public bool key_enter { get; set; }
|
||||
}
|
||||
|
||||
public class FrameData {
|
||||
|
||||
public FrameData(Stream st) {
|
||||
var temp = new byte[ConstValue.FRAMEDATA_SIZE];
|
||||
st.Read(temp, 0, ConstValue.FRAMEDATA_SIZE);
|
||||
|
||||
deltaTime = BitConverter.ToSingle(temp, ConstValue.FRAMEDATA_OFFSET_DELTATIME);
|
||||
keystates = BitConverter.ToUInt32(temp, ConstValue.FRAMEDATA_OFFSET_KEY_STATES);
|
||||
}
|
||||
public FrameData(FrameDataDisplay fdd) {
|
||||
this.deltaTime = fdd.deltaTime;
|
||||
this.keystates = fdd.keystates;
|
||||
}
|
||||
|
||||
public FrameData() {
|
||||
this.deltaTime = 0f;
|
||||
this.keystates = 0;
|
||||
}
|
||||
|
||||
public FrameData(float d, UInt32 k) {
|
||||
this.deltaTime = d;
|
||||
this.keystates = k;
|
||||
}
|
||||
|
||||
public void SetKeyStates(UInt32 offset) {
|
||||
keystates |= offset;
|
||||
}
|
||||
|
||||
public void UnsetKeyStates(UInt32 offset) {
|
||||
keystates &= ~offset;
|
||||
}
|
||||
|
||||
public float deltaTime;
|
||||
public UInt32 keystates;
|
||||
}
|
||||
|
||||
public class ConstValue {
|
||||
public static readonly Dictionary<FrameDataField, UInt32> Mapping = new Dictionary<FrameDataField, UInt32>() {
|
||||
{FrameDataField.Key_Up, (1 << 0)},
|
||||
{FrameDataField.Key_Down, (1 << 1)},
|
||||
{FrameDataField.Key_Left, (1 << 2)},
|
||||
{FrameDataField.Key_Right, (1 << 3)},
|
||||
{FrameDataField.Key_Shift, (1 << 4)},
|
||||
{FrameDataField.Key_Space, (1 << 5)},
|
||||
{FrameDataField.Key_Q, (1 << 6)},
|
||||
{FrameDataField.Key_Esc, (1 << 7)},
|
||||
{FrameDataField.Key_Enter, (1 << 8)}
|
||||
};
|
||||
public const int FRAMEDATA_SIZE = 8;
|
||||
public const int FRAMEDATA_OFFSET_DELTATIME = 0;
|
||||
public const int FRAMEDATA_OFFSET_KEY_STATES = 4;
|
||||
}
|
||||
|
||||
public enum FrameDataField {
|
||||
Key_Up,
|
||||
Key_Down,
|
||||
Key_Left,
|
||||
Key_Right,
|
||||
Key_Shift,
|
||||
Key_Space,
|
||||
Key_Q,
|
||||
Key_Esc,
|
||||
Key_Enter
|
||||
}
|
||||
|
||||
}
|
||||
22
Core/Util.cs
Normal file
22
Core/Util.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using BallanceTASEditor.Core.TASStruct;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BallanceTASEditor.Core {
|
||||
public static class Util {
|
||||
public static bool ToBool(this UInt32 num) {
|
||||
return (num != 0);
|
||||
}
|
||||
public static UInt32 ToUInt32(this bool b) {
|
||||
return (UInt32)(b ? 1 : 0);
|
||||
}
|
||||
//public static void RemoveRange(this ModifiedObservableCollection<FrameData> list, int index, int count) {
|
||||
// if (index >= list.Count) return;
|
||||
// if (index + count > list.Count) count = list.Count - index;
|
||||
// for (int i = 0; i < count; i++) list.RemoveAt(index);
|
||||
//}
|
||||
}
|
||||
}
|
||||
55
Core/ZlibUtil.cs
Normal file
55
Core/ZlibUtil.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using BallanceTASEditor.Core.TASStruct;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BallanceTASEditor.Core {
|
||||
public class ZlibUtil {
|
||||
private const int COPY_STREAM_UNIT = 1024;
|
||||
|
||||
public static void CompressTAS(LinkedList<FrameData> mem, FileStream file) {
|
||||
file.Write(BitConverter.GetBytes(mem.Count * ConstValue.FRAMEDATA_SIZE), 0, 4);
|
||||
|
||||
var zo = new zlib.ZOutputStream(file, 9);
|
||||
var node = mem.First;
|
||||
while (node != null) {
|
||||
zo.Write(BitConverter.GetBytes(node.Value.deltaTime), 0, 4);
|
||||
zo.Write(BitConverter.GetBytes(node.Value.keystates), 0, 4);
|
||||
node = node.Next;
|
||||
}
|
||||
zo.finish();
|
||||
zo.Close();
|
||||
}
|
||||
|
||||
public static void DecompressTAS(LinkedList<FrameData> ls, FileStream file) {
|
||||
var lengthTemp = new byte[4];
|
||||
var mem = new MemoryStream();
|
||||
file.Read(lengthTemp, 0, 4);
|
||||
Int32 expectedLength = BitConverter.ToInt32(lengthTemp, 0);
|
||||
long expectedCount = expectedLength / ConstValue.FRAMEDATA_SIZE;
|
||||
|
||||
var zo = new zlib.ZOutputStream(mem);
|
||||
CopyStream(file, zo);
|
||||
zo.finish();
|
||||
|
||||
mem.Seek(0, SeekOrigin.Begin);
|
||||
for(long i = 0; i < expectedCount; i++) {
|
||||
ls.AddLast(new FrameData(mem));
|
||||
}
|
||||
mem.Close();
|
||||
zo.Close();
|
||||
}
|
||||
|
||||
public static void CopyStream(Stream origin, Stream target) {
|
||||
var buffer = new byte[COPY_STREAM_UNIT];
|
||||
int len;
|
||||
while ((len = origin.Read(buffer, 0, COPY_STREAM_UNIT)) > 0) {
|
||||
target.Write(buffer, 0, len);
|
||||
}
|
||||
//target.Flush();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
33
DialogUtil.cs
Normal file
33
DialogUtil.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
public class DialogUtil {
|
||||
|
||||
public static string OpenFileDialog() {
|
||||
Microsoft.Win32.OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();
|
||||
op.RestoreDirectory = true;
|
||||
op.Multiselect = false;
|
||||
op.Filter = "TAS file(*.tas)|*.tas|All file(*.*)|*.*";
|
||||
if (!(bool)op.ShowDialog()) return "";
|
||||
return op.FileName;
|
||||
}
|
||||
|
||||
public static string SaveFileDialog() {
|
||||
Microsoft.Win32.SaveFileDialog op = new Microsoft.Win32.SaveFileDialog();
|
||||
op.RestoreDirectory = true;
|
||||
op.Filter = "TAS file(*.tas)|*.tas|All file(*.*)|*.*";
|
||||
if (!(bool)op.ShowDialog()) return "";
|
||||
return op.FileName;
|
||||
}
|
||||
|
||||
public static bool ConfirmDialog(string str) {
|
||||
var result = MessageBox.Show(str, "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
return (result == MessageBoxResult.Yes);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
271
MainWindow.xaml
Normal file
271
MainWindow.xaml
Normal file
@ -0,0 +1,271 @@
|
||||
<Window x:Class="BallanceTASEditor.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:BallanceTASEditor"
|
||||
xmlns:converter="clr-namespace:BallanceTASEditor"
|
||||
mc:Ignorable="d"
|
||||
Title="Ballance TAS Editor" Height="800" Width="500">
|
||||
<Window.Resources>
|
||||
<converter:BackgroundConverter x:Key="bgConv"></converter:BackgroundConverter>
|
||||
<converter:FloatConverter x:Key="floatConv"></converter:FloatConverter>
|
||||
<converter:LongConverter x:Key="longConv"></converter:LongConverter>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Menu Grid.Row="0">
|
||||
<MenuItem Header="File">
|
||||
<MenuItem x:Name="uiMenu_File_Open" Header="Open" Click="funcMenu_File_Open"/>
|
||||
<MenuItem x:Name="uiMenu_File_Save" Header="Save" Click="funcMenu_File_Save"/>
|
||||
<MenuItem x:Name="uiMenu_File_SaveAs" Header="Save As..." Click="funcMenu_File_SaveAs"/>
|
||||
<MenuItem x:Name="uiMenu_File_Close" Header="Close" Click="funcMenu_File_Close"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Help">
|
||||
<MenuItem x:Name="uiMenu_Help_ReportBugs" Header="Report bugs" Click="funcMenu_Help_ReportBugs"/>
|
||||
<MenuItem x:Name="uiMenu_Help_About" Header="About" Click="funcMenu_Help_About"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<TextBlock x:Name="uiEditorNote" Grid.Row="1" Text="Open a TAS file for editing" Opacity="0.5" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16"/>
|
||||
|
||||
<Grid x:Name="uiEditorPanel" Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.ColumnSpan="2">
|
||||
<Button x:Name="uiBtn_Select" Margin="5" Padding="5">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Viewbox Width="24" Height="24">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
<TextBlock Text="Select mode" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button x:Name="uiBtn_Fill" Margin="5" Padding="5">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Viewbox Width="24" Height="24">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
<TextBlock Text="Fill mode" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button x:Name="uiBtn_Draw" Margin="5" Padding="5">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Viewbox Width="24" Height="24">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M18.62,1.5C18.11,1.5 17.6,1.69 17.21,2.09L10.75,8.55L14.95,12.74L21.41,6.29C22.2,5.5 22.2,4.24 21.41,3.46L20.04,2.09C19.65,1.69 19.14,1.5 18.62,1.5M9.8,9.5L3.23,16.07L3.93,16.77C3.4,17.24 2.89,17.78 2.38,18.29C1.6,19.08 1.6,20.34 2.38,21.12C3.16,21.9 4.42,21.9 5.21,21.12C5.72,20.63 6.25,20.08 6.73,19.58L7.43,20.27L14,13.7" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
<TextBlock Text="Draw mode" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid x:Name="uiTASData" ItemsSource="{Binding}" Grid.Column="0" Grid.Row="1" CanUserReorderColumns="False" CanUserSortColumns="False" IsReadOnly="true" AutoGenerateColumns="False" SelectionUnit="Cell" SelectionMode="Single" Background="#00000000" BorderThickness="1" Margin="5" HorizontalScrollBarVisibility="Visible">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Frame" Binding="{Binding index,Converter={StaticResource longConv},Mode=OneWay}"/>
|
||||
<DataGridTextColumn Header="Delta Time" Binding="{Binding deltaTime,Converter={StaticResource floatConv},Mode=OneWay}"/>
|
||||
|
||||
<DataGridTemplateColumn Header="^" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_up,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="v" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_down,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="<" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_left,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header=">" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_right,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="shift" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_shift,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="space" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_space,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="q" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_q,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="esc" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_esc,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="enter" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_enter,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem x:Name="uiDataMenu_Set" Header="Set"/>
|
||||
<MenuItem x:Name="uiDataMenu_Unset" Header="Unset"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_Copy" Header="Copy"/>
|
||||
<MenuItem x:Name="uiDataMenu_Delete" Header="Delete"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_PasteAfter" Header="Paste after this"/>
|
||||
<MenuItem x:Name="uiDataMenu_PasteBefore" Header="Paste before this"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_AddAfter" Header="Add blank item after this"/>
|
||||
<MenuItem x:Name="uiDataMenu_AddBefore" Header="Add blank item before this"/>
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
</DataGrid>
|
||||
|
||||
<Grid Grid.Column="1" Grid.Row="1" Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" RenderTransformOrigin="0.5,0.5" Margin="2" HorizontalAlignment="Center">
|
||||
<Button.RenderTransform>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Button.RenderTransform>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M13,6V18L21.5,12M4,18L12.5,12L4,6V18Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M7,15L12,10L17,15H7Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Slider x:Name="uiTASSlider" Margin="0, 5, 0, 5" Grid.Row="2" Orientation="Vertical" RenderTransformOrigin="0.5,0.5" SmallChange="1" LargeChange="10" Maximum="1" HorizontalAlignment="Center">
|
||||
<Slider.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleY="-1" ScaleX="1"/>
|
||||
<SkewTransform AngleY="0" AngleX="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Slider.LayoutTransform>
|
||||
</Slider>
|
||||
<Button Grid.Row="3" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M7,10L12,15L17,10H7Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Grid.Row="4" RenderTransformOrigin="0.5,0.5" Margin="2" HorizontalAlignment="Center">
|
||||
<Button.RenderTransform>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Button.RenderTransform>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M11.5,12L20,18V6M11,18V6L2.5,12L11,18Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<StatusBar Grid.Row="2">
|
||||
<TextBlock Text="Select mode"/>
|
||||
<TextBlock Text="Fill mode"/>
|
||||
<TextBlock Text="Draw mode"/>
|
||||
<Separator/>
|
||||
<TextBlock Text="Selected: "/>
|
||||
<TextBlock Text="aaa"/>
|
||||
</StatusBar>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
91
MainWindow.xaml.cs
Normal file
91
MainWindow.xaml.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using BallanceTASEditor.Core;
|
||||
using BallanceTASEditor.Core.TASStruct;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window {
|
||||
public MainWindow() {
|
||||
InitializeComponent();
|
||||
RefreshUI(false);
|
||||
}
|
||||
|
||||
TASFile mFile;
|
||||
TASViewer mViewer;
|
||||
|
||||
#region ui func
|
||||
|
||||
// menu
|
||||
private void funcMenu_Help_ReportBugs(object sender, RoutedEventArgs e) {
|
||||
System.Diagnostics.Process.Start("https://github.com/yyc12345/BallanceTASEditor/issues");
|
||||
}
|
||||
|
||||
private void funcMenu_Help_About(object sender, RoutedEventArgs e) {
|
||||
MessageBox.Show("Under MIT License\nVersion 0\nyyc12345.", "Ballance TAS Editor");
|
||||
}
|
||||
|
||||
private void funcMenu_File_Open(object sender, RoutedEventArgs e) {
|
||||
var file = DialogUtil.OpenFileDialog();
|
||||
if (file == "") return;
|
||||
mFile = new TASFile(file);
|
||||
mViewer = new TASViewer(mFile, uiTASSlider, uiTASData);
|
||||
RefreshUI(true);
|
||||
}
|
||||
|
||||
private void funcMenu_File_Save(object sender, RoutedEventArgs e) {
|
||||
mFile.Save();
|
||||
}
|
||||
|
||||
private void funcMenu_File_SaveAs(object sender, RoutedEventArgs e) {
|
||||
var file = DialogUtil.SaveFileDialog();
|
||||
if (file == "") return;
|
||||
mFile.SaveAs(file);
|
||||
}
|
||||
|
||||
private void funcMenu_File_Close(object sender, RoutedEventArgs e) {
|
||||
if (!DialogUtil.ConfirmDialog("Do you want to close this TAS file?")) return;
|
||||
mViewer.Dispose();
|
||||
mFile = null;
|
||||
mViewer = null;
|
||||
RefreshUI(false);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
private void RefreshUI(bool isFileOpened) {
|
||||
if (isFileOpened) {
|
||||
uiEditorPanel.Visibility = Visibility.Visible;
|
||||
uiEditorNote.Visibility = Visibility.Collapsed;
|
||||
|
||||
uiMenu_File_Open.IsEnabled = false;
|
||||
uiMenu_File_Save.IsEnabled = true;
|
||||
uiMenu_File_SaveAs.IsEnabled = true;
|
||||
uiMenu_File_Close.IsEnabled = true;
|
||||
} else {
|
||||
uiEditorPanel.Visibility = Visibility.Collapsed;
|
||||
uiEditorNote.Visibility = Visibility.Visible;
|
||||
|
||||
uiMenu_File_Open.IsEnabled = true;
|
||||
uiMenu_File_Save.IsEnabled = false;
|
||||
uiMenu_File_SaveAs.IsEnabled = false;
|
||||
uiMenu_File_Close.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
55
Properties/AssemblyInfo.cs
Normal file
55
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("BallanceTASEditor")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BallanceTASEditor")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//若要开始生成可本地化的应用程序,请设置
|
||||
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
|
||||
//例如,如果您在源文件中使用的是美国英语,
|
||||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
|
||||
//对以下 NeutralResourceLanguage 特性的注释。 更新
|
||||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
||||
//(未在页面中找到资源时使用,
|
||||
//或应用程序资源字典中找到时使用)
|
||||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
||||
//(未在页面中找到资源时使用,
|
||||
//、应用程序或任何主题专用资源字典中找到时使用)
|
||||
)]
|
||||
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
62
Properties/Resources.Designer.cs
generated
Normal file
62
Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,62 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace BallanceTASEditor.Properties {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强类型资源类,用于查找本地化字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if ((resourceMan == null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BallanceTASEditor.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 覆盖当前线程的 CurrentUICulture 属性
|
||||
/// 使用此强类型的资源类的资源查找。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Properties/Resources.resx
Normal file
117
Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
Properties/Settings.Designer.cs
generated
Normal file
26
Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace BallanceTASEditor.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Properties/Settings.settings
Normal file
7
Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
61
StyleConverter.cs
Normal file
61
StyleConverter.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
|
||||
[ValueConversion(typeof(bool), typeof(Color))]
|
||||
public class BackgroundConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
try {
|
||||
bool bl = System.Convert.ToBoolean(value);
|
||||
if (bl) return Color.FromRgb(30, 144, 255);
|
||||
else return Color.FromArgb(0, 255, 255, 255);
|
||||
} catch {
|
||||
return Color.FromArgb(0, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[ValueConversion(typeof(float), typeof(string))]
|
||||
public class FloatConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
try {
|
||||
float bl = System.Convert.ToSingle(value);
|
||||
if (bl < 0) return "";
|
||||
else return bl.ToString();
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[ValueConversion(typeof(long), typeof(string))]
|
||||
public class LongConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
try {
|
||||
float bl = System.Convert.ToInt64(value);
|
||||
if (bl < 0) return "";
|
||||
else return bl.ToString();
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
67
TASViewer.cs
Normal file
67
TASViewer.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BallanceTASEditor.Core;
|
||||
using BallanceTASEditor.Core.TASStruct;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
public class TASViewer : IDisposable {
|
||||
public TASViewer(TASFile file, Slider slider, DataGrid datagrid) {
|
||||
mFile = file;
|
||||
mSlider = slider;
|
||||
mDataGrid = datagrid;
|
||||
|
||||
// restore slider
|
||||
mSlider.Minimum = 0;
|
||||
updateSliderRange();
|
||||
|
||||
// init data
|
||||
mPosition = 0;
|
||||
mDataSource = new ObservableCollection<FrameDataDisplay>();
|
||||
INVALID_FRAME_DATA = new FrameData(-1f, 0);
|
||||
for (int i = 0; i < DATA_LIST_LENGTH; i++) {
|
||||
mDataSource.Add(new FrameDataDisplay(0, INVALID_FRAME_DATA));
|
||||
}
|
||||
mFile.Get(mDataSource, 0, DATA_LIST_LENGTH);
|
||||
|
||||
// bind event and source
|
||||
mDataGrid.ItemsSource = mDataSource;
|
||||
mSlider.ValueChanged += sliderValueChanged;
|
||||
}
|
||||
public void Dispose() {
|
||||
mDataGrid.ItemsSource = null;
|
||||
mSlider.ValueChanged -= sliderValueChanged;
|
||||
}
|
||||
|
||||
const int DATA_LIST_LENGTH = 30;
|
||||
FrameData INVALID_FRAME_DATA;
|
||||
TASFile mFile;
|
||||
Slider mSlider;
|
||||
DataGrid mDataGrid;
|
||||
long mPosition;
|
||||
ObservableCollection<FrameDataDisplay> mDataSource;
|
||||
|
||||
private void sliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||
long pos = Convert.ToInt64(Math.Floor(e.NewValue));
|
||||
long offset = pos - mPosition;
|
||||
mFile.Shift(offset);
|
||||
var gotten = mFile.Get(mDataSource, pos, DATA_LIST_LENGTH);
|
||||
for(; gotten < DATA_LIST_LENGTH; gotten++) {
|
||||
mDataSource[gotten].Reload(-1, INVALID_FRAME_DATA);
|
||||
}
|
||||
|
||||
mPosition = pos;
|
||||
}
|
||||
|
||||
private void updateSliderRange() {
|
||||
long newSize = mFile.mFrameCount - 1;
|
||||
if (mSlider.Value > newSize)
|
||||
mSlider.Value = newSize;
|
||||
mSlider.Maximum = newSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
4
packages.config
Normal file
4
packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="zlib.net" version="1.0.4.0" targetFramework="net40" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user