Skip to content

Commit

Permalink
chore: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Forgot-Dream committed Feb 25, 2024
1 parent a88a768 commit 84cd93f
Show file tree
Hide file tree
Showing 22 changed files with 832 additions and 848 deletions.
14 changes: 7 additions & 7 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<prism:PrismApplication x:Class="STS_Bcut.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:STS_Bcut"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:prism="http://prismlibrary.com/">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:prism="http://prismlibrary.com/">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="BlueGrey" SecondaryColor="Lime" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</prism:PrismApplication>
</prism:PrismApplication>
50 changes: 24 additions & 26 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
using Prism.DryIoc;
using System.Windows;
using Prism.DryIoc;
using Prism.Ioc;
using System.Windows;
using Prism.Services.Dialogs;
using STS_Bcut.src;
using STS_Bcut.src.Common;
using STS_Bcut.src.ViewModels;
using STS_Bcut.src.Views;
using STS_Bcut.src.Common;

namespace STS_Bcut
namespace STS_Bcut;

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : PrismApplication
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : PrismApplication
protected override Window CreateShell()
{
protected override Window CreateShell()
{
return Container.Resolve<MainView>();
}
return Container.Resolve<MainView>();
}

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<IDialogHostService, DialogHostService>();
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<IDialogHostService, DialogHostService>();

containerRegistry.RegisterForNavigation<AboutView,AboutViewModel>();
containerRegistry.RegisterForNavigation<SettingsView,SettingsViewModel>();
containerRegistry.RegisterForNavigation<MainView, MainViewModel>();
}
containerRegistry.RegisterForNavigation<AboutView, AboutViewModel>();
containerRegistry.RegisterForNavigation<SettingsView, SettingsViewModel>();
containerRegistry.RegisterForNavigation<MainView, MainViewModel>();
}

protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
ConfigUtil.WriteConfig(MainViewModel.config);
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
ConfigUtil.WriteConfig(MainViewModel.config);

Check warning on line 33 in App.xaml.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Possible null reference argument for parameter 'config' in 'void ConfigUtil.WriteConfig(Config config)'.

Check warning on line 33 in App.xaml.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Possible null reference argument for parameter 'config' in 'void ConfigUtil.WriteConfig(Config config)'.
}
}
}
8 changes: 4 additions & 4 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
215 changes: 108 additions & 107 deletions src/APIDataStruct.cs
Original file line number Diff line number Diff line change
@@ -1,139 +1,140 @@
using System.Collections.Generic;
using System.Linq;

namespace STS_Bcut.src
namespace STS_Bcut.src;

public class UploadStruct
{
public class UploadStruct
public string model_id = "7";

public int type = 2;

public UploadStruct(string name, int size, string res)
{
public UploadStruct(string name, int size, string res)
{
this.name = name;
this.size = size;
ResourceFileType = res;
}

public int type = 2;
public string name { get; set; }
public int size { get; set; }
public string ResourceFileType { get; set; }
public string model_id = "7";
this.name = name;
this.size = size;
ResourceFileType = res;
}

public string name { get; set; }
public int size { get; set; }
public string ResourceFileType { get; set; }
}

public class CommitUploadStruct
{
public string Etags;

public string InBossKey;
public string model_id = "7";
public string ResourceId;
public string UploadId;

public class CommitUploadStruct
public CommitUploadStruct(string in_boss_key, string resource_id, string etags, string upload_id)
{
public CommitUploadStruct(string in_boss_key, string resource_id, string etags, string upload_id)
{
InBossKey = in_boss_key;
ResourceId = resource_id;
Etags = etags;
UploadId = upload_id;
}

public string InBossKey;
public string ResourceId;
public string Etags;
public string UploadId;
public string model_id = "7";
InBossKey = in_boss_key;
ResourceId = resource_id;
Etags = etags;
UploadId = upload_id;
}
}

public class CreateTaskStruct
{
public string model_id = "7";

public string resource;

public CreateTaskStruct(string resource)
{
this.resource = resource;
}
}

public enum ResultStateEnum
{
WAITING = 0,
RUNNING = 1,
ERROR = 3,
COMLETE = 4
}

public class ResultResponse
{
public string remark;

Check warning on line 64 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'remark' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 64 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'remark' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public string result;

Check warning on line 65 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'result' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 65 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'result' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public ResultStateEnum state;
public string task_id;

Check warning on line 67 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'task_id' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 67 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'task_id' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
}

public class STSDataSeg
{
public int confidence;
public int end_time;
public int start_time;
public string transcript;

Check warning on line 75 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'transcript' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 75 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'transcript' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public List<STSDataWords> words;

Check warning on line 76 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'words' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 76 in src/APIDataStruct.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

Non-nullable field 'words' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

public class CreateTaskStruct
private (int, int, int, int) _Srt_Time_Conv_(int time)
{
public CreateTaskStruct(string resource)
{
this.resource = resource;
}
return (time / 3600000, time / 60000 % 60, time / 1000 % 60, time % 1000);
}

public string resource;
public string model_id = "7";
private (int, int, int) _Lrc_Time_Conv_(int time)
{
return (time / 60000, time / 1000 % 60, time % 1000 / 10);
}

public enum ResultStateEnum : int
public string ToSrtTs()
{
WAITING = 0,
RUNNING = 1,
ERROR = 3,
COMLETE = 4
var (s_h, s_m, s_s, s_ms) = _Srt_Time_Conv_(start_time);
var (e_h, e_m, e_s, e_ms) = _Srt_Time_Conv_(end_time);
return string.Format("{0:00}:{1:00}:{2:00},{3:000} --> {4:00}:{5:00}:{6:00},{7:000}", s_h, s_m, s_s, s_ms, e_h,
e_m, e_s, e_ms);
}

public class ResultResponse
public string ToLrcTs()
{
public string task_id;
public string result;
public string remark;
public ResultStateEnum state;
var (s_m, s_s, s_ms) = _Lrc_Time_Conv_(start_time);
return string.Format("[{0:00}:{1:00}.{2:00}]", s_m, s_s, s_ms);
}

public class STSDataSeg
public class STSDataWords
{
public class STSDataWords
{
public string label;
public int start_time;
public int end_time;
public int confidence;
}
public int start_time;
public int end_time;
public string transcript;
public List<STSDataWords> words;
public int confidence;

private (int, int, int, int) _Srt_Time_Conv_(int time) => (time / 3600000, time / 60000 % 60, time / 1000 % 60, time % 1000);
private (int, int, int) _Lrc_Time_Conv_(int time) => (time / 60000, time / 1000 % 60, time % 1000 / 10);

public string ToSrtTs()
{
var (s_h, s_m, s_s, s_ms) = _Srt_Time_Conv_(start_time);
var (e_h, e_m, e_s, e_ms) = _Srt_Time_Conv_(end_time);
return string.Format("{0:00}:{1:00}:{2:00},{3:000} --> {4:00}:{5:00}:{6:00},{7:000}", s_h, s_m, s_s, s_ms, e_h, e_m, e_s, e_ms);
}

public string ToLrcTs()
{
var (s_m, s_s, s_ms) = _Lrc_Time_Conv_(start_time);
return string.Format("[{0:00}:{1:00}.{2:00}]", s_m, s_s, s_ms);
}
public int end_time;
public string label;
public int start_time;
}
}

public class STSData
{
public List<STSDataSeg> utterances;
public string version;

public class STSData
public bool HasData()
{
public List<STSDataSeg> utterances;
public string version;

public bool HasData()
{
return utterances.Count > 0;
}

public string ToTxt()
{
return string.Join("\n", utterances.Select(x => x.transcript).ToList());
}

public string ToSrt()
{
List<string> srt = new();
for (int i = 0; i < utterances.Count; i++)
{
srt.Add($"{i + 1}\n{utterances[i].ToSrtTs()}\n{utterances[i].transcript}\n");
}
return string.Join("\n", srt);
}

public string ToLrc()
{
List<string> lrc = new();
foreach (var item in utterances)
{
lrc.Add($"{item.ToLrcTs()}{item.transcript}");
}
return string.Join("\n", lrc);
}
return utterances.Count > 0;
}

public string ToTxt()
{
return string.Join("\n", utterances.Select(x => x.transcript).ToList());
}

public string ToSrt()
{
List<string> srt = new();
for (var i = 0; i < utterances.Count; i++)
srt.Add($"{i + 1}\n{utterances[i].ToSrtTs()}\n{utterances[i].transcript}\n");
return string.Join("\n", srt);
}

}
public string ToLrc()
{
List<string> lrc = new();
foreach (var item in utterances) lrc.Add($"{item.ToLrcTs()}{item.transcript}");
return string.Join("\n", lrc);
}
}
Loading

0 comments on commit 84cd93f

Please sign in to comment.