public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ViewModelStatus status = (ViewModelStatus)value; bool?dialogResult = false; switch (status) { case ViewModelStatus.NoChange: dialogResult = false; break; case ViewModelStatus.Running: dialogResult = null; break; case ViewModelStatus.Complete: dialogResult = true; break; default: throw IntegrityCheck.FailUnexpectedDefault(status); } return(dialogResult); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Activity currentActivity = (Activity)value; ResourceDictionary imageLookup = (ResourceDictionary)parameter; ImageSource image; switch (currentActivity) { case Activity.Fault: image = (ImageSource)imageLookup["errorStatus"]; break; case Activity.Loading: case Activity.Transitioning: image = (ImageSource)imageLookup["loadingStatus"]; break; case Activity.Templating: case Activity.Idle: // TODO: uninitialised image? case Activity.Uninitialised: image = null; break; default: throw IntegrityCheck.FailUnexpectedDefault(currentActivity); } return(image); }
public string this[string property] { get { String errorMessage = String.Empty; switch (property) { case "ApiKey": if (!m_SettingsManager.ValidateQuerySetting( Setting.ApiKey, m_ApiKey.QueryValue)) { errorMessage = m_SettingsManager.ValidationHelpText(Setting.ApiKey); } break; case "RootUrl": if (!m_SettingsManager.ValidateQuerySetting( Setting.RootUrl, m_RootUrl.QueryValue)) { errorMessage = m_SettingsManager.ValidationHelpText(Setting.RootUrl); } break; default: throw IntegrityCheck.FailUnexpectedDefault(property); } return(errorMessage); } }
protected override void OnOperationComplete(SaveTemplateEventArgs e) { switch (e.Result) { case DataRequestResult.Success: Outer.PromptText = "Saved successfully"; // Save operation complete // Clear the TemplatingViewModel of any leftover information Outer.TemplatingViewModel.QuitTemplating(); // Now transition to Idle TransitionTo(typeof(Idle)); break; case DataRequestResult.Failed: Outer.PromptText = "Server failed to save"; // Save operation failed due to connection. Wait TransitionTo(typeof(Templating)); break; case DataRequestResult.TaskFailed: Outer.PromptText = "Application failed to save"; // Save operation failed due to bug. Transition to Fault TransitionTo(typeof(Error)); break; default: throw IntegrityCheck.FailUnexpectedDefault(e.Result); } }
private void ViewModel_ActivityChanged(object sender, ActivityChangedEventArgs e) { // Set the Status Image ImageSource statusImageSource; switch (e.NewActivity) { case Activity.Fault: statusImageSource = (ImageSource)mainWindow.Resources["errorStatus"]; break; case Activity.Loading: case Activity.Transitioning: statusImageSource = (ImageSource)mainWindow.Resources["loadingStatus"]; break; case Activity.Templating: case Activity.Idle: // TODO: uninitialised image? case Activity.Uninitialised: statusImageSource = null; break; default: throw IntegrityCheck.FailUnexpectedDefault(e.NewActivity); } // Load File icon ImageSource loadFileIcon; if (e.NewActivity == Activity.Loading) { loadFileIcon = (ImageSource)mainWindow.Resources["cancelIcon"]; } else { loadFileIcon = (ImageSource)mainWindow.Resources["loadIcon"]; } // Update UI element on application thread m_ViewModel.DispatcherHelper.Invoke(new Action(() => { statusImage.Source = statusImageSource; ((System.Windows.Controls.Image)loadFile.Content).Source = loadFileIcon; })); }
protected override void OnOperationComplete(GetCaptureCompleteEventArgs e) { // We have recieved a response from our request. // Indicate we are no longer loading. switch (e.Result) { case DataRequestResult.Success: IntegrityCheck.IsNotNull(e.Capture); Outer.PromptText = "Capture loaded"; Outer.m_TemplatingViewModel.BeginTemplating(e.Capture); TransitionTo(typeof(Templating)); break; case DataRequestResult.Failed: // No capture was obtained. Outer.PromptText = "No capture matching the criteria obtained."; Log.DebugFormat( "Capture request returned Failed response.", Outer.FilteredScannerType); TransitionTo(typeof(Idle)); break; case DataRequestResult.TaskFailed: // No capture was obtained. Outer.PromptText = "App failed to carry out capture request."; Log.ErrorFormat( "Capture request returned TaskFailed response.", Outer.FilteredScannerType); TransitionTo(typeof(Idle)); break; default: throw IntegrityCheck.FailUnexpectedDefault(e.Result); } }