本文整理汇总了C#中TvDatabase.TvBusinessLayer.AddChannelToGroup方法的典型用法代码示例。如果您正苦于以下问题:C# TvBusinessLayer.AddChannelToGroup方法的具体用法?C# TvBusinessLayer.AddChannelToGroup怎么用?C# TvBusinessLayer.AddChannelToGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TvDatabase.TvBusinessLayer
的用法示例。
在下文中一共展示了TvBusinessLayer.AddChannelToGroup方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReLoad
public void ReLoad()
{
//System.Diagnostics.Debugger.Launch();
try
{
SetupDatabaseConnection();
Log.Info("get channels from database");
SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
sb.AddConstraint(Operator.Equals, "isTv", 1);
sb.AddOrderByField(true, "sortOrder");
SqlStatement stmt = sb.GetStatement(true);
channels = ObjectFactory.GetCollection(typeof (Channel), stmt.Execute());
Log.Info("found:{0} tv channels", channels.Count);
TvNotifyManager.OnNotifiesChanged();
m_groups.Clear();
TvBusinessLayer layer = new TvBusinessLayer();
RadioChannelGroup allRadioChannelsGroup =
layer.GetRadioChannelGroupByName(TvConstants.RadioGroupNames.AllChannels);
IList<Channel> radioChannels = layer.GetAllRadioChannels();
if (radioChannels != null)
{
if (radioChannels.Count > allRadioChannelsGroup.ReferringRadioGroupMap().Count)
{
foreach (Channel radioChannel in radioChannels)
{
layer.AddChannelToRadioGroup(radioChannel, allRadioChannelsGroup);
}
}
}
Log.Info("Done.");
Log.Info("get all groups from database");
sb = new SqlBuilder(StatementType.Select, typeof (ChannelGroup));
sb.AddOrderByField(true, "groupName");
stmt = sb.GetStatement(true);
IList<ChannelGroup> groups = ObjectFactory.GetCollection<ChannelGroup>(stmt.Execute());
IList<GroupMap> allgroupMaps = GroupMap.ListAll();
bool hideAllChannelsGroup = false;
using (
Settings xmlreader =
new MPSettings())
{
hideAllChannelsGroup = xmlreader.GetValueAsBool("mytv", "hideAllChannelsGroup", false);
}
foreach (ChannelGroup group in groups)
{
if (group.GroupName == TvConstants.TvGroupNames.AllChannels)
{
foreach (Channel channel in channels)
{
if (channel.IsTv == false)
{
continue;
}
bool groupContainsChannel = false;
foreach (GroupMap map in allgroupMaps)
{
if (map.IdGroup != group.IdGroup)
{
continue;
}
if (map.IdChannel == channel.IdChannel)
{
groupContainsChannel = true;
break;
}
}
if (!groupContainsChannel)
{
layer.AddChannelToGroup(channel, TvConstants.TvGroupNames.AllChannels);
}
}
break;
}
}
groups = ChannelGroup.ListAll();
foreach (ChannelGroup group in groups)
{
//group.GroupMaps.ApplySort(new GroupMap.Comparer(), false);
if (hideAllChannelsGroup && group.GroupName.Equals(TvConstants.TvGroupNames.AllChannels) && groups.Count > 1)
{
continue;
}
m_groups.Add(group);
}
Log.Info("loaded {0} tv groups", m_groups.Count);
//TVHome.Connected = true;
}
catch (Exception ex)
{
Log.Error("TVHome: Error in Reload");
Log.Error(ex);
//TVHome.Connected = false;
}
//.........这里部分代码省略.........
示例2: AddSelectedItemsToGroup
private void AddSelectedItemsToGroup(MPListView sourceListView)
{
if (_channelGroup == null)
{
return;
}
TvBusinessLayer layer = new TvBusinessLayer();
foreach (ListViewItem sourceItem in sourceListView.SelectedItems)
{
Channel channel = null;
if (sourceItem.Tag is Channel)
{
channel = (Channel)sourceItem.Tag;
}
else if (sourceItem.Tag is GroupMap)
{
channel = layer.GetChannel(((GroupMap)sourceItem.Tag).IdChannel);
}
else
{
continue;
}
GroupMap groupMap = null;
layer.AddChannelToGroup(channel, _channelGroup);
//get the new group map and set the listitem tag
SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (GroupMap));
sb.AddConstraint(Operator.Equals, "idChannel", channel.IdChannel);
sb.AddConstraint(Operator.Equals, "idGroup", _channelGroup.IdGroup);
SqlStatement stmt = sb.GetStatement(true);
groupMap = ObjectFactory.GetInstance<GroupMap>(stmt.Execute());
foreach (ListViewItem item in listView1.Items)
{
if ((item.Tag as Channel) == channel)
{
item.Tag = groupMap;
break;
}
}
}
}
示例3: addToFavoritesToolStripMenuItem_Click
private void addToFavoritesToolStripMenuItem_Click(object sender, EventArgs e)
{
ChannelGroup group;
ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
if (menuItem.Tag == null)
{
GroupNameForm dlg = new GroupNameForm();
if (dlg.ShowDialog(this) != DialogResult.OK)
{
return;
}
group = new ChannelGroup(dlg.GroupName, 9999);
group.Persist();
UpdateMenuAndTabs();
}
else
{
group = (ChannelGroup)menuItem.Tag;
}
ListView.SelectedIndexCollection indexes = listView1.SelectedIndices;
if (indexes.Count == 0)
return;
TvBusinessLayer layer = new TvBusinessLayer();
for (int i = 0; i < indexes.Count; ++i)
{
ListViewItem item = listView1.Items[indexes[i]];
GroupMap map = (GroupMap)item.Tag;
Channel channel = map.ReferencedChannel();
layer.AddChannelToGroup(channel, group.GroupName);
}
}
示例4: importButton_Click
//.........这里部分代码省略.........
channelCount++;
// rtv: since analog allows NOT to merge channels we need to take care of this. US users e.g. have multiple stations named "Sport" with different tuningdetails.
// using AddChannel would incorrectly "merge" these totally different channels.
// see this: http://forum.team-mediaportal.com/1-0-rc1-svn-builds-271/importing-exported-channel-list-groups-channels-39368/
Log.Info("TvChannels: Adding {0}. channel: {1}", channelCount, displayName);
IList<Channel> foundExistingChannels = layer.GetChannelsByName(displayName);
if (mergeChannels && (foundExistingChannels != null && foundExistingChannels.Count > 0))
{
dbChannel = foundExistingChannels[0];
}
else
{
dbChannel = layer.AddNewChannel(displayName, chChannelNumber);
}
dbChannel.GrabEpg = grabEpg;
dbChannel.IsRadio = isRadio;
dbChannel.IsTv = isTv;
dbChannel.LastGrabTime = lastGrabTime;
dbChannel.SortOrder = sortOrder;
dbChannel.TimesWatched = timesWatched;
dbChannel.TotalTimeWatched = totalTimeWatched;
dbChannel.VisibleInGuide = visibileInGuide;
dbChannel.DisplayName = displayName;
dbChannel.Persist();
//
// chemelli: When we import channels we need to add those to the "AllChannels" group
//
if (isTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
}
else
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
}
foreach (XmlNode nodeMap in mappingList)
{
int idCard = Int32.Parse(nodeMap.Attributes["IdCard"].Value);
XmlNode nodeCard =
doc.SelectSingleNode(String.Format("/tvserver/servers/server/cards/card[@IdCard={0}]", idCard));
Card dbCard = layer.GetCardByDevicePath(nodeCard.Attributes["DevicePath"].Value);
if (dbCard != null)
{
layer.MapChannelToCard(dbCard, dbChannel, false);
}
}
foreach (XmlNode nodeTune in tuningList)
{
int bandwidth = Int32.Parse(nodeTune.Attributes["Bandwidth"].Value);
int channelNumber = Int32.Parse(nodeTune.Attributes["ChannelNumber"].Value);
int channelType = Int32.Parse(nodeTune.Attributes["ChannelType"].Value);
int countryId = Int32.Parse(nodeTune.Attributes["CountryId"].Value);
int diseqc = Int32.Parse(nodeTune.Attributes["Diseqc"].Value);
bool fta = (nodeTune.Attributes["FreeToAir"].Value == "True");
int frequency = Int32.Parse(nodeTune.Attributes["Frequency"].Value);
int majorChannel = Int32.Parse(nodeTune.Attributes["MajorChannel"].Value);
int minorChannel = Int32.Parse(nodeTune.Attributes["MinorChannel"].Value);
int modulation = Int32.Parse(nodeTune.Attributes["Modulation"].Value);
string name = nodeTune.Attributes["Name"].Value;
int networkId = Int32.Parse(nodeTune.Attributes["NetworkId"].Value);
int pmtPid = Int32.Parse(nodeTune.Attributes["PmtPid"].Value);
示例5: DoScan
//.........这里部分代码省略.........
TvBusinessLayer.GetChannelType(channel));
}
else
{
//There are certain providers that do not maintain unique ONID + SID combinations.
//In those cases, ONID + TSID + SID is generally unique. The consequence of using the TSID to identify
//a service is that channel movement tracking won't work (each transponder/mux should have its own TSID).
currentDetail = layer.GetTuningDetail(channel.NetworkId, channel.TransportId, channel.ServiceId,
TvBusinessLayer.GetChannelType(channel));
}
if (currentDetail == null)
{
//add new channel
exists = false;
dbChannel = layer.AddNewChannel(channel.Name);
dbChannel.SortOrder = 10000;
if (channel.LogicalChannelNumber >= 1)
{
dbChannel.SortOrder = channel.LogicalChannelNumber;
}
dbChannel.IsTv = channel.IsTv;
dbChannel.IsRadio = channel.IsRadio;
dbChannel.Persist();
}
else
{
exists = true;
dbChannel = currentDetail.ReferencedChannel();
}
if (dbChannel.IsTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.DVBC);
}
if (checkBoxCreateGroups.Checked)
{
layer.AddChannelToGroup(dbChannel, channel.Provider);
}
}
if (dbChannel.IsRadio)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.DVBC);
}
if (checkBoxCreateGroups.Checked)
{
layer.AddChannelToRadioGroup(dbChannel, channel.Provider);
}
}
if (currentDetail == null)
{
layer.AddTuningDetails(dbChannel, channel);
}
else
{
//update tuning details...
TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
td.Persist();
}
示例6: mpButton1_Click
private void mpButton1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_configuration.Graph.Crossbar.Name))
{
IUser user = new User();
user.CardId = _cardNumber;
AnalogChannel temp = new AnalogChannel();
temp.TunerSource = TunerInputType.Antenna;
temp.VideoSource = AnalogChannel.VideoInputType.Tuner;
temp.AudioSource = AnalogChannel.AudioInputType.Tuner;
temp.IsRadio = false;
temp.IsTv = true;
RemoteControl.Instance.Tune(ref user, temp, -1);
_configuration = Configuration.readConfiguration(_cardNumber, _cardName, _devicePath);
if (string.IsNullOrEmpty(_configuration.Graph.Crossbar.Name))
{
MessageBox.Show(this, "The S-Video channels could not be detected.");
return;
}
ReCheckSettings();
}
TvBusinessLayer layer = new TvBusinessLayer();
Dictionary<AnalogChannel.VideoInputType, int> videoPinMap = _configuration.Graph.Crossbar.VideoPinMap;
AnalogChannel tuningDetail;
Card card = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber));
Channel dbChannel;
if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.VideoInput1))
{
string channelName = "CVBS#1 on " + card.IdCard;
IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
if (tuningDetails != null && tuningDetails.Count > 0)
{
dbChannel = tuningDetails[0].ReferencedChannel();
}
else
{
dbChannel = layer.AddNewChannel(channelName);
}
dbChannel.IsTv = true;
dbChannel.Persist();
tuningDetail = new AnalogChannel();
tuningDetail.IsTv = true;
tuningDetail.Name = dbChannel.DisplayName;
tuningDetail.VideoSource = AnalogChannel.VideoInputType.VideoInput1;
layer.AddTuningDetails(dbChannel, tuningDetail);
layer.MapChannelToCard(card, dbChannel, false);
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
}
if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.VideoInput2))
{
string channelName = "CVBS#2 on " + card.IdCard;
IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
if (tuningDetails != null && tuningDetails.Count > 0)
{
dbChannel = tuningDetails[0].ReferencedChannel();
}
else
{
dbChannel = layer.AddNewChannel(channelName);
}
dbChannel.IsTv = true;
dbChannel.Persist();
tuningDetail = new AnalogChannel();
tuningDetail.IsTv = true;
tuningDetail.Name = dbChannel.DisplayName;
tuningDetail.VideoSource = AnalogChannel.VideoInputType.VideoInput2;
layer.AddTuningDetails(dbChannel, tuningDetail);
layer.MapChannelToCard(card, dbChannel, false);
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
}
if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.VideoInput3))
{
string channelName = "CVBS#3 on " + card.IdCard;
IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
if (tuningDetails != null && tuningDetails.Count > 0)
{
dbChannel = tuningDetails[0].ReferencedChannel();
}
else
{
dbChannel = layer.AddNewChannel(channelName);
}
dbChannel.IsTv = true;
dbChannel.Persist();
tuningDetail = new AnalogChannel();
tuningDetail.IsTv = true;
tuningDetail.Name = dbChannel.DisplayName;
tuningDetail.VideoSource = AnalogChannel.VideoInputType.VideoInput3;
layer.AddTuningDetails(dbChannel, tuningDetail);
layer.MapChannelToCard(card, dbChannel, false);
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
}
if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.SvhsInput1))
{
string channelName = "S-Video#1 on " + card.IdCard;
IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
if (tuningDetails != null && tuningDetails.Count > 0)
{
dbChannel = tuningDetails[0].ReferencedChannel();
//.........这里部分代码省略.........
示例7: DoTvScan
//.........这里部分代码省略.........
channel = (AnalogChannel)channels[0];
if (channel.Name == "")
channel.Name = String.Format(channel.ChannelNumber.ToString());
Channel dbChannel = null;
if (checkBoxNoMerge.Checked)
{
dbChannel = layer.AddNewChannel(channel.Name);
}
else
{
IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channel.Name, 0);
if (tuningDetails != null && tuningDetails.Count > 0)
{
dbChannel = tuningDetails[0].ReferencedChannel();
}
if (dbChannel != null)
{
exists = true;
}
else
{
dbChannel = layer.AddNewChannel(channel.Name);
}
}
dbChannel.IsTv = channel.IsTv;
dbChannel.IsRadio = channel.IsRadio;
dbChannel.Persist();
layer.AddTuningDetails(dbChannel, channel);
layer.MapChannelToCard(card, dbChannel, false);
if (dbChannel.IsTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.Analog);
}
}
if (dbChannel.IsRadio)
{
layer.AddChannelToGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.Analog);
}
}
if (exists)
{
line = String.Format("channel:{0} source:{1} : Channel update found - {2}", channel.ChannelNumber,
mpComboBoxSource.SelectedItem, channel.Name);
channelsUpdated++;
}
else
{
line = String.Format("channel:{0} source:{1} : New channel found - {2}", channel.ChannelNumber,
mpComboBoxSource.SelectedItem, channel.Name);
channelsNew++;
}
item.Text = line;
}
}
catch (TvExceptionSWEncoderMissing)
{
Log.Error("analog: DoTvScan error (missing software encoder)");
示例8: DoScan
//.........这里部分代码省略.........
//services: one ONID + SID based, the other domain/URL based. At this time we don't fully and properly implement the DVB-IP
//specifications, so the safest method for service identification is the URL. The user has the option to enable the use of
//ONID + SID identification and channel move detection...
if (checkBoxEnableChannelMoveDetection.Checked)
{
currentDetail = layer.GetTuningDetail(channel.NetworkId, channel.ServiceId,
TvBusinessLayer.GetChannelType(channel));
}
else
{
currentDetail = layer.GetTuningDetail(channel.Url, TvBusinessLayer.GetChannelType(channel));
}
if (currentDetail == null)
{
//add new channel
exists = false;
dbChannel = layer.AddNewChannel(channel.Name, channel.LogicalChannelNumber);
dbChannel.SortOrder = 10000;
if (channel.LogicalChannelNumber >= 1)
{
dbChannel.SortOrder = channel.LogicalChannelNumber;
}
dbChannel.IsTv = channel.IsTv;
dbChannel.IsRadio = channel.IsRadio;
dbChannel.Persist();
}
else
{
exists = true;
dbChannel = currentDetail.ReferencedChannel();
}
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
if (checkBoxCreateGroups.Checked)
{
layer.AddChannelToGroup(dbChannel, channel.Provider);
}
if (currentDetail == null)
{
layer.AddTuningDetails(dbChannel, channel);
}
else
{
//update tuning details...
TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
td.Persist();
}
if (channel.IsTv)
{
if (exists)
{
tvChannelsUpdated++;
updatedChannels++;
}
else
{
tvChannelsNew++;
newChannels++;
}
}
if (channel.IsRadio)
{
if (exists)
示例9: OnAddToFavoritesMenuItem_Click
private void OnAddToFavoritesMenuItem_Click(object sender, EventArgs e)
{
ChannelGroup group;
ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
if (menuItem.Tag == null)
{
GroupNameForm dlg = new GroupNameForm();
if (dlg.ShowDialog(this) != DialogResult.OK)
{
return;
}
group = new ChannelGroup(dlg.GroupName, 9999);
group.Persist();
this.RefreshContextMenu();
this.RefreshTabs();
}
else
{
group = (ChannelGroup)menuItem.Tag;
}
ListView.SelectedIndexCollection indexes = mpListView1.SelectedIndices;
if (indexes.Count == 0)
return;
TvBusinessLayer layer = new TvBusinessLayer();
for (int i = 0; i < indexes.Count; ++i)
{
ListViewItem item = mpListView1.Items[indexes[i]];
Channel channel = (Channel)item.Tag;
layer.AddChannelToGroup(channel, group.GroupName);
string groupString = item.SubItems[1].Text;
if (groupString == string.Empty)
{
groupString = group.GroupName;
}
else
{
groupString += ", " + group.GroupName;
}
item.SubItems[1].Text = groupString;
}
mpListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}
示例10: DoRadioScan
//.........这里部分代码省略.........
float freqMHz = channel.Frequency;
freqMHz /= 1000000f;
string line = String.Format("frequence:{0} MHz ", freqMHz.ToString("f2"));
ListViewItem item = mpListView1.Items.Add(new ListViewItem(line));
item.EnsureVisible();
IUser user = new User();
user.CardId = _cardNumber;
TvResult tuneResult = RemoteControl.Instance.Tune(ref user, channel, -1);
if (tuneResult == TvResult.SWEncoderMissing)
{
Log.Error("analog: DoTvScan error (missing software encoder)");
MessageBox.Show("Please install a supported audio/video encoder for your software analog card",
"Unable to scan", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
if (tuneResult == TvResult.GraphBuildingFailed)
{
Log.Error("analog: DoTvScan error (missing software encoder)");
MessageBox.Show(
"The graph building. Mostly your card is not supported by TvServer. Please create a report in our forum",
"Unable to scan", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
UpdateStatus();
Thread.Sleep(2000);
if (SignalStrength(sensitivity) == 100)
{
channel.Name = String.Format("{0}", freq);
Channel dbChannel = null;
IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channel.Name, 0);
if (tuningDetails != null && tuningDetails.Count > 0)
{
dbChannel = tuningDetails[0].ReferencedChannel();
}
if (dbChannel != null)
{
line = String.Format("frequence:{0} MHz : Channel update found - {1}", freqMHz.ToString("f2"),
channel.Name);
channelsUpdated++;
}
else
{
dbChannel = layer.AddNewChannel(channel.Name);
line = String.Format("frequence:{0} MHz : New channel found - {1}", freqMHz.ToString("f2"), channel.Name);
channelsNew++;
}
item.Text = line;
dbChannel.IsTv = channel.IsTv;
dbChannel.IsRadio = channel.IsRadio;
dbChannel.Persist();
if (dbChannel.IsTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.Analog);
}
if (dbChannel.IsRadio)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.Analog);
}
layer.AddTuningDetails(dbChannel, channel);
layer.MapChannelToCard(card, dbChannel, false);
freq += 300000;
}
else
{
line = String.Format("frequence:{0} MHz : No Signal", freqMHz.ToString("f2"));
item.Text = line;
item.ForeColor = Color.Red;
}
}
}
catch (Exception ex)
{
Log.Write(ex);
}
finally
{
checkButton.Enabled = true;
IUser user = new User();
user.CardId = _cardNumber;
RemoteControl.Instance.StopCard(user);
RemoteControl.Instance.EpgGrabberEnabled = true;
mpButtonScanRadio.Text = buttonText;
progressBar1.Value = 100;
mpComboBoxCountry.Enabled = true;
mpComboBoxSource.Enabled = true;
mpComboBoxSensitivity.Enabled = true;
checkBoxCreateSignalGroup.Enabled = true;
checkBoxNoMerge.Enabled = true;
mpButtonScanTv.Enabled = true;
mpButtonScanRadio.Enabled = true;
mpButtonAddSvideoChannels.Enabled = true;
_isScanning = false;
}
ListViewItem lastItem =
mpListView1.Items.Add(
new ListViewItem(String.Format("Total radio channels new:{0} updated:{1}", channelsNew, channelsUpdated)));
lastItem.EnsureVisible();
}
示例11: OnAddToFavoritesMenuItem_Click
private void OnAddToFavoritesMenuItem_Click(object sender, EventArgs e)
{
ChannelGroup group;
ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
if (menuItem.Tag == null)
{
GroupNameForm dlg = new GroupNameForm();
if (dlg.ShowDialog(this) != DialogResult.OK)
{
return;
}
group = new ChannelGroup(dlg.GroupName, 9999);
group.Persist();
this.RefreshContextMenu();
this.RefreshTabs();
}
else
{
group = (ChannelGroup)menuItem.Tag;
}
ListView.SelectedIndexCollection indexes = mpListView1.SelectedIndices;
if (indexes.Count == 0)
return;
TvBusinessLayer layer = new TvBusinessLayer();
for (int i = 0; i < indexes.Count; ++i)
{
ListViewItem item = mpListView1.Items[indexes[i]];
Channel channel = (Channel)item.Tag;
layer.AddChannelToGroup(channel, group.GroupName);
IList<string> groups = channel.GroupNames;
List<string> groupNames = new List<string>();
foreach (string groupName in groups)
{
if (groupName != TvConstants.TvGroupNames.AllChannels &&
groupName != TvConstants.RadioGroupNames.AllChannels)
{
//Don't add "All Channels"
groupNames.Add(groupName);
}
}
item.SubItems[2].Text = String.Join(", ", groupNames.ToArray());
}
mpListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}
示例12: buttonOk_Click
private void buttonOk_Click(object sender, EventArgs e)
{
if (textBoxName.Text.Length == 0)
{
MessageBox.Show("Please enter a name for this channel");
return;
}
int channelNumber;
if (!Int32.TryParse(textBoxChannelNumber.Text, out channelNumber))
{
MessageBox.Show(this, "Please enter a valid channel number!", "Incorrect input");
return;
}
if (channelNumber < 0)
{
MessageBox.Show(this, "Please enter a positive channel number!", "Incorrect input");
return;
}
_channel.DisplayName = textBoxName.Text;
_channel.ChannelNumber = channelNumber;
_channel.VisibleInGuide = checkBoxVisibleInTvGuide.Checked;
_channel.IsTv = _isTv;
_channel.IsRadio = !_isTv;
_channel.Persist();
if (_newChannel)
{
TvBusinessLayer layer = new TvBusinessLayer();
if (_isTv)
{
layer.AddChannelToGroup(_channel, TvConstants.TvGroupNames.AllChannels);
}
else
{
layer.AddChannelToRadioGroup(_channel, TvConstants.RadioGroupNames.AllChannels);
}
}
foreach (TuningDetail detail in _tuningDetails)
{
detail.IdChannel = _channel.IdChannel;
detail.IsRadio = !_isTv;
detail.IsTv = _isTv;
if (string.IsNullOrEmpty(detail.Name))
{
detail.Name = _channel.DisplayName;
}
detail.Persist();
}
foreach (TuningDetail detail in _tuningDetailsToDelete)
{
detail.Remove();
}
DialogResult = DialogResult.OK;
Close();
}
示例13: DoScan
//.........这里部分代码省略.........
int updatedChannels = 0;
for (int i = 0; i < channels.Length; ++i)
{
Channel dbChannel;
ATSCChannel channel = (ATSCChannel)channels[i];
//No support for channel moving, or merging with existing channels here.
//We do not know how ATSC works to correctly implement this.
TuningDetail currentDetail = layer.GetTuningDetail(channel);
if (currentDetail != null)
if (channel.Frequency != currentDetail.Frequency)
currentDetail = null;
bool exists;
if (currentDetail == null)
{
//add new channel
exists = false;
dbChannel = layer.AddNewChannel(channel.Name);
dbChannel.SortOrder = 10000;
if (channel.LogicalChannelNumber >= 1)
{
dbChannel.SortOrder = channel.LogicalChannelNumber;
}
}
else
{
exists = true;
dbChannel = currentDetail.ReferencedChannel();
}
dbChannel.IsTv = channel.IsTv;
dbChannel.IsRadio = channel.IsRadio;
dbChannel.Persist();
if (dbChannel.IsTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
}
if (dbChannel.IsRadio)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
}
if (currentDetail == null)
{
layer.AddTuningDetails(dbChannel, channel);
}
else
{
//update tuning details...
TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
td.Persist();
}
if (channel.IsTv)
{
if (exists)
{
tvChannelsUpdated++;
updatedChannels++;
}
else
{
tvChannelsNew++;
newChannels++;
}
}
if (channel.IsRadio)
{
if (exists)
{
示例14: DoScan
//.........这里部分代码省略.........
ATSCChannel channel = (ATSCChannel)channels[i];
//No support for channel moving, or merging with existing channels here.
//We do not know how ATSC works to correctly implement this.
TuningDetail currentDetail = layer.GetTuningDetail(channel);
if (currentDetail != null)
{
if (channel.IsDifferentTransponder(layer.GetTuningChannel(currentDetail)))
{
currentDetail = null;
}
}
bool exists;
if (currentDetail == null)
{
//add new channel
exists = false;
dbChannel = layer.AddNewChannel(channel.Name, channel.LogicalChannelNumber);
dbChannel.SortOrder = 10000;
if (channel.LogicalChannelNumber >= 1)
{
dbChannel.SortOrder = channel.LogicalChannelNumber;
}
}
else
{
exists = true;
dbChannel = currentDetail.ReferencedChannel();
}
dbChannel.IsTv = channel.IsTv;
dbChannel.IsRadio = channel.IsRadio;
dbChannel.Persist();
if (dbChannel.IsTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
}
if (dbChannel.IsRadio)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
}
if (currentDetail == null)
{
layer.AddTuningDetails(dbChannel, channel);
}
else
{
//update tuning details...
TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
td.Persist();
}
if (channel.IsTv)
{
if (exists)
{
tvChannelsUpdated++;
updatedChannels++;
}
else
{
tvChannelsNew++;
newChannels++;
}
}
if (channel.IsRadio)
{
if (exists)
{