Skip to content

Commit

Permalink
Mobile Windows issues fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MeniKadosh1 committed Sep 19, 2024
1 parent f177bd0 commit b56b4aa
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 79 deletions.
87 changes: 28 additions & 59 deletions Ginger/Ginger/Drivers/DriversWindows/MobileDriverWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:UserControls="clr-namespace:Amdocs.Ginger.UserControls" xmlns:Ginger="clr-namespace:Ginger" xmlns:GingerCore="clr-namespace:GingerCore;assembly=GingerCore"
mc:Ignorable="d"
Title="Loading Device..." Height="650" Width="350"
MinHeight="650" MinWidth="350" WindowStyle="ToolWindow" ResizeMode="CanResizeWithGrip"
MinHeight="650" MinWidth="350" WindowStyle="ThreeDBorderWindow" ResizeMode="CanMinimize"
WindowStartupLocation="CenterScreen" Closing="Window_Closing" SizeChanged="Window_SizeChanged" Loaded="Window_Loaded"
Topmost="False" KeyDown="Window_KeyDown">
<Grid x:Name="xWindowGrid" Background="Transparent">
Expand Down Expand Up @@ -123,75 +123,44 @@
</Grid.RowDefinitions>

<!--Top buttons-->
<Frame Grid.Row="0" Grid.Column="1" Margin="0,0,0,0" Background="Black"/>
<UserControls:ImageMakerControl x:Name="xRecordingImage" Grid.Row="0" Grid.Column="1" Height="16" Width="16" ImageType="Recording" Foreground="Red" ImageForeground="Red" HorizontalAlignment="Center" VerticalAlignment="Center" SetBorder="False" ToolTip="Recording..." Margin="0,0,0,0" Visibility="Collapsed" />

<!--Sides-->
<DockPanel Grid.Column="0" Grid.Row="0" Background="Transparent" >
<Border BorderThickness="1" CornerRadius="20,0,0,0" BorderBrush="Black" Background="Black" />
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="1" Background="Black"/>
<DockPanel Grid.Column="2" Grid.Row="0" Background="Transparent" >
<Border BorderThickness="1" CornerRadius="0,20,0,0" BorderBrush="Black" Background="Black"/>
</DockPanel>
<DockPanel Grid.Column="0" Grid.Row="1" Background="Black" />
<DockPanel Grid.Column="0" Grid.Row="2" Background="Transparent" >
<Border BorderThickness="1" CornerRadius="0,0,0,20" BorderBrush="Black" Background="Black"/>
</DockPanel>
<DockPanel Grid.Column="2" Grid.Row="1" Background="Black"/>
<DockPanel Grid.Column="2" Grid.Row="2" Background="Transparent" >
<Border BorderThickness="1" CornerRadius="0,0,20,0" BorderBrush="Black" Background="Black"/>
</DockPanel>
<DockPanel Grid.Column="3" Grid.Row="1" Background="Transparent">
<Grid DockPanel.Dock="Top">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="20"/>
<RowDefinition Height="5"/>
<RowDefinition Height="20"/>
<RowDefinition Height="30"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<StackPanel x:Name="xVolumUpPnl" Grid.Row="1" Background="Black" Height="20" Width="2" ToolTip="Volume Up" Cursor="Hand" MouseLeftButtonDown="xVolumUpPnl_MouseLeftButtonDown"/>
<StackPanel x:Name="xVolumDownPnl" Grid.Row="3" Background="Black" Height="20" Width="2" ToolTip="Volume Down" Cursor="Hand" MouseLeftButtonDown="xVolumDownPnl_MouseLeftButtonDown"/>
<StackPanel x:Name="xLockPnl" Grid.Row="5" Background="Black" Height="20" Width="2" ToolTip="Lock/Un-Lock Device" Cursor="Hand" MouseLeftButtonDown="xLockPnl_MouseLeftButtonDown"/>
</Grid>
</DockPanel>

<!--mobile image-->
<DockPanel Grid.Column="1" Grid.Row="1" Background="#424242">
<StackPanel x:Name="xMessagePnl" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,100,0,0" DockPanel.Dock="Top">
<UserControls:ImageMakerControl x:Name="xMessageImage" ImageType="AndroidWhite" Width="110" Height="110"/>
<Label x:Name="xMessageLbl" Content="Loading..." Foreground="WhiteSmoke" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" FontWeight="Normal"/>
<UserControls:ImageMakerControl x:Name="xMessageProcessingImage" ImageType="Processing" SetAsFontImageWithSize="30" Width="30" Height="30" Foreground="WhiteSmoke" HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>
<!--mobile image -->
<Border Grid.Column="1" Grid.Row="1" BorderThickness="1" CornerRadius="0" BorderBrush="#424242" Background="#424242" Margin="0">
<Border.Effect>
<DropShadowEffect Color="Black" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<DockPanel Background="#424242">
<StackPanel x:Name="xMessagePnl" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,100,0,0" DockPanel.Dock="Top">
<UserControls:ImageMakerControl x:Name="xMessageImage" ImageType="AndroidWhite" Width="110" Height="110"/>
<Label x:Name="xMessageLbl" Content="Loading..." Foreground="WhiteSmoke" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" FontWeight="Normal"/>
<UserControls:ImageMakerControl x:Name="xMessageProcessingImage" ImageType="Processing" SetAsFontImageWithSize="30" Width="30" Height="30" Foreground="WhiteSmoke" HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>

<Canvas x:Name="xDeviceScreenshotCanvas" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" DockPanel.Dock="Top">
<Image x:Name="xDeviceScreenshotImage" Panel.ZIndex="1" Cursor="Hand" Height="{Binding ActualHeight, ElementName=xDeviceScreenshotCanvas}" Width="{Binding ActualWidth, ElementName=xDeviceScreenshotCanvas}"
<Canvas x:Name="xDeviceScreenshotCanvas" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" DockPanel.Dock="Top" MinWidth="200" MinHeight="500">
<Image x:Name="xDeviceScreenshotImage" Panel.ZIndex="1" Cursor="Hand" Height="{Binding ActualHeight, ElementName=xDeviceScreenshotCanvas}" Width="{Binding ActualWidth, ElementName=xDeviceScreenshotCanvas}"
MouseLeftButtonDown="xDeviceScreenshotImage_MouseLeftButtonDown"
MouseMove="xDeviceScreenshotImage_MouseMove"
MouseLeftButtonUp="xDeviceScreenshotImage_MouseLeftButtonUp"
MouseWheel="xDeviceScreenshotImage_MouseWheel"
SizeChanged="xDeviceScreenshotImage_SizeChanged">
</Image>
<Border x:Name="xHighlighterBorder" BorderBrush="{StaticResource $amdocsLogoLinarGradientBrush}" BorderThickness="3" Visibility="Collapsed" Margin="3" Panel.ZIndex="2" />
<UserControls:ucButton x:Name="xSwipeUp" Panel.ZIndex="3" Canvas.Top="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowUp" Click="xSwipeUp_Click" MouseDoubleClick="xSwipeUp_MouseDoubleClick" ToolTip="Swipe Up (Double Click For Double Swipe Up)" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<UserControls:ucButton x:Name="xSwipeLeft" Panel.ZIndex="3" Canvas.Left="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowLeft" Click="xSwipeLeft_Click" ToolTip="Swipe Left" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<UserControls:ucButton x:Name="xSwipeRight" Panel.ZIndex="3" Canvas.Right="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowRight" Click="xSwipeRight_Click" ToolTip="Swipe Right" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<UserControls:ucButton x:Name="xSwipeDown" Panel.ZIndex="3" Canvas.Bottom="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowDown" Click="xSwipeDown_Click" MouseDoubleClick="xSwipeDown_MouseDoubleClick" ToolTip="Swipe Down (Double Click For Double Swipe Down)" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<StackPanel x:Name="xCordsStack" Panel.ZIndex="4" Canvas.Left="1" Visibility="Collapsed" MouseEnter="xCordsStack_MouseEnter" Background="{StaticResource $BackgroundColor_White}">
<Label x:Name="xXcord" Foreground="{StaticResource $HighlightColor_Purple}" Content="X: 0" FontSize="12" FontWeight="Bold" HorizontalAlignment="Left" />
<Label x:Name="xYcord" Foreground="{StaticResource $HighlightColor_Purple}" Content="Y: 0" FontSize="12" FontWeight="Bold" HorizontalAlignment="Left" />
</StackPanel>
</Canvas>
</DockPanel>

<!--bottom buttons-->
<Frame Grid.Row="2" Grid.Column="1" Margin="0,0,0,0" Background="Black"/>
</Grid>
</Image>
<Border x:Name="xHighlighterBorder" BorderBrush="{StaticResource $amdocsLogoLinarGradientBrush}" BorderThickness="3" Visibility="Collapsed" Margin="3" Panel.ZIndex="2" />
<UserControls:ucButton x:Name="xSwipeUp" Panel.ZIndex="3" Canvas.Top="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowUp" Click="xSwipeUp_Click" MouseDoubleClick="xSwipeUp_MouseDoubleClick" ToolTip="Swipe Up (Double Click For Double Swipe Up)" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<UserControls:ucButton x:Name="xSwipeLeft" Panel.ZIndex="3" Canvas.Left="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowLeft" Click="xSwipeLeft_Click" ToolTip="Swipe Left" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<UserControls:ucButton x:Name="xSwipeRight" Panel.ZIndex="3" Canvas.Right="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowRight" Click="xSwipeRight_Click" ToolTip="Swipe Right" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<UserControls:ucButton x:Name="xSwipeDown" Panel.ZIndex="3" Canvas.Bottom="1" ButtonType="ImageButton" ButtonFontImageSize="30" ButtonImageType="AngleArrowDown" Click="xSwipeDown_Click" MouseDoubleClick="xSwipeDown_MouseDoubleClick" ToolTip="Swipe Down (Double Click For Double Swipe Down)" Margin="0,0,0,0" ButtonImageForground="{StaticResource $HighlightColor_Purple}" Visibility="Collapsed"/>
<StackPanel x:Name="xCordsStack" Panel.ZIndex="4" Canvas.Left="1" Visibility="Collapsed" MouseEnter="xCordsStack_MouseEnter" Background="{StaticResource $BackgroundColor_White}">
<Label x:Name="xXcord" Foreground="{StaticResource $HighlightColor_Purple}" Content="X: 0" FontSize="12" FontWeight="Bold" HorizontalAlignment="Left" />
<Label x:Name="xYcord" Foreground="{StaticResource $HighlightColor_Purple}" Content="Y: 0" FontSize="12" FontWeight="Bold" HorizontalAlignment="Left" />
</StackPanel>
</Canvas>
</DockPanel>
</Border>

<!--<GridSplitter x:Name="xConfigurationsSplitter" Grid.Column="2" Grid.Row="0" ResizeDirection="Columns" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="1" Background="{StaticResource $BackgroundColor_DarkGray}"/>-->

</Grid>
<!--Control buttons-->
<DockPanel Grid.Column="2" Background="Transparent">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Background="{StaticResource $BackgroundColor_White}" >
Expand Down
51 changes: 31 additions & 20 deletions Ginger/Ginger/Drivers/DriversWindows/MobileDriverWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,7 @@ await this.Dispatcher.InvokeAsync(async () =>
SetTitle(mDeviceGeneralInfo);
AlloworDisableControls(true);
xPinBtn_Click(null, null);
if (mDriver.GetDevicePlatformType() == eDevicePlatformType.Android)
{
AdjustWindowSize(imageSourceWidthPrecentage);
}
AdjustWindowSize(eImageChangeType.DoNotChange, true);
});

}
Expand Down Expand Up @@ -859,7 +856,7 @@ private void xOrientationBtn_Click(object sender, RoutedEventArgs e)
}
SetOrientationButton();
RefreshDeviceScreenshotAsync();
AdjustWindowSize(imageSourceWidthPrecentage);
AdjustWindowSize(eImageChangeType.DoNotChange, true);
needToAutoZoom = true;
}
catch (Exception ex)
Expand Down Expand Up @@ -1204,9 +1201,6 @@ public void InitWindowLook()
{
this.Icon = ImageMakerControl.GetImageSource(eImageType.Ios);
}

this.Width = 350;
this.Height = 625;
xMessageLbl.Content = "Connecting to Device...";

//Configurations & Metrics
Expand Down Expand Up @@ -1281,10 +1275,6 @@ private void AlloworDisableControls(bool toAllow)
xHomeBtn.IsEnabled = toAllow;
xMenuBtn.IsEnabled = toAllow;

xVolumUpPnl.IsEnabled = toAllow;
xVolumDownPnl.IsEnabled = toAllow;
xLockPnl.IsEnabled = toAllow;

if (!toAllow)
{
//set LightGray brush from hex
Expand Down Expand Up @@ -1757,30 +1747,51 @@ private void xExternalViewBtn_Click(object sender, RoutedEventArgs e)
mDriver.OpenDeviceExternalView();
}

double imageSourceWidthPrecentage = 0.25;
enum eImageChangeType { Increase, Decrease, DoNotChange }
private void xZoomInBtn_Click(object sender, RoutedEventArgs e)
{
imageSourceWidthPrecentage += 0.05;
AdjustWindowSize(imageSourceWidthPrecentage);
AdjustWindowSize(eImageChangeType.Increase, false);
}

private void xZoomOutBtn_Click(object sender, RoutedEventArgs e)
{
imageSourceWidthPrecentage -= 0.05;
AdjustWindowSize(imageSourceWidthPrecentage);
AdjustWindowSize(eImageChangeType.Decrease, false);
}

private void AdjustWindowSize(double widthPrecentage)
private void AdjustWindowSize(eImageChangeType operationType, bool resetCanvasSize)
{

if (xDeviceScreenshotImage.Source != null && widthPrecentage > 0.2 && widthPrecentage < 0.5)
if (xDeviceScreenshotImage.Source != null )
{
double imageSourceHightWidthRatio = xDeviceScreenshotImage.Source.Height / xDeviceScreenshotImage.Source.Width;
if (resetCanvasSize)
{
if (mDriver.GetDevicePlatformType() == eDevicePlatformType.iOS)
{
xDeviceScreenshotCanvas.Width = xDeviceScreenshotImage.Source.Width * 0.5;
}
else
{
xDeviceScreenshotCanvas.Width = xDeviceScreenshotImage.Source.Width * 0.25;
}
}
double previousCanasWidth = xDeviceScreenshotCanvas.ActualWidth;
double previousCanasHeight = xDeviceScreenshotCanvas.ActualHeight;
double targetWidthRatio = xDeviceScreenshotImage.Source.Width / xDeviceScreenshotCanvas.Width;

//Update canvas size
xDeviceScreenshotCanvas.Width = (xDeviceScreenshotImage.Source.Width * widthPrecentage);
switch (operationType)

Check failure on line 1783 in Ginger/Ginger/Drivers/DriversWindows/MobileDriverWindow.xaml.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/Ginger/Drivers/DriversWindows/MobileDriverWindow.xaml.cs#L1783

Add a 'default' clause to this 'switch' statement.
{
case eImageChangeType.Increase:
xDeviceScreenshotCanvas.Width = (xDeviceScreenshotImage.Source.Width / targetWidthRatio) * (1.15);
break;
case eImageChangeType.Decrease:
xDeviceScreenshotCanvas.Width = (xDeviceScreenshotImage.Source.Width / targetWidthRatio) * (0.85);
break;
case eImageChangeType.DoNotChange:
xDeviceScreenshotCanvas.Width = (xDeviceScreenshotImage.Source.Width / targetWidthRatio) * (1);
break;
}
xDeviceScreenshotCanvas.Height = xDeviceScreenshotCanvas.Width * imageSourceHightWidthRatio;

//Update window size
Expand Down

0 comments on commit b56b4aa

Please sign in to comment.