예제 #1
0
 // This is the main entry point of the application.
 static void Main(string[] args)
 {
     // if you want to use a different Application Delegate class from "AppDelegate"
     // you can specify it here.
     UIApplication.Main(args, null, "AppDelegate");
     UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).BackgroundColor = UIColor.White;
 }
예제 #2
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
#if DEBUG // the logger should be removed for release builds
            TIPGlobalConfiguration.SharedInstance.Logger = new Logger();
#endif
            TIPGlobalConfiguration.SharedInstance.SerializeCGContextAccess = true;
            TIPGlobalConfiguration.SharedInstance.ClearMemoryCachesOnApplicationBackgroundEnabled = true;
            TIPGlobalConfiguration.SharedInstance.AddImagePipelineObserver(new Observer());

            ImagePipeline = new TIPImagePipeline("Twitter.Example");
            ImagePipeline.AdditionalCaches = new[] { new AdditionalCache() };

            TwitterApi.SharedInstance.WorkStarted  += delegate { IncrementNetworkOperations(); };
            TwitterApi.SharedInstance.WorkFinished += delegate { DecrementNetworkOperations(); };

            // appearance
            var lightBlueColor = UIColor.FromRGB(150f / 255f, 215f / 255f, 1);
            UISearchBar.Appearance.BarTintColor = lightBlueColor;
            UISearchBar.Appearance.TintColor    = UIColor.White;
            UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).TintColor = lightBlueColor;
            UINavigationBar.Appearance.BarTintColor = lightBlueColor;
            UINavigationBar.Appearance.TintColor    = UIColor.White;
            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes {
                TextColor = UIColor.White
            });
            UITabBar.Appearance.BarTintColor          = lightBlueColor;
            UITabBar.Appearance.TintColor             = UIColor.White;
            UISlider.Appearance.MinimumTrackTintColor = lightBlueColor;
            UISlider.Appearance.TintColor             = lightBlueColor;
            UIWindow.Appearance.TintColor             = lightBlueColor;

            // the UI
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            // Image from https://icons8.com
            var firstNavController = new UINavigationController(new TwitterSearchViewController());
            firstNavController.TabBarItem = new UITabBarItem("Search", UIImage.FromBundle("Search"), 1);
            var secondNavController = new UINavigationController(new SettingsViewController());
            secondNavController.TabBarItem = new UITabBarItem("Settings", UIImage.FromBundle("Settings"), 2);
            var thirdNavController = new UINavigationController(new InspectorViewController());
            thirdNavController.TabBarItem = new UITabBarItem("Inspector", UIImage.FromBundle("Inspector"), 3);

            tabBarController = new UITabBarController();
            tabBarController.ViewControllers = new[] {
                firstNavController,
                secondNavController,
                thirdNavController
            };

            Window.RootViewController = tabBarController;
            Window.BackgroundColor    = UIColor.Orange;
            Window.MakeKeyAndVisible();

            return(true);
        }
예제 #3
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.SearchBar> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                return;
            }

            var searchBar = e.NewElement;

            Control.AutocapitalizationType = UITextAutocapitalizationType.None;
            Control.AutocorrectionType     = UITextAutocorrectionType.No;
            Control.SearchBarStyle         = UISearchBarStyle.Minimal;

            // Handles the cursor color
            Control.TintColor = UIColor.White;

            // Handles customizing the search icon.
            var searchImage = UIImage.FromBundle("icon-search.png").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);

            Control.SetImageforSearchBarIcon(searchImage, UISearchBarIcon.Search, UIControlState.Normal);

            // Handles customizing the clear icon.
            var searchTextField  = Control.ValueForKey(new NSString("_searchField")) as UITextField;
            var placeholderLabel = searchTextField.ValueForKey(new NSString("placeholderLabel")) as UILabel;

            placeholderLabel.TextColor = UIColor.White;
            var clearButton   = searchTextField.ValueForKey(new NSString("_clearButton")) as UIButton;
            var newClearImage = clearButton.ImageView?.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);

            Control.SetImageforSearchBarIcon(newClearImage, UISearchBarIcon.Clear, UIControlState.Normal);


            // Styles the placeholder and the cursor
            var textfieldAppearance = UITextField.AppearanceWhenContainedIn(typeof(UISearchBar));

            textfieldAppearance.TintColor = UIColor.White;

            // Styles the placeholder text
            UILabel.AppearanceWhenContainedIn(typeof(UISearchBar)).TextColor = UIColor.White;
        }
예제 #4
0
        //protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> args)
        //{
        //    base.OnElementChanged(args);
        //    UISearchBar bar = (UISearchBar)this.Control;
        //    bar.TintColor = UIColor.Black;
        //}

        //// hide cancel button
        //protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        //{
        //    base.OnElementPropertyChanged(sender, e);

        //    //if (e.PropertyName == "Text")
        //    //{
        //    //    Control.ShowsCancelButton = false;
        //    //}
        //}
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);
            //UISearchBar bar = (UISearchBar)this.Control;
            //bar.TintColor = UIColor.Black;

            //!!! Works, but only for the first search bar (we have 3) **
            UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).BackgroundColor =
                UIColor.White;

            //Match text field within SearchBar to its background color
            //using (var searchKey = new NSString("_searchField"))
            //{
            //    if (e.NewElement == null) return;

            //    //!!! Throws an iOS error on iOS 13 ***
            //    //var textField = (UITextField)Control.ValueForKey(searchKey);
            //    //textField.BackgroundColor = e.NewElement.BackgroundColor.ToUIColor();
            //    //textField.TintColor = UIColor.White;
            //}
        }
예제 #5
0
 protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
 {
     base.OnElementChanged(e);
     UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).BackgroundColor = UIColor.Clear;
 }
예제 #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // For accelerometer readings
            motionManager = new CMMotionManager();
            motionManager.AccelerometerUpdateInterval = 0.01; // 100Hz

            //To handle long presses and bring up path start/end menu
            var longPressManager = new UILongPressGestureRecognizer();

            //Graph loading code
            //Graph loading code
            var assembly = Assembly.GetExecutingAssembly();
            var asset    = assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsfloorWideDoors.xml");
            var asset2   = assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsFloor1.xml");
            var assetSci = assembly.GetManifestResourceStream("Navigator.iOS.Resources.ConFloor.xml");


            pf = new Pathfinding.Pathfinding(new Dictionary <int, Stream>()
            {
                { 0, assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsfloorWideDoors.xml") },
                { 1, assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsFloor1.xml") },
                { 2, assembly.GetManifestResourceStream("Navigator.iOS.Resources.ConFloor.xml") }
            }, assembly.GetManifestResourceStream("Navigator.iOS.Resources.Rooms.xml"));
            pf.CurrentFloor = 0;

            while (true)
            {
                if (pf.Ready)
                {
                    break;
                }
                Thread.Sleep(500);
            }



            //set up the search bar and prediction box
            SearchBar.TintColor = UIColor.White;

            UITextView.AppearanceWhenContainedIn(typeof(UISearchBar)).BackgroundColor  = UIColor.White;
            UITextView.AppearanceWhenContainedIn(typeof(UISearchBar)).TintColor        = UIColor.White;
            UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).BackgroundColor = UIColor.White;
            UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).TintColor       = UIColor.White;

            var shadowView = new UIView(SearchPredictionTable.Frame);

            shadowView.BackgroundColor       = UIColor.White;
            shadowView.Layer.ShadowColor     = UIColor.DarkGray.CGColor;
            shadowView.Layer.ShadowOpacity   = 1.0f;
            shadowView.Layer.ShadowRadius    = 6.0f;
            shadowView.Layer.ShadowOffset    = new System.Drawing.SizeF(0f, 3f);
            shadowView.Layer.ShouldRasterize = true;
            shadowView.Layer.MasksToBounds   = false;
            Add(shadowView);


            var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark);

            topblurView = new UIVisualEffectView(blur)
            {
                Frame = new RectangleF(0, 0, (float)View.Frame.Width, 90)
            };
            bottomblurView = new UIVisualEffectView(blur)
            {
                Frame = new RectangleF(0, (float)View.Frame.Height - 70, (float)View.Frame.Width, 70)
            };

            View.Add(topblurView);
            View.Add(bottomblurView);

            View.BringSubviewToFront(SearchPredictionTable);
            View.BringSubviewToFront(returnButton);
            View.BringSubviewToFront(SearchBar);
            View.BringSubviewToFront(directionsButton);



            var searchController = new CustomSearchController(this, SearchBar, SearchPredictionTable, shadowView, pf.Rooms);

            //var directionsController = new CustomDirectionsController (this, directionsTable, pf.Rooms);

            floorPlanGraph   = Graph.Load(asset);
            floorplanWallCol = UIImage.FromBundle("Images/dcsfloorWideDoors.png");
            wallCollImg      = floorplanWallCol;

            col = new Collision(floorPlanGraph, new StepDetector());

            ((Collision)col).WallCol = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg));
            wallColTest = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg));

            pathView = new PathView(wallColTest, this);

            col.SetLocation(707.0f, 677.0f);
            col.PassHeading(90);
            col.PositionChanged += HandleStepsTaken;

            //Container for floorplan and any overlaid images
            var container = new UIView();

            //Will contain floorplan images
            floorplanImageView = new UIImageView();

            //Load floorplan images
            floorplanImageNoGrid      = UIImage.FromBundle("Images/FinalDcsFloor1.png");
            floorplanImageWithGrid    = UIImage.FromBundle("Images/dcsFloorWideDoorsGrid.png");
            floorplanFirstFloorNoGrid = UIImage.FromBundle("Images/final2ndFloorDisplay.png");
            floorplanSci = UIImage.FromBundle("Images/ConFloorGrid");
            floorplanFirstFloorWallCol = UIImage.FromBundle("Images/dcsFloor1.png");


            //Initiate the location arrow
            locationArrow             = new LocationArrowImageView();
            locationArrow.ScaleFactor = floorplanView.ZoomScale;
            pathView.ScaleFactor      = floorplanView.ZoomScale;
            setStartPoint(690.0f, 840.0f, this.floor);

            //Set sizes for floorplan view and path view
            floorplanView.ContentSize = floorplanImageNoGrid.Size;
            pathView.Frame            = new CGRect(new CGPoint(0, 0), floorplanImageNoGrid.Size);

            //Add subviews to the container (including pathview and floorplanview)
            container.AddSubview(floorplanImageView);
            container.AddSubview(locationArrow);
            floorplanImageView.AddSubview(pathView);
            changeFloorPlanImage(floorplanImageView, floorplanImageNoGrid);
            container.SizeToFit();

            //Adjust scrolling and zooming properties for the floorplanView
            floorplanView.MaximumZoomScale = 1f;
            floorplanView.MinimumZoomScale = .25f;
            floorplanView.AddSubview(container);
            floorplanView.ViewForZoomingInScrollView += (UIScrollView sv) => { return(floorplanImageView); };

            //Variables needed to convert device acceleration to world z direction acceleration
            double accelX = 0, accelY = 0, accelZ = 0;

            //Scale location arrow and paths when zooming the floorplan
            floorplanView.DidZoom += (sender, e) =>
            {
                locationArrow.ScaleFactor = floorplanView.ZoomScale;
                pathView.ScaleFactor      = floorplanView.ZoomScale;
            };



            floorplanView.DraggingStarted += (sender, e) =>
            {
                handleAnimate(topblurView, bottomblurView, true);
            };

            var tapGestureRecognizer = new UITapGestureRecognizer();

            tapGestureRecognizer.NumberOfTapsRequired = 1;
            tapGestureRecognizer.AddTarget(() => {
                handleAnimate(topblurView, bottomblurView, false);
            });
            floorplanView.AddGestureRecognizer(tapGestureRecognizer);


            //LongPressManager will cause the path input menu to appear after a stationary long press
            longPressManager.AllowableMovement = 0;
            longPressManager.AddTarget(() => handleLongPress(longPressManager, floorPlanGraph));
            floorplanView.AddGestureRecognizer(longPressManager);

            //the location manager handles the phone heading
            locationManager = new CLLocationManager();
            locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
            locationManager.HeadingFilter   = 1;
            locationManager.UpdatedHeading += HandleUpdatedHeading;
            locationManager.StartUpdatingHeading();

            //Another testing button

            returnButton.TouchUpInside += delegate { returnToMenu(); };

            directionsButton.TouchUpInside += delegate {
                if (!initStep)
                {
                    //Pass acceleremoter values to the collision class
                    motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue,
                                                            (data, error) =>
                    {
                        accelX = data.Acceleration.X * 9.8;
                        accelY = data.Acceleration.Y * 9.8;
                        accelZ = Math.Sqrt(Math.Pow(accelX, 2) + Math.Pow(accelY, 2) + Math.Pow(data.Acceleration.Z * 9.8, 2));

                        col.PassSensorReadings(CollisionSensorType.Accelometer, accelX,
                                               accelY, accelZ);
                        //displayAccelVal((float)accelZ);
                    });

                    directionsButton.SetTitle("Change Floor", UIControlState.Normal);
                    initStep = true;
                }
                else if (floor == 0)
                {
                    Console.Out.WriteLine("Changing to floor 1 ");
                    floor = 1;
                    changeFloorPlanImage(floorplanImageView, floorplanFirstFloorNoGrid);
                    setStartPoint(447.0f, 850.0f, this.floor, false);

                    wallCollImg = floorplanFirstFloorWallCol;

                    col = new Collision(floorPlanGraph, new StepDetector());

                    ((Collision)col).WallCol = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg));
                    wallColTest = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg));

                    pathView = new PathView(wallColTest, this);

                    col.SetLocation(447, 850);
                    col.PositionChanged += HandleStepsTaken;
                }
                else if (floor == 1)
                {
                    Console.Out.WriteLine("Changing to floor 0 ");
                    floor = 0;
                    changeFloorPlanImage(floorplanImageView, floorplanImageNoGrid);

                    setStartPoint(486.0f, 980.0f, this.floor, false);

                    wallCollImg = floorplanWallCol;

                    col = new Collision(floorPlanGraph, new StepDetector());

                    ((Collision)col).WallCol = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg));
                    wallColTest = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg));

                    pathView = new PathView(wallColTest, this);

                    col.SetLocation(486, 980);
                    col.PositionChanged += HandleStepsTaken;
                }
                else
                {
                    floor = 0;
                }
            };
        }