當前位置: 首頁>>代碼示例>>C#>>正文


C# CollectionView.MoveCurrentToPosition方法代碼示例

本文整理匯總了C#中CollectionView.MoveCurrentToPosition方法的典型用法代碼示例。如果您正苦於以下問題:C# CollectionView.MoveCurrentToPosition方法的具體用法?C# CollectionView.MoveCurrentToPosition怎麽用?C# CollectionView.MoveCurrentToPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CollectionView的用法示例。


在下文中一共展示了CollectionView.MoveCurrentToPosition方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UserControl_Loaded

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            DependencyPropertyDescriptor
                .FromProperty(ButtonProfileProperty, typeof (ButtonMappingEntryControl))
                .AddValueChanged(this, (s, args) =>
                {
                    if (ButtonProfile == null) return;

                    CurrentCommandTypeView = new CollectionView(AvailableCommandTypes);
                    CurrentCommandTypeView.MoveCurrentToPosition((int) ButtonProfile.MappingTarget.CommandType);

                    switch (ButtonProfile.MappingTarget.CommandType)
                    {
                        case CommandType.GamepadButton:
                            CurrentCommandTargetView = new CollectionView(AvailableGamepadButtons);
                            CurrentCommandTargetView.MoveCurrentTo(ButtonProfile.MappingTarget.CommandTarget);
                            break;
                        case CommandType.Keystrokes:
                            CurrentCommandTargetView = new CollectionView(AvailableKeys);
                            CurrentCommandTargetView.MoveCurrentTo(
                                AvailableKeys.FirstOrDefault(
                                    k => k == ToVirtualKeyCode(ButtonProfile.MappingTarget.CommandTarget)));
                            break;
                            // TODO: implement!
                        case CommandType.MouseButtons:
                            CurrentCommandTargetView = new CollectionView(AvailableMouseButtons);
                            break;
                    }

                    CurrentCommandTypeView.CurrentChanged += CurrentCommandTypeOnCurrentChanged;
                    CurrentCommandTargetView.CurrentChanged += CurrentCommandTargetOnCurrentChanged;
                });
        }
開發者ID:CheesyKek,項目名稱:ScpToolkit,代碼行數:33,代碼來源:ButtonMappingEntryControl.xaml.cs

示例2: MoveCurrentToPosition

 private void MoveCurrentToPosition(CollectionView cv, int position)
 {
     if (cv != null && IsSynchronizedWithCurrentItemInternal)
     {
         cv.MoveCurrentToPosition(position);
     }
 }
開發者ID:kasicass,項目名稱:kasicass,代碼行數:7,代碼來源:RibbonGallery.cs

示例3: MoveCurrentToPosition_Throws_Exception_For_Past_End_Index

        public void MoveCurrentToPosition_Throws_Exception_For_Past_End_Index()
        {
            List<int> source = new List<int> { 1, 2, 3 };
            CollectionView target = new CollectionView(source);

            target.MoveCurrentToPosition(4);
        }
開發者ID:modulexcite,項目名稱:Avalonia,代碼行數:7,代碼來源:CollectionViewTests.cs

示例4: CurrentChanged_Should_Be_Raised_Even_If_Position_Doesnt_Change

        public void CurrentChanged_Should_Be_Raised_Even_If_Position_Doesnt_Change()
        {
            List<int> source = new List<int> { 1, 2, 3 };
            CollectionView target = new CollectionView(source);
            bool eventRaised = false;

            target.CurrentChanged += (s, e) => eventRaised = true;
            target.MoveCurrentToPosition(0);

            Assert.IsTrue(eventRaised);
        }
開發者ID:modulexcite,項目名稱:Avalonia,代碼行數:11,代碼來源:CollectionViewTests.cs

示例5: MoveCurrentToPosition_Returns_False_For_After_End_Index

        public void MoveCurrentToPosition_Returns_False_For_After_End_Index()
        {
            List<int> source = new List<int> { 1, 2, 3 };
            CollectionView target = new CollectionView(source);

            Assert.IsFalse(target.MoveCurrentToPosition(3));
            Assert.IsNull(target.CurrentItem);
            Assert.AreEqual(3, target.CurrentPosition);
            Assert.IsFalse(target.IsCurrentBeforeFirst);
            Assert.IsTrue(target.IsCurrentAfterLast);
        }
開發者ID:modulexcite,項目名稱:Avalonia,代碼行數:11,代碼來源:CollectionViewTests.cs

示例6: MoveCurrentToPosition_Minus_1_Can_Be_Cancelled

        public void MoveCurrentToPosition_Minus_1_Can_Be_Cancelled()
        {
            List<int> source = new List<int> { 1, 2, 3 };
            CollectionView target = new CollectionView(source);

            target.CurrentChanging += (s, e) => e.Cancel = true;

            Assert.IsTrue(target.MoveCurrentToPosition(-1));
            Assert.AreEqual(1, target.CurrentItem);
            Assert.AreEqual(0, target.CurrentPosition);
            Assert.IsFalse(target.IsCurrentBeforeFirst);
        }
開發者ID:modulexcite,項目名稱:Avalonia,代碼行數:12,代碼來源:CollectionViewTests.cs

示例7: MoveCurrentToPosition_Returns_True_When_Item_Available

        public void MoveCurrentToPosition_Returns_True_When_Item_Available()
        {
            List<int> source = new List<int> { 1, 2, 3 };
            CollectionView target = new CollectionView(source);

            Assert.IsTrue(target.MoveCurrentToPosition(1));
            Assert.AreEqual(2, target.CurrentItem);
            Assert.AreEqual(1, target.CurrentPosition);
        }
開發者ID:modulexcite,項目名稱:Avalonia,代碼行數:9,代碼來源:CollectionViewTests.cs

示例8: MoveCurrentToPosition_Returns_False_For_Empty_Collection

        public void MoveCurrentToPosition_Returns_False_For_Empty_Collection()
        {
            List<int> source = new List<int>();
            CollectionView target = new CollectionView(source);

            Assert.IsFalse(target.MoveCurrentToPosition(0));
            Assert.IsNull(target.CurrentItem);
            Assert.AreEqual(-1, target.CurrentPosition);
        }
開發者ID:modulexcite,項目名稱:Avalonia,代碼行數:9,代碼來源:CollectionViewTests.cs

示例9: MoveCurrentToPosition

		public void MoveCurrentToPosition ()
		{
			CollectionView c = new CollectionView (new object [] { 1, 2 });
			Assert.IsTrue (c.MoveCurrentToPosition (1), "1");
			Assert.AreEqual (c.CurrentItem, 2, "2");
			Assert.AreEqual (c.CurrentPosition, 1, "3");
			Assert.IsFalse (c.MoveCurrentToPosition (2), "4");
			Assert.AreEqual (c.CurrentItem, null, "5");
			Assert.AreEqual (c.CurrentPosition, 2, "6");
			try {
				c.MoveCurrentToPosition (3);
				Assert.Fail ("7");
			} catch (ArgumentOutOfRangeException ex) {
				Assert.AreEqual (ex.ParamName, "position", "8");
			}
			Assert.AreEqual (c.CurrentItem, null, "9");
			Assert.AreEqual (c.CurrentPosition, 2, "10");

			c = new CollectionView (new object [] { 1, 2 });
			try {
				c.MoveCurrentToPosition (3);
				Assert.Fail ("11");
			} catch (ArgumentOutOfRangeException ex) {
				Assert.AreEqual (ex.ParamName, "position", "12");
			}
		}
開發者ID:JianwenSun,項目名稱:mono-soc-2007,代碼行數:26,代碼來源:CollectionViewTest.cs


注:本文中的CollectionView.MoveCurrentToPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。