Skip to content

Commit

Permalink
v1.4
Browse files Browse the repository at this point in the history
Update MainWindow.xaml
  • Loading branch information
kingsznhone committed Jan 10, 2023
1 parent d61ced1 commit 653a2b1
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 72 deletions.
30 changes: 15 additions & 15 deletions NCMDump.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NCMDumpCore", "NCMDumpCore\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NCMDumpCLI", "NCMDumpCLI\NCMDumpCLI.csproj", "{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NCMDumpGUI", "NCMDumpGUI\NCMDumpGUI.csproj", "{F4B097C1-58BB-4A79-8997-8225639D2A92}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NCMDumpGUI", "NCMDumpGUI\NCMDumpGUI.csproj", "{F4B097C1-58BB-4A79-8997-8225639D2A92}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Release|Any CPU.Build.0 = Release|Any CPU
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Release|Any CPU.Build.0 = Release|Any CPU
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Release|Any CPU.Build.0 = Release|Any CPU
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Debug|x64.ActiveCfg = Debug|x64
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Debug|x64.Build.0 = Debug|x64
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Release|x64.ActiveCfg = Release|x64
{6D29FF99-9A20-4AC2-8246-746C2AE4FB73}.Release|x64.Build.0 = Release|x64
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Debug|x64.ActiveCfg = Debug|x64
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Debug|x64.Build.0 = Debug|x64
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Release|x64.ActiveCfg = Release|x64
{4CB104C3-FE3A-4CF4-9910-5FB0150B22A6}.Release|x64.Build.0 = Release|x64
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Debug|x64.ActiveCfg = Debug|x64
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Debug|x64.Build.0 = Debug|x64
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Release|x64.ActiveCfg = Release|x64
{F4B097C1-58BB-4A79-8997-8225639D2A92}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 2 additions & 1 deletion NCMDumpCLI/NCMDumpCLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<ApplicationIcon>NCMDumpCLI.ico</ApplicationIcon>
<PlatformTarget>x64</PlatformTarget>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>1.3.0</Version>
<Version>1.4.0</Version>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion NCMDumpCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async void WalkThrough(DirectoryInfo dir)

Console.WriteLine();
}

}
}

Expand Down
16 changes: 9 additions & 7 deletions NCMDumpCore/NCMDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ public class NCMDump
readonly byte[] coreKey = { 0x68, 0x7A, 0x48, 0x52, 0x41, 0x6D, 0x73, 0x6F, 0x35, 0x6B, 0x49, 0x6E, 0x62, 0x61, 0x78, 0x57 };
readonly byte[] metaKey = { 0x23, 0x31, 0x34, 0x6C, 0x6A, 0x6B, 0x5F, 0x21, 0x5C, 0x5D, 0x26, 0x30, 0x55, 0x3C, 0x27, 0x28 };

public NCMDump()
{
}
private bool ReadHeader(ref MemoryStream ms)
{
byte[] header = new byte[8];
// Header Should be "CTENFDAM"
ms.Read(header, 0, header.Length);
return Encoding.ASCII.GetString(header) == "CTENFDAM";
// Header Should be "CTENFDAM"
return Enumerable.SequenceEqual(header, new byte[] { 067, 084, 069, 078, 070, 068, 065, 077 });
}

private byte[] MakeKeybox(ref MemoryStream ms)
{
// read keybox length
uint KeyboxLength = ReadUint32(ms);
//Console.WriteLine($"AES Key Length: {KeyboxLength}");
uint KeyboxLength = ReadUint32(ref ms);

// read raw keybox data
var buffer = new byte[KeyboxLength];
Expand Down Expand Up @@ -66,7 +68,7 @@ private byte[] MakeKeybox(ref MemoryStream ms)
private MetaInfo ReadMeta(ref MemoryStream ms)
{
// read meta length
var MetaLength = ReadUint32(ms);
var MetaLength = ReadUint32(ref ms);
var RawMetaData = new byte[MetaLength];
ms.Read(RawMetaData, 0, RawMetaData.Length);
for (int i = 0; i < RawMetaData.Length; i++)
Expand Down Expand Up @@ -194,7 +196,7 @@ void AddCover(TagLib.File tagfile)
}
}

private uint ReadUint32(MemoryStream ms)
private uint ReadUint32(ref MemoryStream ms)
{
byte[] buffer = new byte[4];
ms.Read(buffer, 0, buffer.Length);
Expand Down Expand Up @@ -242,7 +244,7 @@ public async Task<bool> ConvertAsync(string path)
ms.Seek(5, SeekOrigin.Current);

// read image length
var ImageLength = ReadUint32(ms);
var ImageLength = ReadUint32(ref ms);
byte[]? ImageData;
if (ImageLength != 0)
{
Expand Down
3 changes: 2 additions & 1 deletion NCMDumpCore/NCMDumpCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<VersionPrefix>1.3.0</VersionPrefix>
<VersionPrefix>1.4.0</VersionPrefix>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion NCMDumpGUI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
xmlns:local="clr-namespace:NCMDumpGUI"
StartupUri="MainWindow.xaml">
<Application.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
46 changes: 22 additions & 24 deletions NCMDumpGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
<Window x:Class="NCMDumpGUI.MainWindow"
<hc:BlurWindow x:Class="NCMDumpGUI.MainWindow"
xmlns:hc="https://handyorg.github.io/handycontrol"
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:NCMDumpGUI"
mc:Ignorable="d"
Title="NCMDumpGUI" Height="480" Width="720" Icon="/NCMDump.png" MinWidth="720" MinHeight="480" ResizeMode="CanResize" WindowStartupLocation="CenterScreen" AllowDrop="True" Closed="Window_Closed">
mc:Ignorable="d"
BorderThickness ="0"
Style="{StaticResource WindowBlur}"
Title="NCMDumpGUI"
Height="480" Width="720"
Icon="/NCMDump.png"
MinWidth="720" MinHeight="480"
ResizeMode="CanResize"
WindowStartupLocation="CenterScreen"
AllowDrop="True"
Closed="Window_Closed">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="75"/>
</Grid.RowDefinitions>

<ListView x:Name="WorkingList" Grid.Row="0" SizeChanged="ListView_SizeChanged" AllowDrop="True" Drop="WorkingList_Drop">
<ListView Style="{StaticResource ListView.Small}" Background="Transparent" x:Name="WorkingList" ItemsSource="{Binding NCMCollection}" Grid.Row="0" SizeChanged="ListView_SizeChanged" AllowDrop="True" Drop="WorkingList_Drop" Margin="20,20,20,20">
<ListView.View>
<GridView>
<GridViewColumn Header="File" DisplayMemberBinding="{Binding FilePath}"/>
<GridViewColumn Header="Status">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding FileStatus}" TextAlignment="Center" HorizontalAlignment="Stretch" />
</DataTemplate>
</GridViewColumn.CellTemplate>
<GridViewColumn.HeaderContainerStyle>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</GridViewColumn.HeaderContainerStyle>
</GridViewColumn>
<GridViewColumn Header="Status" DisplayMemberBinding="{Binding FileStatus}"/>
</GridView>
</ListView.View>
</ListView>
<Button x:Name="StartButton" Content="Convert" HorizontalAlignment="Right" Margin="0,0,20,20" Click="StartButton_Click" Grid.Row="1" FontSize="18" Background="#FF005FB8" Foreground="White" VerticalAlignment="Bottom" Height="35" Width="120"/>
<Button x:Name="SelectFileButton" Content="Select File" HorizontalAlignment="Right" Click="SelectFileButton_Click" Grid.Row="1" FontSize="18" Background="#FFFBFBFB" Foreground="Black" VerticalAlignment="Bottom" Height="35" Width="120" Margin="0,0,160,20"/>
<Button x:Name="SelectFolderButton" Content="Select Folder" HorizontalAlignment="Right" Click="SelectFolderButton_Click" Grid.Row="1" FontSize="18" Background="#FFFBFBFB" Foreground="Black" VerticalAlignment="Bottom" Height="35" Width="120" Margin="0,0,300,20"/>
<Button x:Name="ClearButton" Content="Clear" HorizontalAlignment="Left" Click="ClearButton_Click" Grid.Row="1" FontSize="18" Background="#FFFBFBFB" Foreground="Black" VerticalAlignment="Top" Height="35" Width="120" Margin="20,20,0,0"/>
<Button x:Name="StartButton" Content="Convert" HorizontalAlignment="Right" Margin="0,0,20,20" Click="StartButton_Click" Grid.Row="1" Style="{StaticResource ButtonPrimary}" VerticalAlignment="Bottom" Height="35" Width="120" FontSize="14"/>
<Button x:Name="SelectFileButton" Content="Select File" HorizontalAlignment="Right" Click="SelectFileButton_Click" Grid.Row="1" Style="{StaticResource ButtonInfo}" VerticalAlignment="Bottom" Height="35" Width="120" Margin="0,0,160,20" FontSize="14"/>
<Button x:Name="SelectFolderButton" Content="Select Folder" HorizontalAlignment="Right" Click="SelectFolderButton_Click" Grid.Row="1" Style="{StaticResource ButtonInfo}" VerticalAlignment="Bottom" Height="35" Width="120" Margin="0,0,300,20" FontSize="14"/>
<Button x:Name="ClearButton" Content="Clear" HorizontalAlignment="Left" Click="ClearButton_Click" Grid.Row="1" Style="{StaticResource ButtonDanger}" VerticalAlignment="Bottom" Height="35" Width="120" Margin="20,0,0,20" FontSize="14"/>
</Grid>


</Window>
</hc:BlurWindow>
78 changes: 58 additions & 20 deletions NCMDumpGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,68 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Interop;
using HandyControl;
using HandyControl.Controls;

namespace NCMDumpGUI
{
public enum ACCENTSTATE
{
ACCENT_DISABLED = 0,
ACCENT_ENABLE_GRADIENT = 1,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3,
ACCENT_ENABLE_ACRYLICBLURBEHIND = 4,
ACCENT_INVALID_STATE = 5
}

[StructLayout(LayoutKind.Sequential)]
public struct ACCENTPOLICY
{
public ACCENTSTATE AccentState;
public int AccentFlags;
public uint GradientColor;
public int AnimationId;
}
public enum WINDOWCOMPOSITIONATTRIB
{
WCA_ACCENT_POLICY = 19
}
[StructLayout(LayoutKind.Sequential)]
public struct WINCOMPATTRDATA
{
public WINDOWCOMPOSITIONATTRIB Attribute;
public IntPtr Data;
public int DataSize;
}

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow : BlurWindow
{
NCMDump core = new NCMDump();
NCMDump Core = new NCMDump();

[DllImport("user32.dll")]
public static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WINCOMPATTRDATA data);

public ObservableCollection<NCMProcessStatus> NCMCollection { get; set; }
= new ObservableCollection<NCMProcessStatus>();

IntPtr Hwnd;

public MainWindow()
{
{
InitializeComponent();
//WorkingList.Items.Add(new NCMProcessStatus ( "AAAAA", "Done"));
WorkingList.ItemsSource = NCMCollection;
App.Current.Resources["BlurGradientValue"] = 0xaaffffff;
}

private void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
Expand Down Expand Up @@ -61,9 +99,8 @@ private void WorkingList_Drop(object sender, System.Windows.DragEventArgs e)
}
}
}


}

private void WalkThrough(DirectoryInfo dir)
{
foreach (DirectoryInfo d in dir.GetDirectories())
Expand All @@ -79,22 +116,22 @@ private void WalkThrough(DirectoryInfo dir)

private async void StartButton_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i < NCMCollection.Count; i++)
Parallel.For(0, NCMCollection.Count, async (i, state) =>
{
if (NCMCollection[i].FileStatus == "Success") continue;

if (await Task.Run(() => core.ConvertAsync(NCMCollection[i].FilePath)))
{
NCMCollection[i].FileStatus = "Success";
this.UpdateLayout();
}
else
if (NCMCollection[i].FileStatus != "Success")
{
NCMCollection[i].FileStatus = "Fail";
this.UpdateLayout();
}

}
if (await Task.Run(() => Core.ConvertAsync(NCMCollection[i].FilePath)))
{
NCMCollection[i].FileStatus = "Success";
Dispatcher.Invoke(()=> this.UpdateLayout());
}
else
{
NCMCollection[i].FileStatus = "Fail";
Dispatcher.Invoke(() => this.UpdateLayout());
}
}
});
}

private void SelectFileButton_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -135,5 +172,6 @@ private void Window_Closed(object sender, System.EventArgs e)
{
Environment.Exit(0);
}

}
}
11 changes: 10 additions & 1 deletion NCMDumpGUI/NCMDumpGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>NCMDumpCLI.ico</ApplicationIcon>
<UseWindowsForms>True</UseWindowsForms>
<Version>1.3.0</Version>
<Version>1.4.0</Version>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand All @@ -27,4 +28,12 @@
<Resource Include="ncmdump.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="HandyControl" Version="3.4.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>

</Project>
File renamed without changes.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ Decipher .ncm file to mp3 || flac

Highly Optimized Corelib.

Keep all ID3 tags and cover image.
Keep ID3 tags and cover image.

<img src="/~https://github.com/kingsznhone/NCMDump.NET/blob/main/Result.png"/>

## Changelog

### v1.4

UI adjustment.

Performance Improvement.

### v1.3

Bug fix.
Expand Down

0 comments on commit 653a2b1

Please sign in to comment.