示例#1
0
        public MessageBoxResponse GetNumericUserInput(string question, string title, int defaultValue, int minValue, int maxValue, Form parent = null)
        {
            NumberDialog dialog = new NumberDialog(title, question, defaultValue, minValue, maxValue);

            if (parent == null)
            {
                CenterDialog(dialog);
            }

            var input = 0;

            var          validInput = false;
            DialogResult result;

            do
            {
                result = dialog.ShowDialog(parent);
                if (result == DialogResult.OK)
                {
                    if (dialog.Value == 0)
                    {
                        continue;
                    }

                    input = dialog.Value;
                }

                validInput = true;
            }while (!validInput && result != DialogResult.OK);

            return(new MessageBoxResponse(Enum <MessageResult> .ConvertFromOtherEnumValue(result), input.ToString()));
        }
示例#2
0
        public MessageBoxResponse GetUserInput(string question, string title, string defaultText, Form parent = null)
        {
            TextDialog dialog = new TextDialog(question, title, defaultText, true);

            if (parent == null)
            {
                CenterDialog(dialog);
            }

            var input = string.Empty;

            var          validInput = false;
            DialogResult result;

            do
            {
                result = dialog.ShowDialog(parent);
                if (result == DialogResult.OK)
                {
                    if (dialog.Response == string.Empty)
                    {
                        continue;
                    }

                    input = dialog.Response;
                }

                validInput = true;
            }while (!validInput && result != DialogResult.OK);

            return(new MessageBoxResponse(Enum <MessageResult> .ConvertFromOtherEnumValue(result), input));
        }
示例#3
0
        public MessageBoxResponse GetUserConfirmation(string question, string title)
        {
            MessageBoxForm mbf = new MessageBoxForm(question, title, MessageBoxButtons.YesNoCancel, SystemIcons.Question);

            CenterDialog(mbf);
            mbf.ShowDialog();

            return(new MessageBoxResponse(Enum <MessageResult> .ConvertFromOtherEnumValue(mbf.DialogResult), null));
        }
示例#4
0
        public MessageBoxResponse ShowError(string message, string title)
        {
            MessageBoxForm mbf = new MessageBoxForm(message, title, MessageBoxButtons.OK, SystemIcons.Error);

            CenterDialog(mbf);
            mbf.ShowDialog();

            return(new MessageBoxResponse(Enum <MessageResult> .ConvertFromOtherEnumValue(mbf.DialogResult), null));
        }
示例#5
0
 /// <summary>
 /// Translates the message button.
 /// </summary>
 /// <param name="button">The button.</param>
 /// <returns>
 /// Corresponding <see cref="MessageBoxButton"/>.
 /// </returns>
 protected static MessageBoxButton TranslateMessageButton(MessageButton button)
 {
     try
     {
         return(Enum <MessageBoxButton> .ConvertFromOtherEnumValue(button));
     }
     catch (Exception)
     {
         throw new NotSupportedInSilverlightException("Unfortunately, the default MessageBox class of Silverlight does not support '{0}'", button);
     }
 }
示例#6
0
 /// <summary>
 /// Translates the message button.
 /// </summary>
 /// <param name="button">The button.</param>
 /// <returns>
 /// Corresponding <see cref="MessageBoxButton"/>.
 /// </returns>
 protected static MessageBoxButton TranslateMessageButton(MessageButton button)
 {
     try
     {
         return(Enum <MessageBoxButton> .ConvertFromOtherEnumValue(button));
     }
     catch (Exception)
     {
         throw new NotSupportedInPlatformException("MessageBox class does not support MessageButton '{0}'", button);
     }
 }
示例#7
0
        /// <summary>
        /// Starts the camera service so it's retrieving data.
        /// </summary>
        /// <param name="cameraType">Type of the camera.</param>
        /// <remarks>
        /// This method is already protected and only called when the service is currently not running.
        /// </remarks>
        protected override void StartService(CameraType cameraType)
        {
            _photoCamera = new PhotoCamera(Enum <Microsoft.Devices.CameraType> .ConvertFromOtherEnumValue(cameraType));

            _photoCamera.Initialized               += OnPhotoCameraInitialized;
            _photoCamera.AutoFocusCompleted        += OnPhotoCameraAutoFocusCompleted;
            _photoCamera.CaptureStarted            += OnPhotoCameraCaptureStarted;
            _photoCamera.CaptureThumbnailAvailable += OnPhotoCameraCaptureThumbnailAvailable;
            _photoCamera.CaptureImageAvailable     += OnPhotoCameraCaptureImageAvailable;
            _photoCamera.CaptureCompleted          += OnPhotoCameraCaptureCompleted;
        }
示例#8
0
 /// <summary>
 /// Translates the message image.
 /// </summary>
 /// <param name="image">The image.</param>
 /// <returns>
 /// Corresponding <see cref="MessageBoxImage"/>.
 /// </returns>
 protected static MessageBoxImage TranslateMessageImage(MessageImage image)
 {
     return(Enum <MessageBoxImage> .ConvertFromOtherEnumValue(image));
 }
示例#9
0
 /// <summary>
 /// Translates the message box result.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <returns>
 /// Corresponding <see cref="MessageResult"/>.
 /// </returns>
 protected static MessageResult TranslateMessageBoxResult(MessageBoxResult result)
 {
     return(Enum <MessageResult> .ConvertFromOtherEnumValue(result));
 }
示例#10
0
 /// <summary>
 /// Sets the flash mode.
 /// </summary>
 /// <param name="flashMode">The flash mode.</param>
 protected override void SetFlashMode(FlashMode flashMode)
 {
     _photoCamera.FlashMode = Enum <Microsoft.Devices.FlashMode> .ConvertFromOtherEnumValue(flashMode);
 }
示例#11
0
 /// <summary>
 /// Gets the type of the camera.
 /// </summary>
 /// <returns>The camera type.</returns>
 protected override CameraType GetCameraType()
 {
     return(Enum <CameraType> .ConvertFromOtherEnumValue(_photoCamera.CameraType));
 }
示例#12
0
 /// <summary>
 /// Determines whether a particular flash mode is supported on the device.
 /// </summary>
 /// <param name="mode">The mode.</param>
 /// <returns>
 ///     <c>true</c> if the specified flash mode is supported; otherwise, <c>false</c>.
 /// </returns>
 /// <remarks>
 /// This method is already protected and only called when the service is currently running.
 /// </remarks>
 protected override bool IsFlashModeSupportedByCamera(FlashMode mode)
 {
     return(_photoCamera.IsFlashModeSupported(Enum <Microsoft.Devices.FlashMode> .ConvertFromOtherEnumValue(mode)));
 }
示例#13
0
 /// <summary>
 /// Gets the flash mode.
 /// </summary>
 /// <returns>The flash mode.</returns>
 protected override FlashMode GetFlashMode()
 {
     return(Enum <FlashMode> .ConvertFromOtherEnumValue(_photoCamera.FlashMode));
 }
示例#14
0
 /// <summary>
 /// Determines whether a particular camera type is supported on the device.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns>
 ///     <c>true</c> if the specified camera type is supported; otherwise, <c>false</c>.
 /// </returns>
 public override bool IsCameraTypeSupported(CameraType type)
 {
     return(PhotoCamera.IsCameraTypeSupported(Enum <Microsoft.Devices.CameraType> .ConvertFromOtherEnumValue(type)));
 }
示例#15
0
 public void ThrowsArgumentNullExceptionForNullEnumValue()
 {
     ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => Enum <Enum2> .ConvertFromOtherEnumValue(null));
 }
示例#16
0
 public void ThrowsArgumentExceptionForNonEnumValue()
 {
     ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => Enum <Enum2> .ConvertFromOtherEnumValue(new object()));
 }
示例#17
0
 public void ThrowsArgumentExceptionForWrongEnumValue()
 {
     ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => Enum <Enum2> .ConvertFromOtherEnumValue(Enum1.MySecondValue));
 }
示例#18
0
 public void ReturnsConvertedEnumValue()
 {
     Assert.AreEqual(Enum2.MyValue, Enum <Enum2> .ConvertFromOtherEnumValue(Enum1.MyValue));
 }