Skip to content

Commit

Permalink
#110 implemented. core part length validation rule. reducing width of…
Browse files Browse the repository at this point in the history
… layer editing columns
  • Loading branch information
dgrechka committed May 17, 2018
1 parent 5bec604 commit 0d19a02
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<UserControl.Resources>
<ap:NumberSelectorConverter x:Key="NumberSelectorConverter"/>
</UserControl.Resources>
<Grid Height="40" Width="100">
<Grid Height="40" Width="50">
<Rectangle HorizontalAlignment="Stretch" Height="40" Fill="LightCoral" Name="Rect"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16">
<TextBlock.Text>
Expand Down
2 changes: 1 addition & 1 deletion Application/AnnotationPlane/PlaneVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ public void SetPresentationColumns(ColumnSettingsVM columnDefinitions, Intervals


blankColumnVM.ColumnHeight = colHeight;
blankColumnVM.ColumnWidth = 100;
blankColumnVM.ColumnWidth = 50;
AnnoGridVM.Columns.Add(beVM);
RegisterForScaleSync(beVM, true);
}
Expand Down
11 changes: 10 additions & 1 deletion Application/PhotoMarkup/CalibratedRegionInfoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<UserControl.Resources>
<app:VisibilityHiddenConverter x:Key="visibilityHiddenConverter"/>
<app:NanToEmptyStringDoubleConverter x:Key="nanToEmptyStringDoubleConverter"/>
<local:NonZeroDoubleValidationRule x:Key="nonZeroDoubleValidationRule"/>
</UserControl.Resources>
<Border CornerRadius="0" Background="White" Padding="15" Margin="15" Opacity="0.95">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
Expand All @@ -24,7 +25,15 @@
<Run Text="Участок №"/>
<Run Text="{Binding Order, FallbackValue=1}"/>
</TextBlock>
<app:TextInput HintText="Введите длину участка (м)" Text="{Binding Length, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource nanToEmptyStringDoubleConverter}, ConverterParameter=#.00}" MinWidth="350"></app:TextInput>
<app:TextInput HintText="Введите длину участка (м)" MinWidth="350">
<app:TextInput.Text>
<Binding Path="Length" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" Converter="{StaticResource nanToEmptyStringDoubleConverter}" ConverterParameter="0.00">
<Binding.ValidationRules>
<local:NonZeroDoubleValidationRule />
</Binding.ValidationRules>
</Binding>
</app:TextInput.Text>
</app:TextInput>
<Button Margin="2,10" FontSize="20" Visibility="{Binding CanMoveUp,Converter={StaticResource visibilityHiddenConverter}}" Command="{Binding MoveUp}" CommandParameter="{Binding Order}" Style="{StaticResource MetroButton}" Width="50">
<media:Arrow_In_circle>
</media:Arrow_In_circle>
Expand Down
28 changes: 28 additions & 0 deletions Application/PhotoMarkup/CalibratedRegionInfoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,32 @@ public CalibratedRegionInfoView()
InitializeComponent();
}
}

public class NonZeroDoubleValidationRule : ValidationRule
{
public NonZeroDoubleValidationRule()
{
}

public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
double result = 0;

try
{
if (((string)value).Length > 0) {
result = Double.Parse((String)value);
}
else
return new ValidationResult(false, "Пустое значение длины");
}
catch (Exception e)
{
return new ValidationResult(false, "Вы ввели не число: " + e.Message+". ВВедите число");
}
if (result <= 0.0)
return new ValidationResult(false,"Длина должна быть положительна");
return ValidationResult.ValidResult;
}
}
}

0 comments on commit 0d19a02

Please sign in to comment.