public void SetUpPasswordEditorViewModel( ) { TestInjection .TestContainer( TestInjection.Mock<IClipboardService>( ), ImmediateScheduler.Module ) .InjectProperties( this ); PasswordRepository.PasswordData = new InMemoryPasswordData( ); ViewModel = ViewModelFactory.NewPasswordEditor( ); }
private void RemoveEditor( PasswordEditorViewModel editorViewModel ) { TabItem tabItem = FindTabItem( editorViewModel ); if ( tabItem != null ) { _tabbed.RemoveItem( tabItem ); if ( !_tabbed.SelectedIndex.HasValue && _tabbed.ItemCount > 0 ) _tabbed.SelectedIndex = 0; } }
public PasswordEditorViewModelFactory( PasswordEditorViewModel.Factory factory, IPasswordManagerEditor editor ) { _factory = factory; _editor = editor; }
private Func<PasswordEditorViewModel, bool> CloseRequestPredicate( PasswordEditorViewModel source, CloseEditorEventType type ) { switch ( type ) { case CloseEditorEventType.Self: return e => e == source; case CloseEditorEventType.All: return e => true; case CloseEditorEventType.AllButSelf: return e => e != source; case CloseEditorEventType.RightOfSelf: return e => Editors.IndexOf( e ) > Editors.IndexOf( source ); case CloseEditorEventType.Insecure: return e => e.RequiredGuidColor == e.ActualGuidColor && e.RequiredGuidColor != Colors.Transparent; default: throw new ArgumentOutOfRangeException( "type" ); } }
private TabItem FindTabItem( PasswordEditorViewModel editorViewModel ) { Func<TabItem, bool> hasMatchingEditor = item => item.Content is PasswordEditor && ( (PasswordEditor) item.Content ).ViewModel == editorViewModel; return _tabbed.Items.FirstOrDefault( hasMatchingEditor ); }
private static TabItem CreateTabItem( PasswordEditorViewModel editorViewModel ) { return new TabItem { Header = new PasswordEditorHeader { ViewModel = editorViewModel }, Content = new PasswordEditor { ViewModel = editorViewModel } }; }
private void AddEditor( PasswordEditorViewModel editorViewModel ) { TabItem newItem = CreateTabItem( editorViewModel ); _tabbed.AddItem( newItem ); _tabbed.SelectedItem = newItem; }