/// <summary> /// Reorder the tabs and refresh collection sorting. /// </summary> /// <param name="reorder"></param> protected virtual void ReorderTabsCommandAction(TabReorder reorder) { ICollectionView view = CollectionViewSource.GetDefaultView(this.ItemCollection) as ICollectionView; int from = reorder.FromIndex; int to = reorder.ToIndex; var tabCollection = view.Cast <TabBase>().ToList(); //Get the ordered collection of our tab control tabCollection[from].TabNumber = tabCollection[to].TabNumber; //Set the new index of our dragged tab if (to > from) { for (int i = from + 1; i <= to; i++) { tabCollection[i].TabNumber--; //When we increment the tab index, we need to decrement all other tabs. } } else if (from > to)//when we decrement the tab index { for (int i = to; i < from; i++) { tabCollection[i].TabNumber++;//When we decrement the tab index, we need to increment all other tabs. } } view.Refresh();//Refresh the view to force the sort description to do its work. }
/// <summary> /// Reorder the tabs and refresh collection sorting. /// </summary> /// <param name="reorder"></param> private void ReorderTabsCommandAction(TabReorder reorder) { ICollectionView view = CollectionViewSource.GetDefaultView(this.ItemCollection) as ICollectionView; int from = reorder.FromIndex; int to = reorder.ToIndex; var sourceCol = view.SourceCollection.Cast <ITab>().OrderBy(x => x.TabNumber).ToList(); //Get the ordered source collection of our tab control sourceCol[from].TabNumber = sourceCol[to].TabNumber; //Set the new index of our dragged tab if (to > from) { for (int i = from + 1; i <= to; i++) { sourceCol[i].TabNumber--; //When we increment the tab index, we need to decrement all other tabs. } } else if (from > to)//when we decrement the tab index { for (int i = to; i < from; i++) { sourceCol[i].TabNumber++;//When we decrement the tab index, we need to increment all other tabs. } } view.Refresh();//Refresh the view to force the sort description to do its work. }
/// <summary> /// タブの順番入れ替え時のコマンド /// </summary> /// <param name="reorder"></param> private void reorderTabsCommandAction(TabReorder reorder) { int from = reorder.FromIndex; int to = reorder.ToIndex; // タブの表示順を入れ替え this.TabContextList.Move(from, to); // MLTFileListの更新(状態保存用) this.MLTFileList.Value.Move(from, to); }