From 869eb95c97462008612b56f2b61cff9bd47df2a8 Mon Sep 17 00:00:00 2001 From: Rambalac Date: Wed, 26 Apr 2017 15:50:31 +0900 Subject: [PATCH] Code cleanup --- Core/Camera/Lumix.cs | 36 +++++----- Core/Camera/OffFrameProcessor.cs | 67 +++++++++---------- Core/Tools/Log.cs | 2 + GMaster/App.xaml.cs | 7 +- GMaster/GMaster.csproj | 1 + GMaster/Views/CameraViewControlResources.xaml | 2 +- .../Views/Commands/ManualFocusAfCommand.cs | 26 ------- GMaster/Views/Commands/MfAssistPinpCommand.cs | 35 ++++++++++ GMaster/Views/Misc/FrameRenderer.cs | 5 +- GMaster/_pkginfo.txt | 2 +- Tools/IObservableHashCollection.cs | 1 - Tools/ObservableHashCollection.cs | 2 - Tools/SettingsContainer.cs | 1 - 13 files changed, 95 insertions(+), 92 deletions(-) create mode 100644 GMaster/Views/Commands/MfAssistPinpCommand.cs diff --git a/Core/Camera/Lumix.cs b/Core/Camera/Lumix.cs index 1d0df3a..ab1bb01 100644 --- a/Core/Camera/Lumix.cs +++ b/Core/Camera/Lumix.cs @@ -310,24 +310,6 @@ public async Task MfAssistZoom(PinchStage stage, FloatPoint p, float size) f => Profile.NewTouch = f); } - private async Task OldMfAssistZoom(PinchStage stage, FloatPoint floatPoint, float size) - { - if (stage == PinchStage.Start) - { - lastOldPinchSize = size; - return true; - } - - if (LumixState.CameraMode != CameraMode.MFAssist) - { - return await MfAssistMove(stage, floatPoint); - } - - var val = size - lastOldPinchSize > 0 ? 10 : 5; - Debug.WriteLine("Mag val:" + val, "MFAssist"); - return await TryGet($"?mode=setsetting&type=mf_asst_mag&value={val}"); - } - [RunnableAction(MethodGroup.Capture)] public async Task RecStart() { @@ -562,6 +544,24 @@ private async Task NewMfAssistMove(PinchStage stage, FloatPoint p) return true; } + private async Task OldMfAssistZoom(PinchStage stage, FloatPoint floatPoint, float size) + { + if (stage == PinchStage.Start) + { + lastOldPinchSize = size; + return true; + } + + if (LumixState.CameraMode != CameraMode.MFAssist) + { + return await MfAssistMove(stage, floatPoint); + } + + var val = size - lastOldPinchSize > 0 ? 10 : 5; + Debug.WriteLine("Mag val:" + val, "MFAssist"); + return await TryGet($"?mode=setsetting&type=mf_asst_mag&value={val}"); + } + private async Task OldNewAction(Func> newAction, Func> oldAction, bool flag, Action flagSet) { return await Try(async () => diff --git a/Core/Camera/OffFrameProcessor.cs b/Core/Camera/OffFrameProcessor.cs index e3c8ede..e3d3d56 100644 --- a/Core/Camera/OffFrameProcessor.cs +++ b/Core/Camera/OffFrameProcessor.cs @@ -1,10 +1,9 @@ -using System.Text; - namespace GMaster.Core.Camera { using System; using System.Collections.Generic; using System.Linq; + using System.Text; using LumixData; using Tools; @@ -15,6 +14,8 @@ public class OffFrameProcessor private readonly LumixState lumixState; private readonly CameraParser parser; + private Slice lastPrint; + public OffFrameProcessor(string deviceName, CameraParser parser, LumixState lumixState) { this.parser = parser; @@ -75,33 +76,6 @@ public void Process(Slice slice, IntPoint size) } } - private Slice lastPrint; - - private void PrintBytes(Slice slice) - { - Debug.WriteLine( - () => - { - if (lastPrint == null || slice.Length != lastPrint.Length) - { - lastPrint = slice; - return string.Join(",", slice.Skip(32).Select(a => a.ToString("X2"))); - } - - var str = new StringBuilder(); - for (int i = 0; i < slice.Length; i++) - { - str.Append(slice[i].ToString("X2")); - if (i < slice.Length - 1) - { - str.Append(slice[i] != lastPrint[i] || slice[i + 1] != lastPrint[i + 1] ? '#' : ','); - } - } - lastPrint = slice; - return str.ToString(); - }, "OffFrameBytes"); - } - private static string FindClosest(IReadOnlyDictionary dict, int value) { var list = dict.Keys.ToList(); @@ -128,11 +102,6 @@ private static string FindClosest(IReadOnlyDictionary dict, int val return val2 - value > value - val1 ? dict[val1] : dict[val2]; } - private static int GetMultiplier(Slice slice) - { - return slice[46] == 0xff ? 12 : 16; - } - private static FocusAreas GetFocusPoint(Slice slice, IntPoint size) { var pointsNum = slice[47]; @@ -160,6 +129,11 @@ private static FocusAreas GetFocusPoint(Slice slice, IntPoint size) return null; } + private static int GetMultiplier(Slice slice) + { + return slice[46] == 0xff ? 12 : 16; + } + private TextBinValue GetFromShort(Slice slice, int index, IReadOnlyDictionary dict) { var bin = slice.ToShort(index); @@ -180,6 +154,31 @@ private TextBinValue GetFromShort(Slice slice, int index, IReadOnlyDictionary + { + if (lastPrint == null || slice.Length != lastPrint.Length) + { + lastPrint = slice; + return string.Join(",", slice.Skip(32).Select(a => a.ToString("X2"))); + } + + var str = new StringBuilder(); + for (int i = 0; i < slice.Length; i++) + { + str.Append(slice[i].ToString("X2")); + if (i < slice.Length - 1) + { + str.Append(slice[i] != lastPrint[i] || slice[i + 1] != lastPrint[i + 1] ? '#' : ','); + } + } + lastPrint = slice; + return str.ToString(); + }, "OffFrameBytes"); + } + private class ProcessState { public ProcessState(Slice array, int multiplier) diff --git a/Core/Tools/Log.cs b/Core/Tools/Log.cs index 5209926..3822ab0 100644 --- a/Core/Tools/Log.cs +++ b/Core/Tools/Log.cs @@ -248,7 +248,9 @@ private class LogglyMessage public string Method { get; set; } public Severity Severity { get; set; } + public string Version { get; set; } + public string Device { get; set; } } } diff --git a/GMaster/App.xaml.cs b/GMaster/App.xaml.cs index 8d3bd1d..2ce4aa9 100644 --- a/GMaster/App.xaml.cs +++ b/GMaster/App.xaml.cs @@ -1,9 +1,7 @@ -using System.Linq; -using Windows.Security.ExchangeActiveSyncProvisioning; - -namespace GMaster +namespace GMaster { using System; + using System.Linq; using System.Threading.Tasks; using Core.Tools; using Views; @@ -11,6 +9,7 @@ namespace GMaster using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; using Windows.ApplicationModel.Resources; + using Windows.Security.ExchangeActiveSyncProvisioning; using Windows.Storage; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/GMaster/GMaster.csproj b/GMaster/GMaster.csproj index 8b2a54b..5f54403 100644 --- a/GMaster/GMaster.csproj +++ b/GMaster/GMaster.csproj @@ -109,6 +109,7 @@ + diff --git a/GMaster/Views/CameraViewControlResources.xaml b/GMaster/Views/CameraViewControlResources.xaml index 2071da3..20508d7 100644 --- a/GMaster/Views/CameraViewControlResources.xaml +++ b/GMaster/Views/CameraViewControlResources.xaml @@ -6,7 +6,7 @@ - +