Example #1
0
 public Tweets()
 {
     ShowTweets = _showTweets.ToReadOnlyReactiveCollection();
     Medias     = _medias.ToReadOnlyReactiveCollection();
     IsOrSearch.Subscribe(async _ => await Reflesh()).AddTo(Disposable);
     Predicates.CollectionChangedAsObservable().Subscribe(async _ => await Reflesh()).AddTo(Disposable);
 }
Example #2
0
        internal TreeViewItemViewModel(TreeViewItemModel item)
        {
            Model = item;

            Title = item
                    .ObserveProperty(x => x.Title)
                    .ToReadOnlyReactivePropertySlim()
                    .AddTo(disposable);

            Tag = item
                  .ObserveProperty(x => x.Tag)
                  .ToReadOnlyReactivePropertySlim()
                  .AddTo(disposable);

            Children = item.Children
                       .ToReadOnlyReactiveCollection(x => new TreeViewItemViewModel(x))
                       .AddTo(disposable);

            new[]
            {
                Children.CollectionChangedAsObservable().OfType <object>(),
                Children.ObserveElementObservableProperty(x => x.Title).OfType <object>(),
                Children.ObserveElementObservableProperty(x => x.Tag).OfType <object>(),
                Children.ObserveElementProperty(x => x.Children).OfType <object>()
            }
            .Merge()
            .Subscribe(_ => OnPropertyChanged(new PropertyChangedEventArgs(nameof(Children))))
            .AddTo(disposable);
        }
Example #3
0
        public ServerListPageViewModel(Models.DiscordContext discordContext, INavigationService navService)
        {
            _DiscordContext    = discordContext;
            _NavigationService = navService;

            Guilds = _DiscordContext.Guilds;
        }
Example #4
0
        public AbemaCommentViewModel(AbemaApiClient abemaApiHost, AbemaState abemaState, Configuration configuration,
                                     StatusService statusService)
        {
            var commentHost = new CommentHost(abemaApiHost, abemaState, configuration, statusService).AddTo(this);

            Comments = commentHost.Comments.ToReadOnlyReactiveCollection(w => new CommentViewModel(w)).AddTo(this);
        }
        /// <summary>
        /// コンストラクタ
        /// DIでModel層を注入する
        /// </summary>
        /// <param name="workitemManager"></param>
        public WorklistViewModel(IRegionManager regionManager, WorkitemManager workitemManager, TitleMessenger titleMessenger)
        {
            this._regionManager   = regionManager;
            this._workitemManager = workitemManager;
            this._titleMessenger  = titleMessenger;

            this.Studies = this._workitemManager.Workitems
                           .ToReadOnlyReactiveCollection(x => new WorkitemViewModel(x));

            this.StudiesView        = CollectionViewSource.GetDefaultView(this.Studies);
            this.StudiesView.Filter = this.WorkitemFilter;

            this.SelectedStudy = new ReactiveProperty <WorkitemViewModel>()
                                 .SetValidateAttribute(() => this.SelectedStudy);

            this.ClearCommand = new ReactiveCommand()
                                .WithSubscribe(this._workitemManager.ClearWorkitems);

            this.ReloadCommand = new ReactiveCommand()
                                 .WithSubscribe(() => this.ReloadWorkitems());

            this.NavigateDetailCommand = this.SelectedStudy
                                         .ObserveHasErrors
                                         .Inverse()
                                         .ToReactiveCommand()
                                         .WithSubscribe(() => this.NavigateToDetailWithParams());

            this.ChangeTitleCommand = new ReactiveCommand()
                                      .WithSubscribe(() => this._titleMessenger.ChangeTitle("Worklist"));

            this.TextFilter.Subscribe(_ => this.Refresh());
        }
        public EpisodeSampleViewModel()
        {
            // ReadOnlyでないReactivePropertyは変数のように扱える
            this.Name    = new ReactiveProperty <string>(string.Empty);
            this.Numbers = new ReactiveCollection <int>()
            {
                0, 1, 2
            };

            // ReadOnlyのReactivePropertyは必ずソースオブジェクトが必要
            this.NickName = this.ObserveProperty(x => x.nickNameSource)
                            .ToReadOnlyReactiveProperty();

            // つまり、以下のような初期化はできない
            //this.NickName = new ReadOnlyReactiveProperty<string>("テスト");


            // この場合の初期化時パラメータにはIObservable<string>が必要と言うエラーになるので
            // ソースにする変数は必須。

            // ReadOnlyReactiveCollectionのソースにはObservableCollectionか
            // ReactiveCollectionから作成するのが楽。
            this.charaList  = new ObservableCollection <Character>(new BleachAgent().GetAllCharacters());
            this.Characters = this.charaList
                              .ToReadOnlyReactiveCollection();
        }
Example #7
0
        internal DelayViewModel(Delay delay)
        {
            DelayPower = delay.DelayPower.ToReadOnlyReactiveCollection(x => new EntryViewModel(x)).AddTo(disposable);

            DelayBrake = delay.DelayBrake.ToReadOnlyReactiveCollection(x => new EntryViewModel(x)).AddTo(disposable);

            DelayLocoBrake = delay.DelayLocoBrake.ToReadOnlyReactiveCollection(x => new EntryViewModel(x)).AddTo(disposable);
        }
        public ClipBoardWatcherViewViewModel(ISampleAppData sampleAppData)
        {
            this.appData = sampleAppData;

            this.ClipBoardDatas = this.appData.Stocks
                                  .ToReadOnlyReactiveCollection(d => new WatchedClipBoardDataViewModel(d))
                                  .AddTo(this.disposables);
        }
Example #9
0
 public PageContentListViewModel(Model1 model)
 {
     Name = model.ToReactivePropertyAsSynchronized(x => x.Name)
            .AddTo(_disposables);
     PageContents = model.Model2s
                    .ToReadOnlyReactiveCollection(x => new PageContentViewModel(x))
                    .AddTo(_disposables);
 }
Example #10
0
        public TalkPageTabViewModel()
        {
            //トーク一覧に表示する情報を更新
            _talk.CreateList();

            //TalkクラスのTalkListプロパティの変更通知を受け取るようにする
            TalkList = _talk.TalkList.ToReadOnlyReactiveCollection();
        }
        internal DeployToOpenShiftModel()
        {
            ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
            {
                return(true);
            };

            Masters = OpenShiftMastersModel.Instance.Masters;

            SelectedMaster = new ReactiveProperty <OpenShiftMasterModel>(Masters.FirstOrDefault());

            Projects = SelectedMaster
                       .Where(m => !string.IsNullOrWhiteSpace(m.MasterUrl.Value) && !string.IsNullOrWhiteSpace(m.Token.Value))
                       .Select(m =>
            {
                //TODO あとでasync
                var client   = new OpenShiftAPIwithKubernetes(new Uri(m.MasterUrl.Value), new TokenCredentials(m.Token.Value));
                var projects = client.ListProject();
                return(projects.Items.Select(p => p.Metadata.Name).ToList());
            })
                       .SelectMany(x => x)
                       // .SelectMany(t => t.Result)
                       .ToReadOnlyReactiveCollection();

            SelectedProject = new ReactiveProperty <string>();

            Name = new ReactivePropertySlim <string>("vssdk-test");

            string branch         = "";
            string gitUrl         = "https://github.com/redhat-developer/s2i-dotnetcore-ex.git";
            string startupProject = "app";

            try
            {
                //DTE.ActiveSolutionProjects?.Cast<Project>().FirstOrDefault()?.FullName
                var project = DTE.SelectedItems.Item(1).Project;
                startupProject = project.Name;
                var git = new GitAnalysis(project.FullName);
                if (git.IsDiscoveredGitRepository)
                {
                    branch = git.BranchName;
                    gitUrl = git.RemoteURL;
                }
            }
            catch (Exception ex)
            {
                //Debug.Write(ex.ToString());
            }

            MemoryLimit = new ReactivePropertySlim <string>("512Mi");
            GitSource   = new ReactivePropertySlim <string>(gitUrl);
            GitRef      = new ReactivePropertySlim <string>(branch);

            //デフォルト値はNameから自動生成
            Host           = new ReactivePropertySlim <string>("vssdk-test.52.175.232.56.xip.io");
            StartupProject = new ReactivePropertySlim <string>(startupProject);
        }
		public FilterViewModelBase()
		{
			IncludeFilterText = new ReactiveProperty<string>("");
			ExcludeFilterText = new ReactiveProperty<string>("");

			var temp = new ObservableCollection<string>();
			IncludeFilterPatterns = temp.ToReadOnlyReactiveCollection();
			ExcludeFilterPatterns = temp.ToReadOnlyReactiveCollection();
			SampleItems = temp.ToReadOnlyReactiveCollection();
		}
        public ComplicateCollectionProperty(Type type, PropertyFactory modelFactory)
        {
            CollectionValue = new CollectionHolder(type, modelFactory);
            Value           = CollectionValue.Value
                              .Cast <object>()
                              .ToReactiveProperty();
            CollectionValue.OnError.Subscribe(x => OnErrorSubject.OnNext(x));

            Collection = CollectionValue.Collection.ToReadOnlyReactiveCollection(x => x.model);
        }
Example #14
0
        public MenuViewModel(IEventAggregator eventAggrigator, IMenuData data)
        {
            var col = new ObservableCollection <MenuViewItemModel>();

            foreach (var child in data.Children)
            {
                col.Add(new MenuViewItemModel(eventAggrigator, child));
            }
            MenuNodes = col.ToReadOnlyReactiveCollection().AddTo(_disposables);
        }
Example #15
0
        public VirtualCollectionSource(IEnumerable <T> dataSource, Func <T, U> converter, int initialSize, IScheduler scheduler)
        {
            _dataSource  = dataSource;
            _proxy       = new List <T>(_dataSource);
            _initialSize = initialSize;

            var source = _proxy.Take(initialSize).ToArray();

            _collectionChangedTrigger = new Subject <CollectionChanged <T> >().AddTo(Disposables);
            Items = source.ToReadOnlyReactiveCollection(_collectionChangedTrigger, converter, scheduler, false).AddTo(Disposables);
        }
Example #16
0
        public Shelf(ISettings settings, CollectionManagerDbContext database)
        {
            this._settings = settings;
            this._database = database;

            var cols = new ReactiveCollection <Col>();

            cols.AddRange(new[] { new Col(AvailableColumns.Title), new Col(AvailableColumns.Max), new Col(AvailableColumns.NextReleaseDate) });
            this.Columns = cols.ToReadOnlyReactiveCollection();
            this.FilterWord.Subscribe(_ => this.RefreshList());
        }
Example #17
0
        /// <summary>コンストラクタ。</summary>
        /// <param name="data">アプリのデータオブジェクト(Unity からインジェクション)</param>
        public NavigationTreeViewModel(WpfTestAppData data)
        {
            this.appData = data;

            this.rootNode = TreeViewItemCreator.Create(this.appData);
            var col = new System.Collections.ObjectModel.ObservableCollection <TreeViewItemViewModel>();

            col.Add(this.rootNode);
            this.TreeNodes = col.ToReadOnlyReactiveCollection()
                             .AddTo(this.disposables);
        }
Example #18
0
        public FileWatcherViewViewModel(ISampleAppData sampleAppData, IRegionManager regionMan)
        {
            this.appData       = sampleAppData;
            this.regionManager = regionMan;

            this.WatchedFiles = this.appData.WatchedFiles
                                .ToReadOnlyReactiveCollection(f => new WatchedFileViewModel(f))
                                .AddTo(this.disposables);

            this.WatchedFiles.ObserveAddChanged()
            .Subscribe(_ => this.regionManager.RequestNavigate("ContentRegion", "FileWatcherView"));
        }
        public NodeGroupViewModel(MainModel mainModel)
        {
            this.mainModel = mainModel;

            Nodes = mainModel.Nodes.ToReadOnlyReactiveCollection(x =>
            {
                // Model class name + "ViewModel" => ViewModel class name
                Type viewModelType     = Type.GetType("NodeCalculator.ViewModels.Nodes." + x.GetType().Name + "ViewModel");
                object[] viewModelArgs = new object[] { x };
                return((NodeViewModel)Activator.CreateInstance(viewModelType, BindingFlags.CreateInstance, null, viewModelArgs, null));
            });
        }
        public ReferenceByIntCollectionProperty(ReferencableMasterInfo source, string idPropertyName, PropertyFactory factory)
        {
            Source          = source;
            IdPropertyName  = idPropertyName;
            CollectionValue = new CollectionHolder(typeof(int[]), factory);
            Value           = CollectionValue.Value
                              .Cast <object>()
                              .ToReactiveProperty();
            CollectionValue.OnError.Subscribe(x => OnErrorSubject.OnNext(x));

            Collection = CollectionValue.Collection.ToReadOnlyReactiveCollection(x => x.model);
        }
        public ConfigService(Config config, ILogger logger)
        {
            _config = config;
            _logger = logger;
            _tags   = new ObservableCollection <string>(config.Tags);
            _recent = new ObservableCollection <Guid>(config.Recent);

            Recent = _recent.ToReadOnlyReactiveCollection(x => x).AddTo(Disposables);
            Tags   = _tags.ToReadOnlyReactiveCollection().AddTo(Disposables);

            // クラス破棄時に編集データを設定データに反映させる
            Disposables.Add(Disposable.Create(ApplyToConfig));
        }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="iNavigationService"></param>
        /// <param name="twitterClient"></param>
        public TweetCreatePageViewModel(INavigationService iNavigationService, TwitterClient twitterClient)
        {
            this.NavigationService         = iNavigationService;
            this._twitterClient            = twitterClient;
            this.FriendScreenNames         = this._twitterClient.FriendScreenNames.ToReadOnlyReactiveCollection();
            this.FilteredFriendScreenNames = this._twitterClient.FilteredFriendScreenNames.ToReadOnlyReactiveCollection();

            this._twitterClient.SetFriendScreenNames();

            this.SelectedPictures = this._pictureModel.PictureFilePaths.ToReadOnlyReactiveCollection();
            this.TweetText.Value  = this._twitterClient.ReplyToStatus != null ? $"@{this._twitterClient.ReplyToStatus.User.ScreenName} "
                                                                              : "";
        }
Example #23
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="logger"></param>
        internal MealModel(ISettings settings, ILogger logger)
        {
            this._settings = settings;
            this._logger   = logger;

            this.MealTypes = this._settings.Master.MealTypes.ToReadOnlyReactiveCollection();

            this.ShoppingList
            .CollectionChangedAsObservable()
            .Where(_ => this.AutoSave.Value)
            .Throttle(new TimeSpan(0, 0, 1))
            .Subscribe(async x => {
                await this.RegisterShoppingListAsync();
            }).AddTo(this._disposable);

            // 食事の内容に変化があれば保存
            this.MealType.Where(x => x != null).Select(x => Unit.Default)
            .Merge(this.Recipes.CollectionChangedAsObservable().Select(x => Unit.Default))
            .Where(_ => this.AutoSave.Value)
            .Throttle(TimeSpan.FromMilliseconds(50))
            .Subscribe(_ => this.Register())
            .AddTo(this._disposable);

            // 食事の倍率に変化があれば保存
            this._adjustmentChange = this.Recipes.ToReadOnlyReactiveCollection(
                x => x.Adjustment
                .Where(_ => this.AutoSave.Value)
                .Throttle(TimeSpan.FromMilliseconds(50))
                .Subscribe(_ => this.Register()))
                                     .AddTo(this._disposable);

            // 不要になったものから破棄する
            this._adjustmentChange
            .CollectionChangedAsObservable()
            .Where(x =>
                   new[] {
                NotifyCollectionChangedAction.Replace,
                NotifyCollectionChangedAction.Remove,
                NotifyCollectionChangedAction.Reset
            }.Contains(x.Action) &&
                   (x.OldItems?.Count ?? 0) != 0
                   ).Subscribe(x => {
                foreach (var item in x.OldItems.Cast <IDisposable>())
                {
                    item.Dispose();
                }
            }).AddTo(this._disposable);

            this._registerCompleted.AddTo(this._disposable);
        }
Example #24
0
        public PixelRenderViewModel()
        {
            CursorX = _imagePixelReader
                      .ObserveProperty(x => x.ReadArea)
                      .Select(x => x.X)
                      .ToReadOnlyReactiveProperty();

            CursorY = _imagePixelReader
                      .ObserveProperty(x => x.ReadArea)
                      .Select(x => x.Y)
                      .ToReadOnlyReactiveProperty();

            Pixels = _imagePixelReader.Pixels
                     .ToReadOnlyReactiveCollection(x => new PixelDataVM(x));
        }
Example #25
0
        public MainWindowViewModel()
        {
            this._doungeon = new DoungeonModel();

            this.AcquiredItems = this._doungeon.AcquiredItems.ToReadOnlyReactiveCollection();


            this.ResetCommand.Subscribe(this._doungeon.Reset);
            this.StartCommand.Subscribe(this._doungeon.Start);
            this.StopCommand.Subscribe(this._doungeon.Stop);
            this.CharactersWindowOpenCommand.Subscribe(() => {
                var vm = new CharactersWindowViewModel(this._doungeon);
                this.Messenger.Raise(new TransitionMessage(vm, "OpenCharactersWindow"));
            });
        }
        /// <summary>
        /// コンストラクタ
        /// DIでModel層を注入する
        /// </summary>
        /// <param name="workitemManager"></param>
        public WorklistViewModel(WorkitemManager workitemManager)
        {
            this._workitemManager = workitemManager;

            this.Studies = this._workitemManager.Workitems
                           .ToReadOnlyReactiveCollection(x => new WorkitemViewModel(x));

            this.StudiesView = CollectionViewSource.GetDefaultView(this.Studies);

            this.ClearCommand = new ReactiveCommand()
                                .WithSubscribe(this._workitemManager.ClearWorkitems);

            this.ReloadCommand = new ReactiveCommand()
                                 .WithSubscribe(() => this.ReloadWorkitems());
        }
Example #27
0
        public Project()
        {
            IsValid = AssemblyPath.CombineLatest(ProjectTypeName, (x, y) =>
            {
                if (x == null || !File.Exists(GetProjectsContentPath(x)))
                {
                    return(false);
                }
                else
                {
                    return(GetProjectType(GetAssembly()) != null);
                }
            }).CombineLatest(SavePath.Select(x => x != null), (x, y) => x && y)
                      .ToReactiveProperty();

            Dependencies = dependencies_.ToReadOnlyReactiveCollection();
            Factory      = new PropertyFactory();
        }
Example #28
0
        public BleScanner()
        {
            
            this.watcher = new BluetoothLEAdvertisementWatcher();
            
            this.Advertisements = Observable
                .FromEvent<TypedEventHandler<BluetoothLEAdvertisementWatcher, BluetoothLEAdvertisementReceivedEventArgs>, BluetoothLEAdvertisementReceivedEventArgs>(
                    handler => (o, e) => handler(e), handler => this.watcher.Received += handler, handler => this.watcher.Received -= handler)
                .Select(e => new BleDeviceAdvertisement(e.Advertisement, e.BluetoothAddress, e.RawSignalStrengthInDBm))
                .Buffer(TimeSpan.FromSeconds(1))                                                                                // Buffer 1[s]
                .SelectMany(buffer => buffer.GroupBy(advertisement => advertisement.Address).Select(group => group.First()))    // Distinct by device address.
                .ToReadOnlyReactiveCollection(this.resetSubject);

            this.IsStopped = Observable
                .FromEvent<TypedEventHandler<BluetoothLEAdvertisementWatcher, BluetoothLEAdvertisementWatcherStoppedEventArgs>, BluetoothLEAdvertisementWatcherStoppedEventArgs>(
                    handler => (o, e) => handler(e), handler => this.watcher.Stopped += handler, handler => this.watcher.Stopped -= handler)
                .Select(_ => true)
                .ToReactiveProperty(true);
        }
Example #29
0
        // コンストラクタ

        /// <summary>
        /// XAMLデザイナー用コンストラクタ
        /// </summary>
        public TestManageAccountViewModel()
        {
            var accounts = Observable
                           .Range(0, 20)
                           .Select(_ => new Account.TestAccount
            {
                Tokens = new CoreTweet.Tokens
                {
                    ScreenName = "science507"
                },
                User = new CoreTweet.User
                {
                    Name = "ポケトレーナー",
                    ProfileImageUrlHttps = "https://pbs.twimg.com/profile_images/815189933124042756/xVkaYdkM_normal.jpg"
                }
            });

            Accounts = accounts.ToReadOnlyReactiveCollection();
        }
Example #30
0
        public LiveMenuSubPageContent(Models.Niconico.Live.NicoLiveSubscriber nicoLiveSubscriber)
        {
            _LiveSubscriber = nicoLiveSubscriber;

            UpdateOnAirStreamsCommand = new AsyncReactiveCommand();

            UpdateOnAirStreamsCommand.Subscribe(async _ =>
            {
                await _LiveSubscriber.UpdateOnAirStreams();
            });

            OnAirStreams = _LiveSubscriber.OnAirStreams.ToReadOnlyReactiveCollection(x =>
                                                                                     new OnAirStream()
            {
                BroadcasterId = x.Video.UserId,
                Id            = x.Video.Id,
                Label         = x.Video.Title,
                Thumbnail     = x.Community?.ThumbnailSmall,
                CommunityName = x.Community.Name,
                StartAt       = x.Video.StartTime.Value
            }
                                                                                     );

            ReservedStreams = _LiveSubscriber.ReservedStreams.ToReadOnlyReactiveCollection(x =>
                                                                                           new OnAirStream()
            {
                BroadcasterId = x.Video.UserId,
                Id            = x.Video.Id,
                Label         = x.Video.Title,
                Thumbnail     = x.Community?.ThumbnailSmall,
                CommunityName = x.Community.Name,
                StartAt       = x.Video.StartTime.Value
            }
                                                                                           );

            MenuItems = new List <HohoemaListingPageItemBase>();
            MenuItems.Add(new MenuItemViewModel("ニコレポ", HohoemaPageType.NicoRepo));
            MenuItems.Add(new MenuItemViewModel("フォロー", HohoemaPageType.FollowManage));
            //            MenuItems.Add(new MenuItemViewModel("タイムシフト", HohoemaPageType.Recommend));
            //            MenuItems.Add(new MenuItemViewModel("予約", HohoemaPageType.NicoRepo));
        }
Example #31
0
        public LwsViewModel()
        {
            model = new LwsModel();

            Output = model.Output.ToReadOnlyReactiveCollection();
            EnchantGroupList.AddRange(Const.EnchantmentList.Select(item => item.Name));

            ExecuteCommand.Subscribe(_ => Execute());
            ExitCommand.Subscribe(_ => Exit());

            SelectedGroupIndex.Subscribe(_ =>
            {
                EnchantNameList.Clear();
                EnchantNameList.AddRange(GetEnchantNameList().Select(i => i.Name));
                SelectedNameIndex.Value = 0;
            });

            Disposable.Add(Output);
            Disposable.Add(ExecuteCommand);
            Disposable.Add(ExitCommand);
        }
        public AbemaProgramInfoViewModel(AbemaState abemaState, StatusService statusService)
        {
            var programHost = new ProgramHost(abemaState, statusService).AddTo(this);

            Title       = programHost.ObserveProperty(w => w.Title).ToReadOnlyReactiveProperty().AddTo(this);
            Description = programHost.ObserveProperty(w => w.Description).ToReadOnlyReactiveProperty().AddTo(this);
            HasInfo     = programHost.ObserveProperty(w => w.Title)
                          .Select(w => !string.IsNullOrWhiteSpace(w))
                          .ToReadOnlyReactiveProperty().AddTo(this);
            Thumbnail1 = programHost.ObserveProperty(w => w.Thumbnail1).ToReadOnlyReactiveProperty().AddTo(this);
            Thumbnail2 = programHost.ObserveProperty(w => w.Thumbnail2).ToReadOnlyReactiveProperty().AddTo(this);
            AtChannel  = abemaState.ObserveProperty(w => w.CurrentChannel)
                         .Where(w => w != null)
                         .Select(w => $"at {w.Name.Replace("チャンネル", "")}")
                         .ToReadOnlyReactiveProperty().AddTo(this);
            Range = abemaState.ObserveProperty(w => w.CurrentSlot)
                    .Where(w => w != null)
                    .Select(w => $"{w.StartAt.ToString("t")} ~ {w.EndAt.ToString("t")}")
                    .ToReadOnlyReactiveProperty().AddTo(this);
            Casts = programHost.Casts.ToReadOnlyReactiveCollection().AddTo(this);
            Crews = programHost.Crews.ToReadOnlyReactiveCollection().AddTo(this);
        }
		public AppLaunchActionViewModel(ActionsEditViewModel editVM, FolderReactionModel reactionModel, AppLaunchReactiveAction appAction)
			 : base(reactionModel)
		{
			EditVM = editVM;
			Action = appAction;

			AppPolicy = appAction.AppPolicy;
			if (AppPolicy != null)
			{
				AppName = AppPolicy.AppName;
				AppGuid = AppPolicy.Guid;

				UsingOptions = Action.Options.ToReadOnlyReactiveCollection(x =>
					new AppOptionInstanceViewModel(Action, x)
					);

				Action.Options.ObserveElementPropertyChanged()
					.Subscribe(x => Action.Validate());
			}
			else
			{
				AppName = "<App not found>";
			}
		}
Example #34
0
        public ImbleWatcher()
        {
            this.watcher = new BluetoothLEAdvertisementWatcher();
            this.watcher.ScanningMode = BluetoothLEScanningMode.Active;     // We have to perform active scanning to check scan responses from devices.
            this.resetSubject = new Subject<Unit>().AddTo(this.disposables);
            
            var candidateAddresses = new ConcurrentDictionary<ulong, ulong>();
            var resetObservable = this.resetSubject
                .Do(_ => candidateAddresses.Clear());

            var receivedObservable = Observable.FromEvent<TypedEventHandler<BluetoothLEAdvertisementWatcher, BluetoothLEAdvertisementReceivedEventArgs>, BluetoothLEAdvertisementReceivedEventArgs>(
                handler => (sender, args) => handler(args),
                handler => this.watcher.Received += handler,
                handler => this.watcher.Received -= handler)
                .Publish();

            // Check scan responses and add their address to the candidate device list if they contains the target service UUID as Service Solicitation data.
            receivedObservable
                .Where(args => args.AdvertisementType.HasFlag(BluetoothLEAdvertisementType.ScanResponse))
                .Where(args => args.Advertisement.DataSections.Any(section => MatchSolicitationServiceLong(section, ImbleDevice.ServiceUuid)))
                .Subscribe(args => candidateAddresses.TryAdd(args.BluetoothAddress, args.BluetoothAddress))
                .AddTo(this.disposables);

            // Check advertisement data 
            this.UnconnectedDevices = receivedObservable
                .Where(args => !args.AdvertisementType.HasFlag(BluetoothLEAdvertisementType.ScanResponse))
                .Where(args => candidateAddresses.ContainsKey(args.BluetoothAddress))
                .Distinct(args => args.BluetoothAddress)
                .Select(args => new UnconnectedImbleDevice(args.BluetoothAddress, args.Advertisement, args.RawSignalStrengthInDBm))
                .ToReadOnlyReactiveCollection(resetObservable)
                .AddTo(this.disposables);

            receivedObservable.Connect().AddTo(this.disposables);

            this.watcher.Start();
        }
		public AppLaunchActionInstanceViewModel(ActionsSelectInstantActionStepViewModel parentVM, AppLaunchReactiveAction action)
		{
			ActionSelectStepVM = parentVM;

			AppLaunchAction = action;
			
			var appPolicy = action.AppPolicy;


			AppName = appPolicy.AppName;
			AppGuid = appPolicy.Guid;

			UsingOptions = AppLaunchAction.Options
				.ToReadOnlyReactiveCollection(x => new AppOptionInstanceViewModel(AppLaunchAction, x));
		}
		public FileSelectInstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction)
			: base(pageVM, instantAction)
		{
			Files = instantAction.TargetFiles.ToReadOnlyReactiveCollection(x => x.FilePath)
				.AddTo(_CompositeDisposable);
		}
 public MainPageViewModel()
 {
     var watcher = ((App) App.Current).Watcher;
     this.UnconnectedDevices = watcher.UnconnectedDevices.ToReadOnlyReactiveCollection(device => new UnconnectedDeviceViewModel(device)).AddTo(this.disposables);
 }