private async void OnBrowseForViewModel( object sender, InteractionRequestedEventArgs e ) { Contract.Requires( e != null ); var picker = new TypePicker() { Title = e.Interaction.Title, NameConvention = "ViewModel", LocalAssemblyName = Model.LocalAssemblyName, SourceProject = projectInfo, RestrictedBaseTypeNames = { "System.Windows.DependencyObject" } }; if ( await picker.ShowDialogAsync( this ) ?? false ) { Model.ViewModelType = picker.SelectedType; e.Interaction.ExecuteDefaultCommand(); } else { e.Interaction.ExecuteCancelCommand(); } }
public void ConstructorShouldSetInteraction() { // arrange var expected = new Interaction(); var args = new InteractionRequestedEventArgs( expected ); // act var actual = args.Interaction; // assert Assert.Same( expected, actual ); }
private void OnAddDataConnection( object sender, InteractionRequestedEventArgs e ) { // ask visual studio to create a dialog using ( var dialog = DataConnectionDialogFactory.CreateConnectionDialog() ) { dialog.AddSources( null ); dialog.LoadSourceSelection(); // display the dialog var connection = dialog.ShowDialog( true ); // if no connection is returned, the dialog was cancelled if ( connection == null ) { e.Interaction.ExecuteCancelCommand(); return; } // save the selections if ( dialog.SaveSelection ) { dialog.SaveProviderSelections(); dialog.SaveProviderSelections(); } IVsDataExplorerConnection dataExplorerConnection = null; try { // add the connection to the data explorer dataExplorerConnection = DataExplorerConnectionManager.AddConnection( null, connection.Provider, connection.EncryptedConnectionString, true ); } catch ( XmlException ex ) { ShowError( e.Interaction.Title, ExceptionMessage.DataConnectionInvalid.FormatDefault( ex.Message ) ); return; } // create a new data source var dataSource = new DataSource( dataExplorerConnection.DisplayName, connection ); var command = e.Interaction.DefaultCommand; // invoke the accept command, supplying the new data source if ( command != null && command.CanExecute( dataSource ) ) command.Execute( dataSource ); } }