Example #1
0
        } //constructor - pageMain

        private void GetSeasonVars(ref string pSeason, ref Color pcolorBack, ref Color pcolorText, ref string pCycle)
        {
            RomCal        cal = new RomCal();
            Season        seaNow;
            clsChurchYear litCal = new clsChurchYear();

            try
            {
                seaNow  = cal.SeasonOf(DateTime.Now);
                pSeason = seaNow.SeasonName;
                pCycle  = litCal.GetChurchYear(DateTime.Now).ToString();

                switch (seaNow.SeasonColor)
                {
                case Season.Colors.Green:
                    pcolorBack = Color.Green;
                    pcolorText = Color.White;
                    break;

                case Season.Colors.Purple:
                    pcolorBack = Color.Purple;
                    pcolorText = Color.White;
                    break;

                case Season.Colors.Red:
                    pcolorBack = Color.Red;
                    pcolorText = Color.White;
                    break;

                case Season.Colors.White:
                    pcolorBack = Color.White;
                    pcolorText = Color.Silver;
                    break;

                default:
                    pcolorBack = Color.Green;
                    pcolorText = Color.White;
                    break;
                }
            }
            catch (Exception)
            {
                //we errored - log later - rtn safe
                pSeason    = "Undefined Season";
                pcolorBack = Color.Blue;
                pcolorText = Color.White;
            }
        } //GetSeasonVars
Example #2
0
        public CHURCHYEAR GetChurchYear(System.DateTime dteToFind)
        {
            //Function to determine Year Cycle for RC Liturgical Calendar
            CHURCHYEAR eAnswer;

            try
            {
                int iYear = dteToFind.Year;
                int iSum  = sumOfDigits(iYear);

                if (iSum % 3 == 0)
                {
                    //if div by 3 its year C
                    eAnswer = CHURCHYEAR.C;
                }
                else
                {
                    //check year before
                    iSum = (iSum - 1);
                    if (iSum % 3 == 0)
                    {
                        //its year A
                        eAnswer = CHURCHYEAR.A;
                    }
                    else
                    {
                        eAnswer = CHURCHYEAR.B;
                    }
                }

                //Last - we need to handle december/lent which is new liturgical year:
                RomCal LitCal = new RomCal();
                //Console.WriteLine(LitCal.SeasonOf(dteToFind).SeasonName);

                if (dteToFind.Month == 12 | dteToFind.Month == 11)
                {
                    //then check if we are in new liturgical year:
                    if (LitCal.SeasonOf(dteToFind).SeasonName == "Advent")
                    {
                        //new year, need to increment
                        switch (eAnswer)
                        {
                        case CHURCHYEAR.A:
                            eAnswer = CHURCHYEAR.B;
                            break;

                        case CHURCHYEAR.B:
                            eAnswer = CHURCHYEAR.C;
                            break;

                        case CHURCHYEAR.C:
                            eAnswer = CHURCHYEAR.A;
                            break;
                        }
                    }
                }
                return(eAnswer);
            }
            catch (Exception)
            {
                //we errored - shouldnt get here but rtn safe with invalid X
                return(CHURCHYEAR.X);
            }
        } //GetChurchYear