Ejemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var parameter = ((CelestiaAppCore, CelestiaRenderer))e.Parameter;

            AppCore       = parameter.Item1;
            Renderer      = parameter.Item2;
            mDestinations = new ObservableCollection <CelestiaDestination>(AppCore.Destinations);
        }
Ejemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var parameter = ((CelestiaAppCore, CelestiaRenderer))e.Parameter;

            AppCore  = parameter.Item1;
            Renderer = parameter.Item2;
            ReadBookmarks();
        }
Ejemplo n.º 3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var args = ((CelestiaAppCore, AppSettings, string[]))(e.Parameter);

            AppCore            = args.Item1;
            AppSettings        = args.Item2;
            AvailableLanguages = args.Item3;

            Nav.SelectedItem = NavigationItems[0];
        }
Ejemplo n.º 4
0
 public void GamepadButtonAction(CelestiaAppCore core, CelestiaJoystickButton button, bool pressed)
 {
     if (pressed)
     {
         core.JoystickButtonDown(button);
     }
     else
     {
         core.JoystickButtonUp(button);
     }
 }
Ejemplo n.º 5
0
        private void Nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
        {
            if (args.SelectedItem == null)
            {
                return;
            }

            var item = (Helper.NavigationViewItem)args.SelectedItem;

            if (item.Tag == "general")
            {
                Container.Navigate(typeof(GeneralSettingsPage), new SettingsArgs()
                {
                    AppCore = AppCore, Object = (AppSettings, AvailableLanguages)
                });
Ejemplo n.º 6
0
        private string GetOverview(CelestiaSelection Selection, CelestiaAppCore AppCore)
        {
            var obj = Selection.Object;

            if (obj is CelestiaBody)
            {
                return(GetBodyOverview((CelestiaBody)obj, AppCore));
            }
            if (obj is CelestiaStar)
            {
                return(GetStarOverview((CelestiaStar)obj, AppCore));
            }
            if (obj is CelestiaDSO)
            {
                return(GetDSOOveriew((CelestiaDSO)obj));
            }
            return(LocalizationHelper.Localize("No overview available."));
        }
Ejemplo n.º 7
0
        public void PollGamepad(CelestiaAppCore core)
        {
            UpdateGamepad();
            var controller = _controller;

            if (controller != null)
            {
                var    reading               = controller.GetCurrentReading();
                bool   isAPressed            = (reading.Buttons & GamepadButtons.A) != 0;
                bool   isXPressed            = (reading.Buttons & GamepadButtons.X) != 0;
                bool   isLeftTriggerPressed  = reading.LeftTrigger >= 0.5;
                bool   isRightTriggerPressed = reading.RightTrigger >= 0.5;
                double thumbstickX           = reading.LeftThumbstickX + reading.RightThumbstickX;
                double thumbstickY           = reading.LeftThumbstickY + reading.RightThumbstickY;
                if (isAPressed != _isAPressed)
                {
                    _isAPressed = isAPressed;
                    GamepadButtonAction(core, CelestiaJoystickButton.Button1, isAPressed);
                }
                if (isXPressed != _isXPressed)
                {
                    _isXPressed = isXPressed;
                    GamepadButtonAction(core, CelestiaJoystickButton.Button2, isXPressed);
                }
                if (isLeftTriggerPressed != _isLeftTriggerPressed)
                {
                    _isLeftTriggerPressed = isLeftTriggerPressed;
                    GamepadButtonAction(core, CelestiaJoystickButton.Button7, isLeftTriggerPressed);
                }
                if (isRightTriggerPressed != _isRightTriggerPressed)
                {
                    _isRightTriggerPressed = isRightTriggerPressed;
                    GamepadButtonAction(core, CelestiaJoystickButton.Button8, isRightTriggerPressed);
                }
                if (thumbstickX != 0.0)
                {
                    GamepadJoystickAction(core, CelestiaJoystickAxis.X, thumbstickX);
                }
                if (thumbstickY != 0.0)
                {
                    GamepadJoystickAction(core, CelestiaJoystickAxis.Y, thumbstickY);
                }
            }
        }
Ejemplo n.º 8
0
        private string GetStarOverview(CelestiaStar Star, CelestiaAppCore AppCore)
        {
            var str = "";

            var time   = AppCore.Simulation.Time;
            var celPos = Star.PositionAtTime(time).OffsetFrom(CelestiaUniversalCoord.Zero);
            var eqPos  = CelestiaHelper.EclipticToEquatorial(CelestiaHelper.CelToJ2000Ecliptic(celPos));
            var sph    = CelestiaHelper.RectToSpherical(eqPos);

            var hms = new CelestiaDMS(sph.X);

            str += string.Format(LocalizationHelper.Localize("RA: {0}h {1}m {2:N2}s"), hms.Hours, hms.Minutes, hms.Seconds);

            str += "\n";
            var dms = new CelestiaDMS(sph.Y);

            str += string.Format(LocalizationHelper.Localize("DEC: {0}° {1}′ {2:N2}″"), dms.Hours, dms.Minutes, dms.Seconds);

            return(str);
        }
Ejemplo n.º 9
0
 protected virtual void OnNavigatedTo(SettingsArgs args)
 {
     AppCore = args.AppCore;
 }
Ejemplo n.º 10
0
        private string GetBodyOverview(CelestiaBody Body, CelestiaAppCore AppCore)
        {
            var         str    = "";
            var         radius = Body.Radius;
            string      radiusString;
            const float oneMiInKm = 1.609344f;
            const float oneFtInKm = 0.0003048f;

            if (AppCore.MeasurementSystem == (int)CelestiaMeasurementSystem.imperial)
            {
                if (radius >= oneMiInKm)
                {
                    radiusString = string.Format(LocalizationHelper.Localize("%d mi").Replace("%d", "{0}"), (int)(radius / oneMiInKm));
                }
                else
                {
                    radiusString = string.Format(LocalizationHelper.Localize("%d ft").Replace("%d", "{0}"), (int)(radius / oneFtInKm));
                }
            }
            else
            {
                if (radius >= oneMiInKm)
                {
                    radiusString = string.Format(LocalizationHelper.Localize("%d km").Replace("%d", "{0}"), (int)radius);
                }
                else
                {
                    radiusString = string.Format(LocalizationHelper.Localize("%d m").Replace("%d", "{0}"), (int)(radius / 1000.0f));
                }
            }
            if (Body.IsEllipsoid)
            {
                str += string.Format(LocalizationHelper.Localize("Equatorial radius: %s").Replace("%s", "{0}"), radiusString);
            }
            else
            {
                str += string.Format(LocalizationHelper.Localize("Size: %s").Replace("%s", "{0}"), radiusString);
            }
            var time          = AppCore.Simulation.Time;
            var orbit         = Body.OrbitAtTime(time);
            var rotation      = Body.RotationModelAtTime(time);
            var orbitalPeriod = orbit.IsPeriodic ? orbit.Period : 0.0;

            if (rotation.IsPeriodic && Body.Type != CelestiaBodyType.spacecraft)
            {
                var rotPeriod = rotation.Period;
                var dayLength = 0.0;
                if (orbit.IsPeriodic)
                {
                    var siderealDaysPerYear = orbitalPeriod / rotPeriod;
                    var solarDaysPerYear    = siderealDaysPerYear - 1.0;
                    if (solarDaysPerYear > 0.0001)
                    {
                        dayLength = orbitalPeriod / (siderealDaysPerYear - 1.0);
                    }
                }
                string unitTemplate;
                if (rotPeriod < 2.0)
                {
                    rotPeriod *= 24;
                    dayLength *= 24;

                    unitTemplate = LocalizationHelper.Localize("%.2f hours").Replace("%.2f", "{0:N2}");
                }
                else
                {
                    unitTemplate = LocalizationHelper.Localize("%.2f days").Replace("%.2f", "{0:N2}");
                }
                str += "\n";
                str += string.Format(LocalizationHelper.Localize("Sidereal rotation period: %s").Replace("%s", "{0}"), string.Format(unitTemplate, rotPeriod));

                if (dayLength != 0.0)
                {
                    str += "\n";
                    str += string.Format(LocalizationHelper.Localize("Length of day: %s").Replace("%s", "{0}"), string.Format(unitTemplate, dayLength));
                }
                if (Body.HasRings)
                {
                    str += "\n";
                    str += LocalizationHelper.Localize("Has rings");
                }

                if (Body.HasAtmosphere)
                {
                    str += "\n";
                    str += LocalizationHelper.Localize("Has atmosphere");
                }
            }

            return(str);
        }
Ejemplo n.º 11
0
 public void GamepadJoystickAction(CelestiaAppCore core, CelestiaJoystickAxis axis, double amount)
 {
     core.JoystickAxis(axis, (float)amount);
 }
Ejemplo n.º 12
0
 public static string Localize(string original)
 {
     return(CelestiaAppCore.LocalizedString(original, "celestia_ui"));
 }