Commit f22f8dc0 authored by Ghislain MARY's avatar Ghislain MARY

Add video size to the screen size.

parent 26adf17a
......@@ -11,6 +11,7 @@
<model:UnitTestCaseStateToSymbolConverter x:Key="UnitTestCaseStateToSymbol"/>
<model:UnitTestCaseStateToSymbolColorConverter x:Key="UnitTestCaseStateToSymbolColor"/>
<model:OutputTraceLevelToColorConverter x:Key="OutputTraceLevelToColor"/>
<model:MultiplyConverter x:Key="Multiply"/>
</ResourceDictionary>
</Application.Resources>
</Application>
......@@ -248,4 +248,29 @@ namespace ms2_tester.DataModel
throw new NotImplementedException();
}
}
public sealed class MultiplyConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
{
if (!value.GetType().Equals(typeof(Double)))
{
throw new ArgumentException("Only Double is supported");
}
if (targetType.Equals(typeof(Double)))
{
Double result = (Double)value * (Double)Convert.ToDouble(parameter);
return result;
}
else
{
throw new ArgumentException(string.Format("Unsupported format {0}", targetType.FullName));
}
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
......@@ -65,7 +65,7 @@
<Button x:Name="ChangeCameraButton" Content="Change camera" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8" Click="ChangeCameraButton_Click" IsEnabled="{Binding ElementName=VideoToggleButton, Path=IsChecked}"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Width="640" Height="480" HorizontalAlignment="Center" BorderBrush="Black" BorderThickness="2">
<Grid x:Name="VideoGrid" Grid.Row="1" HorizontalAlignment="Center" Background="Black">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
......@@ -77,7 +77,7 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<SwapChainPanel x:Name="VideoSwapChainPanel" Width="640" Height="480" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3"/>
<SwapChainPanel x:Name="VideoSwapChainPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3"/>
<SwapChainPanel x:Name="PreviewSwapChainPanel" Width="160" Height="120" Grid.Column="2" Grid.Row="2" RenderTransformOrigin="0.5,0.5">
<SwapChainPanel.RenderTransform>
<CompositeTransform ScaleX="-1"/>
......
......@@ -50,6 +50,12 @@ namespace ms2_tester
orientationSensor.OrientationChanged += OrientationSensor_OrientationChanged;
}
Window.Current.SizeChanged += Current_SizeChanged;
this.Loaded += VideoPage_Loaded;
}
private void VideoPage_Loaded(object sender, RoutedEventArgs e)
{
AdaptVideoSize();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
......@@ -74,6 +80,7 @@ namespace ms2_tester
private async void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
{
AdaptVideoSize();
displayOrientation = ApplicationView.GetForCurrentView().Orientation;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => SetVideoOrientation());
}
......@@ -103,10 +110,12 @@ namespace ms2_tester
if (_videoSource != null)
{
_videoSource.Stop();
_videoSource = null;
}
if (_previewSource != null)
{
_previewSource.Stop();
_previewSource = null;
}
StopVideoStream();
}
......@@ -355,6 +364,21 @@ namespace ms2_tester
}
}
private void AdaptVideoSize()
{
if (ActualWidth > 640)
{
VideoGrid.Width = 640;
}
else
{
VideoGrid.Width = ActualWidth;
}
VideoGrid.Height = VideoGrid.Width * 3 / 4;
PreviewSwapChainPanel.Width = VideoGrid.Width / 4;
PreviewSwapChainPanel.Height = VideoGrid.Height / 4;
}
private VoipPhoneCall call;
private ApplicationViewOrientation displayOrientation;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment