Exemple #1
0
        public Preferences(string sWorkFolder, string sData)
        {
            _sWorkFolder = sWorkFolder;

            XmlDocument cXmlDocument = new XmlDocument();

            cXmlDocument.LoadXml(sData);
            XmlNode cXmlNode = cXmlDocument.NodeGet("data");

            cDBCredentials = new DB.Credentials(cXmlNode.NodeGet("database"));

            bMessagesRelease = cXmlNode.AttributeOrDefaultGet <bool>("release", false);
            eBroadcastType   = cXmlNode.AttributeOrDefaultGet <BroadcastType>("type", BroadcastType.linear);
            nSMSQtty         = cXmlNode.AttributeGet <int>("queue");
            bAnotherAirError = cXmlNode.AttributeOrDefaultGet <bool>("another_air_err", false);

            XmlNode cNodeChild = cXmlNode.NodeGet("vip");

            if (null != cNodeChild)
            {
                cVIP = new VIP();
                XmlNode cXNPromos = cNodeChild.NodeGet("promos", false);
                if (null != cXNPromos)
                {
                    cVIP.tsPromoPeriod = cXNPromos.AttributeGet <TimeSpan>("period");
                    cVIP.aPromos       = new List <Promo>();
                    List <Promo>       aPromos = new List <Promo>();
                    List <WeeklyRange> aWeeklyRanges;
                    foreach (XmlNode cPromo in cXNPromos.NodesGet("promo", false))
                    {
                        aWeeklyRanges = new List <WeeklyRange>();
                        foreach (XmlNode cWeeklyRange in cPromo.NodesGet("weeklyrange", false))
                        {
                            aWeeklyRanges.Add(new WeeklyRange(
                                                  cWeeklyRange.AttributeValueGet("dayin"),
                                                  cWeeklyRange.AttributeValueGet("timein"),
                                                  cWeeklyRange.AttributeValueGet("dayout"),
                                                  cWeeklyRange.AttributeValueGet("timeout")
                                                  ));
                        }
                        aPromos.Add(new Promo()
                        {
                            nID          = cPromo.InnerXml.GetHashCode(),
                            aWeeklyRange = aWeeklyRanges,
                            bEnabled     = cPromo.AttributeGet <bool>("enabled"),
                            sText        = cPromo.NodeGet("text").InnerXml
                        });
                    }
                    cVIP.aPromos.AddRange(aPromos);
                }
                cVIP.sFile   = System.IO.Path.Combine(_sWorkFolder, "data/vip.dat");
                cVIP.sPrefix = "VIP";
                cVIP.cFont   = FontParse(cNodeChild.NodeGet("font"));
            }
            #region . ROLL .
            cNodeChild           = cXmlNode.NodeGet("roll");
            cRoll                = new Roll();
            cRoll.nLayer         = cNodeChild.AttributeGet <ushort>("layer");
            cRoll.nSpeed         = cNodeChild.AttributeGet <float>("speed");
            cRoll.nUseHistorySMS = cNodeChild.AttributeOrDefaultGet <int>("use_history", 0); // 0 is off
            string sEx = cNodeChild.AttributeOrDefaultGet <string>("exceptions", "");        // 0 is off
            cRoll.cExceptions = new Roll.HoursExceptions(sEx);
            cRoll.stMerging   = new MergingMethod(cNodeChild);
            XmlNode cXNGrandChild = cNodeChild.NodeGet("holds");
            cRoll.SecondsPerLineSet(cXNGrandChild.AttributeGet <float>("line"));
            cRoll.nSecondsPerPause = cXNGrandChild.AttributeGet <float>("pause");
            cXNGrandChild          = cNodeChild.NodeGet("masks");
            cRoll.sMaskPageSingle  = cXNGrandChild.NodeGet("single").InnerXml;
            cRoll.sMaskPageMulti   = cXNGrandChild.NodeGet("multi").InnerXml;
            cRoll.stSize           = SizeParse(cNodeChild.NodeGet("size"));

            cRoll.cSMSCommon = RollCategoryGet(cNodeChild.NodeGet("common"));
            cRoll.cSMSVIP    = RollCategoryGet(cNodeChild.NodeGet("vip"));
            cRoll.cSMSPromo  = RollCategoryGet(cNodeChild.NodeGet("promo"));
            cRoll.cSMSPhoto  = RollCategoryGet(cNodeChild.NodeGet("photo"));
            #endregion
            #region . CRAWL .
            cNodeChild = cXmlNode.NodeGet("crawl");
            cCrawl     = new Crawl();
            cCrawl.sInfoStringNight = System.IO.Path.Combine(sWorkFolder, "data/info_night.dat");
            cCrawl.sCrowlLastStart  = System.IO.Path.Combine(sWorkFolder, "data/crowl_last_start.dat");;
            cCrawl.stMerging        = new MergingMethod(cNodeChild);
            cCrawl.nSpeed           = cNodeChild.AttributeGet <float>("speed");
            cCrawl.nLayer           = cNodeChild.AttributeGet <ushort>("layer");
            cCrawl.nShiftTop        = cXmlNode.AttributeOrDefaultGet <short>("shift_top", 0);
            cCrawl.nPressBottom     = cXmlNode.AttributeOrDefaultGet <short>("press_bot", 0);
            cCrawl.bRenderFields    = cXmlNode.AttributeOrDefaultGet <bool>("render_fields", false);
            cCrawl.stSize           = SizeParse(cNodeChild.NodeGet("size"));
            cCrawl.sText            = cNodeChild.NodeGet("text").InnerXml;
            cCrawl.sRegistryInfo    = cNodeChild.NodeGet("registration").InnerXml;

            cCrawl.cFont         = FontParse(cNodeChild = cNodeChild.NodeGet("font"));
            cCrawl.stColor       = ColorParse(cNodeChild.NodeGet("color"));
            cNodeChild           = cNodeChild.NodeGet("border");
            cCrawl.nBorderWidth  = cNodeChild.AttributeGet <float>("width");
            cCrawl.stBorderColor = ColorParse(cNodeChild.NodeGet("color", false));
            #endregion
            #region . ANIMATION .
            cNodeChild       = cXmlNode.NodeGet("mat");
            cMat             = new Mat();
            cXNGrandChild    = cNodeChild.NodeGet("badge");
            cMat.nBadgeLayer = cXNGrandChild.AttributeGet <ushort>("layer");
            cMat.stBadgeSize = SizeParse(cXNGrandChild.NodeGet("size"));
            cMat.sBadgeIn    = cXNGrandChild.NodeGet("in").InnerXml;
            cMat.sBadgeLoop  = cXNGrandChild.NodeGet("loop").InnerXml;
            cMat.sBadgeOut   = cXNGrandChild.NodeGet("out").InnerXml;

            cXNGrandChild        = cNodeChild.NodeGet("show");
            cMat.nShowLayer      = cXNGrandChild.AttributeGet <ushort>("layer");
            cMat.stShowSize      = SizeParse(cXNGrandChild.NodeGet("size"));
            cMat.sShowLoop       = cXNGrandChild.NodeGet("loop").InnerXml;
            cMat.sShowOut        = cXNGrandChild.NodeGet("out").InnerXml;
            cMat.sShowTransition = cXNGrandChild.NodeGet("transition").InnerXml;

            cXNGrandChild           = cXNGrandChild.NodeGet("standby");
            cMat.sStandbyIn         = cXNGrandChild.NodeGet("in").InnerXml;
            cMat.sStandbyLoop       = cXNGrandChild.NodeGet("loop").InnerXml;
            cMat.sStandbyOut        = cXNGrandChild.NodeGet("out").InnerXml;
            cMat.sStandbyTransition = cXNGrandChild.NodeGet("transition").InnerXml;

            cXNGrandChild  = cNodeChild.NodeGet("out");
            cMat.nOutLayer = cXNGrandChild.AttributeGet <ushort>("layer");
            cMat.stOutSize = SizeParse(cXNGrandChild.NodeGet("size"));
            cMat.sOut      = cXNGrandChild.NodeGet("animation").InnerXml;
            #endregion
        }
Exemple #2
0
            public btl.Roll NewRollMidGet()
            {
                XmlDocument cXmlDocument = new XmlDocument();

                string[] aOld      = aVotesOld, aNew = aVotesNew;
                string   sOuterXML = sOuterXMLMidRoll.Replace("%%MID_TXT_L_OLD%%", aOld[0]);

                sOuterXML = sOuterXML.Replace("%%MID_TXT_R_OLD%%", aOld[1]);
                sOuterXML = sOuterXML.Replace("%%MID_TXT_L_NEW%%", aNew[0]);
                sOuterXML = sOuterXML.Replace("%%MID_TXT_R_NEW%%", aNew[1]);
                cXmlDocument.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + sOuterXML);
                List <XmlNode> aToDelete = new List <XmlNode>();
                XmlNode        cXmlEff   = cXmlDocument.NodeGet("roll/effects");

                foreach (XmlNode cXml in cXmlEff.ChildNodes)
                {
                    switch (cXml.AttributeValueGet("name"))
                    {
                    case "mid_left_old":
                        if (aOld[0] == "")
                        {
                            aToDelete.Add(cXml);
                        }
                        break;

                    case "mid_right_old":
                        if (aOld[1] == "")
                        {
                            aToDelete.Add(cXml);
                        }
                        break;

                    case "mid_left_new":
                        if (aNew[0] == "")
                        {
                            aToDelete.Add(cXml);
                        }
                        break;

                    case "mid_right_new":
                        if (aNew[1] == "")
                        {
                            aToDelete.Add(cXml);
                        }
                        break;
                    }
                }
                foreach (XmlNode cXml in aToDelete)
                {
                    cXmlEff.RemoveChild(cXml);
                }
                Roll cRetVal  = new Roll(cXmlDocument.NodeGet("roll"));
                Text cMLeftO  = (Text)cRetVal.EffectGet("mid_left_old");
                Text cMLeftN  = (Text)cRetVal.EffectGet("mid_left_new");
                Text cMRightO = (Text)cRetVal.EffectGet("mid_right_old");
                Text cMRightN = (Text)cRetVal.EffectGet("mid_right_new");
                int  nWL      = (cRetVal.stArea.nWidth - nMidGap) / 2;

                if (null != cMLeftO)
                {
                    cMLeftO.cDock.cOffset.nLeft += (short)((nWL - cMLeftO.stArea.nWidth) / 2);
                }
                cMLeftN.cDock.cOffset.nLeft += (short)((nWL - cMLeftN.stArea.nWidth) / 2);
                if (null != cMRightO)
                {
                    cMRightO.cDock.cOffset.nLeft += (short)(nWL + nMidGap + (nWL - cMRightO.stArea.nWidth) / 2);
                }
                cMRightN.cDock.cOffset.nLeft += (short)(nWL + nMidGap + (nWL - cMRightN.stArea.nWidth) / 2);
                return(cRetVal);
            }