Skip to content

Commit

Permalink
Merge pull request #589 from hcmlab/ws
Browse files Browse the repository at this point in the history
introduce batchtools
  • Loading branch information
tobiasbaur authored Sep 6, 2024
2 parents 85843ca + c1a220c commit b276bdf
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Controls/MainControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
<MenuItem Header="Convert Signal" Name="convertSignalMenu">
<MenuItem Header="To Continuous Annotation" Name="convertSignalToAnnoContinuousMenu" />
</MenuItem>
<MenuItem Header="Batch Tools" Name="BatchToolsMenu" Visibility="Visible">
</MenuItem>
</MenuItem>
<MenuItem Header="LEARNING" Name="databaseCMLMenu">

Expand Down Expand Up @@ -129,6 +131,8 @@
<MenuItem Header="NOSTR DVM" Name="NostrDVMMenu" Visibility="Collapsed">
</MenuItem>



<MenuItem Header="?">
<MenuItem Header="Buy us a coffee ☕" Name="supportMenu" />
<MenuItem Header="About" Name="aboutMenu" />
Expand Down
15 changes: 12 additions & 3 deletions Controls/MainHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public partial class MainHandler
{

//Config
public static string BuildVersion = "1.2.8.3";
public static string BuildVersion = "1.2.8.4";
public static MEDIABACKEND MediaBackend = (Properties.Settings.Default.MediaBackend == "Hardware") ? MEDIABACKEND.MEDIAKIT : MEDIABACKEND.MEDIA;
public static bool ENABLE_PYTHON = Properties.Settings.Default.EnablePython;
public static bool ENABLE_LIGHTNING = Properties.Settings.Default.EnableLightning;
Expand Down Expand Up @@ -116,10 +116,11 @@ public AnnoTier getAnnoTierFromName(string name)
public MainHandler(MainControl view)
{
control = view;

//TEST
//DatabaseHandler.ExportMultipleCSV();
//batchConvertNoldus("W:\\nova\\data\\DFG-PP_T5");



// Shadow box
control.shadowBoxCancelButton.Click += shadowBoxCancel_Click;
Expand Down Expand Up @@ -276,6 +277,8 @@ public MainHandler(MainControl view)
}


control.BatchToolsMenu.Click += BatchToolsMenu_Click;

//PYTHON
//if(ENABLE_PYTHON) startExplainableThread();
if (ENABLE_PYTHON)
Expand Down Expand Up @@ -488,6 +491,12 @@ public MainHandler(MainControl view)
control.Drop += controlDrop;
}

private void BatchToolsMenu_Click(object sender, RoutedEventArgs e)
{
BatchTools batchtools = new BatchTools();
batchtools.Show();
}

private void AssistantMenu_Click(object sender, RoutedEventArgs e)
{
LLAMA llama = new LLAMA();
Expand Down
5 changes: 3 additions & 2 deletions Controls/MainHandlerFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ private void saveProjectFile(List<AnnoTier> annoTiers, List<MediaBox> mediaBoxes
#region IMPORT


private void BatchConvertElanAnnotations(string parentDiretory)
public static void BatchConvertElanAnnotations(string parentDiretory)
{
DirectoryInfo directory = new DirectoryInfo(parentDiretory);
DirectoryInfo[] directories = directory.GetDirectories();
Expand All @@ -1107,6 +1107,7 @@ private void BatchConvertElanAnnotations(string parentDiretory)
foreach (AnnoList list in lists)
{
list.Scheme.Name = convert_uml(list.Scheme.Name);
list.Scheme.Name = list.Scheme.Name.Replace(" ", "_");

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


private void batchConvertNoldus (string directory)
public static void batchConvertNoldus (string directory)
{
string[] dirs = Directory.GetDirectories(directory, "*", SearchOption.AllDirectories);
foreach(string dir in dirs)
Expand Down
4 changes: 2 additions & 2 deletions Nostr/NostrDVM.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public partial class NostrDVM : System.Windows.Window
List<string> relays = new List<string>
{
"wss://relay.primal.net",
"wss://nos.lol/",
"wss://nostr.mom/"
"wss://nostr.mom/",
"wss://nostr.oxtr.dev/"
};

public NostrDVM()
Expand Down
42 changes: 42 additions & 0 deletions Tools/BatchTools.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Window x:Class="ssi.BatchTools"
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:ssi"
mc:Ignorable="d"
Title="BatchTools" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="70"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<Grid>

</Grid>

<DockPanel Grid.Row="0" LastChildFill="True" Grid.ColumnSpan="2">
<Label DockPanel.Dock="Top"
VerticalContentAlignment="Center">Convert Annotation Formats:</Label>
<RadioButton Name="elan" DockPanel.Dock="Top"
VerticalContentAlignment="Center" IsChecked="True">Elan Format</RadioButton>
<RadioButton Name="noldus" DockPanel.Dock="Top"
VerticalContentAlignment="Center">Noldus Format</RadioButton>
</DockPanel>

<DockPanel Grid.Row="2" LastChildFill="True" Grid.ColumnSpan="2">
<Label>Root Directory:</Label>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<Button Name="PickDownloadDirectory" Margin="5,0,5,5" Click="PickDownloadDirectory_Click">Pick</Button>
<Button Name="ViewDownloadDirectory" Margin="5,0,5,5" Click="ViewDownloadDirectory_Click">View</Button>
</StackPanel>
<TextBox Name="DownloadDirectory" Margin="5,0,5,5" DockPanel.Dock="Left"/>
</DockPanel>


<Button x:Name="batch_send" Grid.Row="3" Height="30" Width="70" Click="batch_send_Click">Process</Button>
</Grid>
</Window>
100 changes: 100 additions & 0 deletions Tools/BatchTools.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

using OxyPlot.Reporting;
using Secp256k1Net;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows;
using System.Windows.Controls;

using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using ThirdParty.BouncyCastle.Utilities.IO.Pem;
using WebSocketSharp;

using static ssi.MainHandler;
using static System.Net.Mime.MediaTypeNames;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using Button = System.Windows.Controls.Button;
using Image = System.Windows.Controls.Image;


namespace ssi
{
/// <summary>
/// Interaktionslogik für NostrDVM.xaml
/// </summary>
public partial class BatchTools : System.Windows.Window
{
public BatchTools()
{
InitializeComponent();


}

private void PickDownloadDirectory_Click(object sender, RoutedEventArgs e)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.SelectedPath = Defaults.LocalDataLocations().First();
dialog.ShowNewFolderButton = true;
dialog.Description = "Select the folder where you want to store the media of your databases in.";
System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.None;

try
{
dialog.SelectedPath = Defaults.LocalDataLocations().First();
result = dialog.ShowDialog();

}

catch
{
dialog.SelectedPath = "";
result = dialog.ShowDialog();
}



if (result == System.Windows.Forms.DialogResult.OK)
{
DownloadDirectory.Text = dialog.SelectedPath;
}
}

private void ViewDownloadDirectory_Click(object sender, RoutedEventArgs e)
{
if (Directory.Exists(DownloadDirectory.Text))
{
Directory.CreateDirectory(DownloadDirectory.Text);
Process.Start(DownloadDirectory.Text);
}
}

private void batch_send_Click(object sender, RoutedEventArgs e)
{
if (elan.IsChecked == true)
{
MainHandler.BatchConvertElanAnnotations(DownloadDirectory.Text);
}
else if (noldus.IsChecked == true)
{
MainHandler.batchConvertNoldus(DownloadDirectory.Text);
}

System.Windows.MessageBox.Show("Done");

}
}
}
6 changes: 4 additions & 2 deletions Types/AnnoListFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,9 @@ public static List<AnnoList> LoadfromElanFile(String filepath)
{
role = tier.Attributes.GetNamedItem("PARTICIPANT").Value.ToString();
}
catch { }
catch {
role = "role";
}

bool hasreftrack = false;
AnnoList refList = new AnnoList();
Expand All @@ -1296,7 +1298,7 @@ public static List<AnnoList> LoadfromElanFile(String filepath)
endtmp = (from kvp in time_order_list where kvp.Key == alignable_annotation.Attributes.GetNamedItem("TIME_SLOT_REF2").Value.ToString() select kvp.Value).ToList()[0];
end = double.Parse(endtmp, CultureInfo.InvariantCulture) / 1000;
id = alignable_annotation.Attributes.GetNamedItem("ANNOTATION_ID").Value.ToString();
label = alignable_annotation.FirstChild.InnerText.Replace(';', ',');
label = alignable_annotation.FirstChild.InnerText.Replace(';', ',').Replace(", ", "_");
if (label == "" || label == " " || label == null)
{
continue;
Expand Down
Binary file modified bin/nova.exe
Binary file not shown.
8 changes: 7 additions & 1 deletion nova.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,9 @@
<Compile Include="Tools\LightningTipps.xaml.cs">
<DependentUpon>LightningTipps.xaml</DependentUpon>
</Compile>
<Compile Include="Tools\NovaServerNostr.cs" />
<Compile Include="Tools\BatchTools.xaml.cs">
<DependentUpon>BatchTools.xaml</DependentUpon>
</Compile>
<Compile Include="Tools\PluginCaller.cs" />
<Compile Include="Tools\Polygon Helper\DataGridChecker.cs" />
<Compile Include="Tools\Polygon Helper\DrawUnit.cs" />
Expand Down Expand Up @@ -1015,6 +1017,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Tools\BatchTools.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Tools\PatternBrushes.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down

0 comments on commit b276bdf

Please sign in to comment.