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())); }
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)); }
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)); }
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)); }
/// <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); } }
/// <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); } }
/// <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; }
/// <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)); }
/// <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)); }
/// <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); }
/// <summary> /// Gets the type of the camera. /// </summary> /// <returns>The camera type.</returns> protected override CameraType GetCameraType() { return(Enum <CameraType> .ConvertFromOtherEnumValue(_photoCamera.CameraType)); }
/// <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))); }
/// <summary> /// Gets the flash mode. /// </summary> /// <returns>The flash mode.</returns> protected override FlashMode GetFlashMode() { return(Enum <FlashMode> .ConvertFromOtherEnumValue(_photoCamera.FlashMode)); }
/// <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))); }
public void ThrowsArgumentNullExceptionForNullEnumValue() { ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => Enum <Enum2> .ConvertFromOtherEnumValue(null)); }
public void ThrowsArgumentExceptionForNonEnumValue() { ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => Enum <Enum2> .ConvertFromOtherEnumValue(new object())); }
public void ThrowsArgumentExceptionForWrongEnumValue() { ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => Enum <Enum2> .ConvertFromOtherEnumValue(Enum1.MySecondValue)); }
public void ReturnsConvertedEnumValue() { Assert.AreEqual(Enum2.MyValue, Enum <Enum2> .ConvertFromOtherEnumValue(Enum1.MyValue)); }