static void Main() { int n = int.Parse(Console.ReadLine()); List <Box <string> > list = new List <Box <string> >(n); for (int i = 0; i < n; i++) { string data = Console.ReadLine(); Box <string> box = new Box <string>(data); list.Add(box); } int[] indexes = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray(); int left = indexes[0]; int right = indexes[1]; Swaper <Box <string> > .Swap(list, left, right); foreach (Box <string> box in list) { Console.WriteLine(box); } }
static void Main(string[] args) { List <Box <string> > collectionOfBoxes = new List <Box <string> >(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string input = Console.ReadLine(); Box <string> box = new Box <string>(input); collectionOfBoxes.Add(box); } int[] indexesToSwap = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); collectionOfBoxes = Swaper <Box <string> > .Swap(indexesToSwap[0], indexesToSwap[1], collectionOfBoxes); foreach (var box in collectionOfBoxes) { Console.WriteLine(box); } }
private void ButtonContextMenuRenderer_Touch(object sender, TouchEventArgs e) { if (horizontalSwaper.IsEnabled) { switch (e.Event.Action) { case MotionEventActions.Up: case MotionEventActions.Cancel: case MotionEventActions.ButtonRelease: horizontalSwaper.Opacity = 1; CScrollViewRenderer.IsDisabled = false; //timer.Start(); break; default: var test = ""; break; case MotionEventActions.Down: case MotionEventActions.ButtonPress: x1 = e.Event.GetX(); y1 = e.Event.GetY(); horizontalSwaper.Opacity = 0.6f; break; case MotionEventActions.Move: var movement = e.Event.GetX() - x1; var offset = 50; var yMovement = e.Event.GetY() - y1; if (yMovement <= 15 && yMovement >= 9 || Math.Abs(movement) > offset) { timer.Stop(); CScrollViewRenderer.IsDisabled = true; } if (Math.Abs(movement) > offset) { if (movement < 0) { horizontalSwaper.Swap(SwipeDirection.Left, e.Event.GetX(), e.Event.GetY()); Console.WriteLine("Left swipe"); } else { horizontalSwaper.Swap(SwipeDirection.Right, e.Event.GetX(), e.Event.GetY()); Console.WriteLine("Right swipe"); } horizontalSwaper.Opacity = 1; } else { if (Math.Abs(yMovement) > offset) { if (movement < 0) { horizontalSwaper.Swap(SwipeDirection.Down, e.Event.GetX(), e.Event.GetY()); Console.WriteLine("Left swipe"); //webView.GoBack(); } else { horizontalSwaper.Swap(SwipeDirection.Up, e.Event.GetX(), e.Event.GetY()); Console.WriteLine("Right swipe"); //webView.GoForward(); } horizontalSwaper.Opacity = 1; } } break; } } if (CScrollViewRenderer.IsDisabled) { timer.Start(); } e.Handled = false; }