CodeTV.WizardForm.CopyChannelToDestinationFolder C# (CSharp) Method

CopyChannelToDestinationFolder() private method

private CopyChannelToDestinationFolder ( ) : void
return void
        private void CopyChannelToDestinationFolder()
        {
            if (radioButtonAddThisChannel.Checked)
            {
                ChannelFolder channelFolder = textBoxFolderDestinationName.Tag as ChannelFolder;
                if (channelFolder != null)
                {
                    ChannelTV channelTV = this.propertyGridChannel.SelectedObject as ChannelTV;
                    if (channelTV != null)
                        MainForm.panelChannel.AddChannelToFavorite(channelFolder, new Channel[] { channelTV });
                }
            }
            else if (radioButtonScanFrequency.Checked)
            {
                ChannelFolder channelFolder = textBoxFolderDestinationName.Tag as ChannelFolder;
                if (channelFolder != null)
                {
                    List<Channel> al = new List<Channel>();
                    foreach (ListViewItem lvi in this.listViewScanResult.SelectedItems)
                        al.Add((lvi.Tag as Channel).MakeCopy());
                    if (al.Count > 0)
                    {
                        al.Sort(delegate(Channel x, Channel y) {
                            short xOrder = short.MaxValue, yOrder = short.MaxValue;
                            if (x is ChannelTV)
                            {
                                xOrder = (x as ChannelTV).ChannelNumber;
                                if (xOrder <= 0)
                                    xOrder = short.MaxValue - 1;
                            }
                            if (y is ChannelTV)
                            {
                                yOrder = (y as ChannelTV).ChannelNumber;
                                if (yOrder <= 0)
                                    yOrder = short.MaxValue - 1;
                            }
                            return xOrder.CompareTo(yOrder);
                        });
                        MainForm.panelChannel.AddChannelToFavorite(channelFolder, (Channel[])al.ToArray());
                    }
                }
            }
            MainForm.UpdateChannelNumber();
        }