public void SetUp() { _context = new TestSynchronizationContext(); _target = new SynchronizationContextCollection <string>(_context); _collectionChanged = new List <NotifyCollectionChangedEventArgs>(); _target.CollectionChanged += (_, e) => _collectionChanged.Add(e); }
/// <summary> /// /// </summary> /// <param name="manager"></param> public MainWindowViewModel(ApplicationManager manager) { _manager = manager; _manager.Error += manager_Error; _applications = _manager.Applications.ToSyncedSynchronizationContextCollection(x => new ApplicationViewModel(_manager, x), SynchronizationContext.Current); IsSettingsOpen = new ReactiveProperty <bool>(false); IsDetailsOpen = new ReactiveProperty <bool>(false); IsProgressActive = new ReactiveProperty <bool>(false); ShowWindowRightCommands = IsSettingsOpen.CombineLatest(IsDetailsOpen, (a, b) => !a && !b) .ToReactiveProperty(); InitialDirectory = _manager.Settings.ToReactivePropertyAsSynchronized(x => x.ApplicationRootDirectoryPath); ShowHelpCommand = new ReactiveCommand(); ShowHelpCommand.Subscribe(_ => ShowHelp()); RegisterApplicationCommand = IsProgressActive.Select(x => !x).ToReactiveCommand(); RegisterApplicationCommand.Subscribe(_ => RegisterApplication()); InstallApplicationCommand = IsProgressActive.Select(x => !x).ToReactiveCommand(); InstallApplicationCommand.Subscribe(_ => InstallApplication()); OpenSettingCommand = new ReactiveCommand(); OpenSettingCommand.Subscribe(_ => ShowSettings()); ShowDetailsCommand = new ReactiveCommand <ApplicationViewModel>(); ShowDetailsCommand.Subscribe(ShowDetails); CurrentItem = new ReactiveProperty <ApplicationViewModel>(); SettingsViewModel = new ReactiveProperty <SettingsViewModel>(); }
public ViewModel() { Model = new Model(); Children = Model.Children.ToSyncedSynchronizationContextCollection( m => new ItemViewModel(m, null), SynchronizationContext.Current ); }
public HelpViewModel() { var sites = new[] { new OssLibraryInfo { Name = "Auto Mapper", ProjectUri = new Uri("http://automapper.org/") }, new OssLibraryInfo { Name = "Rx(Reactive Extensions) / Ix(Interactive Extensions)", ProjectUri = new Uri("https://rx.codeplex.com/") }, new OssLibraryInfo { Name = "Json.NET", ProjectUri = new Uri("http://www.newtonsoft.com/json") }, new OssLibraryInfo { Name = "Livet", ProjectUri = new Uri("http://ugaya40.hateblo.jp/entry/Livet") }, new OssLibraryInfo { Name = "StatefulModel", ProjectUri = new Uri("https://github.com/ugaya40/StatefulModel") }, new OssLibraryInfo { Name = "MahApps.Metro", ProjectUri = new Uri("http://mahapps.com/") }, new OssLibraryInfo { Name = "NLog", ProjectUri = new Uri("http://nlog-project.org/") }, new OssLibraryInfo { Name = "ReactiveProperty", ProjectUri = new Uri("https://github.com/runceel/ReactiveProperty") }, }; _usingLibraries = new SynchronizationContextCollection<WebsiteViewModel>( sites.Select(x => new WebsiteViewModel(x)), SynchronizationContext.Current); IconProvider = new WebsiteViewModel("IconDrawer", new Uri("http://www.icondrawer.com/")); }
public HelpViewModel() { var sites = new[] { new OssLibraryInfo { Name = "Auto Mapper", ProjectUri = new Uri("http://automapper.org/") }, new OssLibraryInfo { Name = "Rx(Reactive Extensions) / Ix(Interactive Extensions)", ProjectUri = new Uri("https://rx.codeplex.com/") }, new OssLibraryInfo { Name = "Json.NET", ProjectUri = new Uri("http://www.newtonsoft.com/json") }, new OssLibraryInfo { Name = "Livet", ProjectUri = new Uri("http://ugaya40.hateblo.jp/entry/Livet") }, new OssLibraryInfo { Name = "StatefulModel", ProjectUri = new Uri("https://github.com/ugaya40/StatefulModel") }, new OssLibraryInfo { Name = "MahApps.Metro", ProjectUri = new Uri("http://mahapps.com/") }, new OssLibraryInfo { Name = "NLog", ProjectUri = new Uri("http://nlog-project.org/") }, new OssLibraryInfo { Name = "ReactiveProperty", ProjectUri = new Uri("https://github.com/runceel/ReactiveProperty") }, }; _usingLibraries = new SynchronizationContextCollection <WebsiteViewModel>( sites.Select(x => new WebsiteViewModel(x)), SynchronizationContext.Current); IconProvider = new WebsiteViewModel("IconDrawer", new Uri("http://www.icondrawer.com/")); }
/// <summary> /// コンストラクタ /// </summary> public MainWindowViewModel() { Source = MenuModel.Instance; MenuItems = Source.MenuItems.ToSyncedSynchronizationContextCollection( model => model.Type == MenuItemType.Favorite ? new MenuItemByFavoriteViewModel(this, model) : new MenuItemViewModel(this, model), SynchronizationContext.Current ); // 初回起動時のワークスペース Current = new RankingViewModel(); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="vm">本インスタンスを保持する親のViewModel</param> /// <param name="model">本インスタンスを構成するモデル</param> public MenuItemViewModel(MainWindowViewModel vm, MenuItemModel model) { VM = vm; Source = model; Parent = null; Name = Source.Name; Type = Source.Type; Children = model.Children.ToSyncedSynchronizationContextCollection( m => m.Type == MenuItemType.Favorite ? new MenuItemByFavoriteViewModel(vm, this, m) : new MenuItemViewModel(vm, this, m), SynchronizationContext.Current );; // メニューアイテムをクリックした際はワークスペースのカレントを変更する。 Click += VM.OnCurrentChanging; }
protected override void OnDisposed() { base.OnDisposed(); MenuItems = null; }
public void TearDown() { _target = null; _context = null; }
/// <summary> /// /// </summary> /// <param name="manager"></param> public MainWindowViewModel(ApplicationManager manager) { _manager = manager; _manager.Error += manager_Error; _applications = _manager.Applications.ToSyncedSynchronizationContextCollection(x => new ApplicationViewModel(_manager, x), SynchronizationContext.Current); IsSettingsOpen = new ReactiveProperty<bool>(false); IsDetailsOpen = new ReactiveProperty<bool>(false); IsProgressActive = new ReactiveProperty<bool>(false); ShowWindowRightCommands = IsSettingsOpen.CombineLatest(IsDetailsOpen, (a, b) => !a && !b) .ToReactiveProperty(); InitialDirectory = _manager.Settings.ToReactivePropertyAsSynchronized(x => x.ApplicationRootDirectoryPath); ShowHelpCommand = new ReactiveCommand(); ShowHelpCommand.Subscribe(_ => ShowHelp()); RegisterApplicationCommand = IsProgressActive.Select(x => !x).ToReactiveCommand(); RegisterApplicationCommand.Subscribe(_ => RegisterApplication()); InstallApplicationCommand = IsProgressActive.Select(x => !x).ToReactiveCommand(); InstallApplicationCommand.Subscribe(_ => InstallApplication()); OpenSettingCommand = new ReactiveCommand(); OpenSettingCommand.Subscribe(_ => ShowSettings()); ShowDetailsCommand = new ReactiveCommand<ApplicationViewModel>(); ShowDetailsCommand.Subscribe(ShowDetails); CurrentItem = new ReactiveProperty<ApplicationViewModel>(); SettingsViewModel = new ReactiveProperty<SettingsViewModel>(); }