protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            listBox1.ItemTemplate = timezoneTemplate;
            IList <String> zones   = TZInfo.readZones();
            string         suggest = ((App)App.Current).tempSuggestedTimezones;

            if (suggest != null)
            {
                string[] szones = suggest.Split(new char[] { ';' });
                for (int i = 0; i < szones.Length; i++)
                {
                    zones.Insert(i, szones[i]);
                }
            }
            listBox1.ItemsSource = zones;

            if (NavigationContext.QueryString.Keys.Contains("selected"))
            {
                string sel = NavigationContext.QueryString["selected"];
                int    i   = 0;
                foreach (object o in listBox1.ItemsSource)
                {
                    if (((String)o).Equals(sel, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Dispatcher.BeginInvoke(() =>
                        {
                            System.Threading.Thread.Sleep(200);
                            listBox1.ScrollIntoView(listBox1.Items[i]);
                        });
                        break;
                    }
                    i++;
                }
            }
        }
예제 #2
0
        public AstroDefs.planet_positions CalculatePositions(bool noPlanets)
        {
            //AstroDefs.EPHEM_YEAR preloadedYear = null;
            //TZInfo.SimpleTime st;
            if (TimeZone != TimeZoneDeviceLocal)
            {
                TZInfo tz;
                if (zoneCache.ContainsKey(TimeZone.Trim()))
                {
                    tz = zoneCache[TimeZone.Trim()];
                }
                else
                {
                    tz = new TZInfo(TimeZone.Trim());
                    zoneCache[TimeZone.Trim()] = tz;
                }
                //TZInfo tz = new TZInfo(TimeZone);
                utcTime = tz.toUTC(Year, Month, Day, Hour, Minute);
            }
            else
            {
                DateTime dt  = new DateTime(Year, Month, Day, Hour, Minute, 0, DateTimeKind.Local);
                DateTime utc = dt.ToUniversalTime();
                utcTime        = new TZInfo.SimpleTime();
                utcTime.year   = utc.Year;
                utcTime.month  = utc.Month;
                utcTime.day    = utc.Day;
                utcTime.hour   = utc.Hour;
                utcTime.minute = utc.Minute;
            }

            AstroDefs.planet_positions pp;
            if (noPlanets)
            {
                pp                 = AstroDefs.NULLpositions();
                pp.gmtTime         = AstroDefs.hmsToHours(utcTime.hour, utcTime.minute, 0);
                pp.gmt0sideralTime = (float)AstroDefs.calcGmtSideralTime(utcTime.year, utcTime.month, utcTime.day, 0, 0);
            }
            else
            {
                //AstroDefs.EPHEM_YEAR yearCache = null;
                if (preloadedYear != null && preloadedYear.days[0].year == utcTime.year)
                {
                    lastUsed = 1;
                    //yearCache = preloadedYear;
                }
                else if (preloadedYear2 != null && preloadedYear2.days[0].year == utcTime.year)
                {
                    lastUsed = 2;
                    //yearCache = preloadedYear2;
                }
                else
                {
                    if (lastUsed == 1)
                    {
                        lastUsed = 2;
                        //yearCache = preloadedYear2;
                    }
                    else
                    {
                        lastUsed = 1;
                        //yearCache = preloadedYear;
                    }
                }

                if (lastUsed == 1)
                {
                    pp = AstroDefs.ephem_calculateRecForGmt(
                        utcTime.year, utcTime.month, utcTime.day, utcTime.hour, utcTime.minute, 0,
                        ref preloadedYear);
                }
                else
                {
                    pp = AstroDefs.ephem_calculateRecForGmt(
                        utcTime.year, utcTime.month, utcTime.day, utcTime.hour, utcTime.minute, 0,
                        ref preloadedYear2);
                }
            }

            if (HouseSystem != HouseCalc.HOUSES_NULL)
            {
                HouseCalc.calcAscAndMc(ref pp, Latitude, Longitude);
            }
            else
            {
                float[] houses = CalculateHouses(pp);
                pp.ascendant   = houses[0];
                pp.mediumCoeli = houses[9];
            }
            return(pp);
        }