/// <summary>
        /// Renders the text.
        /// </summary>
        /// <param name="timePassed"></param>
        /// <param name="positionX">The X position of the text.</param>
        /// <param name="positionY">The Y position of the text.</param>
        /// <param name="maxRenderWidth">The maximum render width.</param>
        /// <param name="text">The actual text.</param>
        /// <returns>true if the render was successful</returns>
        private bool RenderText(float timePassed, float positionX, float positionY, float maxRenderWidth, string text)
        {
            bool result = false;

            // do not render if we don't have a font
            if (_font == null)
            {
                return(true);
            }

            // set text color and apply dimming if requested
            long color = _textColor;

            if (Dimmed)
            {
                color &= DimColor;
            }

            if (WrapAround())
            {
                text += _wrapString;
            }

            // get the text dimensions.
            float textWidth  = 0;
            float textHeight = 0;

            _font.GetTextExtent(text, ref textWidth, ref textHeight);

            // scroll
            string originalText = text;

            do
            {
                _font.GetTextExtent(originalText, ref textWidth, ref textHeight);
                originalText += (!string.IsNullOrEmpty(_labelTail) ? _labelTail : " ");
            } while (textWidth > 0 && textWidth < maxRenderWidth);

            if (_timeElapsed > _scrollStartDelay)
            {
                string scrollText = string.Empty;

                if (_allowScrolling)
                {
                    if (GUIGraphicsContext.ScrollSpeedHorizontal < 3)
                    {
                        if (_frameLimiter % (4 - GUIGraphicsContext.ScrollSpeedHorizontal) == 0)
                        {
                            _scrollPosititionX++;
                        }
                    }
                    else
                    {
                        _scrollPosititionX = _scrollPosititionX + GUIGraphicsContext.ScrollSpeedHorizontal - 2;
                    }
                }

                float  fWidth   = 0;
                float  fHeight  = 0;
                string tempText = _scrollPosition >= originalText.Length ? (!string.IsNullOrEmpty(_labelTail) ? _labelTail : " ") : originalText.Substring(_scrollPosition, 1);
                _font.GetTextExtent(tempText, ref fWidth, ref fHeight);

                if (_scrollPosititionX - _scrollOffset >= fWidth)
                {
                    _scrollPosition++;
                    if (_scrollPosition > text.Length)
                    {
                        _scrollPosition = 0;
                        result          = true;
                        if (!WrapAround())
                        {
                            return(result);
                        }
                    }
                    _scrollOffset += fWidth;
                }

                int wrapPosition = 0;
                for (int i = 0; i < originalText.Length; i++)
                {
                    if (_scrollPosition + i < originalText.Length)
                    {
                        scrollText += originalText[i + _scrollPosition];
                    }
                    else
                    {
                        scrollText += WrapAround() ? originalText[wrapPosition++] : (!string.IsNullOrEmpty(_labelTail) && _labelTail.Length == 1 ? _labelTail[0] : ' ');
                    }
                }

                _labelControl.TextAlignment  = Alignment.ALIGN_LEFT;
                _labelControl.TextVAlignment = _textVAlignment;
                _labelControl.TrimText       = false;
                _labelControl.Label          = scrollText + " "; // Fade end of text in GUILabel...
                if (_maxWidth > 0)
                {
                    _labelControl.MinWidth = MinWidth;
                    _labelControl.MaxWidth = (int)(maxRenderWidth + _scrollPosititionX - _scrollOffset);
                }
                else
                {
                    _labelControl.Width = (int)(maxRenderWidth + _scrollPosititionX - _scrollOffset);
                }
                _labelControl.TextColor = color;

                double xpos;
                double xoff;
                double xclipoff = 0;
                switch (_textAlignment)
                {
                case Alignment.ALIGN_RIGHT:
                    xoff     = textWidth >= maxRenderWidth ? -1 * maxRenderWidth : 0;
                    xclipoff = xoff;
                    xpos     = positionX + xoff - _scrollPosititionX + _scrollOffset;
                    _labelControl.SetPosition((int)xpos, (int)positionY);
                    break;

                case Alignment.ALIGN_CENTER:
                    _labelControl.TextVAlignment = VAlignment.ALIGN_TOP;
                    xpos = positionX - _scrollPosititionX + _scrollOffset;
                    xoff = System.Math.Max(0, (maxRenderWidth - textWidth) / 2);
                    double yoff = (Height - textHeight) / 2;
                    _labelControl.SetPosition((int)(xpos + xoff), (int)(positionY + yoff));
                    break;

                default:
                    xpos = positionX - _scrollPosititionX + _scrollOffset;
                    _labelControl.SetPosition((int)xpos, (int)positionY);
                    break;
                }

                var clipRect = new Rectangle();
                clipRect.X      = (int)(positionX + xclipoff);
                clipRect.Y      = _labelControl.YPosition;
                clipRect.Width  = maxRenderWidth > 0 ? (int)(maxRenderWidth - xclipoff) : GUIGraphicsContext.Width - clipRect.X;
                clipRect.Height = GUIGraphicsContext.Height - clipRect.Y;

                GUIGraphicsContext.BeginClip(clipRect);
                _labelControl.Render(timePassed);
                GUIGraphicsContext.EndClip();
            }
            else
            {
                _labelControl.TextAlignment  = _textAlignment;
                _labelControl.TextVAlignment = _textVAlignment;
                _labelControl.TrimText       = true;
                _labelControl.Label          = originalText;

                if (_maxWidth > 0)
                {
                    _labelControl.MinWidth = MinWidth;
                    _labelControl.MaxWidth = (int)maxRenderWidth;
                }
                else
                {
                    _labelControl.Width = (int)maxRenderWidth;
                }
                _labelControl.Render(timePassed);
            }

            return(result);
        }
Exemplo n.º 2
0
        public override void Render(float timePassed)
        {
            if (null == _font)
            {
                return;
            }
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

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

                strText = strText.Replace("\\r", "\r");
                if (strText != _previousProperty)
                {
                    _offset = 0;
                    _itemList.DisposeAndClearList();

                    _previousProperty = strText;
                    SetText(strText);
                }
            }

            int dwPosY = _positionY;

            for (int i = 0; i < _itemsPerPage; i++)
            {
                int dwPosX = _positionX;
                if (i + _offset < _itemList.Count)
                {
                    // render item
                    GUIListItem item      = (GUIListItem)_itemList[i + _offset];
                    string      strLabel1 = item.Label;
                    string      strLabel2 = item.Label2;

                    string wszText1  = String.Format("{0}", strLabel1);
                    int    dMaxWidth = _width + 16;
                    float  x         = 0;
                    if (strLabel2.Length > 0)
                    {
                        string wszText2;
                        float  fTextWidth = 0, fTextHeight = 0;
                        wszText2 = String.Format("{0}", strLabel2);
                        _font.GetTextExtent(wszText2, ref fTextWidth, ref fTextHeight);
                        dMaxWidth -= (int)(fTextWidth);
                        uint color = (uint)_textColor;
                        color = GUIGraphicsContext.MergeAlpha(color);
                        if (Shadow)
                        {
                            uint sc = (uint)_shadowColor;
                            sc = GUIGraphicsContext.MergeAlpha(sc);
                            _font.DrawShadowTextWidth((float)dwPosX + dMaxWidth, (float)dwPosY + 2, color, wszText2, _textAlignment,
                                                      _shadowAngle, _shadowDistance, sc, (float)fTextWidth);
                        }
                        else
                        {
                            _font.DrawTextWidth((float)dwPosX + dMaxWidth, (float)dwPosY + 2, color, wszText2, (float)fTextWidth,
                                                _textAlignment);
                        }
                    }
                    switch (_textAlignment)
                    {
                    case Alignment.ALIGN_RIGHT:
                        x = (float)dwPosX + _width;
                        break;

                    default:
                        x = (float)dwPosX;
                        break;
                    }
                    {
                        uint color = (uint)_textColor;
                        color = GUIGraphicsContext.MergeAlpha(color);
                        if (Shadow)
                        {
                            uint sc = (uint)_shadowColor;
                            sc = GUIGraphicsContext.MergeAlpha(sc);
                            _font.DrawShadowTextWidth(x, (float)dwPosY + 2, color, wszText1, _textAlignment,
                                                      _shadowAngle, _shadowDistance, sc, (float)dMaxWidth);
                        }
                        else
                        {
                            _font.DrawTextWidth(x, (float)dwPosY + 2, color, wszText1, (float)dMaxWidth, _textAlignment);
                        }
                        dwPosY += (int)(_itemHeight * _lineSpacing);
                    }
                }
            }
            if (_upDownEnabled)
            {
                int iPages = _itemList.Count / _itemsPerPage;
                if ((_itemList.Count % _itemsPerPage) != 0)
                {
                    iPages++;
                }

                if (iPages > 1)
                {
                    _upDownControl.Render(timePassed);
                }
            }
            base.Render(timePassed);
        }
 public override bool Init()
 {
     return(Load(GUIGraphicsContext.GetThemedSkinFile(@"\settings_MyPictures_Slideshow.xml")));
 }
 public override bool Init()
 {
     return(Load(GUIGraphicsContext.GetThemedSkinFile(@"\dialogDateTime.xml")));
 }
        public static void LoadSkinSettings()
        {
            #region Init variables
            SpectrumImage          = @"Spectrum\Spectrum.png";
            SpectrumPeakImage      = @"Spectrum\SpectrumPeak.png";
            SpectrumSpacing        = 2;
            SpectrumImageFound     = false;
            SpectrumPeakImageFound = false;

            VUMeterImage          = @"Spectrum\VUMeter.png";
            VUMeterPeakImage      = @"Spectrum\VUMeterPeak.png";
            SpectrumDBSpacing     = 5;
            VUMeterImageFound     = false;
            VUMeterPeakImageFound = false;
            #endregion

            string filename = GUIGraphicsContext.GetThemedSkinFile(@"\" + SkinConfigFilename);
            if (File.Exists(filename))
            {
                try
                {
                    logger.Debug("Load Skin settings from: " + filename);
                    #region Load settings
                    using (var settings = new Settings(filename))
                    {
                        SpectrumEnabled        = settings.GetValueAsBool("Enabled", "Spectrum", SpectrumEnabled);
                        SpectrumPeakEnabled    = settings.GetValueAsBool("Enabled", "SpectrumPeak", SpectrumPeakEnabled);
                        SpectrumVUMeterEnabled = settings.GetValueAsBool("Enabled", "SpectrumVUMeter", SpectrumVUMeterEnabled);

                        SpectrumImage     = settings.GetValueAsString("SpectrumAnalyzer", "SpectrumImage", SpectrumImage);
                        SpectrumPeakImage = settings.GetValueAsString("SpectrumAnalyzer", "SpectrumPeakImage", SpectrumPeakImage);

                        Int32.TryParse(settings.GetValueAsString("SpectrumAnalyzer", "SpectrumSpacing", SpectrumSpacing.ToString()), out SpectrumSpacing);

                        Int32.TryParse(settings.GetValueAsString("SpectrumAnalyzer", "SpectrumCount", SpectrumCount.ToString()), out SpectrumCount);
                        Int32.TryParse(settings.GetValueAsString("SpectrumAnalyzer", "SpectrumMax", SpectrumMax.ToString()), out SpectrumMax);

                        VUMeterImage     = settings.GetValueAsString("SpectrumAnalyzer", "SpectrumVUMeterImage", VUMeterImage);
                        VUMeterPeakImage = settings.GetValueAsString("SpectrumAnalyzer", "SpectrumVUMeterPeakImage", VUMeterPeakImage);

                        Int32.TryParse(settings.GetValueAsString("SpectrumAnalyzer", "SpectrumVUMeterSpacing", SpectrumDBSpacing.ToString()), out SpectrumDBSpacing);
                        Int32.TryParse(settings.GetValueAsString("SpectrumAnalyzer", "SpectrumVUMeterMax", SpectrumDBMax.ToString()), out SpectrumDBMax);

                        string   spectrumShow = settings.GetValueAsString("SpectrumAnalyzer", "SpectrumShow", ShowSpectrum.ToString());
                        Spectrum _spectrumShow;
                        if (string.IsNullOrEmpty(spectrumShow))
                        {
                            _spectrumShow = ShowSpectrum;
                        }
                        else
                        {
                            if (!Enum.TryParse(spectrumShow, out _spectrumShow))
                            {
                                _spectrumShow = ShowSpectrum;
                            }
                            if (!Enum.IsDefined(typeof(Spectrum), _spectrumShow))
                            {
                                _spectrumShow = ShowSpectrum;
                            }
                        }
                        ShowSpectrum = _spectrumShow;

                        string   vumeterShow = settings.GetValueAsString("SpectrumAnalyzer", "VUMeterShow", ShowVUMeter.ToString());
                        Spectrum _vumeterShow;
                        if (string.IsNullOrEmpty(vumeterShow))
                        {
                            _vumeterShow = ShowVUMeter;
                        }
                        else
                        {
                            if (!Enum.TryParse(vumeterShow, out _vumeterShow))
                            {
                                _vumeterShow = ShowVUMeter;
                            }
                            if (!Enum.IsDefined(typeof(Spectrum), _vumeterShow))
                            {
                                _vumeterShow = ShowVUMeter;
                            }
                        }
                        ShowVUMeter = _vumeterShow;
                    }
                    #endregion
                    logger.Debug("Load Skin settings from: " + ConfigFilename + " complete.");
                }
                catch (Exception ex)
                {
                    logger.Error("LoadSkinSettings: " + ex);
                }
            }
            else
            {
                logger.Debug("Load Skin settings from: " + filename + " failed. File not found!");
            }
            //
            #region Report Settings
            SpectrumImage     = @"\Media\" + SpectrumImage;
            SpectrumPeakImage = @"\Media\" + SpectrumPeakImage;

            string spectrumImage     = GUIGraphicsContext.GetThemedSkinFile(SpectrumImage);
            string spectrumPeakImage = GUIGraphicsContext.GetThemedSkinFile(SpectrumPeakImage);

            SpectrumImageFound     = File.Exists(spectrumImage);
            SpectrumPeakImageFound = File.Exists(spectrumPeakImage);

            VUMeterImage     = @"\Media\" + SpectrumImage;
            VUMeterPeakImage = @"\Media\" + SpectrumPeakImage;

            string vumeterImage     = GUIGraphicsContext.GetThemedSkinFile(VUMeterImage);
            string vumeterPeakImage = GUIGraphicsContext.GetThemedSkinFile(VUMeterPeakImage);

            VUMeterImageFound     = File.Exists(vumeterImage);
            VUMeterPeakImageFound = File.Exists(vumeterPeakImage);

            logger.Debug("Spectrum Analyzer Skin Settings: {0} Spectrum, {1} Peak, {2} VU Meter, Show: {3}, VU Meter: {4}",
                         Check(Utils.SpectrumEnabled), Check(SpectrumPeakEnabled), Check(Utils.SpectrumVUMeterEnabled), ShowSpectrum, ShowVUMeter);
            logger.Debug("Spectrum Analyzer Skin Settings: Spectrum Image: {0} {1}, PeakImage: {2} {3}, Spacing: {4}",
                         Check(SpectrumImageFound), SpectrumImage, Check(SpectrumPeakImageFound), SpectrumPeakImage, SpectrumSpacing);
            logger.Debug("Spectrum Analyzer Skin Settings: VU Meter Image: {0} {1}, PeakImage: {2} {3}, Spacing: {4}",
                         Check(VUMeterImageFound), VUMeterImage, Check(VUMeterPeakImageFound), VUMeterPeakImage, SpectrumDBSpacing);
            logger.Debug("Spectrum Analyzer Skin Settings: Count: {0}, Max: {1}, VU Meter Max: {2}", SpectrumCount, SpectrumMax, SpectrumDBMax);
            #endregion
        }
Exemplo n.º 6
0
        public static int Load(string fileNameOrg, long lColorKey, int iMaxWidth, int iMaxHeight, bool persistent)
        {
            string fileName = GetFileName(fileNameOrg);
            string cacheKey = fileName.ToLowerInvariant();

            if (String.IsNullOrEmpty(fileName))
            {
                return(0);
            }

            CachedTexture cached;

            if (_cacheTextures.TryGetValue(cacheKey, out cached))
            {
                return(cached.Frames);
            }

            string extension = Path.GetExtension(fileName).ToLowerInvariant();

            if (extension == ".gif")
            {
                Image theImage = null;
                try
                {
                    try
                    {
                        theImage = ImageFast.FromFile(fileName);
                    }
                    catch (FileNotFoundException)
                    {
                        Log.Warn("TextureManager: texture: {0} does not exist", fileName);
                        return(0);
                    }
                    catch (Exception)
                    {
                        Log.Warn("TextureManager: Fast loading texture {0} failed using safer fallback", fileName);
                        theImage = Image.FromFile(fileName);
                    }
                    if (theImage != null)
                    {
                        CachedTexture newCache = new CachedTexture();

                        newCache.Name = fileName;
                        FrameDimension oDimension = new FrameDimension(theImage.FrameDimensionsList[0]);
                        newCache.Frames = theImage.GetFrameCount(oDimension);
                        int[] frameDelay = new int[newCache.Frames];
                        for (int num2 = 0; (num2 < newCache.Frames); ++num2)
                        {
                            frameDelay[num2] = 0;
                        }

                        // Getting Frame duration of an animated Gif image
                        try
                        {
                            int          num1  = 20736;
                            PropertyItem item1 = theImage.GetPropertyItem(num1);
                            if (item1 != null)
                            {
                                byte[] buffer1 = item1.Value;
                                for (int num2 = 0; (num2 < newCache.Frames); ++num2)
                                {
                                    frameDelay[num2] = (((buffer1[(num2 * 4)] + (256 * buffer1[((num2 * 4) + 1)])) +
                                                         (65536 * buffer1[((num2 * 4) + 2)])) + (16777216 * buffer1[((num2 * 4) + 3)]));
                                }
                            }
                        }
                        catch (Exception) {}

                        for (int i = 0; i < newCache.Frames; ++i)
                        {
                            theImage.SelectActiveFrame(oDimension, i);

                            //load gif into texture
                            using (MemoryStream stream = new MemoryStream())
                            {
                                theImage.Save(stream, ImageFormat.Png);
                                ImageInformation info2 = new ImageInformation();
                                stream.Flush();
                                stream.Seek(0, SeekOrigin.Begin);
                                Texture texture = TextureLoader.FromStream(
                                    GUIGraphicsContext.DX9Device,
                                    stream,
                                    0, 0, //width/height
                                    1,    //mipslevels
                                    0,    //Usage.Dynamic,
                                    Format.A8R8G8B8,
                                    GUIGraphicsContext.GetTexturePoolType(),
                                    Filter.None,
                                    Filter.None,
                                    (int)lColorKey,
                                    ref info2);
                                newCache.Width  = info2.Width;
                                newCache.Height = info2.Height;
                                newCache[i]     = new CachedTexture.Frame(fileName, texture, (frameDelay[i] / 5) * 50);
                            }
                        }

                        theImage.SafeDispose();
                        theImage           = null;
                        newCache.Disposed += new EventHandler(cachedTexture_Disposed);
                        if (persistent && !_persistentTextures.ContainsKey(cacheKey))
                        {
                            _persistentTextures[cacheKey] = true;
                        }

                        _cacheTextures[cacheKey] = newCache;

                        //Log.Info("  TextureManager:added:" + fileName + " total:" + _cache.Count + " mem left:" + GUIGraphicsContext.DX9Device.AvailableTextureMemory.ToString());
                        return(newCache.Frames);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("TextureManager: exception loading texture {0} - {1}", fileName, ex.Message);
                }
                return(0);
            }

            try
            {
                int     width, height;
                Texture dxtexture = LoadGraphic(fileName, lColorKey, iMaxWidth, iMaxHeight, out width, out height);
                if (dxtexture != null)
                {
                    CachedTexture newCache = new CachedTexture();
                    newCache.Name    = fileName;
                    newCache.Frames  = 1;
                    newCache.Width   = width;
                    newCache.Height  = height;
                    newCache.texture = new CachedTexture.Frame(fileName, dxtexture, 0);
                    //Log.Info("  texturemanager:added:" + fileName + " total:" + _cache.Count + " mem left:" + GUIGraphicsContext.DX9Device.AvailableTextureMemory.ToString());
                    newCache.Disposed += new EventHandler(cachedTexture_Disposed);
                    if (persistent && !_persistentTextures.ContainsKey(cacheKey))
                    {
                        _persistentTextures[cacheKey] = true;
                    }

                    _cacheTextures[cacheKey] = newCache;
                    return(1);
                }
            }
            catch (Exception)
            {
                return(0);
            }
            return(0);
        }
Exemplo n.º 7
0
        private static Texture LoadGraphic(string fileName, long lColorKey, int iMaxWidth, int iMaxHeight, out int width,
                                           out int height)
        {
            width  = 0;
            height = 0;
            Image   imgSrc  = null;
            Texture texture = null;

            try
            {
#if DO_RESAMPLE
                imgSrc = Image.FromFile(fileName);
                if (imgSrc == null)
                {
                    return(null);
                }
                //Direct3D prefers textures which height/width are a power of 2
                //doing this will increases performance
                //So the following core resamples all textures to
                //make sure all are 2x2, 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, 256x256, 512x512
                int w = -1, h = -1;
                if (imgSrc.Width > 2 && imgSrc.Width < 4)
                {
                    w = 2;
                }
                if (imgSrc.Width > 4 && imgSrc.Width < 8)
                {
                    w = 4;
                }
                if (imgSrc.Width > 8 && imgSrc.Width < 16)
                {
                    w = 8;
                }
                if (imgSrc.Width > 16 && imgSrc.Width < 32)
                {
                    w = 16;
                }
                if (imgSrc.Width > 32 && imgSrc.Width < 64)
                {
                    w = 32;
                }
                if (imgSrc.Width > 64 && imgSrc.Width < 128)
                {
                    w = 64;
                }
                if (imgSrc.Width > 128 && imgSrc.Width < 256)
                {
                    w = 128;
                }
                if (imgSrc.Width > 256 && imgSrc.Width < 512)
                {
                    w = 256;
                }
                if (imgSrc.Width > 512 && imgSrc.Width < 1024)
                {
                    w = 512;
                }


                if (imgSrc.Height > 2 && imgSrc.Height < 4)
                {
                    h = 2;
                }
                if (imgSrc.Height > 4 && imgSrc.Height < 8)
                {
                    h = 4;
                }
                if (imgSrc.Height > 8 && imgSrc.Height < 16)
                {
                    h = 8;
                }
                if (imgSrc.Height > 16 && imgSrc.Height < 32)
                {
                    h = 16;
                }
                if (imgSrc.Height > 32 && imgSrc.Height < 64)
                {
                    h = 32;
                }
                if (imgSrc.Height > 64 && imgSrc.Height < 128)
                {
                    h = 64;
                }
                if (imgSrc.Height > 128 && imgSrc.Height < 256)
                {
                    h = 128;
                }
                if (imgSrc.Height > 256 && imgSrc.Height < 512)
                {
                    h = 256;
                }
                if (imgSrc.Height > 512 && imgSrc.Height < 1024)
                {
                    h = 512;
                }
                if (w > 0 || h > 0)
                {
                    if (h > w)
                    {
                        w = h;
                    }
                    Log.Info("TextureManager: resample {0}x{1} -> {2}x{3} {4}",
                             imgSrc.Width, imgSrc.Height, w, w, fileName);

                    Image imgResampled = Resample(imgSrc, w, h);
                    imgSrc.SafeDispose();
                    imgSrc       = imgResampled;
                    imgResampled = null;
                }
#endif

                Format fmt = Format.A8R8G8B8;

                ImageInformation info2 = new ImageInformation();

                texture = TextureLoader.FromFile(GUIGraphicsContext.DX9Device,
                                                 fileName,
                                                 0, 0, //width/height
                                                 1,    //mipslevels
                                                 0,    //Usage.Dynamic,
                                                 fmt,
                                                 GUIGraphicsContext.GetTexturePoolType(),
                                                 Filter.None,
                                                 Filter.None,
                                                 (int)lColorKey,
                                                 ref info2);
                width  = info2.Width;
                height = info2.Height;
            }
            catch (InvalidDataException e1) // weird : should have been FileNotFoundException when file is missing ??
            {
                //we need to catch this on higer level.
                throw e1;
            }
            catch (Exception)
            {
                Log.Error("TextureManager: LoadGraphic - invalid thumb({0})", fileName);
                Format fmt      = Format.A8R8G8B8;
                string fallback = GUIGraphicsContext.GetThemedSkinFile(@"\media\" + "black.png");

                ImageInformation info2 = new ImageInformation();
                texture = TextureLoader.FromFile(GUIGraphicsContext.DX9Device,
                                                 fallback,
                                                 0, 0, //width/height
                                                 1,    //mipslevels
                                                 0,    //Usage.Dynamic,
                                                 fmt,
                                                 GUIGraphicsContext.GetTexturePoolType(),
                                                 Filter.None,
                                                 Filter.None,
                                                 (int)lColorKey,
                                                 ref info2);
                width  = info2.Width;
                height = info2.Height;
            }
            finally
            {
                if (imgSrc != null)
                {
                    imgSrc.SafeDispose();
                }
            }
            return(texture);
        }
Exemplo n.º 8
0
        public void OnMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED:
            {
                PlayListItem item = GetCurrentItem();
                if (item != null)
                {
                    if (item.Type != PlayListItem.PlayListItemType.AudioStream)
                    {
                        if (!Player.g_Player.IsPicturePlaylist)
                        {
                            Reset();
                            _currentPlayList = PlayListType.PLAYLIST_NONE;
                        }
                        else
                        {
                            Player.g_Player.IsPicturePlaylist = false;
                        }
                    }
                }
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null);
                GUIGraphicsContext.SendMessage(msg);
            }
            break;

            // SV Allows BassMusicPlayer to continuously play
            case GUIMessage.MessageType.GUI_MSG_PLAYBACK_CROSSFADING:
            {
                // This message is only sent by BASS in gapless/crossfading mode
                PlayNext();
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED:
            {
                // This message is sent by both the internal and BASS player
                // In case of gapless/crossfading it is only sent after the last song
                PlayNext(false);
                if (!g_Player.Playing)
                {
                    g_Player.Release();

                    // Clear focus when playback ended
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null);
                    GUIGraphicsContext.SendMessage(msg);
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_PLAY_FILE:
            {
                Log.Info("Playlistplayer: Start file ({0})", message.Label);
                g_Player.Play(message.Label);
                if (!g_Player.Playing)
                {
                    g_Player.Stop();
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_STOP_FILE:
            {
                Log.Info("Playlistplayer: Stop file");
                g_Player.Stop();
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_PERCENTAGE:
            {
                Log.Info("Playlistplayer: SeekPercent ({0}%)", message.Param1);
                g_Player.SeekAsolutePercentage(message.Param1);
                Log.Debug("Playlistplayer: SeekPercent ({0}%) done", message.Param1);
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_END:
            {
                double duration = g_Player.Duration;
                double position = g_Player.CurrentPosition;
                if (position < duration - 1d)
                {
                    Log.Info("Playlistplayer: SeekEnd ({0})", duration);
                    g_Player.SeekAbsolute(duration - 2d);
                    Log.Debug("Playlistplayer: SeekEnd ({0}) done", g_Player.CurrentPosition);
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_SEEK_POSITION:
            {
                g_Player.SeekAbsolute(message.Param1);
            }
            break;
            }
        }
Exemplo n.º 9
0
        public bool Play(int iSong, bool setFullScreenVideo)
        {
            // if play returns false PlayNext is called but this does not help against selecting an invalid track
            bool skipmissing = false;

            do
            {
                if (_currentPlayList == PlayListType.PLAYLIST_NONE)
                {
                    Log.Debug("PlaylistPlayer.Play() no playlist selected");
                    return(false);
                }
                PlayList playlist = GetPlaylist(_currentPlayList);
                if (playlist.Count <= 0)
                {
                    Log.Debug("PlaylistPlayer.Play() playlist is empty");
                    return(false);
                }
                if (iSong < 0)
                {
                    iSong = 0;
                }
                if (iSong >= playlist.Count)
                {
                    if (skipmissing)
                    {
                        return(false);
                    }
                    else
                    {
                        if (_entriesNotFound < playlist.Count)
                        {
                            iSong = playlist.Count - 1;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                //int previousItem = _currentItem;
                _currentItem = iSong;
                PlayListItem item = playlist[_currentItem];

                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, _currentItem, 0, null);
                msg.Label = item.FileName;
                GUIGraphicsContext.SendMessage(msg);

                if (playlist.AllPlayed())
                {
                    playlist.ResetStatus();
                }

                //Log.Debug("PlaylistPlayer: Play - {0}", item.FileName);
                bool playResult = false;
                if (_currentPlayList == PlayListType.PLAYLIST_MUSIC_VIDEO)
                {
                    playResult = g_Player.PlayVideoStream(item.FileName, item.Description);
                }
                else if (item.Type == PlayListItem.PlayListItemType.AudioStream) // Internet Radio
                {
                    playResult = g_Player.PlayAudioStream(item.FileName);
                }
                else
                {
                    switch (_currentPlayList)
                    {
                    case PlayListType.PLAYLIST_MUSIC:
                    case PlayListType.PLAYLIST_MUSIC_TEMP:
                        playResult = g_Player.Play(item.FileName, MediaPortal.Player.g_Player.MediaType.Music);
                        break;

                    case PlayListType.PLAYLIST_VIDEO:
                    case PlayListType.PLAYLIST_VIDEO_TEMP:
                        playResult = g_Player.Play(item.FileName, MediaPortal.Player.g_Player.MediaType.Video);
                        break;

                    default:
                        playResult = g_Player.Play(item.FileName);
                        break;
                    }
                }
                if (!playResult)
                {
                    //	Count entries in current playlist
                    //	that couldn't be played
                    _entriesNotFound++;
                    Log.Error("PlaylistPlayer: *** unable to play - {0} - skipping track!", item.FileName);

                    // do not try to play the next movie or internetstream in the list
                    if (Util.Utils.IsVideo(item.FileName) || Util.Utils.IsLastFMStream(item.FileName))
                    {
                        skipmissing = false;
                    }
                    else
                    {
                        skipmissing = true;
                    }

                    iSong++;
                }
                else
                {
                    item.Played = true;
                    skipmissing = false;
                    if (Util.Utils.IsVideo(item.FileName) && setFullScreenVideo)
                    {
                        if (g_Player.HasVideo)
                        {
                            g_Player.ShowFullScreenWindow();
                        }
                    }
                }
            } while (skipmissing);
            return(g_Player.Playing);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Draws the element on the given graphics
        /// </summary>
        /// <param name="graph">Graphics</param>
        public override void DrawElement(Graphics graph)
        {
            if (_wasVisible)
            {
                _listItems = _list.ListItems;
                int dwPosY = _list.YPosition;
                // Render the buttons first.
                for (int i = 0; i < _list.ItemsPerPage; i++)
                {
                    if (i + _offset < _listItems.Count)
                    {
                        // render item
                        bool gotFocus = false;
                        if (_list.DrawFocus && i == _cursorX && _list.IsFocused && _list.TypeOfList == GUIListControl.ListType.CONTROL_LIST)
                        {
                            gotFocus = true;
                        }
                        RenderButton(graph, i, _list.XPosition, dwPosY, gotFocus);
                    }
                    dwPosY += _list.ItemHeight + _list.Space;
                }

                // Render new item list
                dwPosY = _list.YPosition;
                for (int i = 0; i < _list.ItemsPerPage; i++)
                {
                    int dwPosX = _list.XPosition;
                    if (i + _offset < _listItems.Count)
                    {
                        int iconX;
                        int labelX;
                        int pinX;

                        int ten = 10;
                        GUIGraphicsContext.ScaleHorizontal(ref ten);
                        switch (_list.TextAlignment)
                        {
                        case GUIControl.Alignment.ALIGN_RIGHT:
                            iconX  = dwPosX + _list.Width - _list.IconOffsetX - _list.ImageWidth;
                            labelX = dwPosX;
                            pinX   = dwPosX + _list.Width - _list.PinIconWidth;
                            break;

                        default:
                            iconX  = dwPosX + _list.IconOffsetX;
                            labelX = dwPosX + _list.ImageWidth + ten;
                            pinX   = dwPosX;
                            break;
                        }

                        // render the icon
                        RenderIcon(graph, i, iconX, dwPosY + _list.IconOffsetY);

                        // render the text
                        RenderLabel(graph, i, labelX, dwPosY);

                        RenderPinIcon(graph, i, pinX, dwPosY);

                        dwPosY += _list.ItemHeight + _list.Space;
                    } //if (i + _offset < _listItems.Count)
                }     //for (int i = 0; i < _itemsPerPage; i++)

                RenderScrollbar(graph);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Renders the label
        /// </summary>
        /// <param name="graph">Graphics</param>
        /// <param name="buttonNr">Number of the button</param>
        /// <param name="dwPosX">X Position</param>
        /// <param name="dwPosY">Y Position</param>
        private void RenderLabel(Graphics graph, int buttonNr, int dwPosX, int dwPosY)
        {
            GUIListItem pItem = _listItems[buttonNr + _offset];
            long        dwColor;

            if (pItem.Shaded)
            {
                dwColor = _list.ShadedColor;
            }

            if (pItem.Selected)
            {
                dwColor = _list.SelectedColor;
            }

            dwPosX += _list.TextOffsetX;
            int dMaxWidth = (_list.Width - _list.TextOffsetX - _list.ImageWidth - GUIGraphicsContext.ScaleHorizontal(20));

            if ((_list.TextVisible2 && pItem.Label2.Length > 0) &&
                (_list.TextOffsetY == _list.TextOffsetY2))
            {
                dwColor = _list.TextColor2;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor2;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }

                int xpos = dwPosX;
                int ypos = dwPosY;

                if (0 == _list.TextOffsetX2)
                {
                    xpos = _list.XPosition + _list.Width - GUIGraphicsContext.ScaleHorizontal(16);
                }
                else
                {
                    xpos = _list.XPosition + _list.TextOffsetX2;
                }

                if ((_labelControls2 != null) &&
                    (buttonNr >= 0) && (buttonNr < _labelControls2.Count))
                {
                    ListLabelElement label2 = _labelControls2[buttonNr];
                    if (label2 != null)
                    {
                        label2.XPosition = xpos;
                        label2.YPosition = ypos + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY2;

                        label2.Label     = pItem.Label2;
                        label2.Alignment = GUIControl.Alignment.ALIGN_RIGHT;
                        label2.Font      = getFont(_list.FontName2);
                        SizeF stringSize = label2.GetStringSize(graph);
                        dMaxWidth = (int)label2.XPosition - dwPosX - (int)stringSize.Width - GUIGraphicsContext.ScaleHorizontal(20);
                    }
                }
            }

            _textLine = pItem.Label;
            if (_list.TextVisible1)
            {
                dwColor = _list.TextColor;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }

                RenderText(graph, buttonNr, (float)dwPosX, (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY, (float)dMaxWidth, dwColor, _textLine);
            }

            if (pItem.Label2.Length > 0)
            {
                dwColor = _list.TextColor2;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor2;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }
                if (0 == _list.TextOffsetX2)
                {
                    dwPosX = _list.XPosition + _list.Width - GUIGraphicsContext.ScaleHorizontal(16);
                }
                else
                {
                    dwPosX = _list.XPosition + _list.TextOffsetX2;
                }

                _textLine = pItem.Label2;

                if (_list.TextVisible2 &&
                    (_labelControls2 != null) &&
                    (buttonNr >= 0) && (buttonNr < _labelControls2.Count))
                {
                    ListLabelElement label2 = _labelControls2[buttonNr];
                    if (label2 != null)
                    {
                        label2.XPosition = dwPosX - GUIGraphicsContext.ScaleHorizontal(6);
                        label2.YPosition = dwPosY + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY2;
                        label2.Label     = _textLine;
                        label2.Alignment = GUIControl.Alignment.ALIGN_RIGHT;
                        label2.Font      = getFont(_list.FontName2);
                        label2.DrawElement(graph);
                        label2 = null;
                    }
                }
            }

            if (pItem.Label3.Length > 0)
            {
                dwColor = _list.TextColor3;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor3;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }

                if (0 == _list.TextColor3)
                {
                    dwPosX = _list.XPosition + _list.TextOffsetX;
                }
                else
                {
                    dwPosX = _list.XPosition + _list.TextOffsetX3;
                }

                int ypos = dwPosY;

                if (0 == _list.TextOffsetY3)
                {
                    ypos += _list.TextOffsetY2;
                }
                else
                {
                    ypos += _list.TextOffsetY3;
                }

                if (_list.TextVisible3 &&
                    (_labelControls3 != null) &&
                    (buttonNr >= 0) && (buttonNr < _labelControls3.Count))
                {
                    ListLabelElement label3 = _labelControls3[buttonNr];

                    if (label3 != null)
                    {
                        label3.XPosition = dwPosX;
                        label3.YPosition = ypos;
                        label3.Label     = pItem.Label3;
                        label3.Alignment = GUIControl.Alignment.ALIGN_LEFT;
                        label3.Font      = getFont(_list.Font3);
                        label3.Width     = (_list.Width - _list.TextOffsetX - _list.ImageWidth - GUIGraphicsContext.ScaleHorizontal(34));
                        label3.DrawElement(graph);
                    }
                }
            }
        }
Exemplo n.º 12
0
        public static void ExamineCD(string strDrive, bool forcePlay)
        {
            if (!enabled)
            {
                return;
            }

            if (string.IsNullOrEmpty(strDrive) || (!forcePlay && DaemonTools.GetVirtualDrive().StartsWith(strDrive)))
            {
                return;
            }

            StopListening();
            DetectMediaType(strDrive);

            if (!forcePlay && !ShouldWeAutoPlay(mediaType))
            {
                StartListening();
                return;
            }

            Log.Info("Autoplay: Start playing media type '{0}/{1}' from drive '{2}'", mediaType, mediaSubType, strDrive);

            switch (mediaType)
            {
            case MediaType.VIDEO:
            {
                switch (mediaSubType)
                {
                case MediaSubType.FILES:
                case MediaSubType.DVD:
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUTOPLAY_VOLUME, 0, 0, 0, 0, 0, null);
                    msg.Label  = strDrive;
                    msg.Param1 = (int)mediaType;
                    msg.Param2 = (int)mediaSubType;
                    msg.Object = mediaFiles;
                    GUIGraphicsContext.SendMessage(msg);
                    break;

                case MediaSubType.BLURAY:
                case MediaSubType.HDDVD:
                    msg        = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUTOPLAY_VOLUME, 0, 0, 0, 0, 0, null);
                    msg.Label  = strDrive;
                    msg.Param1 = (int)mediaType;
                    msg.Param2 = (int)mediaSubType;
                    GUIGraphicsContext.SendMessage(msg);
                    break;

                case MediaSubType.VCD:
                    long     lMaxLength = 0;
                    string   sPlayFile  = "";
                    string[] files      = Directory.GetFiles(Path.Combine(strDrive, "MPEGAV"));
                    foreach (string file in files)
                    {
                        FileInfo info = new FileInfo(file);
                        if (info.Length > lMaxLength)
                        {
                            lMaxLength = info.Length;
                            sPlayFile  = file;
                        }
                    }
                    mediaFiles.Clear();
                    mediaFiles.Add(sPlayFile);
                    msg        = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUTOPLAY_VOLUME, 0, 0, 0, 0, 0, null);
                    msg.Label  = strDrive;
                    msg.Param1 = (int)mediaType;
                    msg.Param2 = (int)mediaSubType;
                    msg.Object = mediaFiles;
                    GUIGraphicsContext.SendMessage(msg);
                    break;
                }
            }
            break;

            case MediaType.AUDIO:
                switch (mediaSubType)
                {
                case MediaSubType.FILES:
                case MediaSubType.AUDIO_CD:
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUTOPLAY_VOLUME, 0, 0, 0, 0, 0, null);
                    msg.Label  = strDrive;
                    msg.Param1 = (int)mediaType;
                    msg.Param2 = (int)mediaSubType;
                    msg.Object = mediaFiles;
                    GUIGraphicsContext.SendMessage(msg);
                    break;
                }
                break;

            case MediaType.PHOTO:
                switch (mediaSubType)
                {
                case MediaSubType.FILES:
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUTOPLAY_VOLUME, 0, 0, 0, 0, 0, null);
                    msg.Label  = strDrive;
                    msg.Param1 = (int)mediaType;
                    msg.Param2 = (int)mediaSubType;
                    msg.Object = mediaFiles;
                    GUIGraphicsContext.SendMessage(msg);
                    break;
                }
                break;

            default:
                Log.Info("Unknown media type inserted into drive {0}", strDrive);
                break;
            }
            StartListening();
        }
        /// <summary>
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
                if (Disabled)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            if (!GUIGraphicsContext.MouseSupport)
            {
                IsVisible = false;
                base.Render(timePassed);
                return;
            }

            int iHeight = _height;

            _imageBackground.Height = iHeight;

            float fPercent = (float)_percentage;
            float fPosYOff = (fPercent / 100.0f);

            // Scale handle-parts for resolution.

            //int backgroundWidth = _imageBackground.TextureWidth;
            //int backgroundWidth = _imageBackground.Width;
            int backgroundWidth = Width;

            GUIGraphicsContext.ScaleHorizontal(ref backgroundWidth);
            _imageBackground.Width = backgroundWidth;

            int handleHeight = _imageTop.TextureHeight;

            GUIGraphicsContext.ScaleVertical(ref handleHeight);
            _imageTop.Height    = handleHeight;
            _imageBottom.Height = handleHeight;

            double ratio = (double)_imageTop.TextureWidth / (double)_imageBackground.TextureWidth;

            //int handleWidth = _imageTop.TextureWidth;
            int handleWidth = (int)(Width * ratio);

            GUIGraphicsContext.ScaleHorizontal(ref handleWidth);
            _imageTop.Width    = handleWidth;
            _imageBottom.Width = handleWidth;

            _heightKnob     = (int)(2 * _imageTop.Height);
            _startPositionY = _imageBackground.YPosition;
            _endPositionY   = _startPositionY + _imageBackground.Height;
            fPosYOff       *= (float)(_endPositionY - _imageTop.Height - _startPositionY);
            _knobPositionY  = _startPositionY + (int)fPosYOff;

            _imageBackground.Render(timePassed);

            int iXPos = _imageBackground.XPosition + ((_imageBackground.Width / 2) - (_imageTop.Width));
            int iYPos = _knobPositionY;

            _imageTop.SetPosition(iXPos, iYPos);
            _imageTop.Render(timePassed);

            iXPos += _imageTop.Width;

            _imageBottom.SetPosition(iXPos, iYPos);
            _imageBottom.Render(timePassed);

            base.Render(timePassed);
        }
Exemplo n.º 14
0
 public override bool Init()
 {
     return(Load(GUIGraphicsContext.GetThemedSkinFile(@"\wikipedia.xml")));
 }
Exemplo n.º 15
0
        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;

            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

                w              = Math.Max(w, _images[index].Width);
                h              = Math.Max(h, _images[index].Height);
                _renderWidth   = Math.Max(_renderWidth, _images[index].RenderWidth);
                _renderHeight  = Math.Max(_renderHeight, _images[index].RenderHeight);
                _textureWidth  = Math.Max(_textureWidth, _images[index].TextureWidth);
                _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 override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    if (_setVideoWindow)
                    {
                        // Here is to hide video window madVR when skin didn't handle video overlay (the value need to be different from Process() player like VMR7)
                        GUIGraphicsContext.VideoWindow = new Rectangle(0, 0, 0, 0);
                    }
                    base.Render(timePassed);
                    return;
                }
            }

            if (!GUIGraphicsContext.Calibrating)
            {
                float x = base.XPosition;
                float y = base.YPosition;
                GUIGraphicsContext.Correct(ref x, ref y);

                _videoWindows[0].X      = (int)x;
                _videoWindows[0].Y      = (int)y;
                _videoWindows[0].Width  = base.Width;
                _videoWindows[0].Height = base.Height;

                if (_setVideoWindow)
                {
                    GUIGraphicsContext.VideoWindow = _videoWindows[0];
                }

                if (GUIGraphicsContext.ShowBackground)
                {
                    if (Focus)
                    {
                        x = base.XPosition;
                        y = base.YPosition;
                        int xoff = 5;
                        int yoff = 5;
                        int w    = 10;
                        int h    = 10;
                        GUIGraphicsContext.ScalePosToScreenResolution(ref xoff, ref yoff);
                        GUIGraphicsContext.ScalePosToScreenResolution(ref w, ref h);
                        _imageFocusRectangle.SetPosition((int)x - xoff, (int)y - yoff);
                        _imageFocusRectangle.Width  = base.Width + w;
                        _imageFocusRectangle.Height = base.Height + h;
                        _imageFocusRectangle.Render(timePassed);
                    }

                    if (GUIGraphicsContext.graphics != null)
                    {
                        GUIGraphicsContext.graphics.FillRectangle(Brushes.Black, _videoWindows[0].X, _videoWindows[0].Y, base.Width,
                                                                  base.Height);
                    }
                    else
                    {
                        //image.SetPosition(_videoWindows[0].X,_videoWindows[0].Y);
                        //image.Width=_videoWindows[0].Width;
                        //image.Height=_videoWindows[0].Height;
                        if (GUIGraphicsContext.VideoWindow.Width < 1)
                        {
                            thumbImage.Render(timePassed);
                        }
                        else
                        {
                            blackImage.Render(timePassed); // causes flickering in fullscreen
                        }
                    }
                }
                else
                {
                    if (GUIGraphicsContext.graphics != null)
                    {
                        GUIGraphicsContext.graphics.FillRectangle(Brushes.Black, _videoWindows[0].X, _videoWindows[0].Y, base.Width,
                                                                  base.Height);
                    }
                }
            }
            base.Render(timePassed);
        }
Exemplo n.º 17
0
        public override bool Init()
        {
            bool result = Load(GUIGraphicsContext.GetThemedSkinFile(@"\MyMusicCoverArtGrabberResults.xml"));

            return(result);
        }
        internal static void SendMovieListRefresh()
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_REFRESH, WindowID, 0, FacadeID, 0, 0, null);

            GUIGraphicsContext.SendMessage(msg);
        }
Exemplo n.º 19
0
        public static int LoadFromMemory(Image memoryImage, string name, long lColorKey, int iMaxWidth, int iMaxHeight)
        {
            Log.Debug("TextureManager: load from memory: {0}", name);
            string cacheName = name;
            string cacheKey  = name.ToLowerInvariant();

            CachedTexture cached;

            if (_cacheTextures.TryGetValue(cacheKey, out cached))
            {
                return(cached.Frames);
            }

            if (memoryImage == null)
            {
                return(0);
            }
            if (memoryImage.FrameDimensionsList == null)
            {
                return(0);
            }
            if (memoryImage.FrameDimensionsList.Length == 0)
            {
                return(0);
            }

            try
            {
                CachedTexture newCache = new CachedTexture();

                newCache.Name = cacheName;
                FrameDimension oDimension = new FrameDimension(memoryImage.FrameDimensionsList[0]);
                newCache.Frames = memoryImage.GetFrameCount(oDimension);
                if (newCache.Frames != 1)
                {
                    return(0);
                }
                //load gif into texture
                using (MemoryStream stream = new MemoryStream())
                {
                    memoryImage.Save(stream, ImageFormat.Png);
                    ImageInformation info2 = new ImageInformation();
                    stream.Flush();
                    stream.Seek(0, SeekOrigin.Begin);
                    Texture texture = TextureLoader.FromStream(
                        GUIGraphicsContext.DX9Device,
                        stream,
                        0, 0, //width/height
                        1,    //mipslevels
                        0,    //Usage.Dynamic,
                        Format.A8R8G8B8,
                        GUIGraphicsContext.GetTexturePoolType(),
                        Filter.None,
                        Filter.None,
                        (int)lColorKey,
                        ref info2);
                    newCache.Width   = info2.Width;
                    newCache.Height  = info2.Height;
                    newCache.texture = new CachedTexture.Frame(cacheName, texture, 0);
                }
                memoryImage.SafeDispose();
                memoryImage        = null;
                newCache.Disposed += new EventHandler(cachedTexture_Disposed);

                _cacheTextures[cacheKey] = newCache;

                Log.Debug("TextureManager: added: memoryImage  " + " total count: " + _cacheTextures.Count + ", mem left (MB): " +
                          ((uint)GUIGraphicsContext.DX9Device.AvailableTextureMemory / 1048576));
                return(newCache.Frames);
            }
            catch (Exception ex)
            {
                Log.Error("TextureManager: exception loading texture memoryImage");
                Log.Error(ex);
            }
            return(0);
        }
Exemplo n.º 20
0
 public override void ScaleToScreenResolution()
 {
     base.ScaleToScreenResolution();
     GUIGraphicsContext.ScaleHorizontal(ref _checkMarkWidth);
     GUIGraphicsContext.ScaleVertical(ref _checkMarkHeight);
 }
Exemplo n.º 21
0
        public static bool IsTemporary(string fileName)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                return(false);
            }
            if (fileName == "-")
            {
                return(false);
            }

            string fullFileName = fileName.ToLowerInvariant();

            if (fullFileName.IndexOf(Config.GetSubFolder(Config.Dir.Thumbs, @"tv\logos").ToLowerInvariant()) >= 0)
            {
                return(false);
            }
            if (fullFileName.IndexOf(Config.GetSubFolder(Config.Dir.Thumbs, "radio").ToLowerInvariant()) >= 0)
            {
                return(false);
            }

            // check if this texture was loaded to be persistent
            if (_persistentTextures.ContainsKey(fullFileName))
            {
                return(false);
            }

            /* Temporary: (textures that are disposed)
             * - all not skin images
             *
             * NOT Temporary: (textures that are kept in cache)
             * - all skin graphics
             *
             */

            // Get fullpath and file name
            if (!MediaPortal.Util.Utils.FileExistsInCache(fileName))
            {
                if (!Path.IsPathRooted(fileName))
                {
                    fullFileName = GUIGraphicsContext.GetThemedSkinFile(@"\media\" + fileName);
                }
            }

            fullFileName = fullFileName.ToLowerInvariant();

            // Check if skin file
            if (fullFileName.IndexOf(@"skin\") >= 0)
            {
                if (fullFileName.IndexOf(@"media\animations\") >= 0)
                {
                    return(true);
                }
                if (fullFileName.IndexOf(@"media\tetris\") >= 0)
                {
                    return(true);
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Renders the GUICheckMarkControl.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

            // Set the selection based on the user specified condition.
            if (_selected.Length != 0)
            {
                try
                {
                    Selected = bool.Parse(GUIPropertyManager.Parse(_selected, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS));
                }
                catch (System.Exception)
                {
                    Log.Debug("GUICheckMarkControl: id={0} <selected> expression does not return a boolean value", GetID);
                }
            }

            if (Focus)
            {
                GUIPropertyManager.SetProperty("#highlightedbutton", _label);
            }
            int dwTextPosX      = _positionX;
            int dwCheckMarkPosX = _positionX;

            _rectangle.X      = _positionY;
            _rectangle.Y      = _positionY;
            _rectangle.Height = _imageCheckMarkFocused.Height;
            if (null != _font)
            {
                if (_alignment == Alignment.ALIGN_LEFT)
                {
                    // calculate the position of the checkmark if the text appears at the left side of the checkmark
                    float fTextHeight = 0, fTextWidth = 0;
                    _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight);
                    dwCheckMarkPosX += ((int)(fTextWidth) + 5);
                    _rectangle.X     = _positionX;
                    _rectangle.Width = 5 + (int)fTextWidth + _imageCheckMarkFocused.Width;
                }
                else
                {
                    // put text at the right side of the checkmark
                    dwTextPosX = (dwCheckMarkPosX + _imageCheckMarkFocused.Width + 5);

                    float fTextHeight = 0, fTextWidth = 0;
                    _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight);
                    _rectangle.X     = dwTextPosX;
                    _rectangle.Width = (dwTextPosX + (int)fTextWidth + 5) - dwTextPosX;
                }
                if (Disabled)
                {
                    // If disabled, draw the text in the disabled color.
                    _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1);
                }
                else
                {
                    // Draw focused text and shadow
                    if (Focus)
                    {
                        if (_shadow)
                        {
                            _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1, 5,
                                                 5, GUIGraphicsContext.MergeAlpha(0xff000000));
                        }
                        else
                        {
                            _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1);
                        }
                    }
                    // Draw non-focused text and shadow
                    else
                    {
                        if (_shadow)
                        {
                            _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT,
                                                 -1,
                                                 5, 5, GUIGraphicsContext.MergeAlpha(0xff000000));
                        }
                        else
                        {
                            _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1);
                        }
                    }
                }
            }

            // Render the selected checkmark image
            if (_isSelected)
            {
                _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkFocused.Render(timePassed);
            }
            else
            {
                // Render the non-selected checkmark image
                _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkNonFocused.Render(timePassed);
            }
            base.Render(timePassed);
        }
 public override bool Init()
 {
     return(Load(GUIGraphicsContext.GetThemedSkinFile(@"\settings_MiniDisplay_Options.xml")));
 }
Exemplo n.º 24
0
        /// <summary>
        /// render the image contained in texture onscreen
        /// </summary>
        /// <param name="texture">Directx texture containing the image</param>
        /// <param name="x">x (left) coordinate</param>
        /// <param name="y">y (top) coordinate</param>
        /// <param name="nw">width </param>
        /// <param name="nh">height</param>
        /// <param name="iTextureWidth">width in texture</param>
        /// <param name="iTextureHeight">height in texture</param>
        /// <param name="iTextureLeft">x (left) offset in texture</param>
        /// <param name="iTextureTop">y (top) offset in texture</param>
        /// <param name="lColorDiffuse">diffuse color</param>
        //public static void RenderImage(ref Texture texture, float x, float y, float nw, float nh, float iTextureWidth, float iTextureHeight, float iTextureLeft, float iTextureTop, long lColorDiffuse)
        public static void RenderImage(Texture texture, float x, float y, float nw, float nh, float iTextureWidth,
                                       float iTextureHeight, float iTextureLeft, float iTextureTop, long lColorDiffuse)
        {
            if (texture == null)
            {
                return;
            }
            if (texture.Disposed)
            {
                return;
            }
            if (GUIGraphicsContext.DX9Device == null)
            {
                return;
            }
            if (GUIGraphicsContext.DX9Device.Disposed)
            {
                return;
            }

            if (x < 0 || y < 0)
            {
                return;
            }
            if (nw < 0 || nh < 0)
            {
                return;
            }
            if (iTextureWidth < 0 || iTextureHeight < 0)
            {
                return;
            }
            if (iTextureLeft < 0 || iTextureTop < 0)
            {
                return;
            }

            VertexBuffer m_vbBuffer = null;

            try
            {
                m_vbBuffer = new VertexBuffer(typeof(CustomVertex.TransformedColoredTextured),
                                              4, GUIGraphicsContext.DX9Device,
                                              0, CustomVertex.TransformedColoredTextured.Format,
                                              GUIGraphicsContext.GetTexturePoolType());

                Direct3D.SurfaceDescription desc;
                desc = texture.GetLevelDescription(0);

                float uoffs = ((float)iTextureLeft) / ((float)desc.Width);
                float voffs = ((float)iTextureTop) / ((float)desc.Height);
                float umax  = ((float)iTextureWidth) / ((float)desc.Width);
                float vmax  = ((float)iTextureHeight) / ((float)desc.Height);

                if (uoffs < 0 || uoffs > 1)
                {
                    return;
                }
                if (voffs < 0 || voffs > 1)
                {
                    return;
                }
                if (umax < 0 || umax > 1)
                {
                    return;
                }
                if (vmax < 0 || vmax > 1)
                {
                    return;
                }
                if (umax + uoffs < 0 || umax + uoffs > 1)
                {
                    return;
                }
                if (vmax + voffs < 0 || vmax + voffs > 1)
                {
                    return;
                }
                if (x < 0)
                {
                    x = 0;
                }
                if (x > GUIGraphicsContext.Width)
                {
                    x = GUIGraphicsContext.Width;
                }
                if (y < 0)
                {
                    y = 0;
                }
                if (y > GUIGraphicsContext.Height)
                {
                    y = GUIGraphicsContext.Height;
                }
                if (nw < 0)
                {
                    nw = 0;
                }
                if (nh < 0)
                {
                    nh = 0;
                }
                if (x + nw > GUIGraphicsContext.Width)
                {
                    nw = GUIGraphicsContext.Width - x;
                }
                if (y + nh > GUIGraphicsContext.Height)
                {
                    nh = GUIGraphicsContext.Height - y;
                }

                CustomVertex.TransformedColoredTextured[] verts =
                    (CustomVertex.TransformedColoredTextured[])m_vbBuffer.Lock(0, 0);
                // Lock the buffer (which will return our structs)
                verts[0].X     = x - 0.5f;
                verts[0].Y     = y + nh - 0.5f;
                verts[0].Z     = 0.0f;
                verts[0].Rhw   = 1.0f;
                verts[0].Color = (int)lColorDiffuse;
                verts[0].Tu    = uoffs;
                verts[0].Tv    = voffs + vmax;

                verts[1].X     = x - 0.5f;
                verts[1].Y     = y - 0.5f;
                verts[1].Z     = 0.0f;
                verts[1].Rhw   = 1.0f;
                verts[1].Color = (int)lColorDiffuse;
                verts[1].Tu    = uoffs;
                verts[1].Tv    = voffs;

                verts[2].X     = x + nw - 0.5f;
                verts[2].Y     = y + nh - 0.5f;
                verts[2].Z     = 0.0f;
                verts[2].Rhw   = 1.0f;
                verts[2].Color = (int)lColorDiffuse;
                verts[2].Tu    = uoffs + umax;
                verts[2].Tv    = voffs + vmax;

                verts[3].X     = x + nw - 0.5f;
                verts[3].Y     = y - 0.5f;
                verts[3].Z     = 0.0f;
                verts[3].Rhw   = 1.0f;
                verts[3].Color = (int)lColorDiffuse;
                verts[3].Tu    = uoffs + umax;
                verts[3].Tv    = voffs;


                m_vbBuffer.Unlock();

                GUIGraphicsContext.DX9Device.SetTexture(0, texture);

                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);


                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);

                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);

                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);

                DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);
                DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);

                int   g_nAnisotropy    = GUIGraphicsContext.DX9Device.DeviceCaps.MaxAnisotropy;
                float g_fMipMapLodBias = 0.0f;

                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);

                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);

                // Render the image
                GUIGraphicsContext.DX9Device.SetStreamSource(0, m_vbBuffer, 0);
                GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
                GUIGraphicsContext.DX9Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);

                // unset the texture and palette or the texture caching crashes because the runtime still has a reference
                GUIGraphicsContext.DX9Device.SetTexture(0, null);
            }
            finally
            {
                if (m_vbBuffer != null)
                {
                    m_vbBuffer.SafeDispose();
                }
            }
        }
Exemplo n.º 25
0
 public override bool Init()
 {
     return(Load(GUIGraphicsContext.GetThemedSkinFile(@"\Settings_MyMusic_Database.xml")));
 }
Exemplo n.º 26
0
        /// <summary>
        /// Evaluates the button number, gets its mapping and executes the action
        /// </summary>
        /// <param name="btnCode">Button code (ref: XML file)</param>
        /// <param name="processID">Process-ID for close/kill commands</param>
        private bool DoMapAction(string btnCode, int processID)
        {
            if (!_isLoaded) // No mapping loaded
            {
                Log.Info("Map: No button mapping loaded");
                return(false);
            }
            Mapping map = null;

            map = GetMapping(btnCode);
            if (map == null)
            {
                return(false);
            }
#if DEBUG
            Log.Info("{0} / {1} / {2} / {3}", map.Condition, map.ConProperty, map.Command, map.CmdProperty);
#endif
            Action action;
            if (map.Sound != string.Empty)
            {
                Util.Utils.PlaySound(map.Sound, false, true);
            }
            if (map.Focus && !GUIGraphicsContext.HasFocus)
            {
                GUIGraphicsContext.ResetLastActivity();
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GETFOCUS, 0, 0, 0, 0, 0, null);
                //GUIWindowManager.SendThreadMessage(msg);
                GUIGraphicsContext.SendMessage(msg);
                return(true);
            }
            switch (map.Command)
            {
            case "ACTION": // execute Action x
                Key key = new Key(map.CmdKeyChar, map.CmdKeyCode);
#if DEBUG
                Log.Info("Executing: key {0} / {1} / Action: {2} / {3}", map.CmdKeyChar, map.CmdKeyCode, map.CmdProperty,
                         ((Action.ActionType)Convert.ToInt32(map.CmdProperty)).ToString());
#endif
                action = new Action(key, (Action.ActionType)Convert.ToInt32(map.CmdProperty), 0, 0);
                GUIGraphicsContext.OnAction(action);
                break;

            case "KEY": // send Key x
                SendKeys.SendWait(map.CmdProperty);
                break;

            case "WINDOW": // activate Window x
                GUIGraphicsContext.ResetLastActivity();
                GUIMessage msg;
                if ((Convert.ToInt32(map.CmdProperty) == (int)GUIWindow.Window.WINDOW_HOME) ||
                    (Convert.ToInt32(map.CmdProperty) == (int)GUIWindow.Window.WINDOW_SECOND_HOME))
                {
                    GUIWindow.Window newHome = _basicHome ? GUIWindow.Window.WINDOW_SECOND_HOME : GUIWindow.Window.WINDOW_HOME;
                    // do we prefer to use only one home screen?
                    if (_useOnlyOneHome)
                    {
                        // skip if we are already in there
                        if (GUIWindowManager.ActiveWindow == (int)newHome)
                        {
                            break;
                        }
                    }
                    // we like both
                    else
                    {
                        // if already in one home switch to the other
                        switch (GUIWindowManager.ActiveWindow)
                        {
                        case (int)GUIWindow.Window.WINDOW_HOME:
                            newHome = GUIWindow.Window.WINDOW_SECOND_HOME;
                            break;

                        case (int)GUIWindow.Window.WINDOW_SECOND_HOME:
                            newHome = GUIWindow.Window.WINDOW_HOME;
                            break;
                        }
                    }
                    msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)newHome, 0, null);
                }
                else
                {
                    msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, Convert.ToInt32(map.CmdProperty),
                                         0, null);
                }

                GUIWindowManager.SendThreadMessage(msg);
                break;

            case "TOGGLE": // toggle Layer 1/2
                if (_currentLayer == 1)
                {
                    _currentLayer = 2;
                }
                else
                {
                    _currentLayer = 1;
                }
                break;

            case "POWER": // power down commands

                if ((map.CmdProperty == "STANDBY") || (map.CmdProperty == "HIBERNATE"))
                {
                    GUIGraphicsContext.ResetLastActivity();
                }

                switch (map.CmdProperty)
                {
                case "EXIT":
                    action = new Action(Action.ActionType.ACTION_EXIT, 0, 0);
                    GUIGraphicsContext.OnAction(action);
                    break;

                case "REBOOT":
                    action = new Action(Action.ActionType.ACTION_REBOOT, 0, 0);
                    GUIGraphicsContext.OnAction(action);
                    break;

                case "SHUTDOWN":
                    action = new Action(Action.ActionType.ACTION_SHUTDOWN, 0, 0);
                    GUIGraphicsContext.OnAction(action);
                    break;

                case "STANDBY":
                    action = new Action(Action.ActionType.ACTION_SUSPEND, 1, 0); //1 = ignore prompt
                    GUIGraphicsContext.OnAction(action);
                    break;

                case "HIBERNATE":
                    action = new Action(Action.ActionType.ACTION_HIBERNATE, 1, 0); //1 = ignore prompt
                    GUIGraphicsContext.OnAction(action);
                    break;

                case "POWEROFF":
                    action = new Action(Action.ActionType.ACTION_POWER_OFF, 1, 0); //1 = ignore prompt
                    GUIGraphicsContext.OnAction(action);
                    break;
                }
                break;

            case "PROCESS":
            {
                GUIGraphicsContext.ResetLastActivity();
                if (processID > 0)
                {
                    Process proc = Process.GetProcessById(processID);
                    if (null != proc)
                    {
                        switch (map.CmdProperty)
                        {
                        case "CLOSE":
                            proc.CloseMainWindow();
                            break;

                        case "KILL":
                            proc.Kill();
                            break;
                        }
                    }
                }
            }
            break;

            default:
                return(false);
            }
            return(true);
        }
Exemplo n.º 27
0
 public override bool Init()
 {
     return(Load(GUIGraphicsContext.GetThemedSkinFile(@"\DialogSelect.xml")));
 }
Exemplo n.º 28
0
        /// <summary>
        /// Callback from subtitle filter, alerting us that a new subtitle is available
        /// It receives the new subtitle as the argument sub, which data is only valid
        /// for the duration of OnSubtitle.
        /// </summary>
        /// <returns></returns>
        public int OnSubtitle(ref NATIVE_SUBTITLE sub)
        {
            if (!_useBitmap || !_renderSubtitles || GUIGraphicsContext.CurrentState != GUIGraphicsContext.State.RUNNING)
            {
                return(0);
                // TODO: Might be good to let this cache and then check in Render method because bitmap subs arrive a while before display
            }
            if (_player != null)
            {
                Log.Debug("OnSubtitle - stream position " + _player.StreamPosition);
            }
            lock (_alert)
            {
                try
                {
                    Log.Debug("SubtitleRenderer:  Bitmap: bpp=" + sub.bmBitsPixel + " planes " + sub.bmPlanes + " dim = " +
                              sub.bmWidth + " x " + sub.bmHeight + " stride : " + sub.bmWidthBytes);
                    Log.Debug("SubtitleRenderer: to = " + sub.timeOut + " ts=" + sub.timeStamp + " fsl=" + sub.firstScanLine +
                              " h pos=" + sub.horizontalPosition + " (startPos = " + _startPos + ")");

                    Subtitle subtitle = new Subtitle();
                    subtitle.subBitmap          = new Bitmap(sub.bmWidth, sub.bmHeight, PixelFormat.Format32bppArgb);
                    subtitle.timeOut            = sub.timeOut;
                    subtitle.presentTime        = ((double)sub.timeStamp / 1000.0f) + _startPos; // compute present time in SECONDS
                    subtitle.height             = (uint)sub.bmHeight;
                    subtitle.width              = (uint)sub.bmWidth;
                    subtitle.screenHeight       = (uint)sub.screenHeight;
                    subtitle.screenWidth        = (uint)sub.screenWidth;
                    subtitle.firstScanLine      = sub.firstScanLine;
                    subtitle.horizontalPosition = sub.horizontalPosition;
                    subtitle.id = _subCounter++;
                    //Log.Debug("Received Subtitle : " + subtitle.ToString());

                    Texture texture = null;
                    try
                    {
                        // allocate new texture
                        texture = new Texture(GUIGraphicsContext.DX9Device, (int)subtitle.width, (int)subtitle.height, 1,
                                              Usage.Dynamic,
                                              Format.A8R8G8B8, GUIGraphicsContext.GetTexturePoolType());

                        if (texture == null)
                        {
                            Log.Debug("OnSubtitle: Failed to create new texture!");
                            return(0);
                        }

                        int pitch;
                        using (GraphicsStream a = texture.LockRectangle(0, LockFlags.Discard, out pitch))
                        {
                            // Quick copy of content
                            unsafe
                            {
                                byte *to   = (byte *)a.InternalDataPointer;
                                byte *from = (byte *)sub.bmBits;
                                for (int y = 0; y < sub.bmHeight; ++y)
                                {
                                    for (int x = 0; x < sub.bmWidth * 4; ++x)
                                    {
                                        to[pitch * y + x] = from[y * sub.bmWidthBytes + x];
                                    }
                                }
                            }
                            a.Close();
                        }

                        texture.UnlockRectangle(0);
                        subtitle.texture = texture;
                    }
                    catch (Exception ex)
                    {
                        Log.Debug("OnSubtitle: Failed to copy bitmap data! {0}", ex.Message);
                        return(0);
                    }

                    AddSubtitle(subtitle);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
            return(0);
        }
Exemplo n.º 29
0
 public override bool Init()
 {
     return(Load(GUIGraphicsContext.GetThemedSkinFile(@"\settings_GUI_Skin.xml")));
 }
 /// <summary>
 /// This method gets called when the control is created and all properties has been set
 /// It allows the control to scale itself to the current screen resolution
 /// </summary>
 public override void ScaleToScreenResolution()
 {
     base.ScaleToScreenResolution();
     GUIGraphicsContext.ScalePosToScreenResolution(ref _maxWidth, ref _maxHeight);
 }