当前位置: 首页>>代码示例>>C#>>正文


C# ReactiveList.RemoveAt方法代码示例

本文整理汇总了C#中ReactiveList.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList.RemoveAt方法的具体用法?C# ReactiveList.RemoveAt怎么用?C# ReactiveList.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReactiveList的用法示例。


在下文中一共展示了ReactiveList.RemoveAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ObserveWindowViewModel

        public ObserveWindowViewModel( string filename, IActorRef tailCoordinator )
        {
            _tailCoordinator = tailCoordinator;
            Filename = filename;
            Title = filename;
            Items = new ReactiveList<String>();

            // start coordinator
            _tailCoordinator.Tell( new TailCoordinatorActor.StartTail( filename, this ) );

            // this is how we can update the viewmodel
            // from the actor.
            Lines = new Subject<String>();
            Lines.ObserveOnDispatcher().Subscribe( item =>
            {
                Items.Add( item );

                if ( Items.Count > 1500 )
                {
                    Items.RemoveAt( 0 );
                }

                SelectedLine = Items.Count - 1;

            } );
        }
开发者ID:njimenez,项目名称:AkkaProjects,代码行数:26,代码来源:ObserveWindowViewModel.cs

示例2: MainWindowModel

        public MainWindowModel()
        {
            Tweets = new ReactiveList<TweetViewModel>();

            LoadTweets = ReactiveCommand.CreateAsyncTask(async _ =>
            {
                await Task.Delay(2000);
                foreach (var t in FakeData.GetFakeTweets())
                    Tweets.Add(t);
            });

            var canRemoveTweet = this.WhenAnyValue(vm => vm.Tweets.Count)
                .Select(c => c > 0);

            RemoveTweet = ReactiveCommand.Create(canRemoveTweet);
            RemoveTweet.Subscribe(_ => Tweets.RemoveAt(0));
        }
开发者ID:reactiveui-forks,项目名称:ProgNET2014,代码行数:17,代码来源:MainWindowModel.cs

示例3: CollectionCountChangedTest

        public void CollectionCountChangedTest()
        {
            var fixture = new ReactiveList<int>();
            var before_output = new List<int>();
            var output = new List<int>();

            fixture.CountChanging.Subscribe(before_output.Add);
            fixture.CountChanged.Subscribe(output.Add);

            fixture.Add(10);
            fixture.Add(20);
            fixture.Add(30);
            fixture.RemoveAt(1);
            fixture.Clear();

            var before_results = new[] { 0, 1, 2, 3, 2 };
            Assert.AreEqual(before_results.Length, before_output.Count);

            var results = new[] { 1, 2, 3, 2, 0 };
            Assert.AreEqual(results.Length, output.Count);
        }
开发者ID:journeyman,项目名称:PodcastReader,代码行数:21,代码来源:FeedViewModelTests.cs

示例4: DerivedCollectionsShouldRaiseListChangedEvents

        public void DerivedCollectionsShouldRaiseListChangedEvents()
        {
            var input = new[] { "Foo", "Bar", "Baz", "Bamf" };
            var fixture = new ReactiveList<TestFixture>(
                input.Select(x => new TestFixture() { IsOnlyOneWord = x }));
            
            IBindingList output = fixture.CreateDerivedBindingList(new Func<TestFixture, string>(x => x.IsOnlyOneWord));
            var capturedEvents = new List<ListChangedEventArgs>();
            output.ListChanged += (o, e) => capturedEvents.Add(e);

            input.AssertAreEqual((IEnumerable<string>)output);

            fixture.Add(new TestFixture() { IsOnlyOneWord = "Hello" });
            Assert.Equal(capturedEvents.Last().ListChangedType,ListChangedType.ItemAdded);
            Assert.Equal(5, output.Count);
            Assert.Equal("Hello", output[4]);

            fixture.RemoveAt(4);
            Assert.Equal(capturedEvents.Last().ListChangedType, ListChangedType.ItemDeleted);
            Assert.Equal(4, output.Count);

            //replacing results in 
            //1 itemdeleted
            //2 itemadded
            fixture[1] = new TestFixture() { IsOnlyOneWord = "Goodbye" };
            Assert.Equal(4, output.Count);
            Assert.Equal("Goodbye", output[1]);
            Assert.Equal(capturedEvents[capturedEvents.Count - 2].ListChangedType, ListChangedType.ItemDeleted);
            Assert.Equal(capturedEvents[capturedEvents.Count - 1].ListChangedType, ListChangedType.ItemAdded);

            fixture.Clear();
            Assert.Equal(0, output.Count);
            Assert.Equal(capturedEvents.Last().ListChangedType, ListChangedType.Reset);
        }
开发者ID:natnmikey,项目名称:ReactiveUI,代码行数:34,代码来源:ReactiveBindingListTests.cs

示例5: SmoothDrawView

		public SmoothDrawView(RectangleF frame, UIColor drawingColor, float lineThickness) : base(frame){
			paths = new ReactiveList<List<UIBezierPath>> ();

			this.BackgroundColor = UIColor.Clear;

			strokeColor = drawingColor ?? UIColor.Yellow;

			this.lineThickness = lineThickness;

			this.MultipleTouchEnabled = false;

			undo = new FlatButton(RectangleF.Empty);
			undo.Alpha = default(float);
			undo.SetTitle ("Undo", UIControlState.Normal);
			undo.SetBackgroundColor (MobileCore.Values.Colors.WhiteSeventyFivePercent.ToNative (), UIControlState.Normal);
			undo.SetTitleColor (MobileCore.Values.Colors.DarkGray.ToNative (), UIControlState.Normal);
			Add (undo);

			this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

			this.AddConstraints (
				undo.AtBottomOf(this, Constants.Layout.VerticalPadding),
				undo.AtRightOf(this, Constants.Layout.HorizontalPadding),
				undo.Width().GreaterThanOrEqualTo(56f),
				undo.Height().GreaterThanOrEqualTo(32f)
			);
				
			Observable.CombineLatest (
				this.WhenAnyValue (x => x.Enabled),
				paths.CountChanged.StartWith(0),
				(enabled, count) => enabled && count > 0)
				.ObserveOn(RxApp.MainThreadScheduler)
				.Subscribe (shouldDisplay => UIView.AnimateAsync(Constants.Animation.StandardAnimationDuration, () => undo.Alpha = shouldDisplay ? 1.0f : default(float) ));

			this.WhenAnyValue (vm => vm.Enabled)
				.ObserveOn(RxApp.MainThreadScheduler)
				.Subscribe (enabled => UserInteractionEnabled = enabled);

			Observable.FromEventPattern(h => undo.TouchUpInside += h, h => undo.TouchUpInside -= h)
				.Where(_ => paths.Any())
				.ObserveOn(RxApp.MainThreadScheduler)
				.Subscribe(_ => {
					paths.RemoveAt (paths.Count - 1);

					this.SetNeedsDisplay ();
					});
		}
开发者ID:ehill8624,项目名称:ValkreRender,代码行数:47,代码来源:SmoothDrawView.cs

示例6: AutoPersistCollectionDisconnectsOnDispose

        public void AutoPersistCollectionDisconnectsOnDispose()
        {
            (new TestScheduler()).With(sched => {
                var manualSave = new Subject<Unit>();

                var item = new TestFixture();
                var fixture = new ReactiveList<TestFixture> { item };

                int timesSaved = 0;
                var disp = fixture.AutoPersistCollection(x => { timesSaved++; return Observable.Return(Unit.Default); }, manualSave, TimeSpan.FromMilliseconds(100));

                sched.AdvanceByMs(2 * 100);
                Assert.Equal(0, timesSaved);

                // By being added to collection, AutoPersist is enabled for item
                item.IsNotNullString = "Foo";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Dispose = no save
                disp.Dispose();

                // Removed from collection = no save
                fixture.Clear();
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Item isn't in the collection, it doesn't get persisted anymore
                item.IsNotNullString = "Bar";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Added back item + dispose = no save
                fixture.Add(item);
                sched.AdvanceByMs(100);  // Compensate for scheduling
                item.IsNotNullString = "Baz";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Even if we issue a reset, no save
                fixture.Reset();
                sched.AdvanceByMs(100);  // Compensate for scheduling
                item.IsNotNullString = "Bamf";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);

                // Remove by hand = no save
                fixture.RemoveAt(0);
                item.IsNotNullString = "Blomf";
                sched.AdvanceByMs(2 * 100);
                Assert.Equal(1, timesSaved);
            });
        }
开发者ID:KimCM,项目名称:ReactiveUI,代码行数:53,代码来源:AutoPersistHelperTest.cs


注:本文中的ReactiveList.RemoveAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。