Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Controls.RestrictRotation(true);

            SQLiteBoostDB.CheckAndCreateDatabase();

            this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("bg.jpg"));

            labelSelectedDealer = GetLabel("No Dealer Selected");

            UIScrollView scrollView = new UIScrollView(new CoreGraphics.CGRect(this.View.Bounds.X, 60f, this.View.Bounds.Width, this.View.Bounds.Height));

            scrollView.AddSubview(new EditGroup(GetDealershipGroup()).View);
            scrollView.AddSubview(new EditGroup(GetButtons()).View);

            nfloat ypos = 0f;

            foreach (UIView view in scrollView.Subviews)
            {
                view.Frame = new CoreGraphics.CGRect(view.Bounds.X + 5f, ypos + 10f, this.View.Bounds.Width - 10f, view.Bounds.Height);
                ypos      += view.Bounds.Height + 10f;
            }

            //makes height of scroller the total ypos of groups + 60 for the top bar + 10 for margin at bottom
            scrollView.ContentSize = new CoreGraphics.CGSize(scrollView.Bounds.Width, ypos + 60f + 10f);

            this.View.AddSubview(scrollView);

            assetsRequireDownload = getAssetsRequired();

            if (assetsRequireDownload)
            {
                showAssetsDialog();
            }

            bool dealershipWarningShown = (bool)NSUserDefaults.StandardUserDefaults.BoolForKey("DealershipWarningShown");

            if (!dealershipWarningShown)
            {
                List <Vehicle> listAllVehicles = new List <Vehicle>();
                using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                    listAllVehicles = new VehicleDB(sqlConn).GetAllVehicles();

                if (listAllVehicles.Count(v => v.DealershipID == null || v.DealershipID == 0) > 0)
                {
                    Controls.OkDialog("Vehicles Without Dealership", "Boost IT has recently changed so that you must select a dealership before creating a vehicle.  You have vehicles that were created without a dealership assigned to them on your device.  You will not be able to upload these vehicles until you go into \"Change a Vehicle\" and select a dealer for each vehicle.\n\n Vehicles not assigned to a dealership will be marked with \"(**)\" on the \"Change a Vehicle\" page.", delegate { NSUserDefaults.StandardUserDefaults.SetBool(true, "DealershipWarningShown"); });
                }
            }
        }