public override IScriptCommand Execute(ParameterDic pm) { IProfile[] rootProfiles = pm.GetValue <IProfile[]>(ProfilesKey); if (rootProfiles == null || rootProfiles.Length == 0) { return(ResultCommand.Error(new ArgumentException(ProfilesKey))); } if (rootProfiles.Length == 1) { pm.SetValue(DestinationKey, rootProfiles[0]); return(NextCommand); } else { IWindowManager wm = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager(); logger.Debug("Showing"); SelectProfileViewModel spvm = new SelectProfileViewModel(rootProfiles); if (wm.ShowDialog(spvm).Value) { logger.Info(String.Format("Selected {0}", spvm.SelectedRootProfile)); pm.SetValue(DestinationKey, spvm.SelectedRootProfile); return(NextCommand); } else { logger.Debug("Cancelled"); return(CancelCommand); } } }
public IProfileType QueryProfileType(IReadOnlyCollection <IProfileType> profileTypes) { var viewModel = new SelectProfileViewModel(profileTypes, this); var window = new SelectProfileWindow(); window.DataContext = viewModel; window.Icon = BitmapFrame.Create(new Uri("pack://application:,,,/CalDavSynchronizer;component/Resources/ApplicationIcon.ico")); ElementHost.EnableModelessKeyboardInterop(window); if (window.ShowDialog() ?? false) { return(viewModel.SelectedProfile); } else { return(null); } }