An implementation of an item that is part of a collection. (E.g, a GUIThumbnailPanel).
Наследование: IDisposable
Пример #1
0
    public List<GUIListItem> MissingEpisodes(string Pretty_Name)
    {
      SQLiteResultSet sqlResults = sqlClient.Execute("SELECT CompositeID, SeasonIndex, EpisodeIndex, EpisodeName FROM online_episodes WHERE SeriesID=\"" + sqlClient.Execute("SELECT id FROM online_series WHERE Pretty_Name=\"" + Pretty_Name + "\"").Rows[0].fields[0].ToString() + "\" ORDER BY SeasonIndex, EpisodeIndex");

      List<GUIListItem> _Results = new List<GUIListItem>();
      GUIListItem _Item = new GUIListItem();

      SQLiteResultSet sqlEpisodes;

      for (int i = 0; i < sqlResults.Rows.Count; i++)
      {
        sqlEpisodes = sqlClient.Execute("SELECT CompositeID FROM local_episodes WHERE CompositeID=\"" + sqlResults.Rows[i].fields[0] + "\"");

        if (sqlEpisodes.Rows.Count == 0)
        {
          _Item = new GUIListItem();

          _Item.DVDLabel = "[S]" + sqlResults.Rows[i].fields[1].ToString().PadLeft(2, '0') + "[E]" + sqlResults.Rows[i].fields[2].ToString().PadLeft(2, '0');
          _Item.Label = _Item.DVDLabel.Replace("[S]0", String.Empty).Replace("[S]", String.Empty).Replace("[E]", "x");

          _Results.Add(_Item);
        }
      }

      return _Results;
    }
Пример #2
0
 private void Update()
 {
   listChannels.Clear();
   IList<Channel> channels = Channel.ListAll();
   foreach (Channel chan in channels)
   {
     if (chan.IsTv)
     {
       continue;
     }
     bool isDigital = false;
     foreach (TuningDetail detail in chan.ReferringTuningDetail())
     {
       if (detail.ChannelType != 0)
       {
         isDigital = true;
         break;
       }
     }
     if (isDigital)
     {
       GUIListItem item = new GUIListItem();
       item.Label = chan.DisplayName;
       item.IsFolder = false;
       item.ThumbnailImage = Utils.GetCoverArt(Thumbs.TVChannel, chan.DisplayName);
       item.IconImage = Utils.GetCoverArt(Thumbs.TVChannel, chan.DisplayName);
       item.IconImageBig = Utils.GetCoverArt(Thumbs.TVChannel, chan.DisplayName);
       item.Selected = chan.GrabEpg;
       item.TVTag = chan;
       listChannels.Add(item);
     }
   }
 }
Пример #3
0
        public new void Add(string strLabel)
        {
            int iItemIndex = ListItems.Count + 1;
              GUIListItem pItem = new GUIListItem {ItemId = iItemIndex};
              ListItems.Add(pItem);

              base.Add(strLabel);
        }
Пример #4
0
 public void Add(PlayListItem item)
 {
     _playlist.Add(item);
     GUIListItem guiItem = new GUIListItem();
     guiItem.Label = item.Description;
     _playlistDic.Add(guiItem, item);
     playlistControl.Add(guiItem);
 }
Пример #5
0
 protected override void OnPageLoad()
 {
   base.OnPageLoad();
   selectedItem = null;
   LoadDirectory();
   while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0)
   {
     m_iSelectedItem--;
   }
   GUIControl.SelectItemControl(GetID, listConflicts.GetID, m_iSelectedItem);
 }
Пример #6
0
        public new void Add(string strLabel)
        {
            int iItemIndex = ListItems.Count + 1;
            GUIListItem pItem = new GUIListItem();
            if (base.ShowQuickNumbers)
                pItem.Label = iItemIndex.ToString() + " " + strLabel;
            else
                pItem.Label = strLabel;

            pItem.ItemId = iItemIndex;
            ListItems.Add(pItem);

            base.Add(strLabel);
        }
Пример #7
0
    public List<GUIListItem> Feeds(XmlDocument xmlDoc, string _Site)
    {
      List<GUIListItem> _Return = new List<GUIListItem>();

      GUIListItem _Item;

      foreach (XmlNode nodeItem in xmlDoc.SelectNodes("sites/suggestion[@name='" + _Site + "']/feeds/feed"))
      {
        _Item = new GUIListItem(nodeItem.Attributes["name"].InnerText);
        _Item.Path = nodeItem.InnerText;

        _Return.Add(_Item);
      }

      return _Return;
    }
        // -> TV Series name ...
        internal static string GetTVSeriesAttributes(GUIListItem currentitem, ref string sGenre, ref string sStudio)
        {
            sGenre = string.Empty;
              sStudio = string.Empty;

              if (currentitem == null || currentitem.TVTag == null)
              {
            return string.Empty;
              }

              try
              {
            DBSeries selectedSeries = null;
            DBSeason selectedSeason = null;
            DBEpisode selectedEpisode = null;

            if (currentitem.TVTag is DBSeries)
            {
              selectedSeries = (DBSeries)currentitem.TVTag;
            }
            else if (currentitem.TVTag is DBSeason)
            {
              selectedSeason = (DBSeason)currentitem.TVTag;
              selectedSeries = Helper.getCorrespondingSeries(selectedSeason[DBSeason.cSeriesID]);
            }
            else if (currentitem.TVTag is DBEpisode)
            {
              selectedEpisode = (DBEpisode)currentitem.TVTag;
              selectedSeason = Helper.getCorrespondingSeason(selectedEpisode[DBEpisode.cSeriesID], selectedEpisode[DBEpisode.cSeasonIndex]);
              selectedSeries = Helper.getCorrespondingSeries(selectedEpisode[DBEpisode.cSeriesID]);
            }

            if (selectedSeries != null)
            {
              string result = selectedSeries[DBOnlineSeries.cPrettyName].ToString() + "|" + selectedSeries[DBOnlineSeries.cOriginalName].ToString();
              sGenre = selectedSeries[DBOnlineSeries.cGenre];
              sStudio = selectedSeries[DBOnlineSeries.cNetworkID];
              return result;
            }
              }
              catch (Exception ex)
              {
            logger.Error("GetTVSeriesAttributes: " + ex);
              }
              return string.Empty;
        }
    public void AddConflictRecording(GUIListItem item)
    {
      string logo = MediaPortal.Util.Utils.GetCoverArt(Thumbs.TVChannel, item.Label3);
      if (!MediaPortal.Util.Utils.FileExistsInCache(logo))      
      {
        logo = "defaultVideoBig.png";
      }
      item.ThumbnailImage = logo;
      item.IconImageBig = logo;
      item.IconImage = logo;
      item.OnItemSelected += OnListItemSelected;

      GUIListControl list = (GUIListControl)GetControl((int)Controls.LIST);
      if (list != null)
      {
        list.Add(item);
      }
    }
        protected void addVideos(YouTubeFeed videos, YouTubeQuery qu)
        {
            downloaQueue.Clear();
              foreach (YouTubeEntry entry in videos.Entries)
              {
            GUIListItem item = new GUIListItem();
            // and add station name & bitrate
            item.Label = entry.Title.Text; //ae.Entry.Author.Name + " - " + ae.Entry.Title.Content;
            item.Label2 = "";
            item.IsFolder = false;

            try
            {
              item.Duration = Convert.ToInt32(entry.Duration.Seconds, 10);
              if (entry.Rating != null)
            item.Rating = (float)entry.Rating.Average;
            }
            catch
            {

            }

            string imageFile = Youtube2MP.GetLocalImageFileName(GetBestUrl(entry.Media.Thumbnails));
            if (File.Exists(imageFile))
            {
              item.ThumbnailImage = imageFile;
              item.IconImage = imageFile;
              item.IconImageBig = imageFile;
            }
            else
            {
              MediaPortal.Util.Utils.SetDefaultIcons(item);
              item.OnRetrieveArt += item_OnRetrieveArt;
              DownloadImage(GetBestUrl(entry.Media.Thumbnails), item);
              //DownloadImage(GetBestUrl(entry.Media.Thumbnails), item);
            }
            item.MusicTag = entry;
            relatated.Add(item);
              }
              //OnDownloadTimedEvent(null, null);
        }
Пример #11
0
        /// <summary>
        /// Get all details needed to create a new list or edit existing list
        /// </summary>
        /// <param name="list">returns list details</param>
        /// <returns>true if list details completed</returns>
        public static bool GetListDetailsFromUser(ref TraktListDetail list)
        {
            // the list will have ids if it exists online
            bool editing = list.Ids != null;

            // Show Keyboard for Name of list
            string name = editing ? list.Name : string.Empty;
            if (!GUIUtils.GetStringFromKeyboard(ref name)) return false;
            if ((list.Name = name) == string.Empty) return false;

            // Skip Description and get Privacy...this requires a custom dialog as
            // virtual keyboard does not allow very much text for longer descriptions.
            // We may create a custom dialog for this in future
            var items = new List<GUIListItem>();
            var item = new GUIListItem();
            int selectedItem = 0;

            // Public
            item = new GUIListItem { Label = Translation.PrivacyPublic, Label2 = Translation.Public };
            if (list.Privacy == "public") { selectedItem = 0; item.Selected = true; }
            items.Add(item);
            // Private
            item = new GUIListItem { Label = Translation.PrivacyPrivate, Label2 = Translation.Private };
            if (list.Privacy == "private") { selectedItem = 1; item.Selected = true; }
            items.Add(item);
            // Friends
            item = new GUIListItem { Label = Translation.PrivacyFriends, Label2 = Translation.Friends };
            if (list.Privacy == "friends") { selectedItem = 2; item.Selected = true; }
            items.Add(item);

            selectedItem = GUIUtils.ShowMenuDialog(Translation.Privacy, items, selectedItem);
            if (selectedItem == -1) return false;

            list.Privacy = GetPrivacyLevelFromTranslation(items[selectedItem].Label2);

            // Skip 'Show Shouts' and 'Use Numbering' until we have Custom Dialog for List edits

            return true;
        }
Пример #12
0
        /// <summary>
        /// Get all details needed to create a new list or edit existing list
        /// </summary>
        /// <param name="list">returns list details</param>
        /// <returns>true if list details completed</returns>
        public static bool GetListDetailsFromUser(ref TraktList list)
        {
            list.UserName = TraktSettings.Username;
            list.Password = TraktSettings.Password;

            bool editing = !string.IsNullOrEmpty(list.Slug);

            // Show Keyboard for Name of list
            string name = editing ? list.Name : string.Empty;
            if (!GUIUtils.GetStringFromKeyboard(ref name)) return false;
            if ((list.Name = name) == string.Empty) return false;

            // Skip Description and get Privacy...this requires a custom dialog as
            // virtual keyboard does not allow very much text for longer descriptions.
            // We may create a custom dialog for this in future
            List<GUIListItem> items = new List<GUIListItem>();
            GUIListItem item = new GUIListItem();
            int selectedItem = 0;

            // Public
            item = new GUIListItem { Label = Translation.PrivacyPublic, Label2 = Translation.Public };
            if (list.Privacy == "public") { selectedItem = 0; item.Selected = true; }
            items.Add(item);
            // Private
            item = new GUIListItem { Label = Translation.PrivacyPrivate, Label2 = Translation.Private };
            if (list.Privacy == "private") { selectedItem = 1; item.Selected = true; }
            items.Add(item);
            // Friends
            item = new GUIListItem { Label = Translation.PrivacyFriends, Label2 = Translation.Friends };
            if (list.Privacy == "friends") { selectedItem = 2; item.Selected = true; }
            items.Add(item);

            selectedItem = GUIUtils.ShowMenuDialog(Translation.Privacy, items, selectedItem);
            if (selectedItem == -1) return false;

            list.Privacy = GetPrivacyLevelFromTranslation(items[selectedItem].Label2);
            return true;
        }
Пример #13
0
 /// <summary>
 /// Creates a GUIListItem based on another GUIListItem.
 /// </summary>
 /// <param name="item">The item on which the new item is based.</param>
 public GUIListItem(GUIListItem item)
 {
   _label = item._label;
   _label2 = item._label2;
   _label3 = item._label3;
   _thumbNailName = item._thumbNailName;
   _smallIconName = item._smallIconName;
   _bigIconName = item._bigIconName;
   _pinIconName = item._pinIconName;
   _isSelected = item._isSelected;
   _isFolder = item._isFolder;
   _folder = item._folder;
   _dvdLabel = item._dvdLabel;
   _duration = item._duration;
   _fileInfo = item._fileInfo;
   _rating = item._rating;
   _year = item._year;
   _idItem = item._idItem;
   _tagMusic = item._tagMusic;
   _tagTv = item._tagTv;
   _tagAlbumInfo = item._tagAlbumInfo;
   _isBdDvdFolder = item._isBdDvdFolder;
 }
Пример #14
0
        private void ShowThumbnailContextMenu()
        {
            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            if (dlg == null) return;

            dlg.Reset();
            dlg.SetHeading(Translation.Thumbnails);

            foreach (int value in Enum.GetValues(typeof(Views)))
            {
                Views thumb = (Views)Enum.Parse(typeof(Views), value.ToString());
                string label = GetThumbnailName(thumb);

                // Create new item
                GUIListItem listItem = new GUIListItem(label);
                listItem.ItemId = value;

                // Set selected if current
                if (thumb == ThumbViewMod) listItem.Selected = true;

                // Add new item to context menu
                dlg.Add(listItem);
            }

            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId <= 0) return;

            // Set new Selection
            ThumbViewMod = (Views)Enum.GetValues(typeof(Views)).GetValue(dlg.SelectedLabel);
            btnThumbViewMod.Label = dlg.SelectedLabelText;
        }
        void workerRefreshUnlinkedFiles_DoWork(object sender, DoWorkEventArgs e)
        {
            List<VideoLocalVM> unlinkedVideos = JMMServerHelper.GetUnlinkedVideos();

            List<GUIListItem> listItems = new List<GUIListItem>();

            foreach (VideoLocalVM locFile in unlinkedVideos)
            {
                GUIListItem itm = new GUIListItem(locFile.FileName);
                itm.TVTag = locFile;
                listItems.Add(itm);
            }

            e.Result = listItems;
        }
    /// <summary>
    /// Method to render a single item of the filmstrip
    /// </summary>
    /// <param name="bFocus">true if item shown be drawn focused, false for normal mode</param>
    /// <param name="dwPosX">x-coordinate of the item</param>
    /// <param name="dwPosY">y-coordinate of the item</param>
    /// <param name="pItem">item itself</param>
    private void RenderItem(int itemNumber, float timePassed, bool bFocus, int dwPosX, int dwPosY, GUIListItem pItem)
    {
      if (_font == null)
      {
        return;
      }
      if (pItem == null)
      {
        return;
      }
      if (dwPosY < 0)
      {
        return;
      }

      bool itemFocused = bFocus == true && Focus && _listType == GUIListControl.ListType.CONTROL_LIST;

      float fTextHeight = 0, fTextWidth = 0;
      _font.GetTextExtent("W", ref fTextWidth, ref fTextHeight);

      float fTextPosY = (float)dwPosY + (float)_textureHeight;

      TransformMatrix tm = null;
      long dwColor = _textColor;
      if (pItem.Selected)
      {
        dwColor = _selectedColor;
      }
      if (pItem.IsPlayed)
      {
        dwColor = _playedColor;
      }
      if (!bFocus && Focus)
      {
        dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
      }
      if (pItem.IsRemote)
      {
        dwColor = _remoteColor;
        if (pItem.IsDownloading)
        {
          dwColor = _downloadColor;
        }
      }
      if (pItem.IsBdDvdFolder)
      {
        dwColor = _bdDvdDirectoryColor;
      }
      if (!Focus)
      {
        dwColor &= DimColor;
      }

      //uint currentTime = (uint) (DXUtil.Timer(DirectXTimer.GetAbsoluteTime)*1000.0);
      uint currentTime = (uint)System.Windows.Media.Animation.AnimationTimer.TickCount;
      // Set oversized value
      int iOverSized = 0;

      if (itemFocused && _enableFocusZoom)
      {
        iOverSized = (_thumbNailWidth + _thumbNailHeight) / THUMBNAIL_OVERSIZED_DIVIDER;
      }
      GUIImage pImage = null;

      if (pItem.HasThumbnail)
      {
        pImage = pItem.Thumbnail;
        if (null == pImage && _sleeper == 0 && !IsAnimating)
        {
          pImage = new GUIImage(0, 0, _thumbNailPositionX - iOverSized + dwPosX,
                                _thumbNailPositionY - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                _thumbNailHeight + 2 * iOverSized, pItem.ThumbnailImage, 0x0);
          pImage.ParentControl = this;
          pImage.KeepAspectRatio = _keepAspectRatio;
          pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
          pImage.ImageAlignment = _imageAlignment;
          pImage.ImageVAlignment = _imageVAlignment;
          pImage.FlipX = _flipX;
          pImage.FlipY = _flipY;
          pImage.DiffuseFileName = _diffuseFileName;
          pImage.MaskFileName = _textureMask;
          pImage.SetAnimations(_allThumbAnimations);
          pImage.AllocResources();

          pItem.Thumbnail = pImage;
          pImage.SetPosition(_thumbNailPositionX - iOverSized + dwPosX, _thumbNailPositionY - iOverSized + dwPosY);
          pImage.DimColor = DimColor;
          _sleeper += SLEEP_FRAME_COUNT;
        }
        if (null != pImage)
        {
          if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
          {
            pImage.SafeDispose();
            pImage.AllocResources();
          }
          pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
          pImage.ImageAlignment = _imageAlignment;
          pImage.ImageVAlignment = _imageVAlignment;
          pImage.Width = _thumbNailWidth + 2 * iOverSized;
          pImage.Height = _thumbNailHeight + 2 * iOverSized;
          pImage.SetPosition(_thumbNailPositionX + dwPosX - iOverSized, _thumbNailPositionY - iOverSized + dwPosY);
          pImage.DimColor = DimColor;
          if (pImage.Focus != itemFocused)
          {
            _imageFolderFocus[itemNumber].Focus = !itemFocused; // ensure that _imageFolderFocus is in sync with pImage 
            _imageFolder[itemNumber].Focus = !itemFocused;
            _frameFocusControl[itemNumber].Focus = !itemFocused;
            _frameControl[itemNumber].Focus = !itemFocused;
          }
          if (itemFocused)
          {
            pImage.ColourDiffuse = 0xffffffff;
            pImage.Focus = true;
          }
          else
          {
            pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            pImage.Focus = false;
          }
          TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
          GUIGraphicsContext.ControlTransform = new TransformMatrix();
          pImage.UpdateVisibility();
          pImage.DoRender(timePassed, currentTime);
          tm = pImage.getTransformMatrix(currentTime);
          GUIGraphicsContext.ControlTransform = matrix;
        }
      }
      else
      {
        if (pItem.HasIconBig)
        {
          pImage = pItem.IconBig;
          if (null == pImage && _sleeper == 0 && !IsAnimating)
          {
            pImage = new GUIImage(0, 0, _thumbNailPositionX - iOverSized + dwPosX,
                                  _thumbNailPositionY - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                  _thumbNailHeight + 2 * iOverSized, pItem.IconImageBig, 0x0);
            pImage.ParentControl = this;
            pImage.KeepAspectRatio = _keepAspectRatio;
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.ImageAlignment = _imageAlignment;
            pImage.ImageVAlignment = _imageVAlignment;
            pImage.AllocResources();
            pImage.FlipX = _flipX;
            pImage.FlipY = _flipY;
            pImage.DiffuseFileName = _diffuseFileName;
            pImage.SetAnimations(_allThumbAnimations);
            pItem.IconBig = pImage;
            pImage.SetPosition(_thumbNailPositionX + dwPosX - iOverSized, _thumbNailPositionY - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            pImage.MaskFileName = _textureMask;

            if (itemFocused)
            {
              pImage.ColourDiffuse = 0xffffffff;
              pImage.Focus = Focus;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
              pImage.Focus = false;
            }
            _sleeper += SLEEP_FRAME_COUNT;
          }
          if (null != pImage)
          {
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.ImageAlignment = _imageAlignment;
            pImage.ImageVAlignment = _imageVAlignment;
            pImage.Width = _thumbNailWidth + 2 * iOverSized;
            pImage.Height = _thumbNailHeight + 2 * iOverSized;
            pImage.SetPosition(_thumbNailPositionX - iOverSized + dwPosX, _thumbNailPositionY - iOverSized + dwPosY);
            pImage.DimColor = DimColor;

            if (itemFocused)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (pImage.Focus != itemFocused)
            {
              _imageFolderFocus[itemNumber].Focus = !itemFocused;
              // ensure that _imageFolderFocus is in sync with pImage  }
              _imageFolder[itemNumber].Focus = !itemFocused;
              _frameFocusControl[itemNumber].Focus = !itemFocused;
              _frameControl[itemNumber].Focus = !itemFocused;
            }
            pImage.Focus = itemFocused;


            TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
            GUIGraphicsContext.ControlTransform = new TransformMatrix();

            pImage.UpdateVisibility();
            pImage.DoRender(timePassed, currentTime);
            tm = pImage.getTransformMatrix(currentTime);
            GUIGraphicsContext.ControlTransform = matrix;
          }
        }
      }

      if (bFocus == true && Focus && _listType == GUIListControl.ListType.CONTROL_LIST)
      {
        TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
        GUIGraphicsContext.ControlTransform = new TransformMatrix();
        //doesn't render items when scrolling left if this "if" clause is uncommented - should be fixed later
        if (!_scrollingLeft)
        {
          if (_showFolder)
          {
            _imageFolderFocus[itemNumber].SetPosition(dwPosX, dwPosY);
            _imageFolder[itemNumber].Focus = true;
            _imageFolderFocus[itemNumber].Focus = true;

            if (true == _showTexture)
            {
              _imageFolderFocus[itemNumber].UpdateVisibility();
              _imageFolderFocus[itemNumber].DoRender(timePassed, currentTime);
            }
            for (int i = 0; i < _imageFolderFocus.Count; ++i)
            {
              if (i != itemNumber)
              {
                _imageFolder[i].Focus = false;
                _imageFolderFocus[i].Focus = false;
              }
            }
          }

          if (_showFrame)
          {
            _frameFocusControl[itemNumber].Focus = true;
            _frameFocusControl[itemNumber].SetPosition(dwPosX, dwPosY);
            _frameFocusControl[itemNumber].UpdateVisibility();
            _frameFocusControl[itemNumber].DoRender(timePassed, currentTime);
            for (int i = 0; i < _frameFocusControl.Count; ++i)
            {
              if (i != itemNumber)
              {
                _frameControl[i].Focus = false;
                _frameFocusControl[i].Focus = false;
              }
            }
          }
        }

        if (tm != null)
        {
          GUIGraphicsContext.AddTransform(tm);
        }

        _listLabels[itemNumber].XPosition = dwPosX + _textXOff;
        _listLabels[itemNumber].YPosition = (int)Math.Truncate(fTextPosY + _textYOff);
        _listLabels[itemNumber].Width = _textureWidth;
        _listLabels[itemNumber].Height = _textureHeight;
        _listLabels[itemNumber].TextColor = dwColor;
        _listLabels[itemNumber].Label = pItem.Label;
        _listLabels[itemNumber].AllowScrolling = true;
        _listLabels[itemNumber].Render(timePassed);

        if (tm != null)
        {
          GUIGraphicsContext.RemoveTransform();
        }
        GUIGraphicsContext.ControlTransform = matrix;
      }
      else
      {
        TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
        GUIGraphicsContext.ControlTransform = new TransformMatrix();
        //doesn't render items when scrolling left if this "if" clause is uncommented - should be fixed later
        if (!_scrollingLeft)
        {
          if (_showFolder)
          {
            _imageFolder[itemNumber].SetPosition(dwPosX, dwPosY);
            _imageFolder[itemNumber].Focus = false;
            _imageFolderFocus[itemNumber].Focus = false;
            if (true == _showTexture)
            {
              _imageFolder[itemNumber].UpdateVisibility();
              _imageFolder[itemNumber].DoRender(timePassed, currentTime);
            }
          }

          if (_showFrame)
          {
            _frameControl[itemNumber].Focus = false;
            _frameFocusControl[itemNumber].Focus = false;
            _frameControl[itemNumber].SetPosition(dwPosX, dwPosY);
            _frameControl[itemNumber].UpdateVisibility();
            _frameControl[itemNumber].DoRender(timePassed, currentTime);
          }
        }

        if (tm != null)
        {
          GUIGraphicsContext.AddTransform(tm);
        }
        _listLabels[itemNumber].XPosition = dwPosX + _textXOff;
        _listLabels[itemNumber].YPosition = (int)Math.Truncate(fTextPosY + _textYOff);
        _listLabels[itemNumber].Width = _textureWidth;
        _listLabels[itemNumber].Height = _textureHeight;
        _listLabels[itemNumber].TextColor = dwColor;
        _listLabels[itemNumber].Label = pItem.Label;
        _listLabels[itemNumber].AllowScrolling = false;
        _listLabels[itemNumber].Render(timePassed);
        if (tm != null)
        {
          GUIGraphicsContext.RemoveTransform();
        }
        GUIGraphicsContext.ControlTransform = matrix;
      }
    }
 public void Insert(int index, GUIListItem item)
 {
   if (item == null)
   {
     return;
   }
   _listItems.Insert(index, item);
   int iItemsPerPage = _columns;
   int iPages = iItemsPerPage == 0 ? 0 : _listItems.Count / iItemsPerPage;
   if (iItemsPerPage != 0)
   {
     if ((_listItems.Count % iItemsPerPage) != 0)
     {
       iPages++;
     }
   }
   if (_upDownControl != null)
   {
     _upDownControl.SetRange(1, iPages);
     _upDownControl.Value = 1;
   }
   _refresh = true;
 }
 public void Replace(int index, GUIListItem item)
 {
   if (item != null && index >= 0 && index < _listItems.Count)
   {
     _listItems[index] = item;
   }
 }
Пример #19
0
    private void OnActiveStreams()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(692); // Active Tv Streams
      int selected = 0;

      IList<Card> cards = TvDatabase.Card.ListAll();
      List<Channel> channels = new List<Channel>();
      int count = 0;
      TvServer server = new TvServer();
      List<IUser> _users = new List<IUser>();
      foreach (Card card in cards)
      {
        if (card.Enabled == false)
        {
          continue;
        }
        if (!RemoteControl.Instance.CardPresent(card.IdCard))
        {
          continue;
        }
        IUser[] users = RemoteControl.Instance.GetUsersForCard(card.IdCard);
        if (users == null)
        {
          return;
        }
        for (int i = 0; i < users.Length; ++i)
        {
          IUser user = users[i];
          if (card.IdCard != user.CardId)
          {
            continue;
          }
          bool isRecording;
          bool isTimeShifting;
          VirtualCard tvcard = new VirtualCard(user, RemoteControl.HostName);
          isRecording = tvcard.IsRecording;
          isTimeShifting = tvcard.IsTimeShifting;
          if (isTimeShifting || (isRecording && !isTimeShifting))
          {
            int idChannel = tvcard.IdChannel;
            user = tvcard.User;
            Channel ch = Channel.Retrieve(idChannel);
            channels.Add(ch);
            GUIListItem item = new GUIListItem();
            item.Label = ch.DisplayName;
            item.Label2 = user.Name;
            string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, ch.DisplayName);
            if (string.IsNullOrEmpty(strLogo))
            {
              strLogo = "defaultVideoBig.png";
            }
            item.IconImage = strLogo;
            if (isRecording)
            {
              item.PinImage = Thumbs.TvRecordingIcon;
            }
            else
            {
              item.PinImage = "";
            }
            dlg.Add(item);
            _users.Add(user);
            if (Card != null && Card.IdChannel == idChannel)
            {
              selected = count;
            }
            count++;
          }
        }
      }
      if (channels.Count == 0)
      {
        GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
        if (pDlgOK != null)
        {
          pDlgOK.SetHeading(692); //my tv
          pDlgOK.SetLine(1, GUILocalizeStrings.Get(1511)); // No Active streams
          pDlgOK.SetLine(2, "");
          pDlgOK.DoModal(this.GetID);
        }
        return;
      }
      dlg.SelectedLabel = selected;
      dlg.DoModal(this.GetID);
      if (dlg.SelectedLabel < 0)
      {
        return;
      }

      VirtualCard vCard = new VirtualCard(_users[dlg.SelectedLabel], RemoteControl.HostName);
      Channel channel = Navigator.GetChannel(vCard.IdChannel);
      ViewChannel(channel);
    }
        private void SetText(string strText)
        {
            try
            {
                _listItems.DisposeAndClearList();
                // start wordwrapping
                // Set a flag so we can determine initial justification effects
                //bool bStartingNewLine = true;
                //bool bBreakAtSpace = false;
                int    pos              = 0;
                int    lpos             = 0;
                int    iLastSpace       = -1;
                int    iLastSpaceInLine = -1;
                string szLine           = "";
                strText = strText.Replace("\r", " ");
                strText.Trim();
                while (pos < strText.Length)
                {
                    // Get the current letter in the string
                    char letter = strText[pos];

                    // Handle the newline character
                    if (letter == '\n')
                    {
                        if (szLine.Length > 0 || _listItems.Count > 0)
                        {
                            GUIListItem item = new GUIListItem(szLine);
                            item.DimColor = DimColor;
                            _listItems.Add(item);
                        }
                        iLastSpace       = -1;
                        iLastSpaceInLine = -1;
                        lpos             = 0;
                        szLine           = "";
                    }
                    else
                    {
                        if (letter == ' ')
                        {
                            iLastSpace       = pos;
                            iLastSpaceInLine = lpos;
                        }

                        if (lpos < 0 || lpos > 1023)
                        {
                            //OutputDebugString("ERRROR\n");
                        }
                        szLine += letter;

                        float  fwidth = 0, fheight = 0;
                        string wsTmp = szLine;
                        _font.GetTextExtent(wsTmp, ref fwidth, ref fheight);
                        if (fwidth > (_width - _xOffset))
                        {
                            if (iLastSpace > 0 && iLastSpaceInLine != lpos)
                            {
                                szLine = szLine.Substring(0, iLastSpaceInLine);
                                pos    = iLastSpace;
                            }
                            if (szLine.Length > 0 || _listItems.Count > 0)
                            {
                                GUIListItem item = new GUIListItem(szLine);
                                item.DimColor = DimColor;
                                _listItems.Add(item);
                            }
                            iLastSpaceInLine = -1;
                            iLastSpace       = -1;
                            lpos             = 0;
                            szLine           = "";
                        }
                        else
                        {
                            lpos++;
                        }
                    }
                    pos++;
                }
                if (lpos > 0)
                {
                    GUIListItem item = new GUIListItem(szLine);
                    item.DimColor = DimColor;
                    _listItems.Add(item);
                }

                int istart = -1;
                for (int i = 0; i < _listItems.Count; ++i)
                {
                    GUIListItem item = (GUIListItem)_listItems[i];
                    if (item.Label.Length != 0)
                    {
                        istart = -1;
                    }
                    else if (istart == -1)
                    {
                        istart = i;
                    }
                }
                if (istart > 0)
                {
                    _listItems.RemoveRange(istart, _listItems.Count - istart);
                }

                // Set _timeElapsed to be 0 so we delay scrolling again
                _timeElapsed  = 0.0f;
                _scrollOffset = 0.0f;
            }
            catch (Exception ex)
            {
                Log.Error("TextBoxScrollUp: Error in SetText - {0}", ex.ToString());
            }
        }
    private void InsertDefaultValues()
    {
      lcRefreshRatesList.Clear();
      _defaultHz.Clear();
      Settings xmlreader = new MPSettings();
      //first time mp config is run, no refreshrate settings available, create the default ones.
      string[] p = new String[4];
      p[0] = "CINEMA";
      p[1] = "23.976;24"; // fps
      p[2] = "24"; //hz
      p[3] = ""; //action
      GUIListItem item = new GUIListItem();
      RefreshRateData refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]);
      item.Label = p[0];
      item.AlbumInfoTag = refreshRateData;
      item.OnItemSelected += OnItemSelected;
      lcRefreshRatesList.Add(item);
      _defaultHz.Add(p[0]);

      p = new String[4];
      p[0] = "PAL";
      p[1] = "25"; // fps
      p[2] = "50"; //hz
      p[3] = ""; //action
      item = new GUIListItem();
      refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]);
      item.Label = p[0];
      item.AlbumInfoTag = refreshRateData;
      item.OnItemSelected += OnItemSelected;
      lcRefreshRatesList.Add(item);
      _defaultHz.Add(p[0]);

      p = new String[4];
      p[0] = "HDTV";
      p[1] = "50"; // fps
      p[2] = "50"; //hz
      p[3] = ""; //action
      item = new GUIListItem();
      refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]);
      item.Label = p[0];
      item.AlbumInfoTag = refreshRateData;
      item.OnItemSelected += OnItemSelected;
      lcRefreshRatesList.Add(item);
      _defaultHz.Add(p[0]);

      p = new String[4];
      p[0] = "NTSC";
      p[1] = "29.97;30"; // fps
      p[2] = "60"; //hz
      p[3] = ""; //action
      item = new GUIListItem();
      refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]);
      item.Label = p[0];
      item.AlbumInfoTag = refreshRateData;
      item.OnItemSelected += OnItemSelected;
      lcRefreshRatesList.Add(item);
      _defaultHz.Add(p[0]);

      //tv section is not editable, it's static.
      string tvExtCmd = xmlreader.GetValueAsString("general", "refreshrateTV_ext", "");
      string tvName = xmlreader.GetValueAsString("general", "refreshrateTV_name", "PAL");
      string tvFPS = xmlreader.GetValueAsString("general", "tv_fps", "25");
      string tvHz = xmlreader.GetValueAsString("general", "tv_hz", "50");

      String[] parameters = new String[4];
      parameters = new String[4];
      parameters[0] = "TV";
      parameters[1] = tvFPS; // fps
      parameters[2] = tvHz; //hz
      parameters[3] = tvExtCmd; //action
      item = new GUIListItem();
      refreshRateData = new RefreshRateData(parameters[0], parameters[1], parameters[2], parameters[3]);
      item.Label = parameters[0];
      item.AlbumInfoTag = refreshRateData;
      item.OnItemSelected += OnItemSelected;
      lcRefreshRatesList.Add(item);
      _defaultHz.Add(parameters[0]);
    }
    protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
    {
      // Enable
      if (control == btnEnableDynamicRefreshRate)
      {
        EnableControls();
        SettingsChanged(true);
      }
      if (_name.ToLowerInvariant().IndexOf("tv") < 1)
      {
        // Remove
        if (control == btnRemove)
        {
          int sIndex = lcRefreshRatesList.SelectedListItemIndex;
          lcRefreshRatesList.RemoveItem(sIndex);
          _defaultHz.RemoveAt(sIndex);

          if (sIndex > 0)
          {
            sIndex--;
            lcRefreshRatesList.SelectedListItemIndex = sIndex;
          }
          SettingsChanged(true);
        }
        
        // Default
        if (control == btnDefault)
        {
          InsertDefaultValues();
          SettingsChanged(true);
        }
        
        if (control == btnUseDefaultRefreshRate)
        {
          if (btnUseDefaultRefreshRate.Selected)
          {
            btnSelectDefaultRefreshRate.IsEnabled = true;
          }
          else
          {
            btnSelectDefaultRefreshRate.IsEnabled = false;
          }
          SettingsChanged(true);
        }
        
        // Add
        if (control == btnAdd)
        {
          _newRefreshRateListItem = new GUIListItem();
          _newRateDataInfo = new RefreshRateData("", "", "", "");
          OnAddItem();

          if (_newRateDataInfo.Name != string.Empty)
          {
            if (_newRateDataInfo.FrameRate != string.Empty)
            {
              if (_newRateDataInfo.Refreshrate != string.Empty)
              {
                _newRefreshRateListItem.Label = _newRateDataInfo.Name;
                _newRefreshRateListItem.AlbumInfoTag = _newRateDataInfo;
                _newRefreshRateListItem.OnItemSelected += OnItemSelected;
                lcRefreshRatesList.Add(_newRefreshRateListItem);
                _defaultHz.Add(_name);
                UpdateRefreshRateDataFields();
                SetProperties();
              }
            }
          }
          SettingsChanged(true);
        }
        // Edit
        if (control == btnEdit)
        {
          OnEditItem();
          
          if (_name != string.Empty)
          {
            if (_framerate != string.Empty)
            {
              if (_refreshrate != string.Empty)
              {
                lcRefreshRatesList.SelectedListItem.Label = _name;
                _newRateDataInfo = new RefreshRateData(_name, _framerate, _refreshrate, _action);
                lcRefreshRatesList.SelectedListItem.AlbumInfoTag = _newRateDataInfo;
                _defaultHz[_defaultHzIndex] = _name;
                UpdateRefreshRateDataFields();
                SetProperties();
                SettingsChanged(true);
              }
            }
          }
        }
      }
      
      // Use default
      if (control == btnUseDefaultRefreshRate)
      {
        EnableControls();
        SettingsChanged(true);
      }
      
      // Select default refreshrate
      if (control == btnSelectDefaultRefreshRate)
      {
        OnSelectDefaultRefreshRate();
        SettingsChanged(true);
      }

      base.OnClicked(controlId, control, actionType);
    }
    private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram)
    {
      int itemToSelect = -1;
      lstUpcomingEpsiodes.Clear();
      TvBusinessLayer layer = new TvBusinessLayer();
      DateTime dtDay = DateTime.Now;

      // build a list of all upcoming instances of program from EPG data based on program name alone
      List<Program> episodes = (List<Program>)layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(28), initialProgram.Title, null);

      // now if schedule is time based then build a second list for that schedule based on start time (see below)
      IList<Program> actualUpcomingEps = new List<Program>();      
      if (currentSchedule != null)
      {
        int scheduletype = currentSchedule.ScheduleType;        

        switch (scheduletype)
        {
          case (int)ScheduleRecordingType.Weekly:
            actualUpcomingEps = Program.RetrieveWeekly(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
            break;

          case (int)ScheduleRecordingType.Weekends:
            actualUpcomingEps = Program.RetrieveWeekends(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
            break;

          case (int)ScheduleRecordingType.WorkingDays:
            actualUpcomingEps = Program.RetrieveWorkingDays(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
            break;

          case (int)ScheduleRecordingType.Daily:
          actualUpcomingEps = Program.RetrieveDaily(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel);
          break;
        }
       
        // now if we have a time based schedule then loop through that and if entry does not exist
        // in the original list then add it
        // an entry will exist in the second list but not first if the program name is different
        // in reality this will probably be a series that has finished
        // eg. we have set a schedule for channel X for Monday 21:00 to 22:00 which happens to be when 
        // program A is on.   The series for program A finishes and now between 21:00 and 22:00 on 
        // channel X is program B.   A time based schedule does not take the program name into account
        // therefore program B will get recorded.
        if (actualUpcomingEps.Count > 0)
        {
          for (int i = actualUpcomingEps.Count - 1; i >= 0; i--)
          {
            Program ep = actualUpcomingEps[i];

            if (!episodes.Contains(ep))
            {
              episodes.Add(ep);
            }
          }
          episodes.Sort((x, y) => (x.StartTime.CompareTo(y.StartTime))); //resort list locally on starttime
        }

      }
      bool updateCurrentProgram = true;
      anyUpcomingEpisodesRecording = false;
      int activeRecordings = 0;
      for (int i = 0; i < episodes.Count; i++)
      {        
        Program episode = episodes[i];
        GUIListItem item = new GUIListItem();
        item.Label = TVUtil.GetDisplayTitle(episode);
        item.OnItemSelected += item_OnItemSelected;
        string logo = Utils.GetCoverArt(Thumbs.TVChannel, episode.ReferencedChannel().DisplayName);
        if (string.IsNullOrEmpty(logo))                      
        {
          item.Label = String.Format("{0} {1}", episode.ReferencedChannel().DisplayName, TVUtil.GetDisplayTitle(episode));
          logo = "defaultVideoBig.png";
        }

        bool isActualUpcomingEps = actualUpcomingEps.Contains(episode) ;
        bool isRecPrg = isActualUpcomingEps;
        Schedule recordingSchedule = currentSchedule;

        // appears a little odd but seems to work
        // if episode is not in second (time based) list then override isRecPrg by actually
        // checking if episode is due to be recorded (if it is in second (time based) list then
        // it is going to be recorded
        if (!isActualUpcomingEps)
        {
            isRecPrg = (episode.IsRecording || episode.IsRecordingOncePending || episode.IsRecordingSeriesPending || 
                        episode.IsPartialRecordingSeriesPending) && IsRecordingProgram(episode, out recordingSchedule, true);
        }
        if (isRecPrg)
        {          
          if (!recordingSchedule.IsSerieIsCanceled(recordingSchedule.GetSchedStartTimeForProg(episode), episode.IdChannel))
          {
            bool hasConflict = recordingSchedule.ReferringConflicts().Count > 0;
            bool isPartialRecording = false;
            bool isSeries = (recordingSchedule.ScheduleType != (int)ScheduleRecordingType.Once);

            //check for partial recordings.
            if (isActualUpcomingEps && currentSchedule != null)
            {
              isPartialRecording = Schedule.IsPartialRecording(currentSchedule, episode);
            }
            if (isPartialRecording)
            {
              item.PinImage = hasConflict ? 
                (isSeries? Thumbs.TvConflictPartialRecordingSeriesIcon : Thumbs.TvConflictPartialRecordingIcon) : 
                (isSeries? Thumbs.TvPartialRecordingSeriesIcon : Thumbs.TvPartialRecordingIcon);
            }
            else
            {
              item.PinImage = hasConflict ? 
                (isSeries? Thumbs.TvConflictRecordingSeriesIcon : Thumbs.TvConflictRecordingIcon) : 
                (isSeries? Thumbs.TvRecordingSeriesIcon : Thumbs.TvRecordingIcon);
            }

            if (updateCurrentProgram)
            {
              //currentProgram = episode;
            }
            activeRecordings++;
            anyUpcomingEpisodesRecording = true;
            updateCurrentProgram = false;
          }          
          item.TVTag = recordingSchedule;
        }
        else
        {
          if (episode.Notify)
          {
            item.PinImage = Thumbs.TvNotifyIcon;
          }
        }

        item.MusicTag = episode;
        item.ThumbnailImage = item.IconImageBig = item.IconImage = logo;

        item.Label2 = String.Format("{0} {1} - {2}",
                                    Utils.GetShortDayString(episode.StartTime),
                                    episode.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                    episode.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

        if (lastSelectedProgram != null)
        {
          if (lastSelectedProgram.IdChannel == episode.IdChannel &&
              lastSelectedProgram.StartTime == episode.StartTime &&
              lastSelectedProgram.EndTime == episode.EndTime && lastSelectedProgram.Title == episode.Title)
          {
            itemToSelect = lstUpcomingEpsiodes.Count;
          }
        }
        lstUpcomingEpsiodes.Add(item);
      }


      if (!anyUpcomingEpisodesRecording)
      {
        currentProgram = initialProgram;
      }

      if (itemToSelect != -1)
      {
        lstUpcomingEpsiodes.SelectedListItemIndex = itemToSelect;
      }

      lblUpcomingEpsiodes.Label = GUILocalizeStrings.Get(1203, new object[] { activeRecordings });

      //set object count label
      GUIPropertyManager.SetProperty("#itemcount", Utils.GetObjectCountLabel(lstUpcomingEpsiodes.ListItems.Count));
    }
    public static void CreateProgram(Program program, int scheduleType, int dialogId)
    {
      Log.Debug("TVProgramInfo.CreateProgram: program = {0}", program.ToString());
      Schedule schedule;
      Schedule saveSchedule = null;
      TvBusinessLayer layer = new TvBusinessLayer();
      if (IsRecordingProgram(program, out schedule, false)) // check if schedule is already existing
      {
        Log.Debug("TVProgramInfo.CreateProgram - series schedule found ID={0}, Type={1}", schedule.IdSchedule,
                  schedule.ScheduleType);
        Log.Debug("                            - schedule= {0}", schedule.ToString());
        //schedule = Schedule.Retrieve(schedule.IdSchedule); // get the correct informations
        if (schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel))
        {
          //lets delete the cancelled schedule.

          saveSchedule = schedule;
          schedule = new Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime);

          schedule.PreRecordInterval = saveSchedule.PreRecordInterval;
          schedule.PostRecordInterval = saveSchedule.PostRecordInterval;
          schedule.ScheduleType = (int)ScheduleRecordingType.Once; // needed for layer.GetConflictingSchedules(...)
        }
      }
      else
      {
        Log.Debug("TVProgramInfo.CreateProgram - no series schedule");
        // no series schedule => create it
        schedule = new Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime);
        schedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
        schedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);
        schedule.ScheduleType = scheduleType;
      }

      // check if this program is conflicting with any other already scheduled recording
      IList conflicts = layer.GetConflictingSchedules(schedule);
      Log.Debug("TVProgramInfo.CreateProgram - conflicts.Count = {0}", conflicts.Count);
      TvServer server = new TvServer();
      bool skipConflictingEpisodes = false;
      if (conflicts.Count > 0)
      {
        TVConflictDialog dlg =
          (TVConflictDialog)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_TVCONFLICT);
        if (dlg != null)
        {
          dlg.Reset();
          dlg.SetHeading(GUILocalizeStrings.Get(879)); // "recording conflict"
          foreach (Schedule conflict in conflicts)
          {
            Log.Debug("TVProgramInfo.CreateProgram: Conflicts = " + conflict);

            GUIListItem item = new GUIListItem(conflict.ProgramName);
            item.Label2 = GetRecordingDateTime(conflict);
            Channel channel = Channel.Retrieve(conflict.IdChannel);
            if (channel != null && !string.IsNullOrEmpty(channel.DisplayName))
            {
              item.Label3 = channel.DisplayName;
            }
            else
            {
              item.Label3 = conflict.IdChannel.ToString();
            }
            item.TVTag = conflict;
            dlg.AddConflictRecording(item);
          }
          dlg.ConflictingEpisodes = (scheduleType != (int)ScheduleRecordingType.Once);
          dlg.DoModal(dialogId);
          switch (dlg.SelectedLabel)
          {
            case 0: // Skip new Recording
              {
                Log.Debug("TVProgramInfo.CreateProgram: Skip new recording");
                return;
              }
            case 1: // Don't record the already scheduled one(s)
              {
                Log.Debug("TVProgramInfo.CreateProgram: Skip old recording(s)");
                foreach (Schedule conflict in conflicts)
                {
                  Program prog =
                    new Program(conflict.IdChannel, conflict.StartTime, conflict.EndTime, conflict.ProgramName, "-", "-",
                                Program.ProgramState.None,
                                DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                string.Empty, -1);
                  CancelProgram(prog, Schedule.Retrieve(conflict.IdSchedule), dialogId);
                }
                break;
              }
            case 2: // keep conflict
              {
                Log.Debug("TVProgramInfo.CreateProgram: Keep Conflict");
                break;
              }
            case 3: // Skip for conflicting episodes
              {
                Log.Debug("TVProgramInfo.CreateProgram: Skip conflicting episode(s)");
                skipConflictingEpisodes = true;
                break;
              }
            default: // Skipping new Recording
              {
                Log.Debug("TVProgramInfo.CreateProgram: Default => Skip new recording");
                return;
              }
          }
        }
      }

      if (saveSchedule != null)
      {
        Log.Debug("TVProgramInfo.CreateProgram - UnCancleSerie at {0}", program.StartTime);
        saveSchedule.UnCancelSerie(program.StartTime, program.IdChannel);
        //saveSchedule.UnCancelSerie();
        saveSchedule.Persist();
        currentSchedule = saveSchedule;
      }
      else
      {
        Log.Debug("TVProgramInfo.CreateProgram - create schedule = {0}", schedule.ToString());
        schedule.Persist();

        if (currentSchedule == null || (currentSchedule.ScheduleType > 0 && schedule.ScheduleType != (int)ScheduleRecordingType.Once))
        {
          currentSchedule = schedule;
        }
      }
      if (skipConflictingEpisodes)
      {
        List<Schedule> episodes = layer.GetRecordingTimes(schedule);
        foreach (Schedule episode in episodes)
        {
          if (DateTime.Now > episode.EndTime)
          {
            continue;
          }
          if (episode.IsSerieIsCanceled(episode.StartTime, program.IdChannel))
          {
            continue;
          }
          foreach (Schedule conflict in conflicts)
          {
            if (episode.IsOverlapping(conflict))
            {
              Log.Debug("TVProgramInfo.CreateProgram - skip episode = {0}", episode.ToString());
              CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, program.IdChannel, episode.StartTime);
              canceledSchedule.Persist();
            }
          }
        }
      }
      server.OnNewSchedule();
    }
 private void item_OnItemSelected(GUIListItem item, GUIControl parent)
 {
   lock (updateLock)
   {
     if (item != null && item.MusicTag != null)
     {
       //CacheManager.ClearQueryResultsByType(typeof(Program));
       Program lstProg = item.MusicTag as Program;
       if (lstProg != null)
       {
         ScheduleInfo refEpisode = new ScheduleInfo(
           lstProg.IdChannel,
           TVUtil.GetDisplayTitle(lstProg),
           lstProg.Description,
           lstProg.Genre,
           lstProg.StartTime,
           lstProg.EndTime
           );
         GUIGraphicsContext.form.Invoke(new UpdateCurrentItem(UpdateProgramDescription), new object[] {refEpisode});
       }
     }
     else
     {
       Log.Warn("TVProgrammInfo.item_OnItemSelected: params where NULL!");
     }
   }
 }
Пример #26
0
    private void OnActiveRecordings(IList<Recording> ignoreActiveRecordings)
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }

      dlg.Reset();
      dlg.SetHeading(200052); // Active Recordings      

      IList<Recording> activeRecordings = Recording.ListAllActive();
      if (activeRecordings != null && activeRecordings.Count > 0)
      {
        foreach (Recording activeRecording in activeRecordings)
        {
          if (!ignoreActiveRecordings.Contains(activeRecording))
          {
            GUIListItem item = new GUIListItem();
            string channelName = activeRecording.ReferencedChannel().DisplayName;
            string programTitle = activeRecording.Title.Trim(); // default is current EPG info

            item.Label = channelName;
            item.Label2 = programTitle;

            string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, channelName);
            if (string.IsNullOrEmpty(strLogo))
            {
              strLogo = "defaultVideoBig.png";
            }

            item.IconImage = strLogo;
            item.IconImageBig = strLogo;
            item.PinImage = "";
            dlg.Add(item);
          }
        }

        dlg.SelectedLabel = activeRecordings.Count;

        dlg.DoModal(this.GetID);
        if (dlg.SelectedLabel < 0)
        {
          return;
        }

        if (dlg.SelectedLabel < 0 || (dlg.SelectedLabel - 1 > activeRecordings.Count))
        {
          return;
        }

        Recording selectedRecording = activeRecordings[dlg.SelectedLabel];
        Schedule parentSchedule = selectedRecording.ReferencedSchedule();
        if (parentSchedule == null || parentSchedule.IdSchedule < 1)
        {
          return;
        }
        bool deleted = TVUtil.StopRecAndSchedWithPrompt(parentSchedule, selectedRecording.IdChannel);
        if (deleted && !ignoreActiveRecordings.Contains(selectedRecording))
        {
          ignoreActiveRecordings.Add(selectedRecording);
        }
        OnActiveRecordings(ignoreActiveRecordings); //keep on showing the list until --> 1) user leaves menu, 2) no more active recordings
      }
      else
      {
        GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
        if (pDlgOK != null)
        {
          pDlgOK.SetHeading(200052); //my tv
          pDlgOK.SetLine(1, GUILocalizeStrings.Get(200053)); // No Active recordings
          pDlgOK.SetLine(2, "");
          pDlgOK.DoModal(this.GetID);
        }
      }
    }
    private void LoadSettings()
    {
      using (Settings xmlreader = new MPSettings())
      {
        btnEnableDynamicRefreshRate.Selected = xmlreader.GetValueAsBool("general", "autochangerefreshrate", false);
        btnNotify.Selected = xmlreader.GetValueAsBool("general", "notify_on_refreshrate", false);
        btnUseDefaultRefreshRate.Selected = xmlreader.GetValueAsBool("general", "use_default_hz", false);
        btnUseDeviceReset.Selected = xmlreader.GetValueAsBool("general", "devicereset", false);
        btnForceRefreshRateChange.Selected = xmlreader.GetValueAsBool("general", "force_refresh_rate", false);
        _sDefaultHz = xmlreader.GetValueAsString("general", "default_hz", "");

        String[] p = null;
        _defaultHzIndex = -1;
        _defaultHz.Clear();

        for (int i = 1; i < 100; i++)
        {
          string extCmd = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_ext", "");
          string name = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_name", "");

          if (string.IsNullOrEmpty(name))
          {
            continue;
          }

          string fps = xmlreader.GetValueAsString("general", name + "_fps", "");
          string hz = xmlreader.GetValueAsString("general", name + "_hz", "");

          p = new String[4];
          p[0] = name;
          p[1] = fps; // fps
          p[2] = hz; //hz
          p[3] = extCmd; //action
          RefreshRateData refreshRateData = new RefreshRateData(name, fps, hz, extCmd);
          GUIListItem item = new GUIListItem();
          item.Label = p[0];
          item.AlbumInfoTag = refreshRateData;
          item.OnItemSelected += OnItemSelected;
          lcRefreshRatesList.Add(item);
          _defaultHz.Add(p[0]);

          if (_sDefaultHz == hz)
          {
            _defaultHzIndex = i - 1;
          }
        }

        if (lcRefreshRatesList.Count == 0)
        {
          InsertDefaultValues();
        }
        lcRefreshRatesList.SelectedListItemIndex = 0;
      }
    }
Пример #28
0
        protected void UpdateListItems()
        {
            Log.Debug("[TVWishListMP GUI_Edit]:UpdateListItems");
            //display edit items
            GUIControl.ClearControl(GetID, myfacade.GetID);            
            
            Log.Debug("myTvWishes.ListAll() " + myTvWishes.ListAll().ToString());
            //string[] edit_item_names = new string[24];
           
            Log.Debug("_listTranslator.Length=" + _listTranslator.Length.ToString());
            for (int i = 0; i < _listTranslator.Length;i++ )
            {
                _listTranslator[i] = -1;
            }
            try
            {
                myfacade.Clear();
                Log.Debug("myTvWishes.FocusedWishIndex=" + myTvWishes.FocusedWishIndex.ToString());
                TvWish mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                int ctr = 0;

                AddEditItem((int)TvWishEntries.active, mywish.active, ref ctr);
                AddEditItem((int)TvWishEntries.name, mywish.name, ref ctr);
                AddEditItem((int)TvWishEntries.searchfor, mywish.searchfor, ref ctr);
                AddEditItem((int)TvWishEntries.matchtype, mywish.matchtype, ref ctr);
                AddEditItem((int)TvWishEntries.exclude, mywish.exclude, ref ctr);
                AddEditItem((int)TvWishEntries.recordtype, mywish.recordtype, ref ctr);
                AddEditItem((int)TvWishEntries.action, mywish.action, ref ctr);
                AddEditItem((int)TvWishEntries.group, mywish.group, ref ctr);
                AddEditItem((int)TvWishEntries.channel, mywish.channel, ref ctr);
                AddEditItem((int)TvWishEntries.afterdays, mywish.afterdays, ref ctr);
                AddEditItem((int)TvWishEntries.beforedays, mywish.beforedays, ref ctr);
                AddEditItem((int)TvWishEntries.aftertime, mywish.aftertime, ref ctr);
                AddEditItem((int)TvWishEntries.beforetime, mywish.beforetime, ref ctr);
                AddEditItem((int)TvWishEntries.withinNextHours, mywish.withinNextHours, ref ctr);
                AddEditItem((int)TvWishEntries.preferredgroup, mywish.preferredgroup, ref ctr);
                AddEditItem((int)TvWishEntries.includerecordings, mywish.includeRecordings, ref ctr);
                AddEditItem((int)TvWishEntries.episodename, mywish.episodename, ref ctr);
                AddEditItem((int)TvWishEntries.episodepart, mywish.episodepart, ref ctr);
                AddEditItem((int)TvWishEntries.episodenumber, mywish.episodenumber, ref ctr);
                AddEditItem((int)TvWishEntries.seriesnumber, mywish.seriesnumber, ref ctr);
                AddEditItem((int)TvWishEntries.prerecord, mywish.prerecord, ref ctr);
                AddEditItem((int)TvWishEntries.postrecord, mywish.postrecord, ref ctr);
                AddEditItem((int)TvWishEntries.keepepisodes, mywish.keepepisodes, ref ctr);
                AddEditItem((int)TvWishEntries.keepuntil, mywish.keepuntil, ref ctr);
                AddEditItem((int)TvWishEntries.priority, mywish.priority, ref ctr);
                AddEditItem((int)TvWishEntries.recommendedcard, mywish.recommendedcard, ref ctr);
                AddEditItem((int)TvWishEntries.useFolderName, mywish.useFolderName, ref ctr);
                AddEditItem((int)TvWishEntries.skip, mywish.skip, ref ctr);
                AddEditItem((int)TvWishEntries.episodecriteria, mywish.episodecriteria, ref ctr);
                //modify for listview table changes       
            }
            catch
            {
                GUIListItem myGuiListItem = new GUIListItem(PluginGuiLocalizeStrings.Get(4302));   //Error in creating item list
                myfacade.Add(myGuiListItem);
                Log.Error("Error in creating item list");
            }
        }
 private RefreshRateData RefreshRateData(GUIListItem item)
 {
   RefreshRateData refreshRateData = item.AlbumInfoTag as RefreshRateData;
   return refreshRateData;
 }
 public void Add(GUIListItem item)
 {
   if (item == null)
   {
     return;
   }
   _listItems.Add(item);
   int iItemsPerPage = _columns;
   int iPages = _listItems.Count / iItemsPerPage;
   if ((_listItems.Count % iItemsPerPage) != 0)
   {
     iPages++;
   }
   if (_upDownControl != null)
   {
     _upDownControl.SetRange(1, iPages);
     _upDownControl.Value = 1;
   }
   _refresh = true;
 }
 private void OnItemSelected(GUIListItem item, GUIControl parent)
 {
   if (item != null)
   {
     _selectedRefreshRateListItem = item;
     UpdateRefreshRateDataFields();
     SetProperties();
   }
 }
        public override void Render(float timePassed)
        {
            try
            {
                _invalidate = false;
                // Nothing visibile - save CPU cycles
                if (null == _font)
                {
                    base.Render(timePassed);
                    return;
                }
                if (GUIGraphicsContext.EditMode == false)
                {
                    if (!IsVisible)
                    {
                        base.Render(timePassed);
                        return;
                    }
                }

                int dwPosY = _positionY;

                _timeElapsed += timePassed;
                if (_frameLimiter < GUIGraphicsContext.MaxFPS)
                {
                    _frameLimiter++;
                }
                else
                {
                    _frameLimiter = 1;
                }

                if (_containsProperty)
                {
                    string strText = GUIPropertyManager.Parse(_property);

                    strText = strText.Replace("\\r", "\r");
                    if (strText != _previousProperty)
                    {
                        // Reset the scrolling position - e.g. if we switch in TV Guide between various items
                        ClearOffsets();

                        _previousProperty = strText;
                        SetText(strText);
                    }
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    _offset = 0;
                }
                if (_listItems.Count > _itemsPerPage)
                {
                    // rest before we start scrolling
                    if ((int)_timeElapsed > _scrollStartDelay)
                    {
                        _invalidate = true;
                        // apply user scroll speed setting. 1 = slowest / 10 = fastest
                        //int userSpeed = 11 - GUIGraphicsContext.ScrollSpeedVertical;           //  10 - 1

                        //if (_frameLimiter % (6 - GUIGraphicsContext.ScrollSpeedVertical) == 0)
                        //  _yPositionScroll++;
                        //_yPositionScroll = _yPositionScroll + GUIGraphicsContext.ScrollSpeedVertical;

                        int vScrollSpeed = (6 - GUIGraphicsContext.ScrollSpeedVertical);
                        if (vScrollSpeed == 0)
                        {
                            vScrollSpeed = 1;
                        }

                        _yPositionScroll += (1.0 / vScrollSpeed) * _lineSpacing; // faster scrolling, if there is bigger linespacing

                        dwPosY -= (int)((_yPositionScroll - _scrollOffset));
                        // Log.Debug("*** _frameLimiter: {0}, dwPosY: {1}, _scrollOffset: {2}, _yPositionScroll: {3}", _frameLimiter, dwPosY, _scrollOffset, _yPositionScroll);

                        if (_positionY - dwPosY >= _itemHeight * _lineSpacing)
                        {
                            // one line has been scrolled away entirely
                            dwPosY        += (int)(_itemHeight * _lineSpacing);
                            _scrollOffset += (_itemHeight * _lineSpacing);
                            _offset++;
                            if (_offset >= _listItems.Count)
                            {
                                // restart with the first line
                                if (Seperator.Length > 0)
                                {
                                    if (_offset >= _listItems.Count + 1)
                                    {
                                        _offset = 0;
                                    }
                                }
                                else
                                {
                                    _offset = 0;
                                }
                            }
                        }
                    }
                    else
                    {
                        _scrollOffset = 0.0f;
                        _frameLimiter = 1;
                        _offset       = 0;
                    }
                }
                else
                {
                    _scrollOffset = 0.0f;
                    _frameLimiter = 1;
                    _offset       = 0;
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    GUIGraphicsContext.graphics.SetClip(new Rectangle(_positionX, _positionY, _width, _height));
                }
                else
                {
                    if (_width < 1 || _height < 1)
                    {
                        base.Render(timePassed);
                        return;
                    }

                    Rectangle clipRect = new Rectangle(_positionX, _positionY, _width, _height);
                    GUIGraphicsContext.BeginClip(clipRect);
                }
                long color = _textColor;
                if (Dimmed)
                {
                    color &= DimColor;
                }
                for (int i = 0; i < 2 + _itemsPerPage; i++) // add one as the itemsPerPage might be almost one less than actual height plus one for the "incoming" item
                {
                    // skip half lines - enable, if only full lines should be visible on initial view (before scrolling starts)
                    // if (!_invalidate && i >= _itemsPerPage) continue;

                    // render each line
                    int dwPosX    = _positionX;
                    int iItem     = i + _offset;
                    int iMaxItems = _listItems.Count;
                    if (_listItems.Count > _itemsPerPage && Seperator.Length > 0)
                    {
                        iMaxItems++;
                    }

                    if (iItem >= iMaxItems)
                    {
                        if (iMaxItems > _itemsPerPage)
                        {
                            iItem -= iMaxItems;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (iItem >= 0 && iItem < iMaxItems)
                    {
                        // render item
                        string strLabel1 = "", strLabel2 = "";
                        if (iItem < _listItems.Count)
                        {
                            GUIListItem item = (GUIListItem)_listItems[iItem];
                            strLabel1 = item.Label;
                            strLabel2 = item.Label2;
                        }
                        else
                        {
                            strLabel1 = Seperator;
                        }

                        int ixoff = _xOffset;
                        int ioffy = 2;
                        GUIGraphicsContext.ScaleVertical(ref ioffy);
                        GUIGraphicsContext.ScaleHorizontal(ref ixoff);
                        string wszText1  = String.Format("{0}", strLabel1);
                        int    dMaxWidth = _width + ixoff;
                        float  x         = dwPosX;
                        if (strLabel2.Length > 0)
                        {
                            string wszText2;
                            float  fTextWidth = 0, fTextHeight = 0;
                            wszText2 = String.Format("{0}", strLabel2);
                            _font.GetTextExtent(wszText2.Trim(), ref fTextWidth, ref fTextHeight);
                            dMaxWidth -= (int)(fTextWidth);

                            switch (_textAlignment)
                            {
                            case Alignment.ALIGN_LEFT:
                            case Alignment.ALIGN_CENTER:
                                x = dwPosX + dMaxWidth;
                                break;

                            case Alignment.ALIGN_RIGHT:
                                x = dwPosX + dMaxWidth + _width;
                                break;
                            }

                            uint aColor = GUIGraphicsContext.MergeAlpha((uint)color);
                            if (Shadow)
                            {
                                uint sColor = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
                                _font.DrawShadowTextWidth(x, (float)dwPosY + ioffy,
                                                          (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor), wszText2.Trim(),
                                                          _textAlignment,
                                                          _shadowAngle, _shadowDistance, sColor, (float)dMaxWidth);
                            }
                            else
                            {
                                _font.DrawTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                    wszText2.Trim(), fTextWidth, _textAlignment);
                            }
                        }

                        switch (_textAlignment)
                        {
                        case Alignment.ALIGN_CENTER:
                        case Alignment.ALIGN_LEFT:
                            x = dwPosX;
                            break;

                        case Alignment.ALIGN_RIGHT:
                            x = dwPosX + _width;
                            break;
                        }
                        {
                            uint aColor = GUIGraphicsContext.MergeAlpha((uint)color);
                            if (Shadow)
                            {
                                uint sColor = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
                                _font.DrawShadowTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                          wszText1.Trim(), _textAlignment,
                                                          _shadowAngle, _shadowDistance, sColor, (float)dMaxWidth);
                            }
                            else
                            {
                                _font.DrawTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                    wszText1.Trim(), (float)dMaxWidth, _textAlignment);
                            }

                            // Log.Info("dw _positionY, dwPosY, _yPositionScroll, _scrollOffset: {0} {1} {2} {3} - wszText1.Trim() {4}", _positionY, dwPosY, _yPositionScroll, _scrollOffset, wszText1.Trim());

                            dwPosY += (int)(_itemHeight * _lineSpacing);
                        }
                    }
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    GUIGraphicsContext.graphics.SetClip(new Rectangle(0, 0, GUIGraphicsContext.Width, GUIGraphicsContext.Height));
                }
                else
                {
                    GUIGraphicsContext.EndClip();
                }
                base.Render(timePassed);
            }
            catch (Exception ex)
            {
                Log.Error("GUITextScrollUpControl: Error during the render process - maybe a threading issue. {0}",
                          ex.ToString());
            }
        }