/// <summary> /// Handler for when the laid out files list is reordered. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void listView_Reorder(object sender, ReorderingListView.ReorderEventArgs e) { System.Diagnostics.Debug.Assert(e.DropIndex <= m_arFileOrder.Count); List <OrderedFile> shuffledItems = new List <OrderedFile>(); for (int i = 0; i < e.SelIndices.Count; i++) { OrderedFile fileToMove = m_arFileOrder[e.SelIndices[i]]; System.Diagnostics.Debug.Assert(fileToMove != null); shuffledItems.Add(fileToMove); } int iOriginalDropIndex = e.DropIndex; for (int i = e.SelIndices.Count - 1; i >= 0; i--) { if (e.SelIndices[i] < iOriginalDropIndex) { --e.DropIndex; } m_arFileOrder.RemoveAt(e.SelIndices[i]); } m_arFileOrder.InsertRange(e.DropIndex, shuffledItems); m_bIsLayoutDirty = true; // Update model, specifying which indices should be selected (and visible). OnModelUpdate(e.DropIndex, shuffledItems.Count); }
public static void AddOrderedFile(ListView in_list, OrderedFile in_file) { ListViewItem item = new ListViewItem(in_file.ShortName); item.SubItems.Add(FileTypeToString(in_file.Type)); item.SubItems.Add(in_file.Language); item.UseItemStyleForSubItems = false; Color statusColor; string szStatus = StatusTypeToString(in_file.Status, out statusColor); item.SubItems.Add(szStatus, statusColor, in_list.BackColor, in_list.Font); in_list.Items.Add(item); }
/// <summary> /// Helper: Arrange file order based on the files referenced in the Info file and /// files referenced in the Layout. /// Sets LayoutDirty flag if it encounters "new" files (files that are in the /// Info file but not in the layout). /// </summary> private void ReorderFiles() { // Extract all file references from the layout: // Those for which a match is found in the file list are added in the temporary // list listReorderedFiles (laidout), the others are added in the temporary // list listMissingFiles. List <OrderedFile> listReorderedFiles = new List <OrderedFile>(); List <OrderedFile> listMissingFiles = new List <OrderedFile>(); if (m_layout != null) { foreach (AK.Wwise.FilePackager.PackageLayout.File laidOutFile in m_layout.FileList.FileCollection) { // Search corresponding entry in the list of files. OrderedFile orderedFile = m_arFileOrder.Find(delegate(OrderedFile in_searchedFile) { return(in_searchedFile.Id == laidOutFile.Id && in_searchedFile.Language == laidOutFile.Language && in_searchedFile.Type == laidOutFile.Type); }); if (orderedFile != null) { // It is there: this file is laid out. Remove and put in temp list to be reinsterted at the beginning. listReorderedFiles.Add(orderedFile); orderedFile.Status = OrderedFile.StatusType.FileStatusLaidOut; m_arFileOrder.Remove(orderedFile); } else { // The file specified in the layout not exist. listMissingFiles.Add(new OrderedFile(laidOutFile.Id, laidOutFile.Language, laidOutFile.Id.ToString(), laidOutFile.Type, OrderedFile.StatusType.FileStatusMissing)); } } } // All remaining files are "new". foreach (OrderedFile file in m_arFileOrder) { file.Status = OrderedFile.StatusType.FileStatusNew; m_bIsLayoutDirty = true; } // Prepend with ordered, laid out files. m_arFileOrder.InsertRange(0, listReorderedFiles); // Append with missing files. m_arFileOrder.AddRange(listMissingFiles); }