private void CheckBox_Preview_CheckedChanged(object sender, EventArgs e)
        {
            RefreshPreview();

            subtitleFileList.BeginUpdate();

            foreach (var item in subtitleFileList)
            {
                item.IsPreview = checkBox_Preview.Checked;
            }

            subtitleFileList.EndUpdate();
        }
Example #2
0
        public static void ListItemsMoveDown(ListBox listBox, BindingList <FileListItem> bindingList)
        {
            int maximum            = bindingList.Count - 1;
            var selectedIndices    = new List <int>(listBox.SelectedIndices.Cast <int>().Reverse());
            var newSelectedIndices = new List <int>();

            bindingList.BeginUpdate();
            foreach (int index in selectedIndices)
            {
                var newIndex = index + 1;
                if (newIndex > maximum)
                {
                    newSelectedIndices.Add(index);
                    maximum = index - 1;
                    continue;
                }

                newSelectedIndices.Add(newIndex);
                var temp = bindingList[index];
                bindingList.RemoveAt(index);
                bindingList.Insert(newIndex, temp);
            }
            bindingList.EndUpdate();

            listBox.SelectedIndices.Clear();
            foreach (var index in newSelectedIndices)
            {
                listBox.SelectedIndices.Add(index);
            }
        }
Example #3
0
        public static void AddPathsToList(DragEventArgs e, BindingList <FileListItem> bindingList, string formatsString)
        {
            string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            bindingList.BeginUpdate();
            var formats = formatsString.Split(',');

            foreach (var path in paths)
            {
                if ((File.GetAttributes(path) & FileAttributes.Directory) != 0)
                {
                    var files = Directory.EnumerateFiles(path)
                                .Where(file => formats.Any(format => file.ToLower().EndsWith(format)));

                    foreach (var file in files)
                    {
                        AddPathIfNotExists(bindingList, file);
                    }
                }
                else
                {
                    AddPathIfNotExists(bindingList, path);
                }
            }
            bindingList.EndUpdate();
        }
Example #4
0
        public static void ListItemsDeleteSelected(ListBox listBox, BindingList <FileListItem> bindingList)
        {
            var selectedIndices = new List <int>(listBox.SelectedIndices.Cast <int>());
            var count           = 0;

            bindingList.BeginUpdate();
            foreach (int index in selectedIndices)
            {
                bindingList.RemoveAt(index - count);
                count++;
            }
            bindingList.EndUpdate();
        }