internal async void addEffectToImageStream()
        {
            try
            {
                if ((m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.AllStreamsIdentical) &&
                                                   (m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.PreviewPhotoStreamsIdentical) &&
                                                   (m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceCharacteristic != Windows.Media.Capture.VideoDeviceCharacteristic.RecordPhotoStreamsIdentical))
                {
                    IMediaEncodingProperties props2 = m_mediaCaptureMgr.VideoDeviceController.GetMediaStreamProperties(Windows.Media.Capture.MediaStreamType.Photo);
                    if (props2.Type.Equals("Image")) //Cant add an effect to an image type
                    {
                        //Change the media type on the stream
                        System.Collections.Generic.IReadOnlyList<IMediaEncodingProperties> supportedPropsList = m_mediaCaptureMgr.VideoDeviceController.GetAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.Photo);
                        int i = 0;
                        while (i++ < supportedPropsList.Count)
                        {
                            if (supportedPropsList[i].Type.Equals("Video"))
                            {
                                var bLowLagPrepare_tmp = m_bLowLagPrepared;

                                //it is necessary to un-prepare the lowlag photo before adding effect, since adding effect needs to change mediaType if it was not "Video" type;   
                                if (m_bLowLagPrepared)
                                {
                                    ShowStatusMessage("Stopping LowLagPhoto");
                                    await m_lowLagPhoto.FinishAsync();
                                    btnTakePhoto2.IsEnabled = false;
                                    m_bLowLagPrepared = false;
                                }
                                await m_mediaCaptureMgr.VideoDeviceController.SetMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.Photo, supportedPropsList[i]);
                                ShowStatusMessage("Change type on image pin successful");
                                await m_mediaCaptureMgr.AddEffectAsync(Windows.Media.Capture.MediaStreamType.Photo, "GrayscaleTransform.GrayscaleEffect", null);
                                ShowStatusMessage("Add effect to photo successful");
                                m_bEffectAddedToPhoto = true;
                                chkAddRemoveEffect.IsEnabled = true;
                                //Prepare LowLag Photo again if LowLag Photo was prepared before adding effect;
                                if (bLowLagPrepare_tmp)
                                {
                                    m_lowLagPhoto = await m_mediaCaptureMgr.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg());
                                    btnTakePhoto2.IsEnabled = true;
                                    m_bLowLagPrepared = true;
                                }
                                break;
                            }
                        }
                        chkAddRemoveEffect.IsEnabled = true;
                    }
                    else
                    {
                        await m_mediaCaptureMgr.AddEffectAsync(Windows.Media.Capture.MediaStreamType.Photo, "GrayscaleTransform.GrayscaleEffect", null);
                        ShowStatusMessage("Add effect to photo successful");
                        chkAddRemoveEffect.IsEnabled = true;
                        m_bEffectAddedToPhoto = true;

                    }
                }
                else
                {
                    chkAddRemoveEffect.IsEnabled = true;
                }
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
            }
        }
        internal async void radTakePhoto_Checked(Object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            try
            {
                if (!m_bLowLagPrepared)
                {
                    //if camera does not support lowlag record and lowlag photo at the same time
                    //disable all buttons while preparing lowlag photo
                    btnStartStopRecord2.IsEnabled = false;
                    btnTakePhoto2.IsEnabled = false;
                    //uncheck record Mode
                    radRecord.IsChecked = false;
                    //disable check option while preparing lowlag photo
                    radTakePhoto.IsEnabled = false;
                    radRecord.IsEnabled = false;

                    if (m_bRecording)
                    {
                        //if camera does not support lowlag record and lowlag photo at the same time
                        //but lowlag record is already prepared, un-prepare lowlag record first, before preparing lowlag photo 
                        m_bRecording = false;
                        await m_lowLagRecord.FinishAsync();

                        ShowStatusMessage("Stopped record on preparing lowlag Photo:" + m_recordStorageFile.Path);

                        m_lowLagPhoto = await m_mediaCaptureMgr.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg());
                        btnTakePhoto2.IsEnabled = true;
                        m_bLowLagPrepared = true;
                        //re-enable check option, after lowlag record finish preparing
                        radTakePhoto.IsEnabled = true;
                        radRecord.IsEnabled = true;
                    }
                    else //(!m_bRecording)
                    {
                        //if camera does not support lowlag record and lowlag photo at the same time
                        //lowlag record is not prepared, go ahead to prepare lowlag photo 
                        m_lowLagPhoto = await m_mediaCaptureMgr.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg());
                        btnTakePhoto2.IsEnabled = true;
                        m_bLowLagPrepared = true;
                        //re-enable check option, after lowlag record finish preparing
                        radTakePhoto.IsEnabled = true;
                        radRecord.IsEnabled = true;
                    }
                }
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
            }
        }
        internal async void btnStartDevice_Click(Object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            try
            {

                btnStartDevice2.IsEnabled = false;
                m_bReversePreviewRotation = false;
                ShowStatusMessage("Starting device");


                m_mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();



                var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
                var chosenDevInfo = m_devInfoCollection[EnumedDeviceList2.SelectedIndex];
                settings.VideoDeviceId = chosenDevInfo.Id;

                if (EnumedMicrophonesList2.SelectedIndex >= 0 && m_microPhoneInfoCollection.Count > 0)
                {
                    var chosenMicrophoneInfo = m_microPhoneInfoCollection[EnumedMicrophonesList2.SelectedIndex];
                    settings.AudioDeviceId = chosenMicrophoneInfo.Id;
                }

                if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back)
                {
                    m_bRotateVideoOnOrientationChange = true;
                    m_bReversePreviewRotation = false;
                }
                else if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front)
                {
                    m_bRotateVideoOnOrientationChange = true;
                    m_bReversePreviewRotation = true;
                }
                else
                {
                    m_bRotateVideoOnOrientationChange = false;
                }


                await m_mediaCaptureMgr.InitializeAsync(settings);

                if (m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceId != "" && m_mediaCaptureMgr.MediaCaptureSettings.AudioDeviceId != "")
                {
                    btnStartPreview2.IsEnabled = true;
                    ShowStatusMessage("Device initialized successful");
                    chkAddRemoveEffect.IsEnabled = true;
                    chkAddRemoveEffect.IsChecked = false;
                    m_mediaCaptureMgr.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(RecordLimitationExceeded);
                    m_mediaCaptureMgr.Failed += new Windows.Media.Capture.MediaCaptureFailedEventHandler(Failed);

                    if (!m_mediaCaptureMgr.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported)
                    {
                        radTakePhoto.IsEnabled = true;
                        radRecord.IsEnabled = true;
                        //choose TakePhoto Mode as defaul
                        radTakePhoto.IsChecked = true;
                    }
                    else
                    {
                        //prepare lowlag photo, then prepare lowlag record
                        m_lowLagPhoto = await m_mediaCaptureMgr.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg());

                        btnTakePhoto2.IsEnabled = true;
                        m_bLowLagPrepared = true;
                        PrepareLowLagRecordAsync();
                        //disable check options
                        radTakePhoto.IsEnabled = false;
                        radRecord.IsEnabled = false;
                    }

                    EnumerateSceneModeAsync();
                }
                else
                {
                    btnStartDevice2.IsEnabled = true;
                    ShowStatusMessage("No VideoDevice/AudioDevice Found");
                }

            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
            }
        }