Skip to content

Commit c1a220c

Browse files
committed
introduce batchtools
1 parent ff9cd95 commit c1a220c

File tree

9 files changed

+174
-10
lines changed

9 files changed

+174
-10
lines changed

Controls/MainControl.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
<MenuItem Header="Convert Signal" Name="convertSignalMenu">
8787
<MenuItem Header="To Continuous Annotation" Name="convertSignalToAnnoContinuousMenu" />
8888
</MenuItem>
89+
<MenuItem Header="Batch Tools" Name="BatchToolsMenu" Visibility="Visible">
90+
</MenuItem>
8991
</MenuItem>
9092
<MenuItem Header="LEARNING" Name="databaseCMLMenu">
9193

@@ -129,6 +131,8 @@
129131
<MenuItem Header="NOSTR DVM" Name="NostrDVMMenu" Visibility="Collapsed">
130132
</MenuItem>
131133

134+
135+
132136
<MenuItem Header="?">
133137
<MenuItem Header="Buy us a coffee ☕" Name="supportMenu" />
134138
<MenuItem Header="About" Name="aboutMenu" />

Controls/MainHandler.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class MainHandler
2323
{
2424

2525
//Config
26-
public static string BuildVersion = "1.2.8.3";
26+
public static string BuildVersion = "1.2.8.4";
2727
public static MEDIABACKEND MediaBackend = (Properties.Settings.Default.MediaBackend == "Hardware") ? MEDIABACKEND.MEDIAKIT : MEDIABACKEND.MEDIA;
2828
public static bool ENABLE_PYTHON = Properties.Settings.Default.EnablePython;
2929
public static bool ENABLE_LIGHTNING = Properties.Settings.Default.EnableLightning;
@@ -116,10 +116,11 @@ public AnnoTier getAnnoTierFromName(string name)
116116
public MainHandler(MainControl view)
117117
{
118118
control = view;
119-
119+
120120
//TEST
121121
//DatabaseHandler.ExportMultipleCSV();
122-
//batchConvertNoldus("W:\\nova\\data\\DFG-PP_T5");
122+
123+
123124

124125
// Shadow box
125126
control.shadowBoxCancelButton.Click += shadowBoxCancel_Click;
@@ -276,6 +277,8 @@ public MainHandler(MainControl view)
276277
}
277278

278279

280+
control.BatchToolsMenu.Click += BatchToolsMenu_Click;
281+
279282
//PYTHON
280283
//if(ENABLE_PYTHON) startExplainableThread();
281284
if (ENABLE_PYTHON)
@@ -488,6 +491,12 @@ public MainHandler(MainControl view)
488491
control.Drop += controlDrop;
489492
}
490493

494+
private void BatchToolsMenu_Click(object sender, RoutedEventArgs e)
495+
{
496+
BatchTools batchtools = new BatchTools();
497+
batchtools.Show();
498+
}
499+
491500
private void AssistantMenu_Click(object sender, RoutedEventArgs e)
492501
{
493502
LLAMA llama = new LLAMA();

Controls/MainHandlerFile.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ private void saveProjectFile(List<AnnoTier> annoTiers, List<MediaBox> mediaBoxes
10921092
#region IMPORT
10931093

10941094

1095-
private void BatchConvertElanAnnotations(string parentDiretory)
1095+
public static void BatchConvertElanAnnotations(string parentDiretory)
10961096
{
10971097
DirectoryInfo directory = new DirectoryInfo(parentDiretory);
10981098
DirectoryInfo[] directories = directory.GetDirectories();
@@ -1107,6 +1107,7 @@ private void BatchConvertElanAnnotations(string parentDiretory)
11071107
foreach (AnnoList list in lists)
11081108
{
11091109
list.Scheme.Name = convert_uml(list.Scheme.Name);
1110+
list.Scheme.Name = list.Scheme.Name.Replace(" ", "_");
11101111

11111112
string saveto = folder.FullName + "\\" + list.Meta.Role + "." + list.Scheme.Name + ".annotation";
11121113
list.Source.StoreToFile = true;
@@ -1242,7 +1243,7 @@ private void ImportAnnoFromAnvil(string filename)
12421243
}
12431244

12441245

1245-
private void batchConvertNoldus (string directory)
1246+
public static void batchConvertNoldus (string directory)
12461247
{
12471248
string[] dirs = Directory.GetDirectories(directory, "*", SearchOption.AllDirectories);
12481249
foreach(string dir in dirs)

Nostr/NostrDVM.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public partial class NostrDVM : System.Windows.Window
4343
List<string> relays = new List<string>
4444
{
4545
"wss://relay.primal.net",
46-
"wss://nos.lol/",
47-
"wss://nostr.mom/"
46+
"wss://nostr.mom/",
47+
"wss://nostr.oxtr.dev/"
4848
};
4949

5050
public NostrDVM()

Tools/BatchTools.xaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<Window x:Class="ssi.BatchTools"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:ssi"
7+
mc:Ignorable="d"
8+
Title="BatchTools" Height="450" Width="800">
9+
<Grid>
10+
<Grid.RowDefinitions>
11+
<RowDefinition Height="70"></RowDefinition>
12+
<RowDefinition Height="*"></RowDefinition>
13+
<RowDefinition Height="40"></RowDefinition>
14+
<RowDefinition Height="Auto"></RowDefinition>
15+
</Grid.RowDefinitions>
16+
17+
<Grid>
18+
19+
</Grid>
20+
21+
<DockPanel Grid.Row="0" LastChildFill="True" Grid.ColumnSpan="2">
22+
<Label DockPanel.Dock="Top"
23+
VerticalContentAlignment="Center">Convert Annotation Formats:</Label>
24+
<RadioButton Name="elan" DockPanel.Dock="Top"
25+
VerticalContentAlignment="Center" IsChecked="True">Elan Format</RadioButton>
26+
<RadioButton Name="noldus" DockPanel.Dock="Top"
27+
VerticalContentAlignment="Center">Noldus Format</RadioButton>
28+
</DockPanel>
29+
30+
<DockPanel Grid.Row="2" LastChildFill="True" Grid.ColumnSpan="2">
31+
<Label>Root Directory:</Label>
32+
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
33+
<Button Name="PickDownloadDirectory" Margin="5,0,5,5" Click="PickDownloadDirectory_Click">Pick</Button>
34+
<Button Name="ViewDownloadDirectory" Margin="5,0,5,5" Click="ViewDownloadDirectory_Click">View</Button>
35+
</StackPanel>
36+
<TextBox Name="DownloadDirectory" Margin="5,0,5,5" DockPanel.Dock="Left"/>
37+
</DockPanel>
38+
39+
40+
<Button x:Name="batch_send" Grid.Row="3" Height="30" Width="70" Click="batch_send_Click">Process</Button>
41+
</Grid>
42+
</Window>

Tools/BatchTools.xaml.cs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
4+
using OxyPlot.Reporting;
5+
using Secp256k1Net;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Diagnostics;
9+
using System.Drawing.Imaging;
10+
using System.IO;
11+
using System.Linq;
12+
using System.Net;
13+
using System.Text;
14+
using System.Threading.Tasks;
15+
using System.Web.UI.WebControls;
16+
using System.Windows;
17+
using System.Windows.Controls;
18+
19+
using System.Windows.Documents;
20+
using System.Windows.Forms;
21+
using System.Windows.Media;
22+
using System.Windows.Media.Imaging;
23+
using ThirdParty.BouncyCastle.Utilities.IO.Pem;
24+
using WebSocketSharp;
25+
26+
using static ssi.MainHandler;
27+
using static System.Net.Mime.MediaTypeNames;
28+
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
29+
using Button = System.Windows.Controls.Button;
30+
using Image = System.Windows.Controls.Image;
31+
32+
33+
namespace ssi
34+
{
35+
/// <summary>
36+
/// Interaktionslogik für NostrDVM.xaml
37+
/// </summary>
38+
public partial class BatchTools : System.Windows.Window
39+
{
40+
public BatchTools()
41+
{
42+
InitializeComponent();
43+
44+
45+
}
46+
47+
private void PickDownloadDirectory_Click(object sender, RoutedEventArgs e)
48+
{
49+
var dialog = new System.Windows.Forms.FolderBrowserDialog();
50+
dialog.SelectedPath = Defaults.LocalDataLocations().First();
51+
dialog.ShowNewFolderButton = true;
52+
dialog.Description = "Select the folder where you want to store the media of your databases in.";
53+
System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.None;
54+
55+
try
56+
{
57+
dialog.SelectedPath = Defaults.LocalDataLocations().First();
58+
result = dialog.ShowDialog();
59+
60+
}
61+
62+
catch
63+
{
64+
dialog.SelectedPath = "";
65+
result = dialog.ShowDialog();
66+
}
67+
68+
69+
70+
if (result == System.Windows.Forms.DialogResult.OK)
71+
{
72+
DownloadDirectory.Text = dialog.SelectedPath;
73+
}
74+
}
75+
76+
private void ViewDownloadDirectory_Click(object sender, RoutedEventArgs e)
77+
{
78+
if (Directory.Exists(DownloadDirectory.Text))
79+
{
80+
Directory.CreateDirectory(DownloadDirectory.Text);
81+
Process.Start(DownloadDirectory.Text);
82+
}
83+
}
84+
85+
private void batch_send_Click(object sender, RoutedEventArgs e)
86+
{
87+
if (elan.IsChecked == true)
88+
{
89+
MainHandler.BatchConvertElanAnnotations(DownloadDirectory.Text);
90+
}
91+
else if (noldus.IsChecked == true)
92+
{
93+
MainHandler.batchConvertNoldus(DownloadDirectory.Text);
94+
}
95+
96+
System.Windows.MessageBox.Show("Done");
97+
98+
}
99+
}
100+
}

Types/AnnoListFile.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,9 @@ public static List<AnnoList> LoadfromElanFile(String filepath)
12701270
{
12711271
role = tier.Attributes.GetNamedItem("PARTICIPANT").Value.ToString();
12721272
}
1273-
catch { }
1273+
catch {
1274+
role = "role";
1275+
}
12741276

12751277
bool hasreftrack = false;
12761278
AnnoList refList = new AnnoList();
@@ -1296,7 +1298,7 @@ public static List<AnnoList> LoadfromElanFile(String filepath)
12961298
endtmp = (from kvp in time_order_list where kvp.Key == alignable_annotation.Attributes.GetNamedItem("TIME_SLOT_REF2").Value.ToString() select kvp.Value).ToList()[0];
12971299
end = double.Parse(endtmp, CultureInfo.InvariantCulture) / 1000;
12981300
id = alignable_annotation.Attributes.GetNamedItem("ANNOTATION_ID").Value.ToString();
1299-
label = alignable_annotation.FirstChild.InnerText.Replace(';', ',');
1301+
label = alignable_annotation.FirstChild.InnerText.Replace(';', ',').Replace(", ", "_");
13001302
if (label == "" || label == " " || label == null)
13011303
{
13021304
continue;

bin/nova.exe

3 KB
Binary file not shown.

nova.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@
645645
<Compile Include="Tools\LightningTipps.xaml.cs">
646646
<DependentUpon>LightningTipps.xaml</DependentUpon>
647647
</Compile>
648-
<Compile Include="Tools\NovaServerNostr.cs" />
648+
<Compile Include="Tools\BatchTools.xaml.cs">
649+
<DependentUpon>BatchTools.xaml</DependentUpon>
650+
</Compile>
649651
<Compile Include="Tools\PluginCaller.cs" />
650652
<Compile Include="Tools\Polygon Helper\DataGridChecker.cs" />
651653
<Compile Include="Tools\Polygon Helper\DrawUnit.cs" />
@@ -1015,6 +1017,10 @@
10151017
<SubType>Designer</SubType>
10161018
<Generator>MSBuild:Compile</Generator>
10171019
</Page>
1020+
<Page Include="Tools\BatchTools.xaml">
1021+
<Generator>MSBuild:Compile</Generator>
1022+
<SubType>Designer</SubType>
1023+
</Page>
10181024
<Page Include="Tools\PatternBrushes.xaml">
10191025
<Generator>MSBuild:Compile</Generator>
10201026
<SubType>Designer</SubType>

0 commit comments

Comments
 (0)