按下鍵盤的return or next 鍵,可以自動跳到下一個TextField,並在最後一個TextField按下return or next 鍵後,會自動執行Default action
- Nov 07 Mon 2016 03:03
[Swift] TextField User Friendly
- Nov 06 Sun 2016 05:02
[Swift] Json to Value Types Model Converter Tool
- Oct 09 Sun 2016 01:35
[UWP] DES加解密
private const string strKey = "Key"; private const string strIV = "IV"; public static string Encrypt(string message) { if (string.IsNullOrEmpty(message)) { return string.Empty; } var keyBuffer = CryptographicBuffer.ConvertStringToBinary(strKey, BinaryStringEncoding.Utf8); var ivBuffer = CryptographicBuffer.ConvertStringToBinary(strIV, BinaryStringEncoding.Utf8); var messageBuffer = CryptographicBuffer.ConvertStringToBinary(message, BinaryStringEncoding.Utf8); var provider = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.DesCbcPkcs7); var key = provider.CreateSymmetricKey(keyBuffer); var buffEncrypt = CryptographicEngine.Encrypt(key, messageBuffer, ivBuffer); return CryptographicBuffer.EncodeToBase64String(buffEncrypt); } public static string Decrypt(string encryptedBase64String) { if (string.IsNullOrEmpty(encryptedBase64String)) { return string.Empty; } var buffer = CryptographicBuffer.ConvertStringToBinary(strKey, BinaryStringEncoding.Utf8); var ivBuffer = CryptographicBuffer.ConvertStringToBinary(strIV, BinaryStringEncoding.Utf8); var provider = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.DesCbcPkcs7); var keyBuffer = provider.CreateSymmetricKey(buffer); var decryptedBuffer = CryptographicEngine.Decrypt(keyBuffer, CryptographicBuffer.DecodeFromBase64String(encryptedBase64String), ivBuffer); return CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, decryptedBuffer); }
- Oct 06 Thu 2016 13:25
[iOS9] canOpenURL return false
- Sep 29 Thu 2016 00:26
[UWP] Win10 Mobile 相機Preview旋轉問題
public partial class TakePhotoPage { private MediaCapture _mediaCapture; private bool _isPreviewing; private DisplayRequest _displayRequest; private async Task StartPreviewAsync() { try { _mediaCapture = new MediaCapture(); await _mediaCapture.InitializeAsync(); PreviewControl.Source = _mediaCapture; await _mediaCapture.StartPreviewAsync(); _isPreviewing = true; _displayRequest = new DisplayRequest(); _displayRequest.RequestActive(); DisplayInformation.AutoRotationPreferences = DisplayOrientations.PortraitFlipped; // 解決手機上的旋轉問題 SimpleOrientationSensor sensor = SimpleOrientationSensor.GetDefault(); if (sensor == null) { return; } sensor.OrientationChanged += (s, arg) => { switch (arg.Orientation) { case SimpleOrientation.Rotated90DegreesCounterclockwise: _mediaCapture.SetPreviewRotation(VideoRotation.None); break; case SimpleOrientation.Rotated180DegreesCounterclockwise: case SimpleOrientation.Rotated270DegreesCounterclockwise: _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise180Degrees); break; default: _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees); break; } }; } catch (UnauthorizedAccessException) { // This will be thrown if the user denied access to the camera in privacy settings var messageDialog = new MessageDialog("The app was denied access to the camera"); await messageDialog.ShowAsync(); } catch (Exception ex) { var messageDialog = new MessageDialog("MediaCapture initialization failed. {0}", ex.Message); await messageDialog.ShowAsync(); } } private async Task CleanupCameraAsync() { if (_mediaCapture == null) { return; } if (_isPreviewing) { await _mediaCapture.StopPreviewAsync(); } await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { PreviewControl.Source = null; if (_displayRequest == null) { return; } _displayRequest.RequestRelease(); }); _mediaCapture.Dispose(); _mediaCapture = null; } }