protected virtual void OnUpButtonClicked(object sender, System.EventArgs e) { Gtk.TreeIter itr; Gtk.TreeModel model; if (mapView.Selection.GetSelected(out model, out itr)) { MapDescription map = (MapDescription)model.GetValue(itr, 0); int index = m_maps.IndexOf(map); if (index > 0) // Can't move the first element up { int[] order = new int[m_maps.Capacity]; for (int i = 0; i < m_maps.Capacity; i++) { order[i] = i; } order[index] = index - 1; order[index - 1] = index; m_mapModel.Reorder(order); // due double data holding, not fine but it works m_maps.RemoveAt(index); m_maps.Insert(index - 1, map); upButton.Sensitive = m_maps.IndexOf(map) > 0; downButton.Sensitive = m_maps.IndexOf(map) < (m_maps.Count - 1); } } }