Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed dashed lower boundary in svg #124

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" SharedSizeGroup="ColumnDefinitionWidth1"/>
<ColumnDefinition Width="auto" SharedSizeGroup="ColumnDefinitionWidth2"/>
<ColumnDefinition Width="auto" SharedSizeGroup="ColumnDefinitionWidth3"/>
<ColumnDefinition Width="auto" SharedSizeGroup="ColumnDefinitionWidth4"/>
<ColumnDefinition SharedSizeGroup="ColumnDefinitionWidth1" Width="Auto"/>
<ColumnDefinition SharedSizeGroup="ColumnDefinitionWidth2" Width="Auto"/>
<ColumnDefinition SharedSizeGroup="ColumnDefinitionWidth3" Width="*"/>
<ColumnDefinition SharedSizeGroup="ColumnDefinitionWidth4" Width="Auto"/>
</Grid.ColumnDefinitions>
<Button FontSize="20" Grid.Column="0" Visibility="{Binding CanMoveLeft,Converter={StaticResource visibilityHiddenConverter}}" CommandParameter="{Binding ColumnOrder}" Command="{Binding MoveLeft}" Style="{StaticResource MetroButton}" Width="50" VerticalAlignment="Center">
<media:Arrow_In_circle>
Expand All @@ -53,8 +53,9 @@
<media:Arrow_In_circle>
</media:Arrow_In_circle>
</Button>
<ContentPresenter Grid.Column="2" Content="{Binding .}" Margin="3" />
<Button FontSize="20" Grid.Column="3" Command="{Binding RemoveCommand}" CommandParameter="{Binding ColumnOrder}" Style="{StaticResource MetroButton}" Width="50" VerticalAlignment="Center">
<ContentPresenter Content="{Binding .}" Margin="3" Grid.Column="2"/>
<Button FontSize="20" Grid.Column="3" Command="{Binding RemoveCommand}" CommandParameter="{Binding ColumnOrder}"
Style="{StaticResource MetroButton}" Width="50" VerticalAlignment="Center" HorizontalAlignment="Right">
<media:CrossIcon/>
</Button>
</Grid>
Expand Down
46 changes: 27 additions & 19 deletions Application/AnnotationPlane/ColumnSettings/ColumnSettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,32 @@
<local:ColumnDefinitionView HorizontalAlignment="Center" />
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" FlowDirection="RightToLeft">
<ItemsControl HorizontalAlignment="Right" ItemsSource="{Binding OrderedColumnDefinitions}" VerticalAlignment="Center" Grid.IsSharedSizeScope="True" FlowDirection="LeftToRight"/>
</ScrollViewer>
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,30,0,30">
<TextBlock VerticalAlignment="Center" FontSize="20">Добавить колонку:</TextBlock>

<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<ScrollViewer Grid.Row="0" Grid.Column="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" FlowDirection="RightToLeft" HorizontalAlignment="Stretch" PanningMode="Both">
<ItemsControl HorizontalAlignment="Right" ItemsSource="{Binding OrderedColumnDefinitions}" VerticalAlignment="Center" Grid.IsSharedSizeScope="True" FlowDirection="LeftToRight"/>
</ScrollViewer>

<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right">
<Button Style="{StaticResource MetroButton}" HorizontalAlignment="Right" Width="50" Height="50" Command="{Binding ActivateAnnotationPlaneCommand}">
<media:TableIcon></media:TableIcon>
</Button>
<Button Style="{StaticResource MetroButton}" Command="{Binding ImportFromFileCommnad}" Content="Загрузить столбцы"/>
<Button Style="{StaticResource MetroButton}" Command="{Binding ExportToFileCommand}" Content="Сохранить столбцы"/>
</StackPanel>

<ScrollViewer Grid.Row="1" Grid.ColumnSpan="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" VerticalAlignment="Center" Margin="5,10,0,10">
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" FontSize="17">Добавить колонку:</TextBlock>
<WrapPanel>
<Button Style="{StaticResource MetroButton}" Command="{Binding AddDepthCommand}">Шкала глубин</Button>
<Button Style="{StaticResource MetroButton}" Command="{Binding AddPhotoCommand}">Фото</Button>
Expand All @@ -34,14 +49,7 @@
<Button Style="{StaticResource MetroButton}" Command="{Binding AddIconsCommand}">Значки</Button>
</WrapPanel>
</StackPanel>
</Grid>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Right">
<Button Style="{StaticResource MetroButton}" HorizontalAlignment="Right" Width="50" Height="50" Command="{Binding ActivateAnnotationPlaneCommand}">
<media:TableIcon></media:TableIcon>
</Button>
<Button Style="{StaticResource MetroButton}" Command="{Binding ImportFromFileCommnad}" Content="Загрузить столбцы"/>
<Button Style="{StaticResource MetroButton}" Command="{Binding ExportToFileCommand}" Content="Сохранить столбцы"/>
</StackPanel>
</ScrollViewer>

</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,43 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CoreSampleAnnotation.AnnotationPlane.ColumnSettings"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center">Крап</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="15" ItemsSource="{Binding AvailableBackgroundImageProps}" SelectedItem="{Binding SelectedBackgroundImageProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center" Margin="15,0,0,0">Ширина</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="15" ItemsSource="{Binding AvailableWidthProps}" SelectedItem="{Binding SelectedWidthProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center" Margin="15,0,0,0">Правая граница</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="15" ItemsSource="{Binding AvailableRightSideProps}" SelectedItem="{Binding SelectedRightSideProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center" Margin="15,0,0,0">Нижняя граница</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="15" ItemsSource="{Binding AvailableBottomSideProps}" SelectedItem="{Binding SelectedBottomSideProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
mc:Ignorable="d">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="0,15,0,15">
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center">Крап</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="5,0,0,0" ItemsSource="{Binding AvailableBackgroundImageProps}" SelectedItem="{Binding SelectedBackgroundImageProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center" Margin="5,0,0,0">Ширина</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="5,0,0,0" ItemsSource="{Binding AvailableWidthProps}" SelectedItem="{Binding SelectedWidthProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center">Правая граница</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="5,0,0,0" ItemsSource="{Binding AvailableRightSideProps}" SelectedItem="{Binding SelectedRightSideProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock VerticalAlignment="Center" FontSize="20" HorizontalAlignment="Center" Margin="5,0,0,0">Нижняя граница</TextBlock>
<ComboBox VerticalAlignment="Center" FontSize="20" MinWidth="150" Margin="5,0,0,0" ItemsSource="{Binding AvailableBottomSideProps}" SelectedItem="{Binding SelectedBottomSideProp}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding PropertyName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</StackPanel>
</UserControl>
37 changes: 31 additions & 6 deletions Application/AnnotationPlane/Columns/Drawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public static IEnumerable<Point> GetRightPolyline(double width, double height, I
return result;
}

public static IEnumerable<Point> GetBottomPolyline(double width, double height, ISideCurveGenerator bottomSideCurve)
public static IEnumerable<Point> GetBottomPolyline(double xOffset, double width, double height, ISideCurveGenerator bottomSideCurve)
{
List<Point> result = new List<Point>();

IEnumerable<Point> bottomSidePoints = bottomSideCurve.GenerateSide(width).
Select(p => new Point(p.X, p.Y + height)); // parallel shift, so that (0.0;0.0);(width;0.0) is shifted to (0.0;height);(width;height)
Select(p => new Point(p.X + xOffset, p.Y + height)); // parallel shift, so that (0.0;0.0);(width;0.0) is shifted to (0.0;height);(width;height)

result.AddRange(bottomSidePoints);

Expand Down Expand Up @@ -78,24 +78,29 @@ public interface IOscillationGenerator
IEnumerable<Point> GeneratePeriod(double xPeriod, double signalMaxY);
}

public enum OscillationAlignment { Left, Center, Right }

/// <summary>
/// Generates a side curve by repeating integer repeating periods provided by oscillationGenerator
/// </summary>
public class OscillatingSignalCurveGenerator : ISideCurveGenerator
{
private double xPeriod, signalMaxY;
private OscillationAlignment alignment;
IOscillationGenerator generator;

/// <param name="xPeriod">The period of the pattern allong X axis</param>
/// <param name="signalMaxY">the avsolute hight of the pattern along Y axis</param>
/// <param name="signalMaxY">the absolute hight of the pattern along Y axis</param>
/// <param name="generator">Which signal to generate</param>
public OscillatingSignalCurveGenerator(double xPeriod, double signalMaxY, IOscillationGenerator generator)
/// <param name="alignment">Where the straight part will be / where to stick the signal curve</param>
public OscillatingSignalCurveGenerator(double xPeriod, double signalMaxY, IOscillationGenerator generator, OscillationAlignment alignment)
{
if (signalMaxY < 0)
throw new ArgumentException("signalMaxY must be non-negative");
this.xPeriod = xPeriod;
this.signalMaxY = signalMaxY;
this.generator = generator;
this.alignment = alignment;
}

public IEnumerable<Point> GenerateSide(double length)
Expand All @@ -104,15 +109,35 @@ public IEnumerable<Point> GenerateSide(double length)
double straitEndsLength = length - periods * xPeriod;

List<Point> result = new List<Point>();

double leftOffset = 0.0;
double rightOffset = 0.0;
switch (alignment)
{
case OscillationAlignment.Center:
leftOffset = straitEndsLength / 2;
rightOffset = straitEndsLength / 2;
break;
case OscillationAlignment.Left:
leftOffset = 0.0;
rightOffset = straitEndsLength;
break;
case OscillationAlignment.Right:
leftOffset = straitEndsLength;
rightOffset = 0.0;
break;
}


//starting straight line
result.Add(new Point(0.0, 0.0));
result.Add(new Point(straitEndsLength * 0.5, 0.0));
result.Add(new Point(leftOffset, 0.0));

//drawing curves
double miniStep = xPeriod * 0.5;
for (int i = 0; i < periods; i++)
{
double xOffset = straitEndsLength * 0.5 + i * xPeriod;
double xOffset = leftOffset + i * xPeriod;
IEnumerable<Point> periodPoints = generator.GeneratePeriod(xPeriod, signalMaxY).Select(p => new Point(p.X + xOffset, p.Y));

result.AddRange(periodPoints);
Expand Down
6 changes: 3 additions & 3 deletions Application/AnnotationPlane/Columns/VisualColumnView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
<Polyline Stroke="Black" StrokeThickness="1" StrokeDashCap="Round">
<Polyline.Points>
<MultiBinding Converter="{StaticResource bottomSidePointsConverter}">
<Binding RelativeSource="{RelativeSource Mode=PreviousData}" Path="BottomSideForm"></Binding>
<Binding Path="Width"></Binding>
<Binding Path="Height"></Binding>
<Binding Path="BottomSideForm"></Binding>
<Binding RelativeSource="{RelativeSource Mode=PreviousData}" Path="Width"></Binding>
</MultiBinding>
</Polyline.Points>
<Polyline.StrokeDashArray>
<Binding Converter="{StaticResource bottomSideStrokeConverter}" Path="BottomSideForm"/>
<Binding Converter="{StaticResource bottomSideStrokeConverter}" Path="BottomSideForm" RelativeSource="{RelativeSource Mode=PreviousData}"/>
</Polyline.StrokeDashArray>
</Polyline>
<Polygon Fill="{Binding BackgroundBrush}" Stroke="Transparent">
Expand Down
Loading