コード例 #1
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item == null)
            {
                return(false);
            }

            switch (item.ItemId)
            {
            case global::Android.Resource.Id.Home:
                NavUtils.NavigateUpFromSameTask(this);

                return(true);

            case Resource.Id.action_refresh_log:
                RefreshLog();

                return(true);

            case Resource.Id.action_clear_log:
                UserLog.Clear();
                RefreshLog();

                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #2
0
        public static void NavigateUp(Activity activity, Bundle extras = null)
        {
            Intent upIntent = NavUtils.GetParentActivityIntent(activity);

            if (upIntent != null)
            {
                if (extras != null)
                {
                    upIntent.PutExtras(extras);
                }

                if (NavUtils.ShouldUpRecreateTask(activity, upIntent))
                {
                    TaskStackBuilder.Create(activity)
                    .AddNextIntentWithParentStack(upIntent)
                    .StartActivities();
                }
                else
                {
                    upIntent.AddFlags(ActivityFlags.ClearTop);
                    activity.StartActivity(upIntent);
                }
            }
            activity.Finish();
        }
コード例 #3
0
        protected override AiAction GetCurrentState()
        {
            if (!_isNear)
            {
                return(_patrolAi);
            }
            float dist;

            if (CurrentState == _patrolAi)
            {
                var pathFound = NavMesh.CalculatePath(transform.position, TargetTransform.position, NavMesh.AllAreas,
                                                      _pathToTarget);
                if (!pathFound)
                {
                    return(_patrolAi);
                }
                dist = NavUtils.GetPathLength(_pathToTarget);
            }
            else
            {
                dist = _navMeshAgent.remainingDistance;
            }

            if (dist <= AttackDistance)
            {
                return(_attackAi);
            }
            return(_patrolAi);
        }
コード例 #4
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                // Some small additions to handle "up" navigation correctly
                var upIntent = NavUtils.GetParentActivityIntent(Activity);
                upIntent.AddFlags(ActivityFlags.ClearTask);


                // Check if up activity needs to be created (usually when
                // detail screen is opened from a notification or from the
                // Wearable app
                if (NavUtils.ShouldUpRecreateTask(Activity, upIntent) ||
                    Activity.IsTaskRoot)
                {
                    // Synthesize parent stack
                    Android.App.TaskStackBuilder.Create(Activity)
                    .AddNextIntentWithParentStack(upIntent)
                    .StartActivities();
                }

                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                {
                    // On Lollipop+ we finish so to run the nice animation
                    Activity.FinishAfterTransition();
                    return(true);
                }

                // Otherwise let the system handle navigating "up"
                return(false);
            }
            return(base.OnOptionsItemSelected(item));
        }
コード例 #5
0
ファイル: FriendView.cs プロジェクト: vackup/Xam.NavDrawer
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                //Wrong:
                //var intent = new Intent(this, typeof(HomeView));
                //intent.AddFlags(ActivityFlags.ClearTop);
                //StartActivity(intent);
                NavUtils.NavigateUpFromSameTask(this);

                //if this could be launched externally:

                /*
                 * var upIntent = NavUtils.GetParentActivityIntent(this);
                 * if (NavUtils.ShouldUpRecreateTask(this, upIntent))
                 * {
                 *  Android.Support.V4.App.TaskStackBuilder.Create(this).
                 *      AddNextIntentWithParentStack(upIntent).
                 *      StartActivities();
                 * }
                 * else
                 * {
                 *  NavUtils.NavigateUpTo(this, upIntent);
                 * }
                 */
                break;
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #6
0
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     switch (item.ItemId)
     {
     case Resource.Id.home:
     {
         var upIntent = NavUtils.GetParentActivityIntent(this);
         if (NavUtils.ShouldUpRecreateTask(this, upIntent))
         {
             // This activity is NOT part of this app's task, so create a new task
             // when navigating up, with a synthesized back stack.
             Android.Support.V4.App.TaskStackBuilder.Create(this).
             AddNextIntentWithParentStack(upIntent).StartActivities();
         }
         else
         {
             // This activity is part of this app's task, so simply
             // navigate up to the logical parent activity.
             NavUtils.NavigateUpTo(this, upIntent);
         }
     }
         return(true);
     }
     return(base.OnOptionsItemSelected(item));
 }
コード例 #7
0
 public override bool OnOptionsItemSelected(Android.Views.IMenuItem item)
 {
     if (item.ItemId == Android.Resource.Id.Home)
     {
         // This is called when the Home (Up) button is pressed in the action bar.
         // Create a simple intent that starts the hierarchical parent activity and
         // use NavUtils in the Support Package to ensure proper handling of Up.
         var upIntent = new Intent(this, typeof(MainActivity));
         if (NavUtils.ShouldUpRecreateTask(this, upIntent))
         {
             // This activity is not part of the application's task, so create a new task
             // with a synthesized back stack.
             TaskStackBuilder.Create(this)
             // If there are ancestor activities, they should be added here.
             .AddNextIntent(upIntent)
             .StartActivities();
             this.Finish();
         }
         else
         {
             // This activity is part of the application's task, so simply
             // navigate up to the hierarchical parent activity.
             NavUtils.NavigateUpTo(this, upIntent);
         }
         return(true);
     }
     return(base.OnOptionsItemSelected(item));
 }
コード例 #8
0
    public void Generate()
    {
        float startTime = DateTime.Now.Millisecond;

        if (UseCanonicalDij)
        {
            NavUtils.GenerateCanonicalDijkstraIntegratField(MapColliderInfo.GameMap, Target);
        }
        else
        {
            NavUtils.GenerateDijkstraIntegratField(MapColliderInfo.GameMap, Target);
        }
        NavUtils.GenerateFlowField(MapColliderInfo.GameMap, Target);

        // for (int y = 0; y < GameSetting.MAP_HEIGHT; y++)
        // {
        //     for (int x = 0; x < GameSetting.MAP_WIDTH; x++)
        //     {
        //         int idx = y * GameSetting.MAP_WIDTH + x;

        //         float value = MapColliderInfo.GameMap.IntegrationField[x, y];

        //         if (value == float.MaxValue)
        //         {
        //             _texts[idx].text = "INF";
        //         }
        //         else
        //         {
        //             _texts[idx].text = string.Format ("{0:F1}", value);
        //         }
        //     }
        // }
    }
コード例 #9
0
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     switch (item.ItemId)
     {
     case Android.Resource.Id.Home:
         NavUtils.NavigateUpFromSameTask(this);
         break;
     }
     return(base.OnOptionsItemSelected(item));
 }
コード例 #10
0
        public StaticObject GetNextGate(StaticObject StartLine, float fNextGate)
        {
            StaticObject soNextGate = null;
            string       sGate      = "Gate" + fNextGate.ToString();
            string       sGroup     = (string)StartLine.getSetting("Group");

            soNextGate = NavUtils.GetNearestFacility(StartLine.gameObject.transform.position, sGate, sGroup);

            return(soNextGate);
        }
コード例 #11
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item.ItemId == Resource.Id.home)
            {
                NavUtils.NavigateUpFromSameTask(this);
                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #12
0
            public static void Update()
            {
                Vessel vessel = FlightGlobals.ActiveVessel;

                if (vessel == null)
                {
                    return;
                }

                if (destinationAirfield == null)
                {
                    return;
                }

                distanceToAirfield = NavUtils.DistanceToAirfield(vessel, destinationAirfield);
                bearingToAirfield  = NavUtils.InitialBearingToAirfield(vessel, destinationAirfield);

                // do this not to often and not in an airfield
                if (landingRunway == null || distanceToAirfield > 2000 || !InBeam)
                {
                    landingRunway = destinationAirfield.GetLandingRunwayForBearing(bearingToAirfield);
                    ILS           = landingRunway.HasILS;
                }

                if (landingRunway != null)
                {
                    // Bearing to runway
                    bearingToRunway = NavUtils.InitialBearingToRunway(vessel, landingRunway);
                    if (bearingToRunway < 0)
                    {
                        bearingToRunway = 360 - bearingToRunway;
                    }
                    //
                    // distance to runway
                    distanceToRunway = NavUtils.DistanceToRunway(vessel, landingRunway);
                    //
                    // glide slope
                    horizontalGlideslopeDeviation = NavUtils.HorizontalGlideSlopeDeviation(bearingToRunway, landingRunway);
                    verticalGlideslopeDeviation   = NavUtils.VerticalGlideSlopeDeviation(vessel, landingRunway);
                    //
                    // check if we are inside the ILS cone
                    bool insideHorizontalBeam = NavUtils.InsideCone(bearingToRunway, landingRunway.To, landingRunway.ILSCone);
                    bool insideVerticalBeam   = NavUtils.InsideCone(verticalGlideslopeDeviation, 0.0, landingRunway.ILSCone);
                    InBeam = insideHorizontalBeam && insideVerticalBeam && distanceToRunway <= landingRunway.ILSRange;
                }
                else
                {
                    bearingToRunway  = 0.0;
                    distanceToRunway = double.MaxValue;
                    InBeam           = false;
                    horizontalGlideslopeDeviation = double.MaxValue;
                    verticalGlideslopeDeviation   = double.MaxValue;
                }
            }
コード例 #13
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                NavUtils.NavigateUpTo(this, new Intent(this, typeof(MainActivity)));
                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #14
0
        /*
         * public override void OnListItemClick(ListView l, global::Android.Views.View v, int position, long id)
         * {
         *  int pos = _adapter.SectionedPositionToPosition(position);
         *  HenspeRowModel henspeRowModel = _itemsAdapter[pos];
         * }
         */

        /*
         * public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
         * {
         * inflater.Inflate(Resource.Menu.MenuHome, menu);
         * }
         */

        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.homeMenuItem:
                NavUtils.NavigateUpFromSameTask(this.Activity);
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
コード例 #15
0
ファイル: NavUtils.cs プロジェクト: linuxgurugamer/NanoGauges
            public static double HorizontalGlideSlopeDeviation(double bearingToRunway, Runway runway)
            {
                return(NavUtils.HeadingDeviation(runway.To, bearingToRunway));

                // deviation by distance (not used anymore)

                /*if(vessel==null) return 0.0;
                 * double d = DistanceToRunway(vessel, runway);
                 * Coords onSlope = DestinationFromRunwayAtDistance(runway, d, vessel.mainBody.Radius);
                 * double deviation = DistanceFromVesselTo(vessel, onSlope);
                 * return deviation;*/
            }
コード例 #16
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item.ItemId != Android.Resource.Id.Home)
            {
                return(base.OnOptionsItemSelected(item));
            }
            cancellationtokenSource?.Cancel();
            var intent = NavUtils.GetParentActivityIntent(this);

            intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            NavUtils.NavigateUpTo(this, intent);
            return(true);
        }
コード例 #17
0
        public float GetGateWidth(StaticObject soGate)
        {
            float        fDistance     = 0f;
            StaticObject soNearestPole = null;

            string sGroup   = (string)soGate.getSetting("Group");
            string sFacType = (string)soGate.getSetting("FacilityType");

            soNearestPole = NavUtils.GetNearestFacility(soGate.gameObject.transform.position, sFacType + "P", sGroup);

            fDistance = Vector3.Distance(soGate.gameObject.transform.position, soNearestPole.gameObject.transform.position);
            return(fDistance);
        }
コード例 #18
0
 protected override AiAction GetCurrentState()
 {
     foreach (var enemy in Enemies)
     {
         var pathFound = NavMesh.CalculatePath(enemy.position, PlayerTransform.position, NavMesh.AllAreas, _navMeshPath);
         if (!pathFound || NavUtils.GetPathLength(_navMeshPath) > AttackDistance)
         {
             continue;
         }
         _attackAi.TargetTransform = enemy;
         return(_attackAi);
     }
     return(_followAi);
 }
コード例 #19
0
            protected override void AjustValues()
            {
                base.AjustValues();
                Vessel vessel = FlightGlobals.ActiveVessel;

                if (NavGlobals.InBeam || IsOff() || NavGlobals.destinationAirfield == null)
                {
                    InLimits();
                }
                else
                {
                    NotInLimits();
                }

                if (IsOn() && vessel != null)
                {
                    if (NavGlobals.landingRunway != null)
                    {
                        // we have a runway
                        //
                        if (IsInLimits())
                        {
                            // on glide slope
                            yellowNeedle.degrees = (float)(-NavGlobals.verticalGlideslopeDeviation * 50.0);
                        }
                        else
                        {
                            // not on glide slope
                            yellowNeedle.degrees = -200.0f;
                        }
                        //
                        // DME
                        double d = NavUtils.DistanceToRunway(vessel, NavGlobals.landingRunway);
                        SetDme(d);
                    }
                    else
                    {
                        // no runway
                        //
                        DmeDisplay.SetValue(99);
                        yellowNeedle.degrees = -200.0f;
                    }
                }
                else
                {
                    // gaue is off or no vessel
                    DmeDisplay.SetValue(99);
                    yellowNeedle.degrees = -200.0f;
                }
            }
コード例 #20
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                NavUtils.NavigateUpFromSameTask(this);
                break;

            case Resource.Id.new_mic:
                //AddSound();
                CheckMicOnline(PostMicCheck.AddSound);
                break;
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #21
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                NavUtils.NavigateUpTo(this, new Intent(this, typeof(MainActivity)));
                return(true);

            case Resource.Id.action_add_item:
                FindViewById(Android.Resource.Id.Empty).Visibility = ViewStates.Gone;
                AddItem();
                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #22
0
        public override bool OnOptionsItemSelected(ActionbarSherlock.View.IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                if (this is HomeActivity)
                {
                    return(false);
                }

                NavUtils.NavigateUpFromSameTask(this);
                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #23
0
        public float GetDistanceToGate(StaticObject soGate, Vector3 vPos)
        {
            float        fDistance     = 0f;
            Vector3      vCenter       = new Vector3(0, 0, 0);
            StaticObject soNearestPole = null;

            string sGroup   = (string)soGate.getSetting("Group");
            string sFacType = (string)soGate.getSetting("FacilityType");

            soNearestPole = NavUtils.GetNearestFacility(soGate.gameObject.transform.position, sFacType + "P", sGroup);

            vCenter = Vector3.Lerp(soGate.gameObject.transform.position, soNearestPole.gameObject.transform.position, 0.5f);

            fDistance = Vector3.Distance(vCenter, vPos);
            return(fDistance);
        }
コード例 #24
0
ファイル: Runway.cs プロジェクト: linuxgurugamer/NanoGauges
            public readonly double ILSRange; // range of ILS in meter

            public Runway(String name, Coords coords, float elevation, float heading, float glideslope = 3.0f)
            {
                this.name         = name;
                this.coords       = coords;
                this.elevation    = elevation;
                this.heading      = heading;
                this.glideslope   = glideslope;
                this.slopeTangens = (float)Math.Tan(Utils.DegreeToRadians(glideslope));
                this.To           = heading;
                this.From         = NavUtils.InverseHeading(To);
                //
                // currently constant
                this.HasILS   = true;
                this.HasDME   = true;
                this.ILSCone  = 10.0;
                this.ILSRange = 80000.0;
            }
コード例 #25
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                NavUtils.NavigateUpTo(this, new Intent(this, typeof(MainActivity)));
                return(true);

            case Resource.Id.action_toggle:
                _contentLoaded = !_contentLoaded;
                ShowContentOrLoadingIndicator(_contentLoaded);
                return(true);
            }


            return(base.OnOptionsItemSelected(item));
        }
コード例 #26
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item == null)
            {
                return(false);
            }

            switch (item.ItemId)
            {
            case global::Android.Resource.Id.Home:
                NavUtils.NavigateUpFromSameTask(this);

                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
コード例 #27
0
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     switch (item.ItemId)
     {
     case Android.Resource.Id.Home:
         // This ID represents the Home or Up button. In the case of this
         // activity, the Up button is shown. Use NavUtils to allow users
         // to navigate up one level in the application structure. For
         // more details, see the Navigation pattern on Android Design:
         //
         // http://developer.android.com/design/patterns/navigation.html#up-vs-back
         //
         NavUtils.NavigateUpTo(this, new Intent(this, typeof(ItemListActivity)));
         return(true);
     }
     return(base.OnOptionsItemSelected(item));
 }
コード例 #28
0
        public static void OpenRTGroundStation(StaticObject obj)
        {
            bool bRTLoaded = AssemblyLoader.loadedAssemblies.Any(a => a.name == "RemoteTech");

            if (!bRTLoaded)
            {
                return;
            }

            string sTSName;
            string sDLat;
            string sDLon;
            string sHeight;

            if ((string)obj.getSetting("FacilityType") == "TrackingStation")
            {
                Vector3       vPos         = (Vector3)obj.getSetting("RadialPosition");
                string        sPos         = vPos.ToString();
                CelestialBody CelBody      = (CelestialBody)obj.getSetting("CelestialBody");
                var           objectpos    = CelBody.transform.InverseTransformPoint(obj.gameObject.transform.position);
                var           dObjectLat   = NavUtils.GetLatitude(objectpos);
                var           dObjectLon   = NavUtils.GetLongitude(objectpos);
                double        disObjectLat = dObjectLat * 180 / Math.PI;
                double        disObjectLon = dObjectLon * 180 / Math.PI;

                sDLat   = disObjectLat.ToString("#0.00");
                sDLon   = disObjectLon.ToString("#0.00");
                sTSName = "Stn Lt " + sDLat + " Ln " + sDLon;
                sHeight = obj.getSetting("RadiusOffset").ToString();

                float  fHeight = (float)obj.getSetting("RadiusOffset");
                double dHeight = (double)fHeight;
                int    iBody   = 1;

                string sGuid = ConstructGuidString(obj);

                Debug.Log("KK: Attempting adding RT GroundStation " + sGuid);
                RemoteTech.API.API.AddGroundStation(sGuid, sTSName, disObjectLat, disObjectLon, dHeight, iBody);

                Debug.Log("KK: Added RT GroundStation " + sGuid);
                KerbalKonstructs.Utilities.PersistenceUtils.saveStaticPersistence(obj);
                RemoteTech.API.API.ReloadRTSettingsNow();
                Debug.Log("KK: Saved station object");
            }
        }
コード例 #29
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                NavUtils.NavigateUpTo(this, new Intent(this, typeof(StockPriceListActivity)));
                return(true);

            case Resource.Id.action_add_moving_average:
                var dialog = new MovingAveragePeriodDialogFragment((period) => {
                    MovingAverageRequested(this, new MovingAverageRequestedEventArgs(period));
                });
                dialog.Show(FragmentManager, "Moving Average Dialog");
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
コード例 #30
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item.ItemId != Android.Resource.Id.Home)
            {
                return(base.OnOptionsItemSelected(item));
            }
            var intent = NavUtils.GetParentActivityIntent(this);

            if (goal != null)
            {
                Preferences.HeroImageGoalId = goal.Id.ToString();
            }

            intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            NavUtils.NavigateUpTo(this, intent);

            OverridePendingTransition(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out);
            return(true);
        }