public static void RemoveAtObjects(LevelArea area, List <Managed3DObject> objList, ListView.ListViewItemCollection lvic, Dictionary <int, Managed3DObject> removedObjs, Dictionary <int, ListViewItem> removedlvis, Dictionary <int, LevelscriptCommand> removedCmds) { foreach (KeyValuePair <int, ListViewItem> kvp in removedlvis.OrderByDescending(n => n.Key)) { lvic.RemoveAt(kvp.Key); } foreach (KeyValuePair <int, Managed3DObject> kvp in removedObjs.OrderByDescending(n => n.Key)) { objList.RemoveAt(kvp.Key); } foreach (KeyValuePair <int, LevelscriptCommand> kvp in removedCmds.OrderByDescending(n => n.Key)) { area.Objects.RemoveAt(kvp.Key); } }
public static void RemoveAtWarps(LevelArea area, List <IManagedLevelscriptCommand> objList, ListView.ListViewItemCollection lvic, Dictionary <int, IManagedLevelscriptCommand> removedObjs, Dictionary <int, ListViewItem> removedlvis, Dictionary <int, LevelscriptCommand> removedCmds, Dictionary <ListViewItem, ListViewGroup> lviGroups) { foreach (KeyValuePair <int, ListViewItem> kvp in removedlvis.OrderByDescending(n => n.Key)) { lvic.RemoveAt(kvp.Key); } foreach (KeyValuePair <int, IManagedLevelscriptCommand> kvp in removedObjs.OrderByDescending(n => n.Key)) { objList.RemoveAt(kvp.Key); } foreach (KeyValuePair <int, LevelscriptCommand> kvp in removedCmds.OrderByDescending(n => n.Key)) { area.Warps.RemoveAt(kvp.Key); } }
private void BackgroundWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { if (dump.Count != 0) { cwd = dump[0].Text; dump.RemoveAt(0); asyncHandler.RunWorkerAsync(); } else { progressBar1.Style = ProgressBarStyle.Blocks; watch.Stop(); var elapsed = watch.Elapsed; statusLbl.Text = statusLbl.Text + " in " + elapsed.ToString("mm\\:ss\\.ff") + " m"; } }
private void btn() { watch = Stopwatch.StartNew(); if (pathView.Items.Count != 0) { j = 0; dump = pathView.Items; // Create a copy of the pathView Items Collection to use as a FIFO progressBar1.Style = ProgressBarStyle.Marquee; // Starting the undefined progress bar cwd = dump[0].Text; // We Start to get the first "Root" path dump.RemoveAt(0); // We Remove it from the queue asyncHandler.RunWorkerAsync(); // Let's run it in a separate Threads } else { statusLbl.Text = "Nothing to Import"; } }
public void RemoveAt(Int32 index) { if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException(nameof(index)); } GenericListViewItem <T> item = (GenericListViewItem <T>)_items[index]; _items.RemoveAt(index); if (item is null) { return; } OnRemove?.Invoke(ref item); ItemsChanged?.Invoke(); }
public void RemoveAt(int index) { _collection.RemoveAt(index); }
public static void UpdateUI(FormMain target) { int index = 0; //clear directory listing, disable listview renders, update directory in path textbox, and reset the listview images target.Invoke(new Action(() => { target.lstFiles.Items.Clear(); target.lstFiles.BeginUpdate(); target.txtCurrentDirectory.Text = target.CurrentDirectory; target.lstFiles.SmallImageList = new ImageList(); target.lstFiles.SmallImageList.ColorDepth = ColorDepth.Depth32Bit; })); //this will ensure directories are put at the top of the list, and still have all special directories shown List <string> paths = new List <string>(); paths.AddRange(Directory.GetDirectories(target.CurrentDirectory)); paths.AddRange(Directory.GetFiles(target.CurrentDirectory)); //paths.AddRange(Directory.GetFileSystemEntries(target.CurrentDirectory).Except(paths)); ListView _lv = new ListView(); ImageList icons = new ImageList(); List <string> fileTypes = new List <string>(); icons.ColorDepth = ColorDepth.Depth32Bit; ListView.ListViewItemCollection items = new ListView.ListViewItemCollection(_lv); string ext; int pos; foreach (string item in paths) { Debug.WriteLine("Parsing file '" + item + "'"); //Grab the icon associated with the filetype/directory and add it to the directory image list. Then add the related item to the file listing //if its a file, get it's extension, otherwise use a character that cannot be in file names to represent directories. if (File.Exists(item)) { ext = new FileInfo(item).Extension; } else { ext = "|"; } //try to get the index of the file extension in the list of filetypes found in the current directory. this will return -1 if the extension is not on the list. pos = fileTypes.IndexOf(ext); //if the extension isnt on the list, set the pos, add it, then try to add the icon to the image list if (pos == -1) { pos = icons.Images.Count; fileTypes.Add(ext); try { icons.Images.Add(iconCache[ext]); } catch (KeyNotFoundException) { if (Utilities.IconCacher.cachedOnLaunch) { icons.Images.Add(iconCache[".|"]); } else { //if the icon is not in the icon cache, add it and then retry adding to the image list if (ext != "|") { iconCache[ext] = Etier.IconHelper.IconReader.GetFileIcon(ext, Etier.IconHelper.IconReader.IconSize.Small, false); } else { iconCache["|"] = Etier.IconHelper.IconReader.GetFolderIcon( Etier.IconHelper.IconReader.IconSize.Small, Etier.IconHelper.IconReader.FolderType.Closed); } icons.Images.Add(iconCache[ext]); } } } //finally, add the entry for the item with the pos set to the index for the relevant icon items.Add(item.Replace(target.CurrentDirectory, ""), pos); // start the parallel foreach here try { FileStream handle = File.OpenRead(item); foreach (ExplodeColumn column in target.lstFiles.Columns) { if (column.Text != "Name") { items[index].SubItems.Add(column.GetInfo(handle)); } } handle.Close(); } // this happens if it's a directory or can't be accessed catch (UnauthorizedAccessException e) { int length = items[index].SubItems.Count; for (int x = 1; x == length; x++) { items[index].SubItems.Add(""); } } // this means that it's trying to process the name column, which we can ignore catch (InvalidCastException e) { ; } // If the file can't be accessed catch (System.IO.IOException) { ; } // I know that this is bad practice but let's do it anyway /* * catch (Exception e) * { * ; * } */ index++; } target.Invoke(new Action(() => { while (items.Count > 0) { ListViewItem k = items[0]; items.RemoveAt(0); target.lstFiles.Items.Add(k); } target.lstFiles.Items.AddRange(items); target.lstFiles.SmallImageList = icons; foreach (ExplodeColumn column in target.lstFiles.Columns) { column.AutoResize(column.handler.ColumnWidth); } target.lstFiles.EndUpdate(); })); Debug.WriteLine("Finished updating"); // The update is now finished so update the flag to show this GlobalVars.isUpdating = false; }