示例#1
0
        //#################################################################

        static private void initFonts(cXMLHandler XmlHandler)
        {
            pFonts = new Hashtable();

            string[] path     = { /*"skin", */ "fonts" };
            XmlNode  fontNode = XmlHandler.XmlGetRootNodeElement(path);

            if (fontNode == null)
            {
                //PVMC Workaround till proper fonts for plugins is implemented in enigma2
                //We expect that the fontloader pseudo screen is the first screen in the skin
                path[0]  = "screen";
                fontNode = XmlHandler.XmlGetRootNodeElement(path);
                if (fontNode.Attributes["name"].Value == "PVMC_FontLoader")
                {
                    Hashtable elements = new Hashtable();
                    foreach (XmlNode myXmlNode in fontNode.ChildNodes)
                    {
                        if (myXmlNode.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        elements.Add(myXmlNode.Attributes["name"].Value, myXmlNode.Attributes["text"].Value);
                    }

                    Int32 api = Convert.ToInt32(elements["API"] != null ? elements["API"] : "1");
                    if (api >= 2)
                    {
                        Int32 count = Convert.ToInt32(elements["COUNT"] != null ? elements["COUNT"] : "0");
                        for (int i = 0; i < count; i++)
                        {
                            string[] fontString = ((string)elements["FONT" + i.ToString()]).Split('|');

                            sFont font = new sFont(
                                fontString[1],
                                fontString[0],
                                Convert.ToInt32(fontString[2]),
                                12,
                                "",
                                fontString[3] != "False"
                                );
                            pFonts.Add(font.Name, font);
                        }
                    }
                }
            }
            else
            {
                foreach (XmlNode myXmlNode in fontNode.ChildNodes)
                {
                    if (myXmlNode.NodeType != XmlNodeType.Element || myXmlNode.Name != "font" && myXmlNode.Name != "alias") //MOD
                    {
                        continue;
                    }
                    if (myXmlNode.Name == "font") //MOD
                    {
                        try                       //MOD
                        {
                            if (pFonts[myXmlNode.Attributes["name"].Value] == null)
                            {
                                sFont font = new sFont(
                                    myXmlNode.Attributes["name"].Value,
                                    myXmlNode.Attributes["filename"].Value,
                                    Convert.ToInt32(myXmlNode.Attributes["scale"] != null ? myXmlNode.Attributes["scale"].Value : "100"),
                                    Convert.ToInt32(myXmlNode.Attributes["size"] != null),
                                    "",
                                    Convert.ToInt32(myXmlNode.Attributes["replacement"] != null ? myXmlNode.Attributes["replacement"].Value : "0") != 0);
                                pFonts.Add(font.Name, font);
                            }
                            else
                            {
                                String errormessage = fMain.GetTranslation("More than one font defined with name") + " '" + myXmlNode.Attributes["name"].Value + "'";

                                MessageBox.Show(errormessage,
                                                fMain.GetTranslation("Error while parsing font table"),
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information,
                                                MessageBoxDefaultButton.Button1);
                            }
                        }
                        catch
                        {
                        }
                    }
                    else if (myXmlNode.Name == "alias")//MOD
                    {
                        try
                        {
                            if (pFonts[myXmlNode.Attributes["name"].Value] == null)
                            {
                                sFont font = new sFont(
                                    myXmlNode.Attributes["name"].Value,
                                    getFont(myXmlNode.Attributes["font"].Value).Path,
                                    100,
                                    Convert.ToInt32(myXmlNode.Attributes["size"].Value),
                                    myXmlNode.Attributes["font"].Value,
                                    false,
                                    true);

                                pFonts.Add(font.Name, font);
                            }
                            else
                            {
                                String errormessage = fMain.GetTranslation("More than one font (alias) defined with name") + " '" + myXmlNode.Attributes["name"].Value + "'";

                                MessageBox.Show(errormessage,
                                                fMain.GetTranslation("Error while parsing font table"),
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information,
                                                MessageBoxDefaultButton.Button1);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
示例#2
0
            public cDataBaseWindowstyle(cXMLHandler XmlHandler)
            {
                Hashtable colors = new Hashtable();
                sFont     titlefont = null;
                float     titlesize = (float)0.0;
                Int32     xOff = 0, yOff = 0;
                ArrayList bordersets = new ArrayList();

                string[] path      = { /*"skin", */ "windowstyle" };
                XmlNode  styleNode = XmlHandler.XmlGetRootNodeElement(path);

                if (styleNode == null)
                {
                    //<font filename= name= scale="90" />
                    sFont font = new sFont(
                        "Regular",
                        "nmsbd.ttf",
                        90,
                        30,
                        "nmsbd",
                        false
                        );
                    pFonts.Add(font.Name, font);

                    colors.Add("Background", pColors.get("#25062748"));
                    colors.Add("LabelForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxBackground", pColors.get("#25062748"));
                    colors.Add("ListboxForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxSelectedBackground", pColors.get("#254f7497"));
                    colors.Add("ListboxSelectedForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxMarkedBackground", pColors.get("#ff0000"));
                    colors.Add("ListboxMarkedForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxMarkedAndSelectedBackground", pColors.get("#800000"));
                    colors.Add("ListboxMarkedAndSelectedForeground", pColors.get("#ffffff"));
                    colors.Add("WindowTitleForeground", pColors.get("#ffffff"));
                    colors.Add("WindowTitleBackground", pColors.get("#25062748"));

                    sWindowStyle.sBorderSet borderset = new sWindowStyle.sBorderSet(
                        "bsWindow",
                        "skin_default/b_tl.png",
                        "skin_default/b_t.png",
                        "skin_default/b_tr.png",
                        "skin_default/b_l.png",
                        "skin_default/b_r.png",
                        "skin_default/b_bl.png",
                        "skin_default/b_b.png",
                        "skin_default/b_br.png");
                    bordersets.Add(borderset);

                    pWindowStyle = new sWindowStyle(getFont("Regular"), 20.0f, 33, 14, colors, (sWindowStyle.sBorderSet[])bordersets.ToArray(typeof(sWindowStyle.sBorderSet)));
                }
                else
                {
                    foreach (XmlNode myXmlNode in styleNode.ChildNodes)
                    {
                        if (myXmlNode.Name == "color")
                        {
                            if (colors[myXmlNode.Attributes["color"].Value] == null)
                            {
                                colors.Add(myXmlNode.Attributes["name"].Value, pColors.get(myXmlNode.Attributes["color"].Value));
                            }
                        }
                        else if (myXmlNode.Name == "title")
                        {
                            String font = myXmlNode.Attributes["font"].Value;
                            titlesize = Convert.ToSingle(font.Substring(font.IndexOf(';') + 1));
                            font      = font.Substring(0, font.IndexOf(';'));
                            titlefont = getFont(font);
                            xOff      = Convert.ToInt32(myXmlNode.Attributes["offset"].Value.Substring(0, myXmlNode.Attributes["offset"].Value.IndexOf(',')));
                            yOff      = Convert.ToInt32(myXmlNode.Attributes["offset"].Value.Substring(myXmlNode.Attributes["offset"].Value.IndexOf(',') + 1));
                        }
                        else if (myXmlNode.Name == "borderset")
                        {
                            String pbpTopLeftName     = "";
                            String pbpTopName         = "";
                            String pbpTopRightName    = "";
                            String pbpLeftName        = "";
                            String pbpRightName       = "";
                            String pbpBottomLeftName  = "";
                            String pbpBottomName      = "";
                            String pbpBottomRightName = "";

                            //string[] path2 = { "skin", "windowstyle", "borderset" };
                            //XmlNode fontNode2 = XmlHandler.XmlGetRootNodeElement(path2);
                            foreach (XmlNode myXmlNode2 in /*fontNode2*/ myXmlNode.ChildNodes)
                            {
                                if (myXmlNode2.Attributes["pos"].Value == "bpTopLeft")
                                {
                                    pbpTopLeftName = myXmlNode2.Attributes["filename"].Value;
                                }
                                else if (myXmlNode2.Attributes["pos"].Value == "bpTop")
                                {
                                    pbpTopName = myXmlNode2.Attributes["filename"].Value;
                                }
                                else if (myXmlNode2.Attributes["pos"].Value == "bpTopRight")
                                {
                                    pbpTopRightName = myXmlNode2.Attributes["filename"].Value;
                                }
                                else if (myXmlNode2.Attributes["pos"].Value == "bpLeft")
                                {
                                    pbpLeftName = myXmlNode2.Attributes["filename"].Value;
                                }
                                else if (myXmlNode2.Attributes["pos"].Value == "bpRight")
                                {
                                    pbpRightName = myXmlNode2.Attributes["filename"].Value;
                                }
                                else if (myXmlNode2.Attributes["pos"].Value == "bpBottomLeft")
                                {
                                    pbpBottomLeftName = myXmlNode2.Attributes["filename"].Value;
                                }
                                else if (myXmlNode2.Attributes["pos"].Value == "bpBottom")
                                {
                                    pbpBottomName = myXmlNode2.Attributes["filename"].Value;
                                }
                                else if (myXmlNode2.Attributes["pos"].Value == "bpBottomRight")
                                {
                                    pbpBottomRightName = myXmlNode2.Attributes["filename"].Value;
                                }
                            }

                            sWindowStyle.sBorderSet borderset = new sWindowStyle.sBorderSet(
                                myXmlNode.Attributes["name"].Value,
                                pbpTopLeftName,
                                pbpTopName,
                                pbpTopRightName,
                                pbpLeftName,
                                pbpRightName,
                                pbpBottomLeftName,
                                pbpBottomName,
                                pbpBottomRightName);
                            bordersets.Add(borderset);
                        }
                    }

                    pWindowStyle = new sWindowStyle(titlefont, titlesize, xOff, yOff, colors, (sWindowStyle.sBorderSet[])bordersets.ToArray(typeof(sWindowStyle.sBorderSet)));
                }
            }
示例#3
0
 static public sFont[] getFonts()
 {
     sFont[] fonts = new sFont[pFonts.Count];
     pFonts.Values.CopyTo(fonts, 0);
     return(fonts);
 }
示例#4
0
        //#################################################################

        static private void initFonts(cXMLHandler XmlHandler)
        {
            pFonts = new Hashtable();

            string[] path     = { /*"skin", */ "fonts" };
            XmlNode  fontNode = XmlHandler.XmlGetRootNodeElement(path);

            if (fontNode == null)
            {
                //PVMC Workaround till proper fonts for plugins is implemented in enigma2
                //We expect that the fontloader pseudo screen is the first screen in the skin
                path[0]  = "screen";
                fontNode = XmlHandler.XmlGetRootNodeElement(path);
                if (fontNode.Attributes["name"].Value == "PVMC_FontLoader")
                {
                    Hashtable elements = new Hashtable();
                    foreach (XmlNode myXmlNode in fontNode.ChildNodes)
                    {
                        if (myXmlNode.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        elements.Add(myXmlNode.Attributes["name"].Value, myXmlNode.Attributes["text"].Value);
                    }

                    Int32 api = Convert.ToInt32(elements["API"] != null ? elements["API"] : "1");
                    if (api >= 2)
                    {
                        Int32 count = Convert.ToInt32(elements["COUNT"] != null ? elements["COUNT"] : "0");
                        for (int i = 0; i < count; i++)
                        {
                            string[] fontString = ((string)elements["FONT" + i.ToString()]).Split('|');

                            sFont font = new sFont(
                                fontString[1],
                                fontString[0],
                                Convert.ToInt32(fontString[2]),
                                fontString[3] != "False"
                                );
                            pFonts.Add(font.Name, font);
                        }
                    }
                }
            }
            else
            {
                foreach (XmlNode myXmlNode in fontNode.ChildNodes)
                {
                    if (myXmlNode.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    sFont font = new sFont(
                        myXmlNode.Attributes["name"].Value,
                        myXmlNode.Attributes["filename"].Value,
                        Convert.ToInt32(myXmlNode.Attributes["scale"] != null ? myXmlNode.Attributes["scale"].Value : "100"),
                        Convert.ToInt32(myXmlNode.Attributes["replacement"] != null ? myXmlNode.Attributes["replacement"].Value : "0") != 0
                        );
                    pFonts.Add(font.Name, font);
                }
            }
        }
            public cDataBaseWindowstyle(cXMLHandler XmlHandler)
            {
                Hashtable colors = new Hashtable();
                sFont     titlefont = null;
                float     titlesize = (float)0.0;
                Int32     xOff = 0, yOff = 0;
                ArrayList bordersets = new ArrayList();

                string[] path      = { /*"skin", */ "windowstyle" };
                XmlNode  styleNode = XmlHandler.XmlGetRootNodeElement(path);

                if (styleNode == null)
                {
                    //<font filename= name= scale="90" />
                    sFont font = new sFont(
                        "Regular",
                        "nmsbd.ttf",
                        90,
                        30,
                        "nmsbd",
                        false
                        );
                    pFonts.Add(font.Name, font);

                    colors.Add("Background", pColors.get("#25062748"));
                    colors.Add("LabelForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxBackground", pColors.get("#25062748"));
                    colors.Add("ListboxForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxSelectedBackground", pColors.get("#254f7497"));
                    colors.Add("ListboxSelectedForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxMarkedBackground", pColors.get("#ff0000"));
                    colors.Add("ListboxMarkedForeground", pColors.get("#ffffff"));
                    colors.Add("ListboxMarkedAndSelectedBackground", pColors.get("#800000"));
                    colors.Add("ListboxMarkedAndSelectedForeground", pColors.get("#ffffff"));
                    colors.Add("WindowTitleForeground", pColors.get("#ffffff"));
                    colors.Add("WindowTitleBackground", pColors.get("#25062748"));

                    sWindowStyle.sBorderSet borderset = new sWindowStyle.sBorderSet(
                        "bsWindow",
                        "skin_default/b_tl.png",
                        "skin_default/b_t.png",
                        "skin_default/b_tr.png",
                        "skin_default/b_l.png",
                        "skin_default/b_r.png",
                        "skin_default/b_bl.png",
                        "skin_default/b_b.png",
                        "skin_default/b_br.png");
                    bordersets.Add(borderset);

                    pWindowStyle = new sWindowStyle(getFont("Regular"), 20.0f, 33, 14, colors, (sWindowStyle.sBorderSet[])bordersets.ToArray(typeof(sWindowStyle.sBorderSet)));
                }
                else
                {
                    foreach (XmlNode myXmlNode in styleNode.ChildNodes)
                    {
                        if (myXmlNode.Name == "color")
                        {
                            if (colors[myXmlNode.Attributes["color"].Value] == null)
                            {
                                colors.Add(myXmlNode.Attributes["name"].Value, pColors.get(myXmlNode.Attributes["color"].Value));
                            }
                        }
                        else if (myXmlNode.Name == "title")
                        {
                            String font = myXmlNode.Attributes["font"].Value;
                            titlesize = Convert.ToSingle(font.Substring(font.IndexOf(';') + 1));
                            font      = font.Substring(0, font.IndexOf(';'));
                            titlefont = getFont(font);
                            xOff      = Convert.ToInt32(myXmlNode.Attributes["offset"].Value.Substring(0, myXmlNode.Attributes["offset"].Value.IndexOf(',')));
                            yOff      = Convert.ToInt32(myXmlNode.Attributes["offset"].Value.Substring(myXmlNode.Attributes["offset"].Value.IndexOf(',') + 1));
                        }
                        else if (myXmlNode.Name == "borderset")
                        {
                            String pbpTopLeftName     = "";
                            String pbpTopName         = "";
                            String pbpTopRightName    = "";
                            String pbpLeftName        = "";
                            String pbpRightName       = "";
                            String pbpBottomLeftName  = "";
                            String pbpBottomName      = "";
                            String pbpBottomRightName = "";

                            //string[] path2 = { "skin", "windowstyle", "borderset" };
                            //XmlNode fontNode2 = XmlHandler.XmlGetRootNodeElement(path2);
                            int anz = 0;
                            foreach (XmlNode myXmlNode2 in /*fontNode2*/ myXmlNode.ChildNodes)
                            {
                                try
                                {
                                    if (myXmlNode2.Attributes["pos"] != null)
                                    {
                                        if (myXmlNode2.Attributes["pos"].Value == "bpTopLeft")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpTopLeftName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                        else if (myXmlNode2.Attributes["pos"].Value == "bpTop")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpTopName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                        else if (myXmlNode2.Attributes["pos"].Value == "bpTopRight")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpTopRightName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                        else if (myXmlNode2.Attributes["pos"].Value == "bpLeft")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpLeftName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                        else if (myXmlNode2.Attributes["pos"].Value == "bpRight")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpRightName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                        else if (myXmlNode2.Attributes["pos"].Value == "bpBottomLeft")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpBottomLeftName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                        else if (myXmlNode2.Attributes["pos"].Value == "bpBottom")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpBottomName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                        else if (myXmlNode2.Attributes["pos"].Value == "bpBottomRight")
                                        {
                                            if (myXmlNode2.OuterXml.Contains("filename="))
                                            {
                                                pbpBottomRightName = myXmlNode2.Attributes["filename"].Value;
                                            }
                                            else
                                            {
                                                anz += 1;
                                            }
                                        }
                                    }
                                    else
                                    { // [pos] = null
                                    }
                                }
                                catch (NullReferenceException err)
                                {
                                    MessageBox.Show("There is something wrong with your borderset" + "\n\n" + err.Message);
                                }
                            }
                            if (anz > 0)
                            {
                                MessageBox.Show("The path of " + anz + " borderset-files is not specified!" + "\n\n",
                                                "Path(s) not specified",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information);
                            }
                            sWindowStyle.sBorderSet borderset = new sWindowStyle.sBorderSet(
                                myXmlNode.Attributes["name"].Value,
                                pbpTopLeftName,
                                pbpTopName,
                                pbpTopRightName,
                                pbpLeftName,
                                pbpRightName,
                                pbpBottomLeftName,
                                pbpBottomName,
                                pbpBottomRightName);
                            bordersets.Add(borderset);
                        }
                    }

                    pWindowStyle = new sWindowStyle(titlefont, titlesize, xOff, yOff, colors, (sWindowStyle.sBorderSet[])bordersets.ToArray(typeof(sWindowStyle.sBorderSet)));
                }
            }
示例#6
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                textBoxName.Text            = listView1.SelectedItems[0].SubItems[1].Text;
                textBoxPath.Text            = listView1.SelectedItems[0].SubItems[5].Text;
                textBoxScale.Text           = listView1.SelectedItems[0].SubItems[6].Text;
                textBox1.Text               = listView1.SelectedItems[0].SubItems[4].Text;
                checkBoxReplacement.Checked = Convert.ToBoolean(listView1.SelectedItems[0].SubItems[7].Text);

                float pSize = Convert.ToSingle(textBox1.Text);
                sFont pFont = cDataBase.getFont(textBoxName.Text);

                // System.Drawing.Font font = null;
                String name  = "";
                bool   found = true;
                try
                {
                    if (pFont.FontFamily != null) //Only do this if the font is valid
                    {
                        name  = pFont.FontFamily.GetName(0);
                        found = pFont.Found; //MOD
                        if (found == true)   //MOD
                        {
                            PreviewText  = fMain.GetTranslation("This is a preview-text to show the font");
                            PreviewText2 = fMain.GetTranslation("Test-String SKY 1234567890 !#?ÜÖÄ$%/()");
                            if (pSize == 0) //MOD if Size=0 set Size and show preview-text
                            {
                                pSize        = 20;
                                PreviewText  = fMain.GetTranslation("To be able to show this preview, the font size");
                                PreviewText2 = fMain.GetTranslation("was temporarily changed from 0 to 20");
                            }
                            // font = new System.Drawing.Font(pFont.FontFamily, pSize, pFont.FontStyle, GraphicsUnit.Pixel);
                            MyFont = new System.Drawing.Font(pFont.FontFamily, pSize, pFont.FontStyle, GraphicsUnit.Pixel);
                            pictureBox1.Invalidate();
                            pictureBox2.Invalidate(); //MOD
                            textBoxPreview.Visible = false;
                        }
                        else
                        {
                            Console.WriteLine(fMain.GetTranslation("Font painting failed!") + " (" + pFont.Name + ")");
                            textBoxPreview.Text    = fMain.GetTranslation("The font") + " '" + pFont.Name + "' " + fMain.GetTranslation("was not found.") + Environment.NewLine + fMain.GetTranslation("Probably this is a default font on the image of your box");
                            textBoxPreview.Visible = true; //MOD
                        }
                    }
                    else
                    {
                        Console.WriteLine("Font painting failed! (" + pFont.Name + ")");
                        textBoxPreview.Text    = fMain.GetTranslation("The font") + " '" + pFont.Name + "' " + fMain.GetTranslation("was not found.") + Environment.NewLine + fMain.GetTranslation("Probably this is a default font on the image of your box");
                        textBoxPreview.Visible = true; //MOD
                    }
                }
                catch (Exception error)
                {
                    Console.WriteLine("Font painting failed! (" + pFont.Name + ")\n" + error);
                    textBoxPreview.Text    = error.Message;
                    textBoxPreview.Visible = true; //MOD
                    return;
                }
            }
        }