public void SetUp()
 {
     _context                   = new TestSynchronizationContext();
     _target                    = new SynchronizationContextCollection <string>(_context);
     _collectionChanged         = new List <NotifyCollectionChangedEventArgs>();
     _target.CollectionChanged += (_, e) => _collectionChanged.Add(e);
 }
Esempio n. 2
0
        /// <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>();
        }
Esempio n. 3
0
 public ViewModel()
 {
     Model    = new Model();
     Children = Model.Children.ToSyncedSynchronizationContextCollection(
         m => new ItemViewModel(m, null),
         SynchronizationContext.Current
         );
 }
Esempio n. 4
0
        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/"));
        }
Esempio n. 5
0
        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/"));
        }
Esempio n. 6
0
        /// <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();
        }
Esempio n. 7
0
        /// <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;
        }
Esempio n. 8
0
        protected override void OnDisposed()
        {
            base.OnDisposed();

            MenuItems = null;
        }
 public void TearDown()
 {
     _target  = null;
     _context = null;
 }
Esempio n. 10
0
        /// <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>();
        }