public void RefreshIcons() { foreach (DataGridViewRow row in _channelsGridView.Rows) { Guid?currentUpcomingProgramId = null; Guid?nextUpcomingProgramId = null; CurrentAndNextProgramView programView = row.DataBoundItem as CurrentAndNextProgramView; if (programView != null) { if (programView.CurrentAndNextProgram.Current != null) { currentUpcomingProgramId = programView.CurrentAndNextProgram.Current.GetUniqueUpcomingProgramId( programView.CurrentAndNextProgram.Channel.ChannelId); } if (programView.CurrentAndNextProgram.Next != null) { nextUpcomingProgramId = programView.CurrentAndNextProgram.Next.GetUniqueUpcomingProgramId( programView.CurrentAndNextProgram.Channel.ChannelId); } } SetCellIcon(row, ColumnIndex.CurrentIcon, programView.CurrentAndNextProgram.Channel, currentUpcomingProgramId); SetCellIcon(row, ColumnIndex.NextIcon, programView.CurrentAndNextProgram.Channel, nextUpcomingProgramId); } }
private Channel GetSelectedChannel() { if (_channelsGridView.SelectedRows.Count > 0) { CurrentAndNextProgramView currentAndNext = _channelsGridView.SelectedRows[0].DataBoundItem as CurrentAndNextProgramView; if (currentAndNext != null) { return(currentAndNext.CurrentAndNextProgram.Channel); } } return(null); }
private void _channelsGridView_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo htinfo = _channelsGridView.HitTest(e.X, e.Y); if (htinfo.Type == DataGridViewHitTestType.Cell) { CurrentAndNextProgramView programView = _channelsGridView.Rows[htinfo.RowIndex].DataBoundItem as CurrentAndNextProgramView; if (programView != null) { GuideProgramSummary guideProgram = null; if (htinfo.ColumnIndex == ColumnIndex.CurrentIcon || htinfo.ColumnIndex == ColumnIndex.CurrentTitle) { guideProgram = programView.CurrentAndNextProgram.Current; } else if (htinfo.ColumnIndex == ColumnIndex.NextIcon || htinfo.ColumnIndex == ColumnIndex.NextTitle) { guideProgram = programView.CurrentAndNextProgram.Next; } if (guideProgram != null) { Guid upcomingProgramId = guideProgram.GetUniqueUpcomingProgramId(programView.CurrentAndNextProgram.Channel.ChannelId); GuideUpcomingProgram upcomingProgramInfo = null; _allUpcomingGuidePrograms.TryGetValue(upcomingProgramId, out upcomingProgramInfo); _channelsGridView.Rows[htinfo.RowIndex].Selected = true; ScheduleType? scheduleType = null; UpcomingProgram upcomingProgram = null; UpcomingGuideProgram upcomingGuideProgram = null; if (upcomingProgramInfo != null) { scheduleType = upcomingProgramInfo.Type; upcomingProgram = upcomingProgramInfo.UpcomingRecording != null ? upcomingProgramInfo.UpcomingRecording.Program : null; upcomingGuideProgram = upcomingProgramInfo.UpcomingGuideProgram; } _programContextMenuStrip.SetTarget(programView.CurrentAndNextProgram.Channel, guideProgram.GuideProgramId, guideProgram.Title, guideProgram.SubTitle, guideProgram.EpisodeNumberDisplay, guideProgram.StartTime, scheduleType, upcomingProgram, upcomingGuideProgram); _programContextMenuStrip.Show(_channelsGridView, e.Location); } } } } }
private void _channelsGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.RowIndex >= 0 && e.RowIndex < _channelsBindingSource.Count) { CurrentAndNextProgramView programView = _channelsGridView.Rows[e.RowIndex].DataBoundItem as CurrentAndNextProgramView; if (programView != null && (programView.CurrentAndNextProgram.LiveState == ChannelLiveState.Tunable || programView.CurrentAndNextProgram.LiveState == ChannelLiveState.Unknown)) { e.CellStyle.ForeColor = Color.Black; e.CellStyle.SelectionForeColor = Color.Black; _channelsGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = null; } else { e.CellStyle.ForeColor = Color.DarkGray; e.CellStyle.SelectionForeColor = Color.Gray; string tooltip = null; if (programView != null) { switch (programView.CurrentAndNextProgram.LiveState) { case ChannelLiveState.NoFreeCard: tooltip = "No free card available for channel"; break; case ChannelLiveState.NotTunable: tooltip = "Channel is not tunable"; break; } } _channelsGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = tooltip; } if (_channelsGridView.Columns[e.ColumnIndex] is DataGridViewLinkColumn) { if (_channelsGridView.Rows[e.RowIndex].Selected) { ((DataGridViewLinkCell)_channelsGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]).LinkColor = e.CellStyle.SelectionForeColor; } else { ((DataGridViewLinkCell)_channelsGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]).LinkColor = e.CellStyle.ForeColor; } } } }
private void _channelsGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if ((e.ColumnIndex == ColumnIndex.CurrentTitle || e.ColumnIndex == ColumnIndex.NextTitle) && e.RowIndex >= 0 && e.RowIndex < _channelsGridView.Rows.Count) { CurrentAndNextProgramView programView = _channelsGridView.Rows[e.RowIndex].DataBoundItem as CurrentAndNextProgramView; GuideProgramSummary programSummary = (e.ColumnIndex == ColumnIndex.CurrentTitle) ? programView.CurrentAndNextProgram.Current : programView.CurrentAndNextProgram.Next; if (programSummary != null) { GuideProgram guideProgram = Proxies.GuideService.GetProgramById(programSummary.GuideProgramId).Result; using (ProgramDetailsPopup popup = new ProgramDetailsPopup()) { popup.Channel = programView.CurrentAndNextProgram.Channel; popup.GuideProgram = guideProgram; Point location = Cursor.Position; location.Offset(-250, -40); popup.Location = location; popup.ShowDialog(this); } } } }