目前分類:UWP (20)

瀏覽方式: 標題列表 簡短摘要

結論:

小賢 發表在 痞客邦 留言(0) 人氣()

[UWP] 在進入背景或進入前景時,觸發OnNavigatedTo, OnNavigatedFrom。

  每個Page都會有自己的進入頁面跟離開頁面的邏輯,有時會希望App進入背景 or 進入前景時也能夠呼叫到目前頁面的 OnNavigatedTo, OnNavigatedFrom,但預設是不會被呼叫的,

小賢 發表在 痞客邦 留言(0) 人氣()

Package.appxmanifest:

<Package xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

小賢 發表在 痞客邦 留言(0) 人氣()

參考資料:

https://www.youtube.com/watch?v=vuGSkrx8fuo

小賢 發表在 痞客邦 留言(0) 人氣()

 

        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);
        }

 

小賢 發表在 痞客邦 留言(0) 人氣()

 

    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;

        }

    }

 

小賢 發表在 痞客邦 留言(0) 人氣()

1.在OnNavigateTo 裡,設定是否顯示Back Button

SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;

小賢 發表在 痞客邦 留言(0) 人氣()

假如想根據不同螢幕寬度來變更GridViewItem的大小,可用Adaptive Trigger 搭配Multi Style 的方式

小賢 發表在 痞客邦 留言(0) 人氣()

※ 不建議升級Win10 Mobile 10572 及Windows insider preview sdk,如果你要submit app 到Windows store 的話...


小賢 發表在 痞客邦 留言(0) 人氣()

客製化StateTriggerBase ,實現類似WinRT 8.1 的Behavior SDK DataTrigger

小賢 發表在 痞客邦 留言(0) 人氣()

1.加一個判斷用的bool flag

2.在 PointerPressed 中

小賢 發表在 痞客邦 留言(0) 人氣()

目前找到暫時性的解法是使用:FallbackValue

名  

小賢 發表在 痞客邦 留言(0) 人氣()

http://blog.spinthemoose.com/2013/03/24/disable-the-xaml-designer-in-visual-studio/


小賢 發表在 痞客邦 留言(0) 人氣()

  Object reference not set to an instance of an object.

  找了很久,再一層一層過濾後發現是DataTemplate 內的 因為在DataTemplate內找不到ViewModel, 將ViewModel中的ButtonClick寫在Collection Type 的Class 內即可..

小賢 發表在 痞客邦 留言(0) 人氣()

  今天使用x:Bind(Compiled Binding) 的時候遇到 無法將類型 'Microsoft.MetadataReader.MetadataOnlyPropertyInfo' 的物件轉換為類型 'System.Reflection.MethodInfo',

  與Richie經過一番討論後,忽然發現問題是除了自己以外,Base也有一個"同名"的Property,所以修改方法是換一個變數名稱即可。

小賢 發表在 痞客邦 留言(0) 人氣()

處理方式:

1.[Delete] ListViewItemTextBlockStyle

小賢 發表在 痞客邦 留言(0) 人氣()

VS2015RC with Win10Mobile ,按F5後出現,

錯誤 錯誤 : DEP4100 : 無法建立資料夾 "D:\WPSystem\SharedData\PhoneTools\AppxLayouts\xxx"。

小賢 發表在 痞客邦 留言(0) 人氣()

App樣式:

1.Pivots

小賢 發表在 痞客邦 留言(0) 人氣()

Win10 for developer mode 進不去解法

 

小賢 發表在 痞客邦 留言(0) 人氣()

  Untitled  

 

小賢 發表在 痞客邦 留言(0) 人氣()