|
From: <mas...@us...> - 2007-09-17 17:58:18
|
Revision: 50
http://mp-webinterface.svn.sourceforge.net/mp-webinterface/?rev=50&view=rev
Author: maschine
Date: 2007-09-17 10:58:15 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Change channel group on index change.
Modified Paths:
--------------
trunk/Version2/Web App/MPW/NowNext.aspx
trunk/Version2/Web App/MPW/NowNext.aspx.cs
Modified: trunk/Version2/Web App/MPW/NowNext.aspx
===================================================================
--- trunk/Version2/Web App/MPW/NowNext.aspx 2007-09-17 16:29:53 UTC (rev 49)
+++ trunk/Version2/Web App/MPW/NowNext.aspx 2007-09-17 17:58:15 UTC (rev 50)
@@ -8,9 +8,8 @@
<ContentTemplate>
<div>
<asp:Label ID="LabelChannelGroup" runat="server" Text="Label"></asp:Label>
- <asp:DropDownList ID="DropDownListChannelGroups" runat="server">
- </asp:DropDownList>
- <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Button" />
+ <asp:DropDownList ID="DropDownListChannelGroups" runat="server" OnSelectedIndexChanged="groupChosen" AutoPostBack="True">
+ </asp:DropDownList>
<asp:Panel ID="NowNextPanel" runat="server">
</asp:Panel>
Modified: trunk/Version2/Web App/MPW/NowNext.aspx.cs
===================================================================
--- trunk/Version2/Web App/MPW/NowNext.aspx.cs 2007-09-17 16:29:53 UTC (rev 49)
+++ trunk/Version2/Web App/MPW/NowNext.aspx.cs 2007-09-17 17:58:15 UTC (rev 50)
@@ -16,7 +16,11 @@
public partial class Default2 : System.Web.UI.Page
{
IList _schedules;
+ IList groups;
+ IList channels;
+ private int chosengroup = 0;
+
/// <summary>
/// Checks if a program is scheduled as single / series recording
/// </summary>
@@ -24,204 +28,210 @@
/// <returns>A bool array with meaning [isScheduled, isSeries]</returns>
protected bool[] IsRecording(Program program)
{
- bool[] result = { false, false };
- foreach (Schedule schedule in _schedules)
- {
- if (schedule.IsRecordingProgram(program, true))
+ bool[] result = { false, false };
+ foreach (Schedule schedule in _schedules)
{
- result[0] = true;
- if (schedule.ScheduleType != 0)
- result[1] = true; ;
+ if (schedule.IsRecordingProgram(program, true))
+ {
+ result[0] = true;
+ if (schedule.ScheduleType != 0)
+ result[1] = true; ;
+ }
}
- }
- return result;
+ return result;
}
protected void Page_Load(object sender, EventArgs e)
{
- //Establish the connection to the TV Server and the DB.
- MPWUtils.SetupConnection();
- if (!IsPostBack)
- {
- MPWMaster m = (MPWMaster)Page.Master;
- //Set language resources
- m.Sectiontitle = Resources.Resource.NowNext;
- LabelChannelGroup.Text = Resources.Resource.ChannelGroup;
- btnUpdate.Text = Resources.Resource.Update;
+ //Establish the connection to the TV Server and the DB.
+ MPWUtils.SetupConnection();
+ if (!IsPostBack)
+ {
+ MPWMaster m = (MPWMaster)Page.Master;
+ //Set language resources
+ m.Sectiontitle = Resources.Resource.NowNext;
+ LabelChannelGroup.Text = Resources.Resource.ChannelGroup;
- IList groups = ChannelGroup.ListAll();
- DropDownListChannelGroups.Items.Clear();
- foreach (ChannelGroup group in groups)
- DropDownListChannelGroups.Items.Add(new ListItem(group.GroupName,group.IdGroup.ToString()));
- DropDownListChannelGroups.SelectedIndex = 0;
- }
- updateContents();
+ groups = ChannelGroup.ListAll();
+ DropDownListChannelGroups.Items.Clear();
+ foreach (ChannelGroup group in groups)
+ DropDownListChannelGroups.Items.Add(new ListItem(group.GroupName, group.IdGroup.ToString()));
+ DropDownListChannelGroups.SelectedIndex = chosengroup;
+ }
+ updateContents();
}
- /// <summary>
+ /// <summary>
/// Updates the now and next program rows.
/// </summary>
protected void updateContents()
{
- //Clear everything
- NowNextPanel.Controls.Clear();
+ //Clear everything
+ NowNextPanel.Controls.Clear();
- //A new Businesslayer
- TvBusinessLayer layer = new TvBusinessLayer();
+ //A new Businesslayer
+ TvBusinessLayer layer = new TvBusinessLayer();
- //Get all schedules
- _schedules = Schedule.ListAll();
+ //Get all schedules
+ _schedules = Schedule.ListAll();
- ChannelGroup group=ChannelGroup.Retrieve(Int32.Parse(DropDownListChannelGroups.SelectedValue));
+ chosengroup = Int32.Parse(DropDownListChannelGroups.SelectedValue);
+ ChannelGroup group = ChannelGroup.Retrieve(chosengroup);
- Table groupTable = new Table();
- groupTable.CellPadding = 0;
- groupTable.CellSpacing = 0;
- groupTable.CssClass = "grouptable";
+ Table groupTable = new Table();
+ groupTable.CellPadding = 0;
+ groupTable.CellSpacing = 0;
+ groupTable.CssClass = "grouptable";
- // Seperator with group name
- TableRow groupSeperatorRow = new TableRow();
- TableCell groupSeperatorCell = new TableCell();
- groupSeperatorCell.CssClass = "seperatorcell";
- groupSeperatorCell.ColumnSpan = 3;
- Label groupName = new Label();
- groupName.Text = group.GroupName;
- groupSeperatorCell.Controls.Add(groupName);
- groupSeperatorRow.Cells.Add(groupSeperatorCell);
- groupTable.Rows.Add(groupSeperatorRow);
+ // Seperator with group name
+ TableRow groupSeperatorRow = new TableRow();
+ TableCell groupSeperatorCell = new TableCell();
+ groupSeperatorCell.CssClass = "seperatorcell";
+ groupSeperatorCell.ColumnSpan = 3;
+ Label groupName = new Label();
+ groupName.Text = group.GroupName;
+ groupSeperatorCell.Controls.Add(groupName);
+ groupSeperatorRow.Cells.Add(groupSeperatorCell);
+ groupTable.Rows.Add(groupSeperatorRow);
- // Get a list of all tv-channels
- IList channels = layer.GetTVGuideChannelsForGroup(group.IdGroup);
- List<Channel> channelstv = new List<Channel>();
+ // Get a list of all tv-channels
+ IList channels = layer.GetTVGuideChannelsForGroup(group.IdGroup);
+ List<Channel> channelstv = new List<Channel>();
// Remove non TV channels
foreach (Channel channel in channels)
{
- if (channel.IsTv)
- channelstv.Add(channel);
+ if (channel.IsTv)
+ channelstv.Add(channel);
}
//Iterate through all the channels
foreach (Channel channel in channelstv)
{
- TableRow channelNameRow = new TableRow();
+ TableRow channelNameRow = new TableRow();
- TableCell spacer = new TableCell();
- spacer.CssClass = "spacer";
- channelNameRow.Controls.Add(spacer);
+ TableCell spacer = new TableCell();
+ spacer.CssClass = "spacer";
+ channelNameRow.Controls.Add(spacer);
- TableCell channelNameCell = new TableCell();
- channelNameCell.CssClass = "namecell";
- channelNameCell.ColumnSpan = 2;
- ImageButton btnStartTimeShift = new ImageButton();
- btnStartTimeShift.ImageUrl = "Images/osd_play_nofocus.png";
- btnStartTimeShift.Width = 20;
- btnStartTimeShift.Height = 20;
- btnStartTimeShift.ToolTip = Resources.Resource.WatchThisChannel;
- btnStartTimeShift.CommandName = "StartTimeshifting";
- btnStartTimeShift.CommandArgument = channel.IdChannel.ToString();
- btnStartTimeShift.Command += new CommandEventHandler(btnStartTimeShift_Command);
- channelNameCell.Controls.Add(btnStartTimeShift);
- Label channelName = new Label();
- channelName.Text = " "+channel.DisplayName;
- channelNameCell.Controls.Add(channelName);
- channelNameRow.Cells.Add(channelNameCell);
- groupTable.Rows.Add(channelNameRow);
+ TableCell channelNameCell = new TableCell();
+ channelNameCell.CssClass = "namecell";
+ channelNameCell.ColumnSpan = 2;
+ ImageButton btnStartTimeShift = new ImageButton();
+ btnStartTimeShift.ImageUrl = "Images/osd_play_nofocus.png";
+ btnStartTimeShift.Width = 20;
+ btnStartTimeShift.Height = 20;
+ btnStartTimeShift.ToolTip = Resources.Resource.WatchThisChannel;
+ btnStartTimeShift.CommandName = "StartTimeshifting";
+ btnStartTimeShift.CommandArgument = channel.IdChannel.ToString();
+ btnStartTimeShift.Command += new CommandEventHandler(btnStartTimeShift_Command);
+ channelNameCell.Controls.Add(btnStartTimeShift);
+ Label channelName = new Label();
+ channelName.Text = " " + channel.DisplayName;
+ channelNameCell.Controls.Add(channelName);
+ channelNameRow.Cells.Add(channelNameCell);
+ groupTable.Rows.Add(channelNameRow);
- TableRow channelRow = new TableRow();
+ TableRow channelRow = new TableRow();
- TableCell spacer2 = new TableCell();
- spacer2.CssClass = "spacer2";
- channelRow.Controls.Add(spacer2);
+ TableCell spacer2 = new TableCell();
+ spacer2.CssClass = "spacer2";
+ channelRow.Controls.Add(spacer2);
- TableCell cell_channel = new TableCell();
- cell_channel.CssClass = "logocell";
+ TableCell cell_channel = new TableCell();
+ cell_channel.CssClass = "logocell";
- Image channelLogo = new Image();
- channelLogo.CssClass = "channellogo";
- channelLogo.ImageUrl = MPWUtils.getChannelLogoPath(this.Server.MapPath("~/TVLogos/"), channel.Name);
+ Image channelLogo = new Image();
+ channelLogo.CssClass = "channellogo";
+ channelLogo.ImageUrl = MPWUtils.getChannelLogoPath(this.Server.MapPath("~/TVLogos/"), channel.Name);
- if (channelLogo.ImageUrl != "")
- cell_channel.Controls.Add(channelLogo);
+ if (channelLogo.ImageUrl != "")
+ cell_channel.Controls.Add(channelLogo);
- TableCell cell_program = new TableCell();
- cell_program.CssClass = "detailscell";
+ TableCell cell_program = new TableCell();
+ cell_program.CssClass = "detailscell";
- Label lbl_program_now = new Label();
- Label lbl_program_next = new Label();
+ Label lbl_program_now = new Label();
+ Label lbl_program_next = new Label();
- try
- {
- Program now = channel.GetProgramAt(DateTime.Now);
- bool[] nowRec = IsRecording(now);
- Program next = channel.GetProgramAt(now.EndTime.AddMinutes(2));
- bool[] nextRec = IsRecording(next);
+ try
+ {
+ Program now = channel.GetProgramAt(DateTime.Now);
+ bool[] nowRec = IsRecording(now);
+ Program next = channel.GetProgramAt(now.EndTime.AddMinutes(2));
+ bool[] nextRec = IsRecording(next);
- lbl_program_now.Text = "<a style href=\"ProgramDetail.aspx?idProgram=" + now.IdProgram.ToString() + "\"><img border=0 src=\"Images/rec_single.png\" alt=\""+Resources.Resource.ScheduleThisProgram+"\" width=12px height=12px/></a> <span class=\"nownext\">" + Resources.Resource.Now + ": </span>";
- lbl_program_now.Text += "<div style=\"display:inline\" TITLE=\"header=["+now.Title+"] body=["+now.Description+"] fade=[on]\">" + now.Title;
- lbl_program_now.Text += " (" + now.StartTime.ToShortTimeString() + " - ";
- lbl_program_now.Text += now.EndTime.ToShortTimeString() + ")</div>";
- cell_program.Controls.Add(lbl_program_now);
+ lbl_program_now.Text = "<a style href=\"ProgramDetail.aspx?idProgram=" + now.IdProgram.ToString() + "\"><img border=0 src=\"Images/rec_single.png\" alt=\"" + Resources.Resource.ScheduleThisProgram + "\" width=12px height=12px/></a> <span class=\"nownext\">" + Resources.Resource.Now + ": </span>";
+ lbl_program_now.Text += "<div style=\"display:inline\" TITLE=\"header=[" + now.Title + "] body=[" + now.Description + "] fade=[on]\">" + now.Title;
+ lbl_program_now.Text += " (" + now.StartTime.ToShortTimeString() + " - ";
+ lbl_program_now.Text += now.EndTime.ToShortTimeString() + ")</div>";
+ cell_program.Controls.Add(lbl_program_now);
- if (nowRec[0])
- {
- Image recIcon = new Image();
- if (nowRec[1])
- recIcon.ImageUrl = "Images/rec_series.png";
- else
- recIcon.ImageUrl = "Images/rec_single.png";
- recIcon.ImageAlign = ImageAlign.Middle;
- cell_program.Controls.Add(recIcon);
- }
+ if (nowRec[0])
+ {
+ Image recIcon = new Image();
+ if (nowRec[1])
+ recIcon.ImageUrl = "Images/rec_series.png";
+ else
+ recIcon.ImageUrl = "Images/rec_single.png";
+ recIcon.ImageAlign = ImageAlign.Middle;
+ cell_program.Controls.Add(recIcon);
+ }
- lbl_program_next.Text = "<br /> <br />";
+ lbl_program_next.Text = "<br /> <br />";
- lbl_program_next.Text += "<a style href=\"ProgramDetail.aspx?idProgram=" + now.IdProgram.ToString() + "\"><img border=0 src=\"Images/rec_single.png\" alt=\""+Resources.Resource.ScheduleThisProgram+"\" width=12px height=12px/></a> <span class=\"nownext\">" + Resources.Resource.Next + ": </span>";
- lbl_program_next.Text += "<div style=\"display:inline\" TITLE=\"header=[" + next.Title + "] body=[" + next.Description + "] fade=[on]\">" + next.Title;
- lbl_program_next.Text += " (" + next.StartTime.ToShortTimeString() + " - ";
- lbl_program_next.Text += next.EndTime.ToShortTimeString() + ")</div>";
- cell_program.Controls.Add(lbl_program_next);
+ lbl_program_next.Text += "<a style href=\"ProgramDetail.aspx?idProgram=" + now.IdProgram.ToString() + "\"><img border=0 src=\"Images/rec_single.png\" alt=\"" + Resources.Resource.ScheduleThisProgram + "\" width=12px height=12px/></a> <span class=\"nownext\">" + Resources.Resource.Next + ": </span>";
+ lbl_program_next.Text += "<div style=\"display:inline\" TITLE=\"header=[" + next.Title + "] body=[" + next.Description + "] fade=[on]\">" + next.Title;
+ lbl_program_next.Text += " (" + next.StartTime.ToShortTimeString() + " - ";
+ lbl_program_next.Text += next.EndTime.ToShortTimeString() + ")</div>";
+ cell_program.Controls.Add(lbl_program_next);
- if (nextRec[0])
+ if (nextRec[0])
+ {
+ Image recIcon = new Image();
+ if (nextRec[1])
+ recIcon.ImageUrl = "Images/rec_series.png";
+ else
+ recIcon.ImageUrl = "Images/rec_single.png";
+ recIcon.ImageAlign = ImageAlign.Middle;
+ cell_program.Controls.Add(recIcon);
+ }
+
+ }
+ catch
{
- Image recIcon = new Image();
- if (nextRec[1])
- recIcon.ImageUrl = "Images/rec_series.png";
- else
- recIcon.ImageUrl = "Images/rec_single.png";
- recIcon.ImageAlign = ImageAlign.Middle;
- cell_program.Controls.Add(recIcon);
+ lbl_program_now.Text = Resources.Resource.NoEPGInfo;
+ cell_program.Controls.Add(lbl_program_now);
}
- }
- catch
- {
- lbl_program_now.Text = Resources.Resource.NoEPGInfo;
- cell_program.Controls.Add(lbl_program_now);
- }
+ channelRow.Cells.Add(cell_channel);
+ channelRow.Cells.Add(cell_program);
- channelRow.Cells.Add(cell_channel);
- channelRow.Cells.Add(cell_program);
+ groupTable.Rows.Add(channelRow);
- groupTable.Rows.Add(channelRow);
+ NowNextPanel.Controls.Add(groupTable);
- NowNextPanel.Controls.Add(groupTable);
+ }
+ }
- }
+ void btnStartTimeShift_Command(object sender, CommandEventArgs e)
+ {
+ string rtspURL = "";
+ TvResult result = MPWUtils.StartTimeShift(Int32.Parse((string)e.CommandArgument), ref rtspURL);
+ if (result == TvResult.Succeeded)
+ ScriptManager.RegisterStartupScript(this, typeof(NowAndNext), "timeshift", "window.open('" + rtspURL + "');", true);
+ else
+ ScriptManager.RegisterStartupScript(this, typeof(NowAndNext), "timeshift", "alert('Failed to start timeshifting." + Environment.NewLine + "Reason: " + result.ToString() + "');", true);
}
- void btnStartTimeShift_Command(object sender, CommandEventArgs e)
- {
- string rtspURL = "";
- TvResult result=MPWUtils.StartTimeShift(Int32.Parse((string)e.CommandArgument), ref rtspURL);
- if (result==TvResult.Succeeded)
- ScriptManager.RegisterStartupScript(this, typeof(NowAndNext), "timeshift", "window.open('" + rtspURL + "');",true);
- else
- ScriptManager.RegisterStartupScript(this, typeof(NowAndNext), "timeshift", "alert('Failed to start timeshifting."+Environment.NewLine+"Reason: "+result.ToString()+"');", true);
- }
- protected void btnUpdate_Click(object sender, EventArgs e)
- {
- updateContents();
- }
+ /// <summary>
+ /// Is called if another channel group is chosen.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ protected void groupChosen(object sender, EventArgs e)
+ {
+ updateContents();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|