Skip to content

Commit

Permalink
Merge pull request #92 from hcmlab/develop
Browse files Browse the repository at this point in the history
added possibility to create schemes also for files
  • Loading branch information
tobiasbaur authored Dec 2, 2016
2 parents 921ee8f + cc7bef4 commit 091b578
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 71 deletions.
2 changes: 1 addition & 1 deletion app/Window1.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:view="clr-namespace:ssi;assembly=ssiview"
xmlns:local="clr-namespace:ssi"
Title="(NOn)Verbal Annotator | v0.9.9.2.8 | HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">
Title="(NOn)Verbal Annotator | v0.9.9.2.9 | HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">

<Grid>

Expand Down
2 changes: 1 addition & 1 deletion app_metro/Window1.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:view="clr-namespace:ssi;assembly=ssiview"
xmlns:local="clr-namespace:ssi"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="(NOn)Verbal Annotator | v0.9.9.2.8 | HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">
Title="(NOn)Verbal Annotator | v0.9.9.2.9 | HCM-Lab, Augsburg University | http://openssi.net" WindowState="Maximized" Height="Auto" Width="Auto" AllowDrop="True" AllowsTransparency="False" Icon="ui.ico">

<Grid>

Expand Down
Binary file modified bin/nova.exe
Binary file not shown.
Binary file modified bin/nova_metro.exe
Binary file not shown.
18 changes: 14 additions & 4 deletions dll/AnnoList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ public static AnnoList LoadfromFileNew(String filepath)
else if (scheme.Attributes["mincolor"] != null) list.AnnotationScheme.mincolor = scheme.Attributes["mincolor"].Value;
if (scheme.Attributes["maxcolor"] != null) list.AnnotationScheme.maxcolor = scheme.Attributes["maxcolor"].Value;

list.Name = "#" + list.Role + " #" + scheme.Attributes["name"].Value + " #" + list.Annotator;
string role = "";
if (list.Role != null) role = "#" + list.Role + " "; ;
string annotator = "";
if (list.Annotator != null) annotator = " #" + list.Annotator;

list.Name = role + "#" + scheme.Attributes["name"].Value + annotator;


if (type == "DISCRETE") list.AnnotationType = AnnoType.DISCRETE;
Expand Down Expand Up @@ -709,9 +714,14 @@ public AnnoList saveToFileNew()
{
if (filepath == null || filepath.Split('.')[1] == "eaf" || filepath.Split('.')[1] == "anvil" || filepath.Split('.')[1] == "anno" || filepath.Split('.')[1] == "csv")
{
if (this.Annotator == null) this.Annotator = this.AnnotatorFullName;
filepath = ViewTools.SaveFileDialog(this.AnnotationScheme.name + "." + this.Role + "." + this.Annotator, ".annotation", Path.GetDirectoryName(this.Filepath));

if(this.AnnotatorFullName != null )
{
if (this.Annotator == null) this.Annotator = this.AnnotatorFullName;
if(this.annotator != null)
filepath = ViewTools.SaveFileDialog(this.AnnotationScheme.name + "." + this.Role + "." + this.Annotator, ".annotation", Path.GetDirectoryName(this.Filepath));
}
else filepath = ViewTools.SaveFileDialog(this.Name, ".annotation", Path.GetDirectoryName(this.Filepath));

if (filepath != null)
{
filename = filepath.Split('.')[0];
Expand Down
34 changes: 17 additions & 17 deletions dll/AnnoSchemeEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>

<Label Content="Scheme Name" Margin="257,109,303,284"/>
<TextBox x:FieldModifier="public" Margin="351,109,153,290" x:Name="scheme_name" Focusable="True" />
<Label Content="Scheme Name" Margin="20,105,510,283"/>
<TextBox x:FieldModifier="public" Margin="144,105,360,294" x:Name="scheme_name" Focusable="True" />

<Border CornerRadius="10" BorderThickness="1" BorderBrush="Black" Background="DarkGray" Margin="47,10,47,339" AllowDrop="True" Drop="Label_Drop">
<Label FontSize="16" Content="Drag Existing Scheme File Here" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="-1" />
<Border CornerRadius="10" BorderThickness="1" BorderBrush="White" Background="DarkGray" Margin="47,10,47,339" AllowDrop="True" Drop="Label_Drop">
<Label FontSize="16" Foreground="White" Content="Drag Existing Scheme File Here" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="-1" />
</Border>
<Label Name="Colorlabel" Content="Background Color" Margin="227,152,278,189" />
<Label Name="Colorlabel" Content="Background Color" Margin="20,148,485,193" />

<p:ColorPicker Name="scheme_colorpickermin" IsEnabled="true" Margin="351,152,260,241" RenderTransformOrigin="1.3,3.75" />
<p:ColorPicker Name="scheme_colorpickermin" IsEnabled="true" Margin="144,148,454,245" RenderTransformOrigin="1.3,3.75" BorderBrush="Transparent" />

<Label Name="labelslabel" Content="Labels" Margin="16,102,578,287" RenderTransformOrigin="0.5,0.5" >
<Label Name="labelslabel" Content="Labels" Margin="24,188,570,201" RenderTransformOrigin="0.5,0.5" >
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
Expand All @@ -36,18 +36,18 @@
</Label>
<!--<ListBox Name="AnnotationResultBox" Grid.Row="0" Grid.Column="0" Margin="246,80,200,211" SelectionMode="Multiple" SelectionChanged="AnnotationResultBox_SelectionChanged" ToolTip="{Binding Path=SelectedItem, RelativeSource={RelativeSource Self}}"></ListBox>-->

<ListView Name="AnnotationResultBox" SelectionChanged="AnnotationResultBox_SelectionChanged" SelectionMode="Single" Margin="11,147,435,55">
<ListView Name="AnnotationResultBox" SelectionChanged="AnnotationResultBox_SelectionChanged" SelectionMode="Single" Margin="20,222,309,50">
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Label">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<p:TextBoxEx Text="{Binding Label}" IsEnabled="true" Width="70" Height="20" Margin="5,0,0,0" PreviewTextInput="TextBoxEx_PreviewTextInput" TextChanged="TextBoxEx_TextChanged" Background="{x:Null}" BorderBrush="{x:Null}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<p:TextBoxEx Text="{Binding Label}" IsEnabled="true" Width="100" Height="20" Margin="5,0,0,0" TextChanged="TextBoxEx_TextChanged" Background="{x:Null}" BorderBrush="{x:Null}"/>
</StackPanel>
</DataTemplate>

</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="Auto" Header="Color">
<GridViewColumn.CellTemplate>
Expand All @@ -67,7 +67,7 @@
<Button Name="Ok" Content="Ok" Grid.Column="0" Grid.Row="1" Click="Ok_Click" Height="25" Margin="347,5,247,10" RenderTransformOrigin="-2.815,0.936" />
<Button Name="Cancel" Content="Cancel" Grid.Row="1" Click="Cancel_Click" Height="25" RenderTransformOrigin="3.367,0.24" Margin="227,5,367,10" />

<Button Name="DeleteAnnotation" Content="-" Grid.Column="0" Click="DeleteAnnotation_Click" Margin="47,390,576,10" Background="Transparent" BorderThickness="0" Visibility="Visible" RenderTransformOrigin="-5.119,7.505" />
<Button Name="AddAnnotation" Content="+" Grid.Column="0" Click="AddAnnotation_Click" Margin="11,390,612,10" Background="Transparent" BorderThickness="0" Visibility="Visible" RenderTransformOrigin="-1.08,-0.519" />
<Button Name="DeleteAnnotation" FontSize="30" Content="-" Grid.Column="0" Click="DeleteAnnotation_Click" Margin="83,376,511,5" Background="Transparent" BorderThickness="0" Visibility="Visible" RenderTransformOrigin="-5.119,7.505" />
<Button Name="AddAnnotation" FontSize="30" Content="+" Grid.Column="0" Click="AddAnnotation_Click" Margin="11,376,588,5" Background="Transparent" BorderThickness="0" Visibility="Visible" RenderTransformOrigin="-1.08,-0.519" />
</Grid>
</Window>
38 changes: 34 additions & 4 deletions dll/AnnoSchemeEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace ssi
public partial class AnnoSchemeEditor : Window
{
private List<AnnotationSchemeSegment> items;
private List<AnnotationSchemeSegment> schemes;
private HashSet<LabelColorPair> usedlabels;
private AnnoList list;

Expand All @@ -23,6 +24,7 @@ public AnnoSchemeEditor(string name = null, HashSet<LabelColorPair> _usedlabels
scheme_colorpickermin.SelectedColor = Colors.Blue;

items = new List<AnnotationSchemeSegment>();
schemes = new List<AnnotationSchemeSegment>();
list = new AnnoList();
list.AnnotationScheme = new AnnotationScheme();
list.AnnotationScheme.LabelsAndColors = new List<LabelColorPair>();
Expand Down Expand Up @@ -57,12 +59,19 @@ private void AddAnnotation_Click(object sender, RoutedEventArgs e)
LabelInputBox l = new LabelInputBox("Add new Label", "Add new label", "", null, 1, "", "", true);
l.WindowStartupLocation = WindowStartupLocation.CenterScreen;
l.ShowDialog();
items = new List<AnnotationSchemeSegment>();

if (l.DialogResult == true)
{
items.Add(new AnnotationSchemeSegment() { Label = l.Result(), BindingColor = (Color)ColorConverter.ConvertFromString(l.Color()) });
AnnotationResultBox.ItemsSource = items;
schemes.Add(new AnnotationSchemeSegment() { Label = l.Result(), BindingColor = (Color)ColorConverter.ConvertFromString(l.Color()) });
}


foreach(var item in schemes)
{
items.Add(item);
}
AnnotationResultBox.ItemsSource = items;
}

private void DeleteAnnotation_Click(object sender, RoutedEventArgs e)
Expand All @@ -72,6 +81,17 @@ private void DeleteAnnotation_Click(object sender, RoutedEventArgs e)
{
items.Remove(AnnotationResultBox.SelectedItem);
}

schemes.Clear();

foreach(var item in AnnotationResultBox.Items)
{
AnnotationSchemeSegment s = new AnnotationSchemeSegment();
s.Label = ((AnnotationSchemeSegment)item).Label;
s.BindingColor = ((AnnotationSchemeSegment)item).BindingColor;
schemes.Add(s);

}
}

private void Ok_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -144,7 +164,7 @@ private void Label_Drop(object sender, DragEventArgs e)
if (scheme.Attributes["color"] != null) list.AnnotationScheme.mincolor = scheme.Attributes["color"].Value;
else list.AnnotationScheme.mincolor = Colors.LightYellow.ToString();


items = new List<AnnotationSchemeSegment>();

if (type == "DISCRETE") list.AnnotationType = AnnoType.DISCRETE;
else return;
Expand All @@ -161,10 +181,20 @@ private void Label_Drop(object sender, DragEventArgs e)
string color = "#000000";
if (item.Attributes["color"] != null) color = item.Attributes["color"].Value;

items.Add(new AnnotationSchemeSegment() { Label = item.Attributes["name"].Value, BindingColor = (Color)ColorConverter.ConvertFromString(color) });
AnnotationSchemeSegment s = new AnnotationSchemeSegment();
s.Label = item.Attributes["name"].Value;
s.BindingColor = (Color)ColorConverter.ConvertFromString(color);

if (!schemes.Contains(s)) schemes.Add(s);
}


foreach (var item in schemes)
{
items.Add(item);
}
AnnotationResultBox.ItemsSource = items;

this.scheme_name.Text = list.Name;
this.scheme_colorpickermin.SelectedColor = (Color)ColorConverter.ConvertFromString(list.AnnotationScheme.mincolor);

Expand Down
14 changes: 7 additions & 7 deletions dll/AnnoTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ public void leftMouseButtonDown(MouseButtonEventArgs e)
{
SelectSegment(s);
this.select(true);
break;
}
}
}
Expand All @@ -763,12 +764,6 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
leftMouseButtonDown(e);

if (selected_segment != null)
{
_PreviouWidth = selected_segment.Width;
_PreviouHeight = selected_segment.Height;
_PreviouMargin = new Point(((FrameworkElement)selected_segment).Margin.Left, ((FrameworkElement)selected_segment).Margin.Top);
}
}

public void rightMouseButtonDown(MouseButtonEventArgs e)
Expand Down Expand Up @@ -966,6 +961,7 @@ public void mouseMove(MouseEventArgs e)
ChangeRepresentationObject ChangeRepresentationObjectOfResize = UnDoObject.MakeChangeRepresentationObjectForResize(pos, (FrameworkElement)selected_segment);
UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfResize);
isMouseAlreadydown = true;
SelectSegment(selected_segment);
}

double minsr = 0;
Expand All @@ -983,7 +979,6 @@ public void mouseMove(MouseEventArgs e)
selected_segment.resize_right(delta);

SelectSegment(selected_segment);

this.select(true);
FireOnMove(selected_segment.Item.Stop);
}
Expand All @@ -1001,6 +996,7 @@ public void mouseMove(MouseEventArgs e)
{
int round = (int)(selected_segment.Item.Stop / (1 / Properties.Settings.Default.DefaultDiscreteSampleRate) + 0.5);
selected_segment.Item.Stop = round * (1 / Properties.Settings.Default.DefaultDiscreteSampleRate);
SelectSegment(selected_segment);
}
}
}
Expand Down Expand Up @@ -1035,6 +1031,7 @@ public void mouseMove(MouseEventArgs e)
{
selected_segment.Item.Start = selected_segment.Item.Stop - Math.Max(Properties.Settings.Default.DefaultMinSegmentSize, minsr);
selected_segment.Item.Duration = Math.Max(Properties.Settings.Default.DefaultMinSegmentSize, minsr);
SelectSegment(selected_segment);
}

if (Properties.Settings.Default.DefaultDiscreteSampleRate != 0)
Expand All @@ -1043,6 +1040,7 @@ public void mouseMove(MouseEventArgs e)
{
int round = (int)(selected_segment.Item.Start / (1 / Properties.Settings.Default.DefaultDiscreteSampleRate) + 0.5);
selected_segment.Item.Start = round * (1 / Properties.Settings.Default.DefaultDiscreteSampleRate);
SelectSegment(selected_segment);
}
}
}
Expand All @@ -1059,6 +1057,7 @@ public void mouseMove(MouseEventArgs e)
ChangeRepresentationObject ChangeRepresentationObjectOfMove = UnDoObject.MakeChangeRepresentationObjectForMove(pos, (FrameworkElement)selected_segment);
UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfMove);
isMouseAlreadydown = true;

}
selected_segment.move(delta);
SelectSegment(selected_segment);
Expand All @@ -1079,6 +1078,7 @@ public void mouseMove(MouseEventArgs e)
int round = (int)(selected_segment.Item.Stop / (1 / Properties.Settings.Default.DefaultDiscreteSampleRate) + 0.5);
selected_segment.Item.Stop = round * (1 / Properties.Settings.Default.DefaultDiscreteSampleRate);
}
SelectSegment(selected_segment);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion dll/Database/DatabaseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public string LoadAnnotationSchemes(string db, AnnoTrack tier, AnnoType type = A
{
if (document["isValid"].AsBoolean == true)
{
if ((type == AnnoType.DISCRETE || type == AnnoType.FREE) && (document["type"].ToString() == "FREE" || document["type"].ToString() == "DISCRETE")) AnnotationSchemes.Add(document["name"].ToString());
if ((type == AnnoType.DISCRETE && document["type"].ToString() == "DISCRETE")) AnnotationSchemes.Add(document["name"].ToString());
else if (type == AnnoType.FREE && (document["type"].ToString() == "FREE")) AnnotationSchemes.Add(document["name"].ToString());
else if (type == AnnoType.CONTINUOUS && document["type"].ToString() == "CONTINUOUS") AnnotationSchemes.Add(document["name"].ToString());
}
}
Expand Down
2 changes: 1 addition & 1 deletion dll/NavigatorControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
<Button Name="clearButton" Width="70" Height="25" Margin="5" VerticalAlignment="Center">Clear</Button>
</StackPanel>

<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Name="Statusbar" Margin="5,0,0,0" HorizontalContentAlignment="Left" BorderThickness="0" Content="" />
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Content="" Name="Statusbar" Margin="5,0,0,0" HorizontalContentAlignment="Left" BorderThickness="0" />
</Grid>
</UserControl>
Loading

0 comments on commit 091b578

Please sign in to comment.