A GUIControl for displaying Images.
Inheritance: GUIControl
Exemple #1
0
 private static extern unsafe void FontEngineDrawTexture2(int textureNo1, float x, float y, float nw, float nh,
                                                          float uoff, float voff, float umax, float vmax,
                                                          int color,
                                                          float[,] matrix, int textureNo2, float uoff2,
                                                          float voff2,
                                                          float umax2, float vmax2,
                                                          GUIImage.FontEngineBlendMode blendMode);
Exemple #2
0
 /// <summary>
 /// Creates the element and retrieves all information from the control
 /// </summary>
 /// <param name="control">GUIControl</param>
 public ImageElement(GUIControl control)
     : base(control)
 {
     _image = control as GUIImage;
       if (_image != null)
       {
     _bitmap = loadBitmap(_image.FileName);
       }
 }
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();
      _imageFocusRectangle = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                                  _focusedTextureName);
      thumbImage = new GUIImage(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                "#Play.Current.Thumb", 1);
      blackImage = new GUIImage(_parentControlId, _controlId, _positionX, _positionY, _width, _height, "black.png", 1);

      _imageFocusRectangle.ParentControl = this;
      thumbImage.ParentControl = this;
      blackImage.ParentControl = this;
    }
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();

      GUIGraphicsContext.ScaleHorizontal(ref _textureWidth);
      GUIGraphicsContext.ScaleVertical(ref _textureHeight);

      for (int i = 0; i < SubItemCount; ++i)
      {
        string strTexture = (string)GetSubItem(i);
        GUIImage img = new GUIImage(_parentControlId, _controlId, _positionX, _positionY, _textureWidth, _textureHeight,
                                    strTexture, 0);
        img.ParentControl = this;
        img.DimColor = DimColor;
        _itemList.Add(img);
      }
    }
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();
      _imageBackground = new GUIImage(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                      _scrollbarBackgroundName, 0);
      _imageTop = new GUIImage(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                               _scrollbarTopTextureName, 0);
      _imageBottom = new GUIImage(_parentControlId, _controlId, _positionX, _positionY, _width, _height,
                                  _scrollbarBottomTextureName, 0);

      _imageBackground.ParentControl = this;
      _imageTop.ParentControl = this;
      _imageBottom.ParentControl = this;

      _imageBackground.DimColor = DimColor;
      _imageTop.DimColor = DimColor;
      _imageBottom.DimColor = DimColor;
    }
    /// <summary>
    /// Deinitialize. Release the vertex buffer and the render target resources
    /// This function should be called at last when playing has been stopped
    /// </summary>
    public void Deinit()
    {
      GUIWindowManager.Receivers -= new SendMessageHandler(this.OnMessage);
      GUILayerManager.UnRegisterLayer(this);
      if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
      {
        //if (MadVrRenderTarget != null)
        //{
        //  //VMR9 changes the directx 9 render target. Thats why we set it back to what it was
        //  if (!MadVrRenderTarget.Disposed)
        //  {
        //    GUIGraphicsContext.DX9Device.SetRenderTarget(0, MadVrRenderTarget);
        //  }
        //  MadVrRenderTarget.Dispose();
        //  MadVrRenderTarget = null;
        //}
      }
      else if (_renderTarget != null)
      {
        //VMR9 changes the directx 9 render target. Thats why we set it back to what it was
        if (!_renderTarget.Disposed)
        {
          GUIGraphicsContext.DX9Device.SetRenderTarget(0, _renderTarget);
        }
        _renderTarget.SafeDispose();
        _renderTarget = null;
      }
      for (int i = 0; i < _vertexBuffers.Length; i++)
      {
        if (_vertexBuffers[i] != null)
        {
          _vertexBuffers[i].SafeDispose();
          _vertexBuffers[i] = null;
        }
      }
      if (_blackImage != null)
      {
        _blackImage.SafeDispose();
        _blackImage = null;
      }

      if (grabber != null) 
      {
        lock (GUIGraphicsContext.RenderModeSwitch)
        {
          grabber.Clean();
        }
      }
      SubtitleRenderer.GetInstance().Clear();

      if (GUIGraphicsContext.LastFrames != null)
      {
        foreach (Texture texture in GUIGraphicsContext.LastFrames)
        {
          texture.Dispose();
        }
        GUIGraphicsContext.LastFrames.Clear();
      }

      if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
      {
        GUIGraphicsContext.InVmr9Render = false;
        if (VMR9Util.g_vmr9 != null)
        {
          VMR9Util.g_vmr9.RestoreGuiForMadVr();
        }
      }
    }
Exemple #7
0
    public override bool OnMessage(GUIMessage message)
    {
      switch (message.Message)
      {
        case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
          {
            for (int j = 0; j < NUM_STORIES; j++)
            {
              m_feed_details[j].m_site = "";
              m_feed_details[j].m_title = "";
              m_feed_details[j].m_description = "";
            }

            base.OnMessage(message);
            LoadSettings();
            m_pSiteImage = (GUIImage)GetControl((int)Controls.CONTROL_IMAGELOGO);

            UpdateNews(true);

            return true;
          }

        case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
          {
            SaveSettings();
          }
          break;

        case GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED:
          {
            int iControl = message.SenderControlId;
            if (iControl == (int)Controls.CONTROL_LIST)
            {
              UpdateDetails();
            }
          }
          break;

        case GUIMessage.MessageType.GUI_MSG_CLICKED:
          {
            int iControl = message.SenderControlId;
            if (iControl == (int)Controls.CONTROL_BTNREFRESH)
            {
              UpdateNews(true);
            }

            if (iControl == (int)Controls.CONTROL_LIST)
            {
              String story = DownloadMainStory();

              if (story != null)
              {
                GUIDialogText dlg = (GUIDialogText)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_TEXT);
                if (dlg != null)
                {
                  dlg.Reset();
                  dlg.ResetAllControls();
                  dlg.SetHeading("Story");
                  dlg.SetText(story);
                  dlg.DoModal(GetID);
                }
              }
            }

            if (iControl == (int)Controls.CONTROL_BTNCHANNEL)
            {
              OnSelectFeed();

              return true;
            }
          }
          break;
      }
      return base.OnMessage(message);
    }
    public override void AllocResources()
    {
      Dispose();
      using (Settings xmlreader = new MPSettings())
      {
        _hidePngAnimations = (xmlreader.GetValueAsBool("general", "hidepnganimations", false));
      }

      if (_filenames == null)
      {
        _filenames = new ArrayList();

        foreach (string filename in _textureNames.Split(';'))
        {
          if (filename.IndexOfAny(new char[] {'?', '*'}) != -1)
          {
            foreach (string match in Directory.GetFiles(GUIGraphicsContext.GetThemedSkinFile(@"\media\" + filename)))
            {
              _filenames.Add(Path.GetFileName(match));
            }
          }
          else
          {
            _filenames.Add(filename.Trim());
          }
        }
      }

      _images = new GUIImage[_filenames.Count];

      int w = 0;
      int h = 0;

      if (_images != null)
      {
        for (int index = 0; index < _images.Length; index++)
        {
          _imageId++;
          _images[index] = new GUIImage(ParentID, _imageId + index, 0, 0, Width, Height, (string) _filenames[index], 0);
          _images[index].ParentControl = this;
          _images[index].ColourDiffuse = ColourDiffuse;
          _images[index].DimColor = DimColor;
          _images[index].KeepAspectRatio = _keepAspectRatio;
          _images[index].Filtering = Filtering;
          _images[index].RepeatBehavior = _repeatBehavior;
          _images[index].DiffuseFileName = _diffuseFileName;
          _images[index].MaskFileName = _maskFileName;
          _images[index].OverlayFileName = _overlayFileName;
          _images[index].FlipX = _flipX;
          _images[index].FlipY = _flipY;
          _images[index].SetBorder(_strBorder, _borderPosition, _borderTextureRepeat,
            _borderTextureRotate, _borderTextureFileName, _borderColorKey, _borderHasCorners,
            _borderCornerTextureRotate);
          _images[index].TileFill = _tileFill;
          _images[index].AllocResources();
          //_images[index].ScaleToScreenResolution(); -> causes too big images in fullscreen


          if (_images.Length > index) w = Math.Max(w, _images[index].Width);
          if (_images.Length > index) h = Math.Max(h, _images[index].Height);
          if (_images.Length > index) _renderWidth = Math.Max(_renderWidth, _images[index].RenderWidth);
          if (_images.Length > index) _renderHeight = Math.Max(_renderHeight, _images[index].RenderHeight);
          if (_images.Length > index) _textureWidth = Math.Max(_textureWidth, _images[index].TextureWidth);
          if (_images.Length > index) _textureHeight = Math.Max(_textureHeight, _images[index].TextureHeight);
        }
      }

      int x = _positionX;
      int y = _positionY;

      if (_horizontalAlignment == HorizontalAlignment.Center)
      {
        x = x - (w / 2);
      }
      else if (_horizontalAlignment == HorizontalAlignment.Right)
      {
        x = x - w;
      }

      if (_verticalAlignment == VerticalAlignment.Center)
      {
        y = y - (h / 2);
      }
      else if (_verticalAlignment == VerticalAlignment.Bottom)
      {
        y = y - h;
      }

      for (int index = 0; index < _images.Length; index++)
      {
        _images[index].SetPosition(x, y);
      }
    }
 public void SetBorderTNF(string border, GUIImage.BorderPosition position, bool repeat, bool rotate,
                          string texture, long colorKey, bool hasCorners, bool cornerRotate)
 {
   _strBorderTNF = border;
   _borderPositionTNF = position;
   _borderTextureRepeatTNF = repeat;
   _borderTextureRotateTNF = rotate;
   _borderTextureFileNameTNF = texture;
   _borderColorKeyTNF = colorKey;
   _borderHasCornersTNF = hasCorners;
   _borderCornerTextureRotateTNF = cornerRotate;
   _imageNonFocused.SetBorder(_strBorderTNF, _borderPositionTNF, _borderTextureRepeatTNF, _borderTextureRotateTNF,
                              _borderTextureFileNameTNF, _borderColorKeyTNF, _borderHasCornersTNF,
                              _borderCornerTextureRotateTNF);
 }
    public PlaneScene(VMR9Util util)
    {
      //	Log.Info("PlaneScene: ctor()");

      _textureAddress = 0;
      _vmr9Util = util;

      // Number of vertex buffers must be same as numer of segments in non-linear stretch
      _vertexBuffers = new VertexBuffer[nlsSourcePartitioning.Length];
      for (int i = 0; i < _vertexBuffers.Length; i++)
      {
        _vertexBuffers[i] = new VertexBuffer(typeof (CustomVertex.TransformedColoredTextured),
                                             4,
                                             GUIGraphicsContext.DX9Device,
                                             0,
                                             CustomVertex.TransformedColoredTextured.Format,
                                             GUIGraphicsContext.GetTexturePoolType());
      }

      _blackImage = new GUIImage(0);
      _blackImage.SetFileName("black.png");
      _blackImage.AllocResources();

      _cropSettings = new CropSettings();
    }
    /// <summary>
    /// This method gets called when the control is created and all properties has been set
    /// It allows the control todo any initialization
    /// </summary>
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();

      _imageIcon = new GUIImage(ParentID, GetID, _positionX, _positionY, 0, 0, _textureIcon, 0);
      _imageIcon2 = new GUIImage(ParentID, GetID, _positionX, _positionY, 0, 0, _textureIcon2, 0);
      _imageFocusedLeft = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureFocusedLeft, 0);
      _imageFocusedMid = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureFocusedMid, 0);
      _imageFocusedRight = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureFocusedRight, 0);
      _imageNonFocusedLeft = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureNonFocusedLeft,
                                          0);
      _imageNonFocusedMid = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height, _textureNonFocusedMid,
                                         0);
      _imageNonFocusedRight = new GUIImage(ParentID, GetID, _positionX, _positionY, Width, Height,
                                           _textureNonFocusedRight, 0);
      _isSelected = false;
      _labelControl1 = new GUILabelControl(ParentID);
      _labelControl2 = new GUILabelControl(ParentID);
      _imageIcon.ParentControl = this;
      _imageIcon2.ParentControl = this;
      _imageFocusedLeft.ParentControl = this;
      _imageFocusedMid.ParentControl = this;
      _imageFocusedRight.ParentControl = this;
      _imageNonFocusedLeft.ParentControl = this;
      _imageNonFocusedMid.ParentControl = this;
      _imageNonFocusedRight.ParentControl = this;
      _labelControl1.ParentControl = this;
      _labelControl2.ParentControl = this;

      _imageFocusedLeft.DimColor = DimColor;
      _imageFocusedMid.DimColor = DimColor;
      _imageFocusedRight.DimColor = DimColor;
      _imageNonFocusedLeft.DimColor = DimColor;
      _imageNonFocusedMid.DimColor = DimColor;
      _imageNonFocusedRight.DimColor = DimColor;
      _imageIcon.DimColor = DimColor;
      _imageIcon2.DimColor = DimColor;
      _labelControl1.DimColor = DimColor;
      _labelControl2.DimColor = DimColor;
      _labelControl1.SetShadow(_shadowAngle1, _shadowDistance1, _shadowColor1);
      _labelControl2.SetShadow(_shadowAngle2, _shadowDistance2, _shadowColor2);

      _imageFocusedLeft.SetBorder(_strBorderTFL, _borderPositionTFL, _borderTextureRepeatTFL, _borderTextureRotateTFL,
                                  _borderTextureFileNameTFL, _borderColorKeyTFL, _borderHasCornersTFL,
                                  _borderCornerTextureRotateTFL);

      _imageNonFocusedLeft.SetBorder(_strBorderTNFL, _borderPositionTNFL, _borderTextureRepeatTNFL,
                                     _borderTextureRotateTNFL,
                                     _borderTextureFileNameTNFL, _borderColorKeyTNFL, _borderHasCornersTNFL,
                                     _borderCornerTextureRotateTNFL);

      _imageFocusedMid.SetBorder(_strBorderTFM, _borderPositionTFM, _borderTextureRepeatTFM, _borderTextureRotateTFM,
                                 _borderTextureFileNameTFM, _borderColorKeyTFM, _borderHasCornersTFM,
                                 _borderCornerTextureRotateTFM);

      _imageNonFocusedMid.SetBorder(_strBorderTNFM, _borderPositionTNFM, _borderTextureRepeatTNFM,
                                    _borderTextureRotateTNFM,
                                    _borderTextureFileNameTNFM, _borderColorKeyTNFM, _borderHasCornersTNFM,
                                    _borderCornerTextureRotateTNFM);

      _imageFocusedRight.SetBorder(_strBorderTFR, _borderPositionTFR, _borderTextureRepeatTFR, _borderTextureRotateTFR,
                                   _borderTextureFileNameTFR, _borderColorKeyTFR, _borderHasCornersTFR,
                                   _borderCornerTextureRotateTFR);

      _imageNonFocusedRight.SetBorder(_strBorderTNFR, _borderPositionTNFR, _borderTextureRepeatTNFR,
                                      _borderTextureRotateTNFR,
                                      _borderTextureFileNameTNFR, _borderColorKeyTNFR, _borderHasCornersTNFR,
                                      _borderCornerTextureRotateTNFR);

      _imageIcon.SetBorder(_strBorderTI, _borderPositionTI, _borderTextureRepeatTI, _borderTextureRotateTI,
                           _borderTextureFileNameTI, _borderColorKeyTI, _borderHasCornersTI,
                           _borderCornerTextureRotateTI);

      _imageIcon2.SetBorder(_strBorderTI2, _borderPositionTI2, _borderTextureRepeatTI2, _borderTextureRotateTI2,
                            _borderTextureFileNameTI2, _borderColorKeyTI2, _borderHasCornersTI2,
                            _borderCornerTextureRotateTI2);

      TileFillTFL = _textureFocusedLeftTileFill;
      TileFillTNFL = _textureNonFocusedLeftTileFill;
      TileFillTFM = _textureFocusedMidTileFill;
      TileFillTNFM = _textureNonFocusedMidTileFill;
      TileFillTFR = _textureFocusedRightTileFill;
      TileFillTNFR = _textureNonFocusedRightTileFill;
    }
 public void SetBorderTI2(string border, GUIImage.BorderPosition position, bool repeat, bool rotate,
                          string texture, long colorKey, bool hasCorners, bool cornerRotate)
 {
   _strBorderTI2 = border;
   _borderPositionTI2 = position;
   _borderTextureRepeatTI2 = repeat;
   _borderTextureRotateTI2 = rotate;
   _borderTextureFileNameTI2 = texture;
   _borderColorKeyTI2 = colorKey;
   _borderHasCornersTI2 = hasCorners;
   _borderCornerTextureRotateTI2 = cornerRotate;
   _imageIcon2.SetBorder(_strBorderTI2, _borderPositionTI2, _borderTextureRepeatTI2, _borderTextureRotateTI2,
                         _borderTextureFileNameTI2, _borderColorKeyTI2, _borderHasCornersTI2,
                         _borderCornerTextureRotateTI2);
 }
    protected virtual void RenderPinIcon(float timePassed, int buttonNr, int x, int y, bool gotFocus)
    {
      GUIListItem pItem = _listItems[buttonNr + _offset];
      if (pItem.HasPinIcon)
      {
        GUIImage pinImage = pItem.PinIcon;
        if (null == pinImage)
        {
          //pinImage = new GUIImage(0, 0, 0, 0, 0, 0, pItem.PinImage, 0x0);
          pinImage = new GUIImage(0, 0, 0, 0, _widthPinIcon, _heightPinIcon, pItem.PinImage, 0x0)
                       {
                         ParentControl = this,
                         KeepAspectRatio = _keepAspectRatio
                       };
          pinImage.AllocResources();
          pItem.PinIcon = pinImage;
        }
        pinImage.KeepAspectRatio = _keepAspectRatio;
        pinImage.Width = PinIconWidth;
        pinImage.Height = PinIconHeight;


        if (PinIconOffsetY < 0 || PinIconOffsetX < 0)
        {
          pinImage.SetPosition(x + (_width) - (pinImage.TextureWidth + pinImage.TextureWidth / 2),
                               y + (_height / 2) - (pinImage.TextureHeight / 2));
        }
        else
        {
          pinImage.SetPosition(x + PinIconOffsetX, y + PinIconOffsetY);
        }

        if (gotFocus || !Focus)
        {
          pinImage.ColourDiffuse = 0xffffffff;
        }
        else
        {
          pinImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }

        if (!pItem.Selected && !gotFocus && _unfocusedAlphaApplyToAll)
        {
          pinImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }
        pinImage.DimColor = DimColor;
        pinImage.Render(timePassed);
      }
    }
    protected virtual void RenderIcon(float timePassed, int buttonNr, int x, int y, bool gotFocus)
    {
      GUIListItem pItem = _listItems[buttonNr + _offset];

      if (pItem.HasIcon)
      {
        if (MediaPortal.Util.Utils.FileExistsInCache(pItem.ThumbnailImage))
        {
          pItem.IconImage = pItem.ThumbnailImage;
        }
        // show icon
        GUIImage pImage = pItem.Icon;
        if (null == pImage)
        {
          pImage = new GUIImage(0, 0, 0, 0, _imageWidth, _imageHeight, pItem.IconImage, 0x0)
                     {
                       ParentControl = this,
                       KeepAspectRatio = _keepAspectRatio
                     };
          pImage.AllocResources();
          pItem.Icon = pImage;
        }
        if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
        {
          pImage.SafeDispose();

          pImage = new GUIImage(0, 0, 0, 0, _imageWidth, _imageHeight, pItem.IconImage, 0x0)
                     {
                       ParentControl = this,
                       KeepAspectRatio = _keepAspectRatio
                     };
          pImage.AllocResources();
          pItem.Icon = pImage;

          //pImage.AllocResources();
        }
        pImage.KeepAspectRatio = _keepAspectRatio;
        pImage.Width = _imageWidth;
        pImage.Height = _imageHeight;
        pImage.SetPosition(x, y);
        if (gotFocus || !Focus)
        {
          pImage.ColourDiffuse = 0xffffffff;
        }
        else
        {
          pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }
        if (!pItem.Selected && !gotFocus && _unfocusedAlphaApplyToAll)
        {
          pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }
        pImage.DimColor = DimColor;
        pImage.Render(timePassed);
      }
    }
    private void DisposeImage(ref GUIImage image)
    {
      if (null == image) return;

      image.SafeDispose();
      image = null;
    }
 public void SetBorder(string border, GUIImage.BorderPosition position, bool textureRepeat, bool textureRotate,
                       string textureFilename, long colorKey, bool hasCorners, bool cornerTextureRotate)
 {
   _strBorder = border;
   _borderPosition = position;
   _borderTextureRepeat = textureRepeat;
   _borderTextureRotate = textureRotate;
   _borderTextureFileName = textureFilename;
   _borderColorKey = colorKey;
   _borderHasCorners = hasCorners;
   _borderCornerTextureRotate = cornerTextureRotate;
 }
    private void RenderItem(float timePassed, int iButton, bool bFocus, int dwPosX, int dwPosY, GUIListItem pItem,
                            bool buttonOnly)
    {
      if (_listButtons == null)
      {
        return;
      }
      if (iButton < 0 || iButton >= _listButtons.Count)
      {
        return;
      }
      GUIButtonControl btn = _listButtons[iButton];
      if (btn == null)
      {
        return;
      }

      btn.Width = _textureWidth;
      btn.Height = _textureHeight;

      bool clipping = false;
      if (bFocus && Focus)
      {
        Rectangle clipRect = new Rectangle();
        clipRect.X = _positionX - _zoomXPixels / 2;
        clipRect.Y = _positionY - _zoomYPixels / 2;
        clipRect.Width = (_columnCount * _itemWidth) + _zoomXPixels + (_zoomXPixels / 2);
        clipRect.Height = (_rowCount * _itemHeight) + _zoomYPixels + (_zoomYPixels / 2);
        if (clipRect.X < 0)
        {
          clipRect.X = 0;
        }
        if (clipRect.Y < 0)
        {
          clipRect.Y = 0;
        }
        GUIGraphicsContext.BeginClip(clipRect, false);
        clipping = true;
      }

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

      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;
      }

      if (bFocus == true && Focus && m_iSelect == GUIListControl.ListType.CONTROL_LIST)
      {
        if (buttonOnly)
        {
          btn.ColourDiffuse = 0xffffffff;
          btn.Focus = true;
          btn.SetPosition(dwPosX, dwPosY);
          //if (true == _showTexture) btn.Render(timePassed);

          if (clipping)
          {
            GUIGraphicsContext.EndClip();
          }
          return;
        }
        if (fTextPosY >= _positionY && _renderFocusText)
        {
          _listLabels[iButton].XPosition = dwPosX + _textXOff;
          _listLabels[iButton].YPosition = (int)Math.Truncate(fTextPosY + _textYOff + _zoomYPixels);
          _listLabels[iButton].Width = _textureWidth;
          _listLabels[iButton].Height = _textureHeight;
          _listLabels[iButton].TextColor = dwColor;
          _listLabels[iButton].Label = pItem.Label;
          _listLabels[iButton].AllowScrolling = true;
          _listLabels[iButton].Render(timePassed);
        }
      }
      else
      {
        if (buttonOnly)
        {
          btn.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
          if (!btn.Focus)
          {
            btn.SetPosition(dwPosX, dwPosY);
          }
          btn.Focus = false;
          if (!_hideUnfocusTexture)
          {
            btn.Render(timePassed);
          }
          if (_showFrame)
          {
            _frameFocusControl.Focus = btn.Focus;
            _frameFocusControl.SetPosition(btn._positionX, btn._positionY);
            _frameFocusControl.Width = btn.Width;
            _frameFocusControl.Height = btn.Height;
            _frameFocusControl.Render(timePassed);
          }

          if (clipping)
          {
            GUIGraphicsContext.EndClip();
          }
          return;
        }
        if (fTextPosY >= _positionY && _renderUnfocusText)
        {
          _listLabels[iButton].XPosition = dwPosX + _textXOff;
          _listLabels[iButton].YPosition = (int)Math.Truncate(fTextPosY + _textYOff);
          _listLabels[iButton].Width = _textureWidth;
          _listLabels[iButton].Height = _textureHeight;
          _listLabels[iButton].TextColor = dwColor;
          _listLabels[iButton].Label = pItem.Label;
          _listLabels[iButton].AllowScrolling = false;
          _listLabels[iButton].Render(timePassed);
        }
      }

      // Set oversized value
      int iOverSized = 0;
      if (bFocus && Focus && _enableFocusZoom && _zoomXPixels == 0 && _zoomYPixels == 0)
      {
        iOverSized = (_thumbNailWidth + _thumbNailHeight) / THUMBNAIL_OVERSIZED_DIVIDER;
      }

      GUIImage pFocusImage = null;
      if (pItem.HasThumbnail)
      {
        GUIImage pImage = pItem.Thumbnail;
        pFocusImage = pImage;
        if (null == pImage /*&& _sleeper==0 */&& !IsAnimating)
        {
          pImage = new GUIImage(0, 0, _xPositionThumbNail - iOverSized + dwPosX,
                                _yPositionThumbNail - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                _thumbNailHeight + 2 * iOverSized, pItem.ThumbnailImage, 0x0);

          if (pImage != null)
          {
            pImage.ParentControl = this;
            pImage.KeepAspectRatio = _keepAspectRatio;
            pImage.ImageAlignment = Alignment.ALIGN_CENTER;
            pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
            pImage.MaskFileName = _textureMask;
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.AllocResources();
            pItem.Thumbnail = pImage;
            pImage.SetPosition(_xPositionThumbNail - iOverSized + dwPosX, _yPositionThumbNail - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            if (bFocus || !Focus)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
            {
              pImage.Width = _textureWidth + _zoomXPixels;
              pImage.Height = _textureHeight + _zoomYPixels;
              pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
            }
            pImage.Render(timePassed);
            _sleeper += SLEEP_FRAME_COUNT;
          }
        }
        if (null != pImage)
        {
          if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
          {
            pImage.SafeDispose();
            pImage.AllocResources();
          }
          pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
          pImage.Width = _thumbNailWidth + 2 * iOverSized;
          pImage.Height = _thumbNailHeight + 2 * iOverSized;
          pImage.ImageAlignment = Alignment.ALIGN_CENTER;
          pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
          pImage.MaskFileName = _textureMask;
          pImage.SetPosition(_xPositionThumbNail + dwPosX - iOverSized, _yPositionThumbNail - iOverSized + dwPosY);
          pImage.DimColor = DimColor;
          if (bFocus || !Focus)
          {
            pImage.ColourDiffuse = 0xffffffff;
          }
          else
          {
            pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
          }
          if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
          {
            pImage.Width = _textureWidth + _zoomXPixels;
            pImage.Height = _textureHeight + _zoomYPixels;
            pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
          }
          pImage.Render(timePassed);
        }
      }
      else
      {
        if (pItem.HasIconBig)
        {
          GUIImage pImage = pItem.IconBig;
          pFocusImage = pImage;
          if (null == pImage /*&& _sleeper==0 */&& !IsAnimating)
          {
            pImage = new GUIImage(0, 0, _xPositionThumbNail - iOverSized + dwPosX,
                                  _yPositionThumbNail - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                  _thumbNailHeight + 2 * iOverSized, pItem.IconImageBig, 0x0);
            pImage.ParentControl = this;
            pImage.KeepAspectRatio = _keepAspectRatio;
            pImage.ImageAlignment = Alignment.ALIGN_CENTER;
            pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
            pImage.MaskFileName = _textureMask;
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;

            pImage.AllocResources();
            pItem.IconBig = pImage;
            pImage.SetPosition(_xPositionThumbNail + dwPosX - iOverSized, _yPositionThumbNail - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            if (bFocus || !Focus)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
            {
              pImage.Width = _textureWidth + _zoomXPixels;
              pImage.Height = _textureHeight + _zoomYPixels;
              pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
            }
            pImage.Render(timePassed);
            _sleeper += SLEEP_FRAME_COUNT;
          }
          else if (null != pImage)
          {
            if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
            {
              pImage.SafeDispose();
              pImage.AllocResources();
            }
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.ImageAlignment = Alignment.ALIGN_CENTER;
            pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
            pImage.MaskFileName = _textureMask;
            pImage.Width = _thumbNailWidth + 2 * iOverSized;
            pImage.Height = _thumbNailHeight + 2 * iOverSized;
            pImage.SetPosition(_xPositionThumbNail - iOverSized + dwPosX, _yPositionThumbNail - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            if (bFocus || !Focus)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
            {
              pImage.Width = _textureWidth + _zoomXPixels;
              pImage.Height = _textureHeight + _zoomYPixels;
              pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
            }
            pImage.Render(timePassed);
          }
        }
      }
      if (bFocus && Focus)
      {
        btn.Width = _textureWidth + _zoomXPixels;
        btn.Height = _textureHeight + _zoomYPixels;
        btn.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
        btn.Render(timePassed);
        if (pFocusImage != null/* && _zoomXPixels == 0 && _zoomYPixels == 0*/)
        {
          pFocusImage.ImageAlignment = Alignment.ALIGN_CENTER;
          pFocusImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
          pFocusImage.Render(timePassed);
        }
        if (_showFrame)
        {
          //_frameFocusControl.Focus = btn.Focus;
          _frameFocusControl.SetPosition(btn._positionX, btn._positionY);
          _frameFocusControl.Width = btn.Width;
          _frameFocusControl.Height = btn.Height;
          _frameFocusControl.Render(timePassed);
        }
      }
      else
      {
        if (_showFrame)
        {
          //_frameNoFocusControl.Focus = btn.Focus;
          _frameNoFocusControl.SetPosition(dwPosX, dwPosY);
          _frameNoFocusControl.Width = btn.Width + 2 * iOverSized;
          _frameNoFocusControl.Height = btn.Height + 2 * iOverSized;
          _frameNoFocusControl.Render(timePassed);
        }
        btn.Width = _textureWidth;
        btn.Height = _textureHeight;
      }

      if (clipping)
      {
        GUIGraphicsContext.EndClip();
      }
    }
Exemple #18
0
    public override void AllocResources()
    {
      try
      {
        if (GUIGraphicsContext.DX9Device == null)
        {
          return;
        }
        if (GUIGraphicsContext.DX9Device.Disposed)
        {
          return;
        }
        if (_registeredForEvent == false)
        {
          GUIPropertyManager.OnPropertyChanged -= GUIPropertyManager_OnPropertyChanged;
          GUIPropertyManager.OnPropertyChanged += GUIPropertyManager_OnPropertyChanged;
          _registeredForEvent = true;
        }
        _currentImage = 0;
        _Info = 0;
        _directoryLoaded = false;
        _isAllocated = false;
        _newPath = _texturePath;
        Dispose();
        base.AllocResources();
      }
      catch (Exception e)
      {
        Log.Error(e);
      }
      finally
      {
        _isAllocated = true;
      }

      if (!_directoryLoaded)
      {
        LoadDirectory();
      }

      // Randomize or sort our images if necessary
      if (_randomized && _fileList.Count > 1)
      {
        Random_Shuffle(ref _fileList);
      }

      for (int i = 0; i < _fileList.Count; i++)
      {
        GUIImage pImage = new GUIImage(ParentID, GetID, _positionX, _positionY, _width, _height, _fileList[i], 0);
        pImage.KeepAspectRatio = _keepAspectRatio;
        _imageList.Add(pImage);
      }

      // Load in the current image, and reset our timer
      _imageTimer.StartZero();
      _fadeTimer.Stop();
      _currentImage = 0;
      if (_imageList.Count == 0)
      {
        return;
      }

      LoadImage(_currentImage);
      _isAllocated = true;
    }
 public void SetBorderTFR(string border, GUIImage.BorderPosition position, bool repeat, bool rotate,
                          string texture, long colorKey, bool hasCorners, bool cornerRotate)
 {
   _strBorderTFR = border;
   _borderPositionTFR = position;
   _borderTextureRepeatTFR = repeat;
   _borderTextureRotateTFR = rotate;
   _borderTextureFileNameTFR = texture;
   _borderColorKeyTFR = colorKey;
   _borderHasCornersTFR = hasCorners;
   _borderCornerTextureRotateTFR = cornerRotate;
   _imageFocusedRight.SetBorder(_strBorderTFR, _borderPositionTFR, _borderTextureRepeatTFR, _borderTextureRotateTFR,
                                _borderTextureFileNameTFR, _borderColorKeyTFR, _borderHasCornersTFR,
                                _borderCornerTextureRotateTFR);
 }
Exemple #20
0
    public void LoadDirectory()
    {
      if (_directoryLoaded)
      {
        return;
      }

      // Unload any images from our texture bundle first
      _fileList.Clear();

      // Don't load any images if our path is empty
      if (_newPath.Length == 0)
      {
        return;
      }

      // Check to see if we have a single image or a folder of images
      if (MediaPortal.Util.Utils.IsPicture(_newPath))
      {
        _fileList.Add(_newPath);
      }
      else
      {
        // Folder of images
        try
        {
          string imageFolder = string.Empty;
          // Try to use the provided folder as an absolute path
          if (Directory.Exists(_newPath) && Path.IsPathRooted(_newPath))
          {
            imageFolder = _newPath;
          }

          // If that didnt work, try to use relative pathing into the skin\Media folder
          if (imageFolder.Trim().Length == 0)
          {
            //Log.Debug("GUIMultiImage - try relative pathing: " + GUIGraphicsContext.GetThemedSkinDirectory(@"\Media\animations\" + _newPath));
            imageFolder = GUIGraphicsContext.GetThemedSkinDirectory(@"\Media\animations\" + _newPath);

            // If the folder doesnt exist, we have an invalid field, exit
            if (!Directory.Exists(imageFolder))
            {
              return;
            }
          }

          // Load the image files
          string[] files = Directory.GetFiles(imageFolder);
          for (int i = 0; i < files.Length; ++i)
          {
            if (MediaPortal.Util.Utils.IsPicture(files[i]))
            {
              _fileList.Add(files[i]);
            }
          }
        }
          // If there was some other error accessing the folder, exit
        catch (UnauthorizedAccessException)
        {
          return;
        }
        catch (IOException)
        {
          return;
        }
      }

      // Randomize or sort our images if necessary
      if (_randomized && _fileList.Count > 1)
      {
        Random_Shuffle(ref _fileList);
      }

      // flag as loaded - no point in antly reloading them
      _directoryLoaded = true;

      for (int i = 0; i < _fileList.Count; i++)
      {
        GUIImage pImage = new GUIImage(ParentID, GetID, _positionX, _positionY, _width, _height, _fileList[i], 0);
        pImage.KeepAspectRatio = _keepAspectRatio;
        _imageList.Add(pImage);
      }

      // Load in the current image, and reset our timer
      _imageTimer.StartZero();
      _fadeTimer.Stop();
      _currentImage = 0;
      if (_imageList.Count == 0)
      {
        return;
      }
      //LoadImage(_currentImage);
      _isAllocated = true;
    }
    /// <summary>
    /// The constructor of the GUIButton3PartControl class.
    /// </summary>
    /// <param name="dwParentID">The parent of this control.</param>
    /// <param name="dwControlId">The ID of this control.</param>
    /// <param name="dwPosX">The X position of this control.</param>
    /// <param name="dwPosY">The Y position of this control.</param>
    /// <param name="dwWidth">The width of this control.</param>
    /// <param name="dwHeight">The height of this control.</param>
    /// <param name="strTextureFocus">The filename containing the texture of the butten, when the button has the focus.</param>
    /// <param name="strTextureNoFocus">The filename containing the texture of the butten, when the button does not have the focus.</param>
    public GUIButton3PartControl(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                                 string strTextureFocusLeft,
                                 string strTextureFocusMid,
                                 string strTextureFocusRight,
                                 string strTextureNoFocusLeft,
                                 string strTextureNoFocusMid,
                                 string strTextureNoFocusRight,
                                 string strTextureIcon)
      : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
    {
      _textureFocusedLeft = strTextureFocusLeft;
      _textureFocusedMid = strTextureFocusMid;
      _textureFocusedRight = strTextureFocusRight;
      _textureNonFocusedLeft = strTextureNoFocusLeft;
      _textureNonFocusedMid = strTextureNoFocusMid;
      _textureNonFocusedRight = strTextureNoFocusRight;
      _textureIcon = strTextureIcon;
      _textureIcon2 = strTextureIcon;
      _imageIcon = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, 0, 0, strTextureIcon, 0);
      _imageIcon2 = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, 0, 0, strTextureIcon, 0);
      _imageFocusedLeft = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight, strTextureFocusLeft,
                                       0);
      _imageFocusedMid = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight, strTextureFocusMid, 0);
      _imageFocusedRight = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight, strTextureFocusRight,
                                        0);
      _imageNonFocusedLeft = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
                                          strTextureNoFocusLeft, 0);
      _imageNonFocusedMid = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
                                         strTextureNoFocusMid, 0);
      _imageNonFocusedRight = new GUIImage(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
                                           strTextureNoFocusRight, 0);
      _isSelected = false;
      _labelControl1 = new GUILabelControl(dwParentID);
      _labelControl2 = new GUILabelControl(dwParentID);
      _imageIcon.ParentControl = this;
      _imageIcon2.ParentControl = this;
      _imageFocusedLeft.ParentControl = this;
      _imageFocusedMid.ParentControl = this;
      _imageFocusedRight.ParentControl = this;
      _imageNonFocusedLeft.ParentControl = this;
      _imageNonFocusedMid.ParentControl = this;
      _imageNonFocusedRight.ParentControl = this;
      _labelControl1.ParentControl = this;
      _labelControl2.ParentControl = this;

      _imageFocusedLeft.DimColor = DimColor;
      _imageFocusedMid.DimColor = DimColor;
      _imageFocusedRight.DimColor = DimColor;
      _imageNonFocusedLeft.DimColor = DimColor;
      _imageNonFocusedMid.DimColor = DimColor;
      _imageNonFocusedRight.DimColor = DimColor;
      _imageIcon.DimColor = DimColor;
      _imageIcon2.DimColor = DimColor;
      _labelControl1.DimColor = DimColor;
      _labelControl2.DimColor = DimColor;

      _imageFocusedLeft.OverlayFileName = _overlayTFL;
      _imageFocusedMid.OverlayFileName = _overlayTFM;
      _imageFocusedRight.OverlayFileName = _overlayTFR;
      _imageNonFocusedLeft.OverlayFileName = _overlayTNFL;
      _imageNonFocusedMid.OverlayFileName = _overlayTNFM;
      _imageNonFocusedRight.OverlayFileName = _overlayTNFR;

      _imageIcon2.Visible = false; // Constructor creates icon2 as a copy of icon1.
    }
    protected override void OnPageLoad()
    {
      base.OnPageLoad();
      _currentMode = Mode.Weather;
      _selectedDayName = "All";
      _dayNum = -2;
      LoadSettings();

      //do image id to control stuff so we can use them later
      //do image id to control stuff so we can use them later
      _nowImage = (GUIImage)GetControl((int)Controls.CONTROL_IMAGENOWICON);
      RefreshNewMode();

      int i = 0;
      int selected = 0;
      //					GUIControl.ClearControl(GetID,(int)Controls.CONTROL_LOCATIONSELECT);
      foreach (LocationInfo loc in _listLocations)
      {
        string city = loc.City;
        int pos = city.IndexOf(",");
        //						if (pos>0) city=city.Substring(0,pos);
        //							GUIControl.AddItemLabelControl(GetID,(int)Controls.CONTROL_LOCATIONSELECT,city);
        if (_locationCode == loc.CityCode)
        {
          _nowLabelLocation = loc.City;
          _urlSatellite = loc.UrlSattelite;
          _urlTemperature = loc.UrlTemperature;
          _urlUvIndex = loc.UrlUvIndex;
          _urlWinds = loc.UrlWinds;
          _urlHumidity = loc.UrlHumidity;
          _urlPreciptation = loc.UrlPrecip;
          selected = i;
        }
        i++;
      }
      //GUIControl.SelectItemControl(GetID,(int)Controls.CONTROL_LOCATIONSELECT,selected);

      // Init Daylight clock _geochronGenerator
      _geochronGenerator = new Geochron(GUIGraphicsContext.Skin + @"\Media");
      int width, height;
      GUIImage clockImage = (GUIImage)GetControl((int)Controls.CONTROL_IMAGE_SUNCLOCK);
      _geochronGenerator.getWidthHeight(out width, out height);
      clockImage.SetMemoryImageSize(width, height);
      clockImage.FileName = "[weatherImage]";

      TimeSpan ts = DateTime.Now - _lastRefreshTime;
      if (ts.TotalMinutes >= _refreshIntercal && _locationCode != string.Empty && !IsRefreshing)
      {
        BackgroundUpdate(false);
      }
    }
    //void SetProperties()

    protected override void RenderSingleChannel(Channel channel)
    {
      string strLogo;
      int chan = ChannelOffset;
      for (int iChannel = 0; iChannel < _channelCount; iChannel++)
      {
        if (chan < _channelList.Count)
        {
          Channel tvChan = _channelList[chan].channel;

          strLogo = GetChannelLogo(tvChan.DisplayName);
          GUIButton3PartControl img = GetControl(iChannel + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
          if (img != null)
          {
            if (_showChannelLogos)
            {
              img.TexutureIcon = strLogo;
            }
            img.Label1 = tvChan.DisplayName;
            img.Data = tvChan;
            img.IsVisible = true;
          }
        }
        chan++;
      }

      GUILabelControl channelLabel = GetControl((int)Controls.SINGLE_CHANNEL_LABEL) as GUILabelControl;
      GUIImage channelImage = GetControl((int)Controls.SINGLE_CHANNEL_IMAGE) as GUIImage;

      strLogo = GetChannelLogo(channel.DisplayName);
      if (channelImage == null)
      {
        if (strLogo.Length > 0)
        {
          channelImage = new GUIImage(GetID, (int)Controls.SINGLE_CHANNEL_IMAGE,
                                      GetControl((int)Controls.LABEL_TIME1).XPosition,
                                      GetControl((int)Controls.LABEL_TIME1).YPosition - 15,
                                      40, 40, strLogo, Color.White);
          channelImage.AllocResources();
          GUIControl temp = (GUIControl)channelImage;
          Add(ref temp);
        }
      }
      else
      {
        channelImage.SetFileName(strLogo);
      }

      if (channelLabel == null)
      {
        channelLabel = new GUILabelControl(GetID, (int)Controls.SINGLE_CHANNEL_LABEL,
                                           channelImage.XPosition + 44,
                                           channelImage.YPosition + 10,
                                           300, 40, "font16", channel.DisplayName, 4294967295, GUIControl.Alignment.Left,
                                           GUIControl.VAlignment.Top,
                                           true, 0, 0, 0xFF000000);
        channelLabel.AllocResources();
        GUIControl temp = channelLabel;
        Add(ref temp);
      }

      setSingleChannelLabelVisibility(true);

      channelLabel.Label = channel.DisplayName;
      if (strLogo.Length > 0)
      {
        channelImage.SetFileName(strLogo);
      }

      if (channelLabel != null)
      {
        channelLabel.Label = channel.DisplayName;
      }
      if (_recalculateProgramOffset)
      {
        _programs = new List<Program>();

        DateTime dtStart = DateTime.Now;
        dtStart = dtStart.AddDays(-1);

        DateTime dtEnd = dtStart.AddDays(30);

        TvBusinessLayer layer = new TvBusinessLayer();
        _programs = layer.GetPrograms(channel, dtStart, dtEnd);

        _totalProgramCount = _programs.Count;
        if (_totalProgramCount == 0)
        {
          _totalProgramCount = _channelCount;
        }

        _recalculateProgramOffset = false;
        bool found = false;
        for (int i = 0; i < _programs.Count; i++)
        {
          Program program = (Program)_programs[i];
          if (program.StartTime <= _viewingTime && program.EndTime >= _viewingTime)
          {
            _programOffset = i;
            found = true;
            break;
          }
        }
        if (!found)
        {
          _programOffset = 0;
        }
      }
      else if (_programOffset < _programs.Count)
      {
        int day = ((Program)_programs[_programOffset]).StartTime.DayOfYear;
        bool changed = false;
        while (day > _viewingTime.DayOfYear)
        {
          _viewingTime = _viewingTime.AddDays(1.0);
          changed = true;
        }
        while (day < _viewingTime.DayOfYear)
        {
          _viewingTime = _viewingTime.AddDays(-1.0);
          changed = true;
        }
        if (changed)
        {
          GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;

          // Find first day in TVGuide and set spincontrol position
          int iDay = CalcDays();
          for (; iDay < 0; ++iDay)
          {
            _viewingTime = _viewingTime.AddDays(1.0);
          }
          for (; iDay >= MaxDaysInGuide; --iDay)
          {
            _viewingTime = _viewingTime.AddDays(-1.0);
          }
          cntlDay.Value = iDay;
        }
      }
      // ichan = number of rows
      for (int ichan = 0; ichan < _channelCount; ++ichan)
      {
        GUIButton3PartControl imgCh = GetControl(ichan + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
        imgCh.TexutureIcon = "";

        int iStartXPos = GetControl(0 + (int)Controls.LABEL_TIME1).XPosition;
        int height = GetControl((int)Controls.IMG_CHAN1 + 1).YPosition;
        height -= GetControl((int)Controls.IMG_CHAN1).YPosition;
        int width = GetControl((int)Controls.LABEL_TIME1 + 1).XPosition;
        width -= GetControl((int)Controls.LABEL_TIME1).XPosition;

        int iTotalWidth = width * _numberOfBlocks;

        Program program;
        int offset = _programOffset;
        if (offset + ichan < _programs.Count)
        {
          program = (Program)_programs[offset + ichan];
        }
        else
        {
          // bugfix for 0 items
          if (_programs.Count == 0)
          {
            program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", string.Empty, string.Empty,
                                  Program.ProgramState.None,
                                  DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                  string.Empty, -1);
          }
          else
          {
            program = (Program)_programs[_programs.Count - 1];
            if (program.EndTime.DayOfYear == _viewingTime.DayOfYear)
            {
              program = new Program(channel.IdChannel, program.EndTime, program.EndTime, "-", "-", "-",
                                    Program.ProgramState.None,
                                    DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                    string.Empty, -1);
            }
            else
            {
              program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", "-", "-",
                                    Program.ProgramState.None,
                                    DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                    string.Empty, -1);
            }
          }
        }

        int ypos = GetControl(ichan + (int)Controls.IMG_CHAN1).YPosition;
        int iControlId = GUIDE_COMPONENTID_START + ichan * RowID + 0 * ColID;
        GUIButton3PartControl img = GetControl(iControlId) as GUIButton3PartControl;
        GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;

        if (img == null)
        {
          if (buttonTemplate != null)
          {
            buttonTemplate.IsVisible = false;
            img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2,
                                            buttonTemplate.TexutureFocusLeftName,
                                            buttonTemplate.TexutureFocusMidName,
                                            buttonTemplate.TexutureFocusRightName,
                                            buttonTemplate.TexutureNoFocusLeftName,
                                            buttonTemplate.TexutureNoFocusMidName,
                                            buttonTemplate.TexutureNoFocusRightName,
                                            String.Empty);

            img.TileFillTFL = buttonTemplate.TileFillTFL;
            img.TileFillTNFL = buttonTemplate.TileFillTNFL;
            img.TileFillTFM = buttonTemplate.TileFillTFM;
            img.TileFillTNFM = buttonTemplate.TileFillTNFM;
            img.TileFillTFR = buttonTemplate.TileFillTFR;
            img.TileFillTNFR = buttonTemplate.TileFillTNFR;
          }
          else
          {
            img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2,
                                            "tvguide_button_selected_left.png",
                                            "tvguide_button_selected_middle.png",
                                            "tvguide_button_selected_right.png",
                                            "tvguide_button_light_left.png",
                                            "tvguide_button_light_middle.png",
                                            "tvguide_button_light_right.png",
                                            String.Empty);
          }
          img.AllocResources();
          img.ColourDiffuse = GetColorForGenre(program.Genre);
          GUIControl cntl = (GUIControl)img;
          Add(ref cntl);
        }
        else
        {
          if (buttonTemplate != null)
          {
            buttonTemplate.IsVisible = false;

            img.TexutureFocusLeftName = buttonTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonTemplate.TexutureNoFocusRightName;
            
            img.TileFillTFL = buttonTemplate.TileFillTFL;
            img.TileFillTNFL = buttonTemplate.TileFillTNFL;
            img.TileFillTFM = buttonTemplate.TileFillTFM;
            img.TileFillTNFM = buttonTemplate.TileFillTNFM;
            img.TileFillTFR = buttonTemplate.TileFillTFR;
            img.TileFillTNFR = buttonTemplate.TileFillTNFR;
          }
          else
          {
            img.TexutureFocusLeftName = "tvguide_button_selected_left.png";
            img.TexutureFocusMidName = "tvguide_button_selected_middle.png";
            img.TexutureFocusRightName = "tvguide_button_selected_right.png";
            img.TexutureNoFocusLeftName = "tvguide_button_light_left.png";
            img.TexutureNoFocusMidName = "tvguide_button_light_middle.png";
            img.TexutureNoFocusRightName = "tvguide_button_light_right.png";
          }
          img.Focus = false;
          img.SetPosition(iStartXPos, ypos);
          img.Width = iTotalWidth;
          img.ColourDiffuse = GetColorForGenre(program.Genre);
          img.IsVisible = true;
          img.DoUpdate();
        }
        img.RenderLeft = false;
        img.RenderRight = false;
        img.StretchIfNotRendered = true;

        bool bSeries = (program.IsRecordingSeries || program.IsRecordingSeriesPending || program.IsPartialRecordingSeriesPending);
        bool bConflict = program.HasConflict;
        bool bRecording = bSeries || (program.IsRecording || program.IsRecordingOncePending);

        img.Data = program;
        img.ColourDiffuse = GetColorForGenre(program.Genre);
        height = height - 10;
        height /= 2;
        int iWidth = iTotalWidth;
        if (iWidth > 10)
        {
          iWidth -= 10;
        }
        else
        {
          iWidth = 1;
        }

        DateTime dt = DateTime.Now;

        img.TextOffsetX1 = 5;
        img.TextOffsetY1 = 5;
        img.FontName1 = "font13";
        img.TextColor1 = 0xffffffff;

        img.Label1 = TVUtil.GetDisplayTitle(program);

        string strTimeSingle = String.Format("{0}",
                                             program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

        if (program.StartTime.DayOfYear != _viewingTime.DayOfYear)
        {
          img.Label1 = String.Format("{0} {1}", Utils.GetShortDayString(program.StartTime),
                                     TVUtil.GetDisplayTitle(program));
        }

        GUILabelControl labelTemplate;
        if (program.IsRunningAt(dt))
        {
          labelTemplate = _titleDarkTemplate;
        }
        else
        {
          labelTemplate = _titleTemplate;
        }

        if (labelTemplate != null)
        {
          img.FontName1 = labelTemplate.FontName;
          img.TextColor1 = labelTemplate.TextColor;
          img.TextOffsetX1 = labelTemplate.XPosition;
          img.TextOffsetY1 = labelTemplate.YPosition;
          img.SetShadow1(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);
        }
        img.TextOffsetX2 = 5;
        img.TextOffsetY2 = img.Height / 2;
        img.FontName2 = "font13";
        img.TextColor2 = 0xffffffff;
        img.Label2 = "";
        if (program.IsRunningAt(dt))
        {
          img.TextColor2 = 0xff101010;
          labelTemplate = _genreDarkTemplate;
        }
        else
        {
          labelTemplate = _genreTemplate;
        }

        if (labelTemplate != null)
        {
          img.FontName2 = labelTemplate.FontName;
          img.TextColor2 = labelTemplate.TextColor;
          img.Label2 = program.Genre;
          img.TextOffsetX2 = labelTemplate.XPosition;
          img.TextOffsetY2 = labelTemplate.YPosition;
          img.SetShadow2(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);
        }
        imgCh.Label1 = strTimeSingle;
        imgCh.TexutureIcon = "";

        if (program.IsRunningAt(dt))
        {
          GUIButton3PartControl buttonRunningTemplate = _programRunningTemplate;
          if (buttonRunningTemplate != null)
          {
            buttonRunningTemplate.IsVisible = false;
            img.TexutureFocusLeftName = buttonRunningTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonRunningTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonRunningTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonRunningTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonRunningTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonRunningTemplate.TexutureNoFocusRightName;
            img.TileFillTFL = buttonRunningTemplate.TileFillTFL;
            img.TileFillTNFL = buttonRunningTemplate.TileFillTNFL;
            img.TileFillTFM = buttonRunningTemplate.TileFillTFM;
            img.TileFillTNFM = buttonRunningTemplate.TileFillTNFM;
            img.TileFillTFR = buttonRunningTemplate.TileFillTFR;
            img.TileFillTNFR = buttonRunningTemplate.TileFillTNFR;
          }
          else
          {
            img.TexutureFocusLeftName = "tvguide_button_selected_left.png";
            img.TexutureFocusMidName = "tvguide_button_selected_middle.png";
            img.TexutureFocusRightName = "tvguide_button_selected_right.png";
            img.TexutureNoFocusLeftName = "tvguide_button_left.png";
            img.TexutureNoFocusMidName = "tvguide_button_middle.png";
            img.TexutureNoFocusRightName = "tvguide_button_right.png";
          }
        }

        img.SetPosition(img.XPosition, img.YPosition);

        img.TexutureIcon = String.Empty;
        if (program.Notify)
        {
          GUIButton3PartControl buttonNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl;
          if (buttonNotifyTemplate != null)
          {
            buttonNotifyTemplate.IsVisible = false;

            img.TexutureFocusLeftName = buttonNotifyTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonNotifyTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonNotifyTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonNotifyTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonNotifyTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonNotifyTemplate.TexutureNoFocusRightName;

            img.TileFillTFL = buttonNotifyTemplate.TileFillTFL;
            img.TileFillTNFL = buttonNotifyTemplate.TileFillTNFL;
            img.TileFillTFM = buttonNotifyTemplate.TileFillTFM;
            img.TileFillTNFM = buttonNotifyTemplate.TileFillTNFM;
            img.TileFillTFR = buttonNotifyTemplate.TileFillTFR;
            img.TileFillTNFR = buttonNotifyTemplate.TileFillTNFR;

            // Use of the button template control implies use of the icon.  Use a blank image if the icon is not desired.
            img.TexutureIcon = Thumbs.TvNotifyIcon;
            img.IconOffsetX = buttonNotifyTemplate.IconOffsetX;
            img.IconOffsetY = buttonNotifyTemplate.IconOffsetY;
            img.IconAlign = buttonNotifyTemplate.IconAlign;
            img.IconVAlign = buttonNotifyTemplate.IconVAlign;
            img.IconInlineLabel1 = buttonNotifyTemplate.IconInlineLabel1;
          }
          else
          {
            if (_useNewNotifyButtonColor)
            {
              img.TexutureFocusLeftName = "tvguide_notifyButton_Focus_left.png";
              img.TexutureFocusMidName = "tvguide_notifyButton_Focus_middle.png";
              img.TexutureFocusRightName = "tvguide_notifyButton_Focus_right.png";
              img.TexutureNoFocusLeftName = "tvguide_notifyButton_noFocus_left.png";
              img.TexutureNoFocusMidName = "tvguide_notifyButton_noFocus_middle.png";
              img.TexutureNoFocusRightName = "tvguide_notifyButton_noFocus_right.png";
            }
            else
            {
              img.TexutureIcon = Thumbs.TvNotifyIcon;
            }
          }
        }
        if (bRecording)
        {
          bool bPartialRecording = program.IsPartialRecordingSeriesPending;
          GUIButton3PartControl buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl;

          // Select the partial recording template if needed.
          if (bPartialRecording)
          {
            buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl;
          }

          if (buttonRecordTemplate != null)
          {
            buttonRecordTemplate.IsVisible = false;

            img.TexutureFocusLeftName = buttonRecordTemplate.TexutureFocusLeftName;
            img.TexutureFocusMidName = buttonRecordTemplate.TexutureFocusMidName;
            img.TexutureFocusRightName = buttonRecordTemplate.TexutureFocusRightName;
            img.TexutureNoFocusLeftName = buttonRecordTemplate.TexutureNoFocusLeftName;
            img.TexutureNoFocusMidName = buttonRecordTemplate.TexutureNoFocusMidName;
            img.TexutureNoFocusRightName = buttonRecordTemplate.TexutureNoFocusRightName;
            
            img.TileFillTFL = buttonRecordTemplate.TileFillTFL;
            img.TileFillTNFL = buttonRecordTemplate.TileFillTNFL;
            img.TileFillTFM = buttonRecordTemplate.TileFillTFM;
            img.TileFillTNFM = buttonRecordTemplate.TileFillTNFM;
            img.TileFillTFR = buttonRecordTemplate.TileFillTFR;
            img.TileFillTNFR = buttonRecordTemplate.TileFillTNFR;

            // Use of the button template control implies use of the icon.  Use a blank image if the icon is not desired.
            if (bConflict)
            {
              img.TexutureIcon = Thumbs.TvConflictRecordingIcon;
            }
            else if (bSeries)
            {
              img.TexutureIcon = Thumbs.TvRecordingSeriesIcon;
            }
            else
            {
              img.TexutureIcon = Thumbs.TvRecordingIcon;
            }
            img.IconOffsetX = buttonRecordTemplate.IconOffsetX;
            img.IconOffsetY = buttonRecordTemplate.IconOffsetY;
            img.IconAlign = buttonRecordTemplate.IconAlign;
            img.IconVAlign = buttonRecordTemplate.IconVAlign;
            img.IconInlineLabel1 = buttonRecordTemplate.IconInlineLabel1;
          }
          else
          {
            if (bPartialRecording && _useNewPartialRecordingButtonColor)
            {
              img.TexutureFocusLeftName = "tvguide_partRecButton_Focus_left.png";
              img.TexutureFocusMidName = "tvguide_partRecButton_Focus_middle.png";
              img.TexutureFocusRightName = "tvguide_partRecButton_Focus_right.png";
              img.TexutureNoFocusLeftName = "tvguide_partRecButton_noFocus_left.png";
              img.TexutureNoFocusMidName = "tvguide_partRecButton_noFocus_middle.png";
              img.TexutureNoFocusRightName = "tvguide_partRecButton_noFocus_right.png";
            }
            else
            {
              if (_useNewRecordingButtonColor)
              {
                img.TexutureFocusLeftName = "tvguide_recButton_Focus_left.png";
                img.TexutureFocusMidName = "tvguide_recButton_Focus_middle.png";
                img.TexutureFocusRightName = "tvguide_recButton_Focus_right.png";
                img.TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png";
                img.TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png";
                img.TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png";
              }
              else
              {
                if (bConflict)
                {
                  img.TexutureIcon = Thumbs.TvConflictRecordingIcon;
                }
                else if (bSeries)
                {
                  img.TexutureIcon = Thumbs.TvRecordingSeriesIcon;
                }
                else
                {
                  img.TexutureIcon = Thumbs.TvRecordingIcon;
                }
              }
            }
          }
        }
      }
    }
    /*public GUIFilmstripControl(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight, 
      string strFontName, 
      string strImageIcon, 
      string strImageIconFocus, 
      int dwitemWidth, int dwitemHeight, 
      int dwSpinWidth, int dwSpinHeight, 
      string strUp, string strDown, 
      string strUpFocus, string strDownFocus, 
      long dwSpinColor, int dwSpinX, int dwSpinY, 
      string strFont, long dwTextColor, long dwSelectedColor, 
      string strScrollbarBackground, string strScrollbarTop, string strScrollbarBottom)
      : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
    {
    }*/

    /// <summary> 
    /// This function is called after all of the XmlSkinnable fields have been filled
    /// with appropriate data.
    /// Use this to do any construction work other than simple data member assignments,
    /// for example, initializing new reference types, extra calculations, etc..
    /// </summary>
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();
      if (_positionY > _positionY && _spinControlPositionY < _positionY + _height)
      {
        _spinControlPositionY = _positionY + _height;
      }
      for (int i = 0; i < 30; ++i)
      {
        GUIAnimation anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth,
                                                 _itemHeight, _imageFolderName);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        anim.FlipX = _flipX;
        anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _imageFolderMask;
        //anim.SetAnimations(ThumbAnimations);
        _imageFolder.Add(anim);

        anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth, _itemHeight,
                                    _imageFolderNameFocus);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        anim.FlipX = _flipX;
        anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _imageFolderFocusMask;
        //anim.SetAnimations(ThumbAnimations);
        _imageFolderFocus.Add(anim);

        anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth, _itemHeight,
                                    _frameName);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        //anim.FlipX = _flipX;
        //anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _frameMask;
        //anim.SetAnimations(ThumbAnimations);
        _frameControl.Add(anim);

        anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth, _itemHeight,
                                    _frameFocusName);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        //anim.FlipX = _flipX;
        //anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _frameFocusMask;
        //anim.SetAnimations(ThumbAnimations);
        _frameFocusControl.Add(anim);

        // for label
        GUIFadeLabel fadelabel = new GUIFadeLabel(_parentControlId, _controlId, _positionX, _positionY, _textureWidth,
                                                  _textureHeight, _fontName, _textColor, Alignment.ALIGN_LEFT,
                                                  VAlignment.ALIGN_TOP, 0, 0, 0, " | ");
        fadelabel.ParentControl = this;
        fadelabel.AllowScrolling = false;
        fadelabel.DimColor = DimColor;
        //fadelabel.AllowFadeIn = false;
        _listLabels.Add(fadelabel);
      }

      _upDownControl = new GUISpinControl(_controlId, 0, _spinControlPositionX, _spinControlPositionY, _spinControlWidth,
                                          _spinControlHeight, _upTextureName, _downTextureName, _upTextureNameFocus,
                                          _downTextureNameFocus, _fontName, _spinControlColor,
                                          GUISpinControl.SpinType.SPIN_CONTROL_TYPE_INT, _spinControlAlignment);
      _upDownControl.ParentControl = this;
      _upDownControl.DimColor = DimColor;

      _font = GUIFontManager.GetFont(_fontName);



      // Create the horizontal scrollbar.
      int scrollbarWidth = _scrollbarWidth;
      int scrollbarHeight = _scrollbarHeight;
      GUIGraphicsContext.ScaleHorizontal(ref scrollbarWidth);
      GUIGraphicsContext.ScaleVertical(ref scrollbarHeight);
      int scrollbarPosX = _positionX + (_width / 2) - (scrollbarWidth / 2);

      _horizontalScrollbar = new GUIHorizontalScrollbar(_controlId, 0,
                                                        scrollbarPosX, _positionY + _scrollbarOffsetY,
                                                        scrollbarWidth, scrollbarHeight,
                                                        _scrollbarBackgroundName, _scrollbarLeftName,
                                                        _scrollbarRightName);
      _horizontalScrollbar.ParentControl = this;
      _horizontalScrollbar.DimColor = DimColor;


      _upDownControl.Orientation = eOrientation.Horizontal;
      _upDownControl.SetReverse(true);

      _imageBackground = LoadAnimationControl(0, 0, _backGroundPositionX, _backGroundPositionY, _backGroundWidth,
                                              _backGroundHeight, _backgroundTextureName);
      _imageBackground.ParentControl = this;
      _imageBackground.DimColor = DimColor;

      _imageInfo = new GUIImage(0, 0, _infoImagePositionX, _infoImagePositionY, _infoImageWidth, _infoImageHeight,
                                _infoImageName, 0);
      _imageInfo.ParentControl = this;
      _imageInfo.Filtering = true;
      _imageInfo.KeepAspectRatio = true;
      _imageInfo.ImageAlignment = Alignment.ALIGN_CENTER;
      _imageInfo.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
      _imageInfo.HorizontalAlignment = MediaPortal.Drawing.HorizontalAlignment.Center;
      _imageInfo.VerticalAlignment = MediaPortal.Drawing.VerticalAlignment.Center;
      _imageInfo.DimColor = DimColor;
      _imageInfo.FlipX = _flipInfoImageX;
      _imageInfo.FlipY = _flipInfoImageY;
      _imageInfo.DiffuseFileName = _diffuseInfoImageFileName;
      _imageInfo.MaskFileName = _infoImageMask;

      SetThumbDimensionsLow(_thumbNailPositionX, _thumbNailPositionY, _thumbNailWidth, _thumbNailHeight);
      SetTextureDimensions(_textureWidth, _textureHeight);
    }
    /// <summary>
    /// Deinitialize. Release the vertex buffer and the render target resources
    /// This function should be called at last when playing has been stopped
    /// </summary>
    public void Deinit()
    {
      GUIWindowManager.Receivers -= new SendMessageHandler(this.OnMessage);
      GUILayerManager.UnRegisterLayer(this);
      if (_renderTarget != null)
      {
        //VMR9 changes the directx 9 render target. Thats why we set it back to what it was
        if (!_renderTarget.Disposed)
        {
          GUIGraphicsContext.DX9Device.SetRenderTarget(0, _renderTarget);
        }
        _renderTarget.SafeDispose();
        _renderTarget = null;
      }
      for (int i = 0; i < _vertexBuffers.Length; i++)
      {
        if (_vertexBuffers[i] != null)
        {
          _vertexBuffers[i].SafeDispose();
          _vertexBuffers[i] = null;
        }
      }
      if (_blackImage != null)
      {
        _blackImage.SafeDispose();
        _blackImage = null;
      }

      grabber.Clean();
      SubtitleRenderer.GetInstance().Clear();
    }
    public override void AllocResources()
    {
      _fontNamedKey = GUIFontManager.GetFont(_namedKeyFont);
      _fontCharKey = GUIFontManager.GetFont(_charKeyFont);
      _fontSearchText = GUIFontManager.GetFont(_inputTextFont);

      labelBox = new GUIImage(GetID, 1, 0, 0, 10, 10, _labelBoxTexture, 1);
      labelBox.AllocResources();

      label = new GUILabelControl(GetID);
      label.FontName = _labelFont;
      label.SetShadow(_labelShadowAngle, _labelShadowDistance, _labelShadowColor);
      label.AllocResources();

      inputTextBox = new GUIImage(GetID, 1, 0, 0, 10, 10, _inputTextBoxTexture, 1);
      inputTextBox.AllocResources();

      inputText = new GUILabelControl(GetID);
      inputText.FontName = _inputTextFont;
      inputText.SetShadow(_inputTextShadowAngle, _inputTextShadowDistance, _inputTextShadowColor);
      inputText.AllocResources();

      inputTextCaret = new GUILabelControl(GetID);
      inputTextCaret.FontName = _inputTextFont;
      inputTextCaret.SetShadow(_inputTextShadowAngle, _inputTextShadowDistance, _inputTextShadowColor);
      inputTextCaret.AllocResources();

      base.AllocResources();
      _isAllocated = true;
    }
 public void SetBorderH(string border, GUIImage.BorderPosition position, bool repeat, bool rotate,
                        string texture, long colorKey, bool hasCorners, bool cornerRotate)
 {
   _strBorderH = border;
   _borderPositionH = position;
   _borderTextureRepeatH = repeat;
   _borderTextureRotateH = rotate;
   _borderTextureFileNameH = texture;
   _borderColorKeyH = colorKey;
   _borderHasCornersH = hasCorners;
   _borderCornerTextureRotateH = cornerRotate;
   _hoverImage.SetBorder(_strBorderH, _borderPositionH, _borderTextureRepeatH, _borderTextureRotateH,
                         _borderTextureFileNameH, _borderColorKeyH, _borderHasCornersH, _borderCornerTextureRotateH);
 }
Exemple #28
0
    /// <summary>
    /// Draws the front of a single item of the cover flow.
    /// </summary>
    /// <param name="timePassed"></param>
    /// <param name="index">The index of the card in the entire set.</param>
    /// <param name="shouldFocus">True if the card should be in focus.</param>
    private void RenderCardFront(float timePassed, int index, bool shouldFocus)
    {
      GUIListItem pItem = _listItems[index];
      GUIImage pCard = null;
      bool itemFocused = (shouldFocus == true);
      uint currentTime = (uint)System.Windows.Media.Animation.AnimationTimer.TickCount;

      if (pItem.HasThumbnail)
      {
        pCard = pItem.Thumbnail;
        if (null == pCard && !IsAnimating)
        {
          pCard = new GUIImage(0, 0,
                               0, 0,
                               _cardWidth, _cardHeight,
                               pItem.ThumbnailImage, 0x0);

          pCard.ParentControl = null; // We want to be able to treat each card as a control.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.AllocResources();

          pItem.Thumbnail = pCard;
        }

        if (null != pCard)
        {
          if (pCard.TextureHeight == 0 && pCard.TextureWidth == 0)
          {
            pCard.SafeDispose();
            pCard.AllocResources();
          }

          if (itemFocused)
          {
            pCard.ColourDiffuse = 0xffffffff;
            pCard.Focus = true;
          }
          else
          {
            pCard.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            pCard.Focus = false;
          }

          // Ensure our card is setup as we expect because other views (filmstrip) may have changed these values.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.Width = _cardWidth;
          pCard.Height = _cardHeight;

          pCard.UpdateVisibility();
          pCard.Render(timePassed);
        }
      }
      else if (pItem.HasIconBig)
      {
        pCard = pItem.IconBig;
        if (null == pCard && !IsAnimating)
        {
          pCard = new GUIImage(0, 0,
                               0, 0,
                               _cardWidth, _cardHeight,
                               pItem.IconImageBig, 0x0);

          pCard.ParentControl = null; // We want to be able to treat each card as a control.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.AllocResources();

          pItem.IconBig = pCard;
        }
        if (null != pCard)
        {
          if (itemFocused)
          {
            pCard.ColourDiffuse = 0xffffffff;
            pCard.Focus = true;
          }
          else
          {
            pCard.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            pCard.Focus = false;
          }

          // Ensure our card is setup as we expect because other views (filmstrip) may have changed these values.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.Width = _cardWidth;
          pCard.Height = _cardHeight;

          pCard.UpdateVisibility();
          pCard.Render(timePassed);
        }
      }

      // Render the card frame.
      if (_showFrame)
      {
        // Choose a frame for the card from the collection of frames for rendered cards.
        GUIAnimation frame = (itemFocused ? _frameFocus : _frame[GetNextAvailableFrameIndex()]);
        frame.Focus = itemFocused;
        frame.Width = _frameWidth;
        frame.Height = _frameHeight;
        frame.MaskFileName = _maskFilename;

        // Center the frame over the card.
        int x = Math.Abs(_frameWidth - _cardWidth) / 2;
        int y = Math.Abs(_frameHeight - _cardHeight) / 2;
        if (_frameWidth >= _cardWidth)
        {
          x = -x;
        }
        if (_frameHeight >= _cardHeight)
        {
          y = -y;
        }

        frame.SetPosition(x, y);
        frame.UpdateVisibility();
        frame.Render(timePassed);
      }
    }
    /// <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;
      }
    }
Exemple #30
0
        private void Update(bool selectCurrentShow)
        {
            lock (this)
            {
                if (GUIWindowManager.ActiveWindowEx != this.GetID)
                {
                    return;
                }

                // sets button visible state
                UpdateGroupButton();

                _updateTimer = DateTime.Now;
                GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;

                // Find first day in TVGuide and set spincontrol position
                int iDay = CalcDays();
                for (; iDay < 0; ++iDay)
                {
                    _viewingTime = _viewingTime.AddDays(1.0);
                }
                for (; iDay >= MaxDaysInGuide; --iDay)
                {
                    _viewingTime = _viewingTime.AddDays(-1.0);
                }
                cntlDay.Value = iDay;

                int xpos, ypos;
                GUIControl cntlPanel = GetControl((int)Controls.PANEL_BACKGROUND);
                GUIImage cntlChannelImg = (GUIImage)GetControl((int)Controls.CHANNEL_IMAGE_TEMPLATE);
                GUILabelControl cntlChannelLabel = (GUILabelControl)GetControl((int)Controls.CHANNEL_LABEL_TEMPLATE);
                GUILabelControl labelTime = (GUILabelControl)GetControl((int)Controls.LABEL_TIME1);
                GUIImage cntlHeaderBkgImg = (GUIImage)GetControl((int)Controls.IMG_TIME1);
                GUIImage cntlChannelTemplate = (GUIImage)GetControl((int)Controls.CHANNEL_TEMPLATE);


                _titleDarkTemplate = GetControl((int)Controls.LABEL_TITLE_DARK_TEMPLATE) as GUILabelControl;
                _titleTemplate = GetControl((int)Controls.LABEL_TITLE_TEMPLATE) as GUILabelControl;
                _genreDarkTemplate = GetControl((int)Controls.LABEL_GENRE_DARK_TEMPLATE) as GUILabelControl;
                _genreTemplate = GetControl((int)Controls.LABEL_GENRE_TEMPLATE) as GUILabelControl;

                _programPartialRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl;
                _programRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl;
                _programNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl;
                _programNotRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
                _programRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RUNNING) as GUIButton3PartControl;

                _showChannelLogos = cntlChannelImg != null;
                if (_showChannelLogos)
                {
                    cntlChannelImg.IsVisible = false;
                }
                cntlChannelLabel.IsVisible = false;
                cntlHeaderBkgImg.IsVisible = false;
                labelTime.IsVisible = false;
                cntlChannelTemplate.IsVisible = false;
                int iLabelWidth = (cntlPanel.XPosition + cntlPanel.Width - labelTime.XPosition) / 4;

                // add labels for time blocks 1-4
                int iHour, iMin;
                iMin = _viewingTime.Minute;
                _viewingTime = _viewingTime.AddMinutes(-iMin);
                iMin = (iMin / _timePerBlock) * _timePerBlock;
                _viewingTime = _viewingTime.AddMinutes(iMin);

                DateTime dt = new DateTime();
                dt = _viewingTime;

                for (int iLabel = 0; iLabel < 4; iLabel++)
                {
                    xpos = iLabel * iLabelWidth + labelTime.XPosition;
                    ypos = labelTime.YPosition;

                    GUIImage img = GetControl((int)Controls.IMG_TIME1 + iLabel) as GUIImage;
                    if (img == null)
                    {
                        img = new GUIImage(GetID, (int)Controls.IMG_TIME1 + iLabel, xpos, ypos, iLabelWidth - 4,
                                           cntlHeaderBkgImg.RenderHeight, cntlHeaderBkgImg.FileName, 0x0);
                        img.AllocResources();
                        GUIControl cntl2 = (GUIControl)img;
                        Add(ref cntl2);
                    }

                    img.IsVisible = !_singleChannelView;
                    img.Width = iLabelWidth - 4;
                    img.Height = cntlHeaderBkgImg.RenderHeight;
                    img.SetFileName(cntlHeaderBkgImg.FileName);
                    img.SetPosition(xpos, ypos);
                    img.DoUpdate();

                    GUILabelControl label = GetControl((int)Controls.LABEL_TIME1 + iLabel) as GUILabelControl;
                    if (label == null)
                    {
                        label = new GUILabelControl(GetID, (int)Controls.LABEL_TIME1 + iLabel, xpos, ypos, iLabelWidth,
                                                    cntlHeaderBkgImg.RenderHeight, labelTime.FontName, String.Empty,
                                                    labelTime.TextColor, GuideBase.TimeAlignment, labelTime.TextVAlignment, false,
                                                    labelTime.ShadowAngle, labelTime.ShadowDistance, labelTime.ShadowColor);
                        label.AllocResources();
                        GUIControl cntl = (GUIControl)label;
                        this.Add(ref cntl);
                    }
                    iHour = dt.Hour;
                    iMin = dt.Minute;
                    string strTime = dt.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                    label.Label = " " + strTime;
                    dt = dt.AddMinutes(_timePerBlock);

                    label.TextAlignment = GuideBase.TimeAlignment;
                    label.IsVisible = !_singleChannelView;
                    label.Width = iLabelWidth;
                    label.Height = cntlHeaderBkgImg.RenderHeight;
                    label.FontName = labelTime.FontName;
                    label.TextColor = labelTime.TextColor;
                    label.SetPosition(xpos, ypos);
                }

                // add channels...
                int iHeight = cntlPanel.Height + cntlPanel.YPosition - cntlChannelTemplate.YPosition;
                int iItemHeight = cntlChannelTemplate.Height;

                _channelCount = (int)(((float)iHeight) / ((float)iItemHeight));
                for (int iChan = 0; iChan < _channelCount; ++iChan)
                {
                    xpos = cntlChannelTemplate.XPosition;
                    ypos = cntlChannelTemplate.YPosition + iChan * iItemHeight;

                    //this.Remove((int)Controls.IMG_CHAN1+iChan);
                    GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChan) as GUIButton3PartControl;
                    if (imgBut == null)
                    {
                        string strChannelImageFileName = String.Empty;
                        if (_showChannelLogos)
                        {
                            strChannelImageFileName = cntlChannelImg.FileName;
                        }

                        // Use a template control if it exists, otherwise use default values.
                        GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
                        if (buttonTemplate != null)
                        {
                            buttonTemplate.IsVisible = false;
                            imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
                                                               cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
                                                               buttonTemplate.TexutureFocusLeftName,
                                                               buttonTemplate.TexutureFocusMidName,
                                                               buttonTemplate.TexutureFocusRightName,
                                                               buttonTemplate.TexutureNoFocusLeftName,
                                                               buttonTemplate.TexutureNoFocusMidName,
                                                               buttonTemplate.TexutureNoFocusRightName,
                                                               strChannelImageFileName);

                            imgBut.TileFillTFL = buttonTemplate.TileFillTFL;
                            imgBut.TileFillTNFL = buttonTemplate.TileFillTNFL;
                            imgBut.TileFillTFM = buttonTemplate.TileFillTFM;
                            imgBut.TileFillTNFM = buttonTemplate.TileFillTNFM;
                            imgBut.TileFillTFR = buttonTemplate.TileFillTFR;
                            imgBut.TileFillTNFR = buttonTemplate.TileFillTNFR;
                        }
                        else
                        {
                            imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
                                                               cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
                                                               "tvguide_button_selected_left.png",
                                                               "tvguide_button_selected_middle.png",
                                                               "tvguide_button_selected_right.png",
                                                               "tvguide_button_light_left.png",
                                                               "tvguide_button_light_middle.png",
                                                               "tvguide_button_light_right.png",
                                                               strChannelImageFileName);
                        }
                        imgBut.AllocResources();
                        GUIControl cntl = (GUIControl)imgBut;
                        Add(ref cntl);
                    }

                    imgBut.Width = cntlChannelTemplate.Width - 2; //labelTime.XPosition-cntlChannelImg.XPosition;
                    imgBut.Height = cntlChannelTemplate.Height - 2; //iItemHeight-2;
                    imgBut.SetPosition(xpos, ypos);
                    imgBut.FontName1 = cntlChannelLabel.FontName;
                    imgBut.TextColor1 = cntlChannelLabel.TextColor;
                    imgBut.Label1 = String.Empty;
                    imgBut.RenderLeft = false;
                    imgBut.RenderRight = false;
                    imgBut.SetShadow1(cntlChannelLabel.ShadowAngle, cntlChannelLabel.ShadowDistance, cntlChannelLabel.ShadowColor);

                    if (_showChannelLogos)
                    {
                        imgBut.TexutureIcon = cntlChannelImg.FileName;
                        imgBut.IconOffsetX = cntlChannelImg.XPosition;
                        imgBut.IconOffsetY = cntlChannelImg.YPosition;
                        imgBut.IconWidth = cntlChannelImg.RenderWidth;
                        imgBut.IconHeight = cntlChannelImg.RenderHeight;
                        imgBut.IconKeepAspectRatio = cntlChannelImg.KeepAspectRatio;
                        imgBut.IconCentered = cntlChannelImg.Centered;
                        imgBut.IconZoom = cntlChannelImg.Zoom;
                    }
                    imgBut.TextOffsetX1 = cntlChannelLabel.XPosition;
                    imgBut.TextOffsetY1 = cntlChannelLabel.YPosition;
                    imgBut.ColourDiffuse = 0xffffffff;
                    imgBut.DoUpdate();
                }

                UpdateHorizontalScrollbar();
                UpdateVerticalScrollbar();

                GetChannels(false);


                string day;
                switch (_viewingTime.DayOfWeek)
                {
                    case DayOfWeek.Monday:
                        day = GUILocalizeStrings.Get(657);
                        break;
                    case DayOfWeek.Tuesday:
                        day = GUILocalizeStrings.Get(658);
                        break;
                    case DayOfWeek.Wednesday:
                        day = GUILocalizeStrings.Get(659);
                        break;
                    case DayOfWeek.Thursday:
                        day = GUILocalizeStrings.Get(660);
                        break;
                    case DayOfWeek.Friday:
                        day = GUILocalizeStrings.Get(661);
                        break;
                    case DayOfWeek.Saturday:
                        day = GUILocalizeStrings.Get(662);
                        break;
                    default:
                        day = GUILocalizeStrings.Get(663);
                        break;
                }
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.SDOW", day);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Month", _viewingTime.Month.ToString());
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Day", _viewingTime.Day.ToString());

                //day = String.Format("{0} {1}-{2}", day, _viewingTime.Day, _viewingTime.Month);
                day = Utils.GetShortDayString(_viewingTime);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Day", day);

                //2004 03 31 22 20 00
                string strStart = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
                                                _viewingTime.Year, _viewingTime.Month, _viewingTime.Day,
                                                _viewingTime.Hour, _viewingTime.Minute, 0);
                DateTime dtStop = new DateTime();
                dtStop = _viewingTime;
                dtStop = dtStop.AddMinutes(_numberOfBlocks * _timePerBlock - 1);
                iMin = dtStop.Minute;
                string strEnd = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
                                              dtStop.Year, dtStop.Month, dtStop.Day,
                                              dtStop.Hour, iMin, 0);

                long iStart = Int64.Parse(strStart);
                long iEnd = Int64.Parse(strEnd);


                LoadSchedules(false);

                if (_channelOffset > _channelList.Count)
                {
                    _channelOffset = 0;
                    _cursorX = 0;
                }

                for (int i = 0; i < controlList.Count; ++i)
                {
                    GUIControl cntl = (GUIControl)controlList[i];
                    if (cntl.GetID >= GUIDE_COMPONENTID_START)
                    {
                        cntl.IsVisible = false;
                    }
                }

                if (_singleChannelView)
                {
                    // show all buttons (could be less visible if channels < rows)
                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                        if (imgBut != null)
                            imgBut.IsVisible = true;
                    }

                    Channel channel = (Channel)_channelList[_singleChannelNumber].channel;
                    setGuideHeadingVisibility(false);
                    RenderSingleChannel(channel);
                }
                else
                {
                    List<Channel> visibleChannels = new List<Channel>();

                    int chan = _channelOffset;
                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            visibleChannels.Add(_channelList[chan].channel);
                        }
                        chan++;
                        if (chan >= _channelList.Count && visibleChannels.Count < _channelList.Count)
                        {
                            chan = 0;
                        }
                    }

                    _controller.RefreshChannelsEpgData(visibleChannels, Utils.longtodate(iStart), Utils.longtodate(iEnd));

                    // make sure the TV Guide heading is visiable and the single channel labels are not.
                    setGuideHeadingVisibility(true);
                    SetSingleChannelLabelVisibility(false);
                    chan = _channelOffset;

                    int firstButtonYPos = 0;
                    int lastButtonYPos = 0;

                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            GuideBaseChannel tvGuideChannel = _channelList[chan];
                            RenderChannel(iChannel, tvGuideChannel, iStart, iEnd, selectCurrentShow);
                            // remember bottom y position from last visible button
                            GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                            if (imgBut != null)
                            {
                                if (iChannel == 0)
                                    firstButtonYPos = imgBut.YPosition;

                                lastButtonYPos = imgBut.YPosition + imgBut.Height;
                            }
                        }
                        chan++;
                        if (chan >= _channelList.Count && _channelList.Count > _channelCount)
                        {
                            chan = 0;
                        }
                        if (chan > _channelList.Count)
                        {
                            GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                            if (imgBut != null)
                            {
                                imgBut.IsVisible = false;
                            }
                        }
                    }

                    GUIImage vertLine = GetControl((int)Controls.VERTICAL_LINE) as GUIImage;
                    if (vertLine != null)
                    {
                        // height taken from last button (bottom) minus the yposition of slider plus the offset of slider in relation to first button
                        vertLine.Height = lastButtonYPos - vertLine.YPosition + (firstButtonYPos - vertLine.YPosition);
                    }
                    // update selected channel
                    _singleChannelNumber = _cursorX + _channelOffset;
                    if (_singleChannelNumber >= _channelList.Count)
                    {
                        _singleChannelNumber -= _channelList.Count;
                    }

                    // instead of direct casting us "as"; else it fails for other controls!
                    GUIButton3PartControl img = GetControl(_cursorX + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
                    if (null != img)
                    {
                        _currentChannel = (Channel)img.Data;
                    }
                }
                UpdateVerticalScrollbar();
            }
        }