Exemplo n.º 1
0
        /// <summary>
        /// Function to populate the list of codecs.
        /// </summary>
        /// <param name="dataContext">The current data context.</param>
        private void FillList(ISettings dataContext)
        {
            ListCodecs.BeginUpdate();

            try
            {
                ListCodecs.Items.Clear();
                DataContext?.SelectedCodecs.Clear();

                if (dataContext == null)
                {
                    return;
                }

                foreach (CodecSetting setting in dataContext.CodecPlugInPaths)
                {
                    var item = new ListViewItem
                    {
                        Text = setting.Description,
                        Name = setting.Name,
                        Tag  = setting
                    };

                    item.SubItems.Add(setting.PlugIn.PlugInPath);

                    ListCodecs.Items.Add(item);
                }
            }
            finally
            {
                ListCodecs.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                ListCodecs.EndUpdate();
            }
        }
Exemplo n.º 2
0
        /// <summary>Handles the CollectionChanged event of the CodecPlugInPaths control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
        private void CodecPlugInPaths_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ListCodecs.BeginUpdate();
            try
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    foreach (CodecSetting setting in e.NewItems.OfType <CodecSetting>())
                    {
                        var item = new ListViewItem
                        {
                            Text = setting.Description,
                            Name = setting.Name,
                            Tag  = setting
                        };

                        item.SubItems.Add(setting.PlugIn.PlugInPath);

                        ListCodecs.Items.Add(item);
                    }
                    break;

                case NotifyCollectionChangedAction.Remove:
                    foreach (CodecSetting setting in e.OldItems.OfType <CodecSetting>())
                    {
                        ListViewItem listItem = ListCodecs.Items.OfType <ListViewItem>().FirstOrDefault(item => item.Tag == setting);

                        if (listItem == null)
                        {
                            continue;
                        }

                        ListCodecs.Items.Remove(listItem);
                    }
                    break;
                }
            }
            finally
            {
                ListCodecs.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                ListCodecs.EndUpdate();
            }
        }