コード例 #1
0
 private void InvalidateCell(GuideProgramCell cell)
 {
     if (cell != null)
     {
         Invalidate(cell.Rectangle);
     }
 }
コード例 #2
0
 protected override void OnMouseLeave(EventArgs e)
 {
     if (!_skipMouseLeave)
     {
         InvalidateCell(_highlightedCell);
         _highlightedCell = null;
     }
     _skipMouseLeave = false;
     this.Cursor     = Cursors.Default;
     base.OnMouseLeave(e);
 }
コード例 #3
0
        private bool IsRecording(GuideProgramCell cell)
        {
            GuideUpcomingProgram upcomingProgramInfo;

            if (cell.GuideProgram != null &&
                _model.UpcomingRecordingsById.TryGetValue(cell.GetUniqueUpcomingProgramId(), out upcomingProgramInfo))
            {
                return(!upcomingProgramInfo.IsCancelled &&
                       upcomingProgramInfo.UpcomingRecording != null &&
                       upcomingProgramInfo.UpcomingRecording.CardChannelAllocation != null);
            }
            return(false);
        }
コード例 #4
0
        private int CreateEpgChannelCells(Channel channel, int top)
        {
            DateTime startDate = EpgControl.GetEpgStartTime(_model);
            DateTime endDate   = EpgControl.GetEpgEndTime(_model);

            int cellHeight = 0;

            int previousRight = 0;

            if (_model.ProgramsByChannel.ContainsKey(channel.ChannelId))
            {
                bool isTop = (top == 0);
                cellHeight = isTop ? _height : (_height - 1);

                foreach (GuideProgramSummary guideProgram in _model.ProgramsByChannel[channel.ChannelId].Programs)
                {
                    GuideProgramCell cell = new GuideProgramCell();
                    cell.GuideProgram = guideProgram;
                    cell.Channel      = channel;
                    cell.IsTop        = isTop;
                    cell.ClipLeft     = (guideProgram.StartTime < startDate);
                    cell.ClipRight    = (guideProgram.StopTime > endDate);
                    cell.StartTime    = cell.ClipLeft ? startDate : guideProgram.StartTime;
                    cell.StopTime     = cell.ClipRight ? endDate : guideProgram.StopTime;

                    TimeSpan leftSpan = cell.StartTime - startDate;
                    int      left     = (int)(leftSpan.TotalMinutes * 4 * _widthFactor);

                    if (left > previousRight)
                    {
                        GuideProgramCell emptyCell = new GuideProgramCell();
                        emptyCell.Rectangle = new Rectangle(previousRight, top, left - previousRight, cellHeight);
                        _guideProgramCells.Add(emptyCell);
                    }

                    cell.Rectangle = new Rectangle(left, top, (int)(cell.Duration.TotalMinutes * 4 * _widthFactor), cellHeight);
                    _guideProgramCells.Add(cell);

                    previousRight = cell.Rectangle.Right;
                }
            }
            if (previousRight < this.Width)
            {
                GuideProgramCell emptyCell = new GuideProgramCell();
                emptyCell.Rectangle = new Rectangle(previousRight, top, this.Width, cellHeight);
                _guideProgramCells.Add(emptyCell);
            }

            return(top + cellHeight);
        }
コード例 #5
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            GuideProgramCell previousHighlightedCell = _highlightedCell;

            _highlightedCell = null;
            foreach (GuideProgramCell cell in _guideProgramCells)
            {
                if (cell.Rectangle.Contains(e.Location) &&
                    cell.GuideProgram != null)
                {
                    _highlightedCell = cell;
                    break;
                }
            }
            if (_highlightedCell != previousHighlightedCell)
            {
                InvalidateCell(previousHighlightedCell);
                InvalidateCell(_highlightedCell);
            }
            this.Cursor = _highlightedCell == null ? Cursors.Default : Cursors.Hand;

            CellToolTip toolTip = null;

            if (_highlightedCell != null)
            {
                toolTip = _highlightedCell.GetToolTipAt(e.Location);
            }

            if (toolTip == null)
            {
                DisposeToolTip();
            }
            else if (_toolTip == null)
            {
                _toolTip = new ToolTip();
                _toolTip.SetToolTip(this, toolTip.Text);
            }

            base.OnMouseMove(e);
        }
コード例 #6
0
        private bool DrawScheduleIcon(GuideProgramCell cell, PaintEventArgs e, float titleTop, ref int titleLeft, SerializableDictionary <Guid, GuideUpcomingProgram> upcomingById)
        {
            GuideUpcomingProgram upcomingProgramInfo;

            if (upcomingById.TryGetValue(cell.GetUniqueUpcomingProgramId(), out upcomingProgramInfo))
            {
                Icon   icon;
                string toolTip = null;
                if (upcomingProgramInfo.UpcomingRecording != null)
                {
                    toolTip = ProcessUtility.BuildRecordingInfoToolTip(upcomingProgramInfo.UpcomingRecording, "on");
                }
                string toolTip2;
                ProgramIconUtility.GetIconAndToolTip(upcomingProgramInfo.Type, upcomingProgramInfo.CancellationReason,
                                                     upcomingProgramInfo.IsPartOfSeries, _model.UpcomingRecordings, upcomingProgramInfo.UpcomingRecording,
                                                     out icon, out toolTip2);
                if (!String.IsNullOrEmpty(toolTip2))
                {
                    if (!String.IsNullOrEmpty(toolTip))
                    {
                        toolTip = toolTip + Environment.NewLine + Environment.NewLine + toolTip2;
                    }
                    else
                    {
                        toolTip = toolTip2;
                    }
                }
                Rectangle iconRectangle = new Rectangle(titleLeft, (int)Math.Round(titleTop), icon.Width, icon.Height);
                if (!String.IsNullOrEmpty(toolTip))
                {
                    cell.ToolTips.Add(new CellToolTip(iconRectangle, toolTip));
                }

                int height = (int)(icon.Height * _heightFactor);
                e.Graphics.DrawIcon(icon, iconRectangle.X, iconRectangle.Y + (int)Math.Floor((height - icon.Height) / 2.0));
                titleLeft += icon.Width;
                return(true);
            }
            return(false);
        }
コード例 #7
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         _mouseDownCell = GetProgramCellAt(e.Location);
     }
     else if (e.Button == MouseButtons.Right)
     {
         GuideProgramCell cell = GetProgramCellAt(e.Location);
         if (this.ProgramContextMenu != null &&
             cell != null &&
             cell.GuideProgram != null)
         {
             InvalidateCell(_highlightedCell);
             _highlightedCell = cell;
             InvalidateCell(_highlightedCell);
             _skipMouseLeave = true;
             this.ProgramContextMenu(this, new EpgControl.ProgramEventArgs(cell.GuideProgram, cell.Channel, e.Location));
         }
     }
     base.OnMouseDown(e);
 }
コード例 #8
0
 private bool IsRecording(GuideProgramCell cell)
 {
     GuideUpcomingProgram upcomingProgramInfo;
     if (cell.GuideProgram != null
         && _model.UpcomingRecordingsById.TryGetValue(cell.GetUniqueUpcomingProgramId(), out upcomingProgramInfo))
     {
         return !upcomingProgramInfo.IsCancelled
             && upcomingProgramInfo.UpcomingRecording != null
             && upcomingProgramInfo.UpcomingRecording.CardChannelAllocation != null;
     }
     return false;
 }
コード例 #9
0
 private void InvalidateCell(GuideProgramCell cell)
 {
     if (cell != null)
     {
         Invalidate(cell.Rectangle);
     }
 }
コード例 #10
0
        private bool DrawScheduleIcon(GuideProgramCell cell, PaintEventArgs e, float titleTop, ref int titleLeft, SerializableDictionary<Guid, GuideUpcomingProgram> upcomingById)
        {
            GuideUpcomingProgram upcomingProgramInfo;
            if (upcomingById.TryGetValue(cell.GetUniqueUpcomingProgramId(), out upcomingProgramInfo))
            {
                Icon icon;
                string toolTip = null;
                if (upcomingProgramInfo.UpcomingRecording != null)
                {
                    toolTip = ProcessUtility.BuildRecordingInfoToolTip(upcomingProgramInfo.UpcomingRecording, "on");
                }
                string toolTip2;
                ProgramIconUtility.GetIconAndToolTip(upcomingProgramInfo.Type, upcomingProgramInfo.CancellationReason,
                    upcomingProgramInfo.IsPartOfSeries, _model.UpcomingRecordings, upcomingProgramInfo.UpcomingRecording,
                    out icon, out toolTip2);
                if (!String.IsNullOrEmpty(toolTip2))
                {
                    if (!String.IsNullOrEmpty(toolTip))
                    {
                        toolTip = toolTip + Environment.NewLine + Environment.NewLine + toolTip2;
                    }
                    else
                    {
                        toolTip = toolTip2;
                    }
                }
                Rectangle iconRectangle = new Rectangle(titleLeft, (int)Math.Round(titleTop), icon.Width, icon.Height);
                if (!String.IsNullOrEmpty(toolTip))
                {
                    cell.ToolTips.Add(new CellToolTip(iconRectangle, toolTip));
                }

                int height = (int)(icon.Height * _heightFactor);
                e.Graphics.DrawIcon(icon, iconRectangle.X, iconRectangle.Y + (int)Math.Floor((height - icon.Height) / 2.0));
                titleLeft += icon.Width;
                return true;
            }
            return false;
        }
コード例 #11
0
        private int CreateEpgChannelCells(Channel channel, int top)
        {
            DateTime startDate = EpgControl.GetEpgStartTime(_model);
            DateTime endDate = EpgControl.GetEpgEndTime(_model);

            int cellHeight = 0;

            int previousRight = 0;
            if (_model.ProgramsByChannel.ContainsKey(channel.ChannelId))
            {
                bool isTop = (top == 0);
                cellHeight = isTop ? _height : (_height - 1);

                foreach (GuideProgramSummary guideProgram in _model.ProgramsByChannel[channel.ChannelId].Programs)
                {
                    GuideProgramCell cell = new GuideProgramCell();
                    cell.GuideProgram = guideProgram;
                    cell.Channel = channel;
                    cell.IsTop = isTop;
                    cell.ClipLeft = (guideProgram.StartTime < startDate);
                    cell.ClipRight = (guideProgram.StopTime > endDate);
                    cell.StartTime = cell.ClipLeft ? startDate : guideProgram.StartTime;
                    cell.StopTime = cell.ClipRight ? endDate : guideProgram.StopTime;

                    TimeSpan leftSpan = cell.StartTime - startDate;
                    int left = (int)(leftSpan.TotalMinutes * 4 * _widthFactor);

                    if (left > previousRight)
                    {
                        GuideProgramCell emptyCell = new GuideProgramCell();
                        emptyCell.Rectangle = new Rectangle(previousRight, top, left - previousRight, cellHeight);
                        _guideProgramCells.Add(emptyCell);
                    }

                    cell.Rectangle = new Rectangle(left, top, (int)(cell.Duration.TotalMinutes * 4 * _widthFactor), cellHeight);
                    _guideProgramCells.Add(cell);

                    previousRight = cell.Rectangle.Right;
                }
            }
            if (previousRight < this.Width)
            {
                GuideProgramCell emptyCell = new GuideProgramCell();
                emptyCell.Rectangle = new Rectangle(previousRight, top, this.Width, cellHeight);
                _guideProgramCells.Add(emptyCell);
            }

            return top + cellHeight;
        }
コード例 #12
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            GuideProgramCell previousHighlightedCell = _highlightedCell;
            _highlightedCell = null;
            foreach (GuideProgramCell cell in _guideProgramCells)
            {
                if (cell.Rectangle.Contains(e.Location)
                    && cell.GuideProgram != null)
                {
                    _highlightedCell = cell;
                    break;
                }
            }
            if (_highlightedCell != previousHighlightedCell)
            {
                InvalidateCell(previousHighlightedCell);
                InvalidateCell(_highlightedCell);
            }
            this.Cursor = _highlightedCell == null ? Cursors.Default : Cursors.Hand;

            CellToolTip toolTip = null;
            if (_highlightedCell != null)
            {
                toolTip = _highlightedCell.GetToolTipAt(e.Location);
            }

            if (toolTip == null)
            {
                DisposeToolTip();
            }
            else if (_toolTip == null)
            {
                _toolTip = new ToolTip();
                _toolTip.SetToolTip(this, toolTip.Text);
            }

            base.OnMouseMove(e);
        }
コード例 #13
0
 protected override void OnMouseLeave(EventArgs e)
 {
     if (!_skipMouseLeave)
     {
         InvalidateCell(_highlightedCell);
         _highlightedCell = null;
     }
     _skipMouseLeave = false;
     this.Cursor = Cursors.Default;
     base.OnMouseLeave(e);
 }
コード例 #14
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         _mouseDownCell = GetProgramCellAt(e.Location);
     }
     else if (e.Button == MouseButtons.Right)
     {
         GuideProgramCell cell = GetProgramCellAt(e.Location);
         if (this.ProgramContextMenu != null
             && cell != null
             && cell.GuideProgram != null)
         {
             InvalidateCell(_highlightedCell);
             _highlightedCell = cell;
             InvalidateCell(_highlightedCell);
             _skipMouseLeave = true;
             this.ProgramContextMenu(this, new EpgControl.ProgramEventArgs(cell.GuideProgram, cell.Channel, e.Location));
         }
     }
     base.OnMouseDown(e);
 }