Exemplo n.º 1
0
 public void AddFiles(IEnumerable <string> paths, int index)
 {
     paths = Utils.ExpandDirectories(paths);
     foreach (string path in paths)
     {
         string lowerPath = path.ToLower();
         if (!loadedPaths.Contains(lowerPath))
         {
             try
             {
                 LoadedFile f = new LoadedFile(path);
                 LoadedFiles.Insert(index++, f);
                 loadedPaths.Add(lowerPath);
             }
             catch (HaException) { }
         }
     }
 }
Exemplo n.º 2
0
        private void fileView_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete)
            {
                // Search for focus destination
                int        old_index         = fileView.SelectedIndex;
                LoadedFile focus_destination = null;

                // Search downward
                for (int i = fileView.SelectedIndex + 1; i < data.LoadedFiles.Count; i++)
                {
                    LoadedFile item = data.LoadedFiles[i];
                    if (!fileView.SelectedItems.Contains(item))
                    {
                        focus_destination = item;
                        break;
                    }
                }

                // If failed, search upward
                if (focus_destination == null)
                {
                    for (int i = fileView.SelectedIndex - 1; i >= 0; i--)
                    {
                        LoadedFile item = data.LoadedFiles[i];
                        if (!fileView.SelectedItems.Contains(item))
                        {
                            focus_destination = item;
                            break;
                        }
                    }
                }

                // We use ToList to copy the list before enumerating
                data.RemoveFiles(fileView.SelectedItems.Cast <LoadedFile>().ToList());

                // Set focused item
                fileView.SelectedIndex = data.LoadedFiles.IndexOf(focus_destination);
                SetFocusItem(focus_destination);

                e.Handled = true;
            }
        }
Exemplo n.º 3
0
 public void SetFocusItem(LoadedFile focus_destination)
 {
     fileView.FocusedItem = null;
     fileView.FocusedItem = focus_destination;
 }