Skip to content

Commit

Permalink
Added Focus and Autofocus indicators.
Browse files Browse the repository at this point in the history
Red blinking for critical battery level.
  • Loading branch information
Rambalac committed May 1, 2017
1 parent 79b5cb3 commit 5529402
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Core/Camera/LumixData/FocusMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum FocusMode
{
[EnumException(0x5)]
[XmlEnum(Name = "mf")]
Manual = 0xff,
MF = 0xff,

[XmlEnum(Name = "afc")]
AFC = 0x3,
Expand Down
2 changes: 1 addition & 1 deletion Core/Camera/LumixState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public CameraMode CameraMode

public bool CanChangeShutter => CameraMode.ToValue<CameraModeFlags>().HasFlag(CameraModeFlags.Shutter);

public bool CanManualFocus => FocusMode == FocusMode.Manual;
public bool CanManualFocus => FocusMode == FocusMode.MF;

public CurMenu CurMenu
{
Expand Down
7 changes: 7 additions & 0 deletions GMaster/GMaster.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<Compile Include="Views\Commands\ManualFocusAfCommand.cs" />
<Compile Include="Views\Commands\MfAssistPinpCommand.cs" />
<Compile Include="Views\Commands\TouchAfReleaseCommand.cs" />
<Compile Include="Views\Converters\AutofocusModeToIconPathConverter.cs" />
<Compile Include="Views\Converters\BatteryToIconConverter.cs" />
<Compile Include="Views\Converters\CameraModeToIconPathConverter.cs" />
<Compile Include="Views\Converters\FalseToVisibileConverter.cs" />
Expand Down Expand Up @@ -236,6 +237,12 @@
<Content Include="Assets\Wide310x150Logo.scale-150.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
<Content Include="Assets\Wide310x150Logo.scale-400.png" />
<Content Include="images\AutofocusMode\Face.png" />
<Content Include="images\AutofocusMode\FreeMultiArea.png" />
<Content Include="images\AutofocusMode\MultiArea.png" />
<Content Include="images\AutofocusMode\OneArea.png" />
<Content Include="images\AutofocusMode\Pinpoint.png" />
<Content Include="images\AutofocusMode\Track.png" />
<Content Include="images\CameraMode\Movie.png" />
<Content Include="images\CameraMode\MovieA.png" />
<Content Include="images\CameraMode\MovieM.png" />
Expand Down
23 changes: 20 additions & 3 deletions GMaster/Views/CameraViewControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
Style="{StaticResource TransparentButtonStyle}"
IsEnabled="{Binding CanCapture}">
<Viewbox>
<TextBlock Padding="5" FontFamily="Segoe MDL2 Assets" Text="&#xE722;" />
<TextBlock Padding="5" FontFamily="Segoe MDL2 Assets" Text="&#xE722;" />
</Viewbox>
</tools:PressButton>
</StackPanel>
Expand All @@ -90,7 +90,13 @@
<Image HorizontalAlignment="Left" Source="{Binding CameraMode, Converter={StaticResource CameraModeToIconPathConverter}}"></Image>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<Viewbox>
<StackPanel Orientation="Horizontal" Margin="20,0,0,0">
<Viewbox>
<TextBlock Text="{Binding FocusMode, Mode=TwoWay}"/>
</Viewbox>
<Image Source="{Binding AutoFocusMode, Converter={StaticResource AutofocusModeToIconPathConverter}, Mode=TwoWay}"/>
</StackPanel>
<Viewbox Margin="20,0,0,0">
<TextBlock Width="120">
<Run FontFamily="Segoe MDL2 Assets" Text="&#xE7F1;"
tools:StoryboardManager.Trigger="{Binding MemoryCardAccess}">
Expand Down Expand Up @@ -120,7 +126,18 @@
<Viewbox.RenderTransform>
<ScaleTransform ScaleX="-1" CenterX="20"/>
</Viewbox.RenderTransform>
<TextBlock Text="{Binding BatteryLevel, Converter={StaticResource BatteryToIconConverter}, Mode=TwoWay}" FontFamily="Segoe MDL2 Assets"/>
<TextBlock Text="{Binding BatteryLevel, Converter={StaticResource BatteryToIconConverter}, Mode=TwoWay}"
FontFamily="Segoe MDL2 Assets"
tools:StoryboardManager.Trigger="{Binding BatteryCritical}">
<tools:StoryboardManager.Storyboard>
<Storyboard RepeatBehavior="Forever" Duration="0:0:1">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="{Binding}">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Red"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="White" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</tools:StoryboardManager.Storyboard>
</TextBlock>
</Viewbox>
</StackPanel>
</Grid>
Expand Down
6 changes: 3 additions & 3 deletions GMaster/Views/CameraViewControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private async void ImageGestureRecognizer_ManipulationCompleted(GestureRecognize
}
else
{
if (Lumix.LumixState.FocusMode == FocusMode.Manual)
if (Lumix.LumixState.FocusMode == FocusMode.MF)
{
if (args.PointerDeviceType != PointerDeviceType.Mouse)
{
Expand Down Expand Up @@ -284,7 +284,7 @@ private async Task MoveFocusPoint(double x, double y, PinchStage stage)
var fp = ToFloatPoint(x, y);
if (fp.IsInRange(0f, 1f) && Lumix != null)
{
if (Lumix.LumixState.FocusMode != FocusMode.Manual)
if (Lumix.LumixState.FocusMode != FocusMode.MF)
{
await Lumix.FocusPointMove(fp);
}
Expand All @@ -298,7 +298,7 @@ private async Task MoveFocusPoint(double x, double y, PinchStage stage)
private async Task PinchZoom(PinchStage stage, FloatPoint point, float extend)
{
extend = (200f + extend) / 1000f;
if (Lumix.LumixState.FocusMode != FocusMode.Manual)
if (Lumix.LumixState.FocusMode != FocusMode.MF)
{
if (Lumix.LumixState.FocusAreas != null
&& Lumix.LumixState.FocusAreas.Boxes.Any(b => b.Props.Type == FocusAreaType.OneAreaSelected))
Expand Down
1 change: 1 addition & 0 deletions GMaster/Views/CameraViewControlResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<converters:RecStateToIconConvertor x:Key="RecStateConvertor" />
<converters:BatteryToIconConverter x:Key="BatteryToIconConverter"/>
<converters:CameraModeToIconPathConverter x:Key="CameraModeToIconPathConverter"/>
<converters:AutofocusModeToIconPathConverter x:Key="AutofocusModeToIconPathConverter"/>
<Style x:Key="TransparentButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />
Expand Down
2 changes: 1 addition & 1 deletion GMaster/Views/Commands/ManualFocusAfCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override async Task InternalExecute()

try
{
if (lumix.Camera.LumixState.FocusMode == FocusMode.Manual)
if (lumix.Camera.LumixState.FocusMode == FocusMode.MF)
{
await lumix.Camera.MfAssistAf();
}
Expand Down
2 changes: 1 addition & 1 deletion GMaster/Views/Commands/MfAssistPinpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override async Task InternalExecute()

try
{
if (lumix.Camera.LumixState.FocusMode == FocusMode.Manual)
if (lumix.Camera.LumixState.FocusMode == FocusMode.MF)
{
await lumix.Camera.MfAssistPinp(false);
}
Expand Down
2 changes: 1 addition & 1 deletion GMaster/Views/Commands/TouchAfReleaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override async Task InternalExecute()

try
{
if (lumix.Camera.LumixState.FocusMode != FocusMode.Manual)
if (lumix.Camera.LumixState.FocusMode != FocusMode.MF)
{
await lumix.Camera.ReleaseTouchAF();
}
Expand Down
22 changes: 22 additions & 0 deletions GMaster/Views/Converters/AutofocusModeToIconPathConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace GMaster.Views.Converters
{
using System;
using System.Collections.Generic;
using Core.Camera.LumixData;
using Tools;

public class AutofocusModeToIconPathConverter : DelegateConverter<AutoFocusMode, string>
{
private static readonly Dictionary<AutoFocusMode, string> Modes = new Dictionary<AutoFocusMode, string>
{
{ AutoFocusMode.Face, "Face.png" },
{ AutoFocusMode.FreeMultiArea, "FreeMultiArea.png" },
{ AutoFocusMode.MultiArea, "MultiArea.png" },
{ AutoFocusMode.OneArea, "OneArea.png" },
{ AutoFocusMode.Pinpoint, "Pinpoint.png" },
{ AutoFocusMode.Track, "Track.png" },
};

protected override Func<AutoFocusMode, string> Converter => value => Modes.TryGetValue(value, out var res) ? "/images/AutofocusMode/" + res : string.Empty;
}
}
13 changes: 11 additions & 2 deletions GMaster/Views/Models/CameraViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public float BatteryLevel

public object CanManualFocus => lumixState?.CanManualFocus ?? false;

public bool CanManualFocusAf => (lumixState?.FocusMode ?? FocusMode.Unknown) == FocusMode.Manual && (selectedCamera?.Camera.Profile.ManualFocusAF ?? false);
public bool CanManualFocusAf => (lumixState?.FocusMode ?? FocusMode.Unknown) == FocusMode.MF && (selectedCamera?.Camera.Profile.ManualFocusAF ?? false);

public bool CanPowerZoom => lumixState?.LensInfo?.HasPowerZoom ?? false;

Expand Down Expand Up @@ -258,6 +258,10 @@ public ICollection<string> ShutterSpeeds
}
}

public FocusMode FocusMode => lumixState?.FocusMode ?? FocusMode.Unknown;

public bool BatteryCritical => BatteryLevel == 0;

[NotifyPropertyChangedInvocator]
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
Expand Down Expand Up @@ -299,7 +303,7 @@ await RunAsync(() =>
{
case nameof(LumixState.FocusMode):
OnPropertyChanged(nameof(CanManualFocusAf));

OnPropertyChanged(nameof(FocusMode));
break;

case nameof(LumixState.CameraMode):
Expand Down Expand Up @@ -383,6 +387,7 @@ await RunAsync(() =>

case nameof(LumixState.State):
OnPropertyChanged(nameof(BatteryLevel));
OnPropertyChanged(nameof(BatteryCritical));
OnPropertyChanged(nameof(MemoryCardInfo));
OnPropertyChanged(nameof(MemoryCardAccess));
OnPropertyChanged(nameof(MemoryCardError));
Expand Down Expand Up @@ -430,6 +435,10 @@ private void RefreshAll()
OnPropertyChanged(nameof(MemoryCardError));
OnPropertyChanged(nameof(MemoryCardAccess));
OnPropertyChanged(nameof(CameraMode));
OnPropertyChanged(nameof(FocusMode));
OnPropertyChanged(nameof(AutoFocusMode));
OnPropertyChanged(nameof(BatteryCritical));

}
catch (Exception ex)
{
Expand Down
Binary file added GMaster/images/AutofocusMode/Face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GMaster/images/AutofocusMode/FreeMultiArea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GMaster/images/AutofocusMode/MultiArea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GMaster/images/AutofocusMode/OneArea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GMaster/images/AutofocusMode/Pinpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GMaster/images/AutofocusMode/Track.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5529402

Please sign in to comment.