本文整理汇总了C#中CollectionView.MoveCurrentTo方法的典型用法代码示例。如果您正苦于以下问题:C# CollectionView.MoveCurrentTo方法的具体用法?C# CollectionView.MoveCurrentTo怎么用?C# CollectionView.MoveCurrentTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollectionView
的用法示例。
在下文中一共展示了CollectionView.MoveCurrentTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogViewModel
public LogViewModel()
{
MessagesLock = new Object();
messages = new ObservableCollection<LogMessageModel>();
BindingOperations.EnableCollectionSynchronization(messages, MessagesLock);
//clearLog = new Command(new Action(() => messages.Clear()));
LogLevel = new CollectionView(Enum.GetValues(typeof(LogMessageModel.LogLevel)));
LogLevel.MoveCurrentTo(LogMessageModel.LogLevel.INFO);
}
示例2: ButtonMappingViewModel
public ButtonMappingViewModel(DsButtonProfile profile)
{
CurrentButtonProfile = profile;
CurrentCommandTypeView = new CollectionView(AvailableCommandTypes);
CurrentCommandTargetView = new CollectionView(AvailableKeys);
CurrentCommandTypeView.MoveCurrentTo(AvailableCommandTypes.First());
CurrentCommandTargetView.MoveCurrentTo(AvailableKeys.First());
if (CurrentButtonProfile != null)
{
CurrentCommandTypeView.MoveCurrentTo(profile.MappingTarget.CommandType);
CurrentCommandTargetView.MoveCurrentTo(profile.MappingTarget.CommandTarget);
}
else
{
CurrentButtonProfile = new DsButtonProfile();
}
CurrentCommandTypeView.CurrentChanged += CurrentCommandTypeOnCurrentChanged;
CurrentCommandTargetView.CurrentChanged += CurrentCommandTargetOnCurrentChanged;
}
示例3: ButtonMappingEntryControl
public ButtonMappingEntryControl()
{
ButtonProfile = new DsButtonProfile();
InitializeComponent();
CurrentCommandTypeView = new CollectionView(AvailableCommandTypes);
CurrentCommandTargetView = new CollectionView(AvailableKeys);
CurrentCommandTypeView.MoveCurrentTo(AvailableCommandTypes.First());
CurrentCommandTargetView.MoveCurrentTo(AvailableKeys.First());
CurrentCommandTypeView.CurrentChanged += CurrentCommandTypeOnCurrentChanged;
CurrentCommandTargetView.CurrentChanged += CurrentCommandTargetOnCurrentChanged;
}
示例4: MoveCurrentTo
private void MoveCurrentTo(CollectionView cv, object item)
{
if (cv != null && IsSynchronizedWithCurrentItemInternal)
{
cv.MoveCurrentTo(item);
}
}
示例5: 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;
});
}
示例6: MoveCurrentTo
public void MoveCurrentTo ()
{
CollectionView c = new CollectionView (new object [] { 1, 2 });
Assert.IsTrue (c.MoveCurrentTo (2), "1");
Assert.AreEqual (c.CurrentItem, 2, "2");
Assert.AreEqual (c.CurrentPosition, 1, "3");
Assert.IsFalse (c.MoveCurrentTo (null), "4");
Assert.IsNull (c.CurrentItem, "5");
Assert.AreEqual (c.CurrentPosition, -1, "6");
Assert.IsFalse (c.MoveCurrentTo (3), "7");
Assert.IsNull (c.CurrentItem, "8");
Assert.AreEqual (c.CurrentPosition, -1, "9");
c = new CollectionView (new object [] { null, 1 });
Assert.IsNull (c.CurrentItem, "10");
Assert.AreEqual (c.CurrentPosition, 0, "11");
Assert.IsTrue (c.MoveCurrentTo (1), "12");
Assert.AreEqual (c.CurrentItem, 1, "13");
Assert.AreEqual (c.CurrentPosition, 1, "14");
Assert.IsTrue (c.MoveCurrentTo (null), "15");
Assert.IsNull (c.CurrentItem, "16");
Assert.AreEqual (c.CurrentPosition, 0, "17");
c = new CollectionView (new object [] { -1, 1 });
c.Filter = MoveCurrentToFilter;
Assert.AreEqual (c.CurrentItem, -1, "18");
Assert.AreEqual (c.CurrentPosition, 0, "19");
Assert.IsTrue (c.MoveCurrentTo (-1), "20");
Assert.AreEqual (c.CurrentItem, -1, "21");
Assert.AreEqual (c.CurrentPosition, 0, "22");
}
示例7: IsCurrentAfterLast
public void IsCurrentAfterLast ()
{
CollectionView c = new CollectionView (new object [] { 1, 2 });
Assert.IsFalse (c.IsCurrentAfterLast, "1");
Assert.IsFalse (c.IsCurrentBeforeFirst, "2");
c.MoveCurrentTo (1);
Assert.IsFalse (c.IsCurrentAfterLast, "3");
Assert.IsFalse (c.IsCurrentBeforeFirst, "4");
c.MoveCurrentTo (3);
Assert.IsFalse (c.IsCurrentAfterLast, "5");
Assert.IsTrue (c.IsCurrentBeforeFirst, "6");
c.MoveCurrentTo (1);
Assert.IsFalse (c.IsCurrentAfterLast, "7");
Assert.IsFalse (c.IsCurrentBeforeFirst, "8");
c.MoveCurrentToPrevious ();
Assert.IsFalse (c.IsCurrentAfterLast, "9");
Assert.IsTrue (c.IsCurrentBeforeFirst, "10");
c.MoveCurrentToLast ();
c.MoveCurrentToNext ();
Assert.IsTrue (c.IsCurrentAfterLast, "11");
Assert.IsFalse (c.IsCurrentBeforeFirst, "12");
c.MoveCurrentToFirst ();
Assert.IsFalse (c.IsCurrentAfterLast, "13");
Assert.IsFalse (c.IsCurrentBeforeFirst, "14");
c.MoveCurrentToPrevious ();
c.MoveCurrentToNext ();
Assert.IsFalse (c.IsCurrentAfterLast, "15");
Assert.IsFalse (c.IsCurrentBeforeFirst, "16");
c.MoveCurrentToLast ();
c.MoveCurrentToNext ();
c.MoveCurrentToPrevious ();
Assert.IsFalse (c.IsCurrentAfterLast, "17");
Assert.IsFalse (c.IsCurrentBeforeFirst, "18");
}
示例8: MoveCurrentToPrevious
public void MoveCurrentToPrevious ()
{
CollectionView c = new CollectionView (new object [] { 1, 2 });
Assert.IsFalse (c.MoveCurrentToPrevious (), "1");
Assert.IsNull (c.CurrentItem, "2");
Assert.AreEqual (c.CurrentPosition, -1, "3");
Assert.IsFalse (c.MoveCurrentToPrevious (), "4");
Assert.IsNull (c.CurrentItem, "5");
Assert.AreEqual (c.CurrentPosition, -1, "6");
c = new CollectionView (new object [] { 1, 2 });
c.MoveCurrentTo (2);
Assert.AreEqual (c.CurrentItem, 2, "8");
Assert.AreEqual (c.CurrentPosition, 1, "9");
Assert.IsTrue (c.MoveCurrentToPrevious (), "10");
Assert.AreEqual (c.CurrentItem, 1, "11");
Assert.AreEqual (c.CurrentPosition, 0, "12");
Assert.IsFalse (c.MoveCurrentToPrevious (), "13");
Assert.IsNull (c.CurrentItem, "14");
Assert.AreEqual (c.CurrentPosition, -1, "15");
}
示例9: MoveCurrentToFirst
public void MoveCurrentToFirst ()
{
CollectionView c = new CollectionView (new object [] { 1, 2 });
c.MoveCurrentTo (2);
Assert.IsTrue (c.MoveCurrentToFirst (), "1");
Assert.AreEqual (c.CurrentItem, 1, "2");
Assert.AreEqual (c.CurrentPosition, 0, "3");
c = new CollectionView (new object [] { });
Assert.AreEqual (c.CurrentPosition, -1, "4");
Assert.IsFalse (c.MoveCurrentToFirst (), "5");
Assert.IsNull (c.CurrentItem, "6");
// Why?
Assert.AreEqual (c.CurrentPosition, 0, "7");
}