Example #1
0
        private static void InsertGroupHeader(int index, string groupLabel)
        {
            // create label text
            string labelText = "--- " + groupLabel + " ";
            float  textwidth = 0; float textheight = 0;
            int    iterationCap = 100;

            while (textwidth <= Browser.Facade.ListLayout().Width)
            {
                GUIFontManager.GetFont(Browser.Facade.ListLayout().FontName).GetTextExtent(labelText, ref textwidth, ref textheight);
                labelText += "-";

                if (iterationCap-- <= 0)
                {
                    break;
                }
            }
            // remove 1 char
            labelText = labelText.Substring(0, labelText.Length - 1);

            GUIListItem groupItem = new GUIListItem();

            groupItem.Label3 = labelText;  // use the textColor3

            Browser.Facade.Insert(index, groupItem);

            groupItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(onGroupHeaderSelected);
        }
Example #2
0
        /// <summary>
        /// Create a banner image of the specified Size, outputting the input text on it
        /// </summary>
        /// <param name="sizeImage">Size of the image to be generated</param>
        /// <param name="label">Text to be output on the image</param>
        /// <returns>a bitmap object</returns>
        private static Bitmap drawSimpleBanner(Size sizeImage, string label)
        {
            Bitmap   image = new Bitmap(sizeImage.Width, sizeImage.Height);
            Graphics gph   = Graphics.FromImage(image);
            //gph.FillRectangle(new SolidBrush(Color.FromArgb(50, Color.White)), new Rectangle(0, 0, sizeImage.Width, sizeImage.Height));
            GUIFont fontList = GUIFontManager.GetFont(s_sFontName);
            Font    font     = new Font(fontList.FontName, 36);

            gph.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            gph.DrawString(label, font, new SolidBrush(Color.FromArgb(200, Color.White)), 5, (sizeImage.Height - font.GetHeight()) / 2);
            gph.Dispose();
            return(image);
        }
Example #3
0
        /// <summary>
        /// Drawing a 'NEW' stamp on top of an existing banner.
        /// </summary>
        /// <param name="origBanner">Original banner.</param>
        /// <returns>The new banner.</returns>
        private static Bitmap drawNewBanner(Bitmap origBanner, ImageType type)
        {
            if (origBanner == null)
            {
                return(null);
            }

            string newStampLocation = Helper.GetThemedSkinFile(ThemeType.Image, "tvseries_newlabel.png");
            Image  newImage         = LoadImageFastFromFile(newStampLocation);

            Graphics gph = Graphics.FromImage(origBanner);

            try
            {
                if (newImage != null)
                {
                    Bitmap newStamp = new Bitmap(newImage);
                    if (type == ImageType.poster)
                    {
                        gph.DrawImage(newStamp, SkinSettings.PosterNewStampPosX, SkinSettings.PosterNewStampPosY);
                    }
                    else
                    {
                        gph.DrawImage(newStamp, SkinSettings.WideBannerNewStampPosX, SkinSettings.WideBannerNewStampPosY);
                    }
                }
                else
                {
                    gph.FillRectangle(new SolidBrush(Color.FromArgb(150, Color.White)), new Rectangle(((origBanner.Width - 200) / 2), ((origBanner.Height - 100) / 2), 200, 100));
                    GUIFont fontList = GUIFontManager.GetFont(s_sFontName);
                    Font    font     = new Font(fontList.FontName, 50);
                    gph.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                    gph.DrawString("New", font, new SolidBrush(Color.FromArgb(200, Color.Red)), ((origBanner.Width - 180) / 2), (origBanner.Height - font.GetHeight()) / 2);
                }
            }
            finally
            {
                gph.Dispose();
            }
            return(origBanner);
        }
Example #4
0
        /// <summary>
        /// Creates a font object based on the given name
        /// </summary>
        /// <param name="name">Name of the font</param>
        /// <returns>Font </returns>
        protected static Font getFont(String name)
        {
            GUIFont guiFont = GUIFontManager.GetFont(name);

            return(new Font(guiFont.FileName, guiFont.FontSize, guiFont.FontStyle));
        }
Example #5
0
        /// <summary>
        /// Create a grid.
        /// </summary>
        /// <param name="labels">The labels to fill the grid with.</param>
        /// <param name="score">The Score to display.</param>
        /// <param name="startLine">The first line to display.</param>
        private void CreateGrid(string[][] labels, BaseScore score, int startLine, int startColumn)
        {
            bool overRight  = false;
            bool overDown   = false;
            int  lineNumber = 0;
            int  colNumber  = 0;

            IScoreBuilder <GUIControl> bld = ScoreFactory.Instance.GetBuilder <GUIControl>(score);

            bld.Styles      = m_center.Styles.ToList().AsReadOnly();
            bld.UseAltColor = m_center.Setup.UseAltColor;

            GUIFont font = GUIFontManager.GetFont(tbxDetails.FontName);
            int     fontSize = font.FontSize;
            int     charHeight = 0, charWidth = 0;

            GetCharFonSize(fontSize, ref charWidth, ref charHeight);
            bld.SetFont(tbxDetails.FontName, tbxDetails.TextColor, tbxDetails.ColourDiffuse, fontSize, charWidth, charHeight);

            // add controls to screen
            try
            {
                m_scoreGroup.Visibility = System.Windows.Visibility.Hidden;
                IList <GUIControl> controls = bld.Build(score, labels,
                                                        startLine, startColumn,
                                                        tbxDetails.XPosition, tbxDetails.YPosition, tbxDetails.Width, tbxDetails.Height,
                                                        this.CreateControl,
                                                        out overRight, out overDown, out lineNumber, out colNumber);

                foreach (GUIControl c in controls)
                {
                    c.AllocResources();
                    m_scoreGroup.AddControl(c);
                }
            }
            catch (Exception exc)
            {
                Tools.LogError(">>>>>>> Error in Create Grid", exc);
            }
            finally
            {
                m_scoreGroup.Visibility = System.Windows.Visibility.Visible;
            }

            #region Set for Next page
            if (overRight)
            {
                // keep current line
                m_currentColumn += tbxDetails.Width;
                ShowNextButton(true);
            }
            else
            {
                // reset current column
                m_currentColumn = 0;

                if (overDown)
                {
                    m_currentLine = lineNumber - 1;
                    ShowNextButton(true);
                }
                else
                {
                    // no more pages
                    m_currentLine = 0;
                }
            }
            #endregion
        }
    public override void AllocResources()
    {
        base.AllocResources();

        m_Font = GUIFontManager.GetFont((m_strFont != "" && m_strFont != "-") ? m_strFont : "font18");

        if (m_imgTexture != null)
        {
            m_imgTexture.AllocResources();
        }

        if (m_imgTextureFocused != null)
        {
            m_imgTextureFocused.AllocResources();
        }

        if (m_imgGuide != null)
        {
            if (m_imgGuide[0] != null)
            {
                m_imgGuide[0].AllocResources();
            }

            if (m_imgGuide[1] != null)
            {
                m_imgGuide[1].AllocResources();
            }
        }

        if (m_imgBlocks != null)
        {
            foreach (GUIImage image in m_imgBlocks)
            {
                image.AllocResources();
            }
        }

        if (m_imgGuide[0] != null)
        {
            m_imgGuide[0].Height = m_nBoardHeight - (m_cyBlock * 2);
            m_imgGuide[0].SetPosition(m_nBoardX - (m_imgGuide[0].Width + 2),
                                      ((m_nBoardY + m_cyBlock) + (Game.Height * m_cyBlock)) - m_imgGuide[0].Height);
        }

        if (m_imgGuide[1] != null)
        {
            m_imgGuide[1].Height = m_nBoardHeight - (m_cyBlock * 2);
            m_imgGuide[1].SetPosition(m_nBoardX + m_nBoardWidth + 2,
                                      ((m_nBoardY + m_cyBlock) + (Game.Height * m_cyBlock)) - m_imgGuide[1].Height);
        }

        if (m_imgBlocksGlow != null)
        {
            foreach (GUIImage image in m_imgBlocksGlow)
            {
                image.AllocResources();
            }
        }

        // we must use local variables for the following transform or we'll lose the original next
        // block positions and experience problems if the user performs multiple fullscreen toggles
        int nNextBlockX = m_nNextBlockX;
        int nNextBlockY = m_nNextBlockY;

        GUIGraphicsContext.ScalePosToScreenResolution(ref nNextBlockX, ref nNextBlockY);

        if (m_imgBlocksNext != null)
        {
            foreach (GUIImage image in m_imgBlocksNext)
            {
                image.AllocResources();

                if (m_nNextBlockAlign == Alignment.ALIGN_LEFT)
                {
                    image.SetPosition(nNextBlockX, nNextBlockY - (image.Height / 2));
                }
                else if (m_nNextBlockAlign == Alignment.ALIGN_CENTER)
                {
                    image.SetPosition(nNextBlockX - (image.Width / 2), nNextBlockY - (image.Height / 2));
                }
                else if (m_nNextBlockAlign == Alignment.ALIGN_RIGHT)
                {
                    image.SetPosition(nNextBlockX - image.Width, nNextBlockY - (image.Height / 2));
                }
            }
        }
    }
    public override void FinalizeConstruction()
    {
        base.FinalizeConstruction();

        m_Font = GUIFontManager.GetFont((m_strFont != "" && m_strFont != "-") ? m_strFont : "font18");

        if (m_strTexture != "" && m_strTexture != "-")
        {
            m_imgTexture = new GUIImage(_parentControlId, 9998, _positionX, _positionY, this.Width, this.Height, m_strTexture,
                                        m_dwColorDiffuse);
        }

        if (m_strTextureFocused != "" && m_strTextureFocused != "-")
        {
            m_imgTextureFocused = new GUIImage(_parentControlId, 9999, _positionX, _positionY, this.Width, this.Height,
                                               m_strTextureFocused, m_dwColorDiffuse);
        }

        m_imgGuide = new GUIImage[2];

        m_nBoardWidth  = (m_nBoardWidth == -99999) ? this.Width : m_nBoardWidth;
        m_nBoardHeight = (m_nBoardHeight == -99999) ? this.Height : m_nBoardHeight;

        m_cyBlock     = m_nBoardHeight / (Game.Height + 2);
        m_cxBlock     = m_cyBlock;
        m_nBoardWidth = m_cxBlock * Game.Width;

        m_nBoardX = (m_nBoardX == -99999) ? _positionX + ((this.Width - (m_cxBlock * Game.Width)) / 2) : m_nBoardX;
        m_nBoardY = (m_nBoardY == -99999) ? _positionY + ((this.Height - (m_cyBlock * Game.Height)) / 2) : m_nBoardY;
        m_nBoardY = m_nBoardY - m_cyBlock;

        m_imgBlocks = new GUIImage[]
        {
            new GUIImage(_parentControlId, 10001, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_red.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10002, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_blue.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10003, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_gray.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10004, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_yellow.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10005, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_cyan.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10006, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_orange.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10007, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_green.png"), m_dwColorDiffuse),
        };

        m_imgBlocksGlow = new GUIImage[]
        {
            new GUIImage(_parentControlId, 10011, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_red_glow.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10012, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_blue_glow.png"), m_dwColorDiffuse)
            ,
            new GUIImage(_parentControlId, 10013, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_gray_glow.png"), m_dwColorDiffuse)
            ,
            new GUIImage(_parentControlId, 10014, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_yellow_glow.png"),
                         m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10015, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_cyan_glow.png"), m_dwColorDiffuse)
            ,
            new GUIImage(_parentControlId, 10016, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_orange_glow.png"),
                         m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10017, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_green_glow.png"), m_dwColorDiffuse)
            ,
        };

        m_strStart    = GUILocalizeStrings.Get(19010);
        m_strPaused   = GUILocalizeStrings.Get(19011);
        m_strGameOver = GUILocalizeStrings.Get(19012);

        m_imgBlocksNext = new GUIImage[7];

        if (m_strTextureO != "" && m_strTextureO != "-")
        {
            m_imgBlocksNext[0] = new GUIImage(_parentControlId, 10021, _positionX, _positionY, 0, 0, m_strTextureO,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureI != "" && m_strTextureI != "-")
        {
            m_imgBlocksNext[1] = new GUIImage(_parentControlId, 10022, _positionX, _positionY, 0, 0, m_strTextureI,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureS != "" && m_strTextureS != "-")
        {
            m_imgBlocksNext[2] = new GUIImage(_parentControlId, 10023, _positionX, _positionY, 0, 0, m_strTextureS,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureZ != "" && m_strTextureZ != "-")
        {
            m_imgBlocksNext[3] = new GUIImage(_parentControlId, 10024, _positionX, _positionY, 0, 0, m_strTextureZ,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureL != "" && m_strTextureL != "-")
        {
            m_imgBlocksNext[4] = new GUIImage(_parentControlId, 10025, _positionX, _positionY, 0, 0, m_strTextureL,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureT != "" && m_strTextureT != "-")
        {
            m_imgBlocksNext[5] = new GUIImage(_parentControlId, 10026, _positionX, _positionY, 0, 0, m_strTextureT,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureJ != "" && m_strTextureJ != "-")
        {
            m_imgBlocksNext[6] = new GUIImage(_parentControlId, 10027, _positionX, _positionY, 0, 0, m_strTextureJ,
                                              m_dwColorDiffuse);
        }

        if (m_imgBlocksNext != null)
        {
            foreach (GUIImage image in m_imgBlocksNext)
            {
                if (image != null)
                {
                    image.ScaleToScreenResolution();
                }
            }
        }

        if (m_strTextureLeft != "" && m_strTextureLeft != "-")
        {
            m_imgGuide[0] = new GUIImage(_parentControlId, 9996, _positionX, _positionY, 0, 0, m_strTextureLeft,
                                         m_dwColorDiffuse);
        }

        if (m_strTextureRight != "" && m_strTextureRight != "-")
        {
            m_imgGuide[1] = new GUIImage(_parentControlId, 9997, _positionX, _positionY, 0, 0, m_strTextureRight,
                                         m_dwColorDiffuse);
        }
    }