Пример #1
0
        void PerformSearch( )
        {
            // only let them submit if they have something beyond "http://" (or some other short crap)
            if (RockUrlField.Text.IsValidURL( ))
            {
                // hide the keyboard
                RockUrlField.ResignFirstResponder( );

                // disable until we're done
                Submit.Enabled = false;

                BlockerView.BringToFront( );
                BlockerView.Show(delegate
                {
                    // see if Rock exists at this endpoint
                    ApplicationApi.IsRockAtURL(RockUrlField.Text, delegate(HttpStatusCode statusCode, string statusDesc)
                    {
                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode))
                        {
                            // attempt to contact Rock and get all the required information.
                            Config.Instance.TryBindToRockServer(RockUrlField.Text, RockAuthKeyField.Text,
                                                                delegate(bool result)
                            {
                                // it worked, so Rock is valid.
                                if (result == true)
                                {
                                    // take these as our values.
                                    Config.Instance.CommitRockSync( );

                                    Config.Instance.SetConfigurationDefinedValue(Config.Instance.ConfigurationTemplates[0],
                                                                                 delegate(bool configResult)
                                    {
                                        if (configResult == true)
                                        {
                                            HandlePerformSearchResult(true, Strings.General_RockBindSuccess);
                                        }
                                        else
                                        {
                                            // ROCK DATA ERROR
                                            HandlePerformSearchResult(false, Strings.General_RockBindError_Data);
                                        }
                                    });
                                }
                                else
                                {
                                    // ROCK DATA ERROR
                                    HandlePerformSearchResult(false, Strings.General_RockBindError_Data);
                                }
                            });
                        }
                        else
                        {
                            // Rock NOT FOUND
                            HandlePerformSearchResult(false, Strings.General_RockBindError_NotFound);
                        }
                    });
                });
            }
        }
Пример #2
0
        void DownloadRockValues( )
        {
            // only let them submit if they have something beyond "http://" (or some other short crap)
            if (RockUrlField.Text.IsValidURL( ) == true)
            {
                // hide the keyboard
                RockUrlField.ResignFirstResponder( );

                // disable until we're done
                Sync.Enabled = false;
                ToggleSaveButton(false);

                BlockerView.BringToFront( );
                BlockerView.Show(delegate
                {
                    // see if Rock is AT this server.
                    ApplicationApi.IsRockAtURL(RockUrlField.Text,
                                               delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                    {
                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode))
                        {
                            // attempt to contact Rock and get all the required information.
                            Config.Instance.TryBindToRockServer(RockUrlField.Text, RockAuthKeyField.Text,
                                                                delegate(bool result)
                            {
                                // it worked, so Rock is valid.
                                if (result == true)
                                {
                                    ConfigurationTemplates = Config.Instance.TempConfigurationTemplates;
                                    Campuses = Config.Instance.TempCampuses;
                                    HandleDownloadResult(Strings.General_RockBindSuccess);
                                }
                                else
                                {
                                    // error - clear the lists
                                    ClearLists( );

                                    HandleDownloadResult(Strings.General_RockBindError_Data);
                                }
                            });
                        }
                        else
                        {
                            BlockerView.Hide(
                                delegate
                            {
                                // error - clear the lists
                                ClearLists( );

                                HandleDownloadResult(Strings.General_RockBindError_NotFound);
                            });
                        }
                    });
                });
            }
        }
Пример #3
0
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();

            Logo.Layer.Position = new CGPoint((View.Bounds.Width - Logo.Bounds.Width) / 2, 25);

            // Title
            RockUrlTitle.Layer.Position = new CGPoint((View.Bounds.Width - RockUrlField.Bounds.Width) / 2, View.Bounds.Height * .25f);

            // because there's no placeholder, we can't SizeToFit the URL Field, so we'll measure the font and then size it.
            RockUrlField.Bounds = new CGRect(0, 0, View.Bounds.Width * .75f, 0);
            CGSize size = RockUrlField.SizeThatFits(new CGSize(RockUrlField.Bounds.Width, RockUrlField.Bounds.Height));

            RockUrlField.Bounds = new CGRect(RockUrlField.Bounds.X, RockUrlField.Bounds.Y, RockUrlField.Bounds.Width, (float)System.Math.Ceiling(size.Height));

            // center the rock URL field and title
            RockUrlField.Layer.Position = new CGPoint((View.Bounds.Width - RockUrlField.Bounds.Width) / 2,
                                                      RockUrlTitle.Frame.Bottom + 5);


            // Title
            RockAuthKeyTitle.Layer.Position = new CGPoint((View.Bounds.Width - RockUrlField.Bounds.Width) / 2, RockUrlField.Frame.Bottom + 20);

            // because there's no placeholder, we can't SizeToFit the URL Field, so we'll measure the font and then size it.
            RockAuthKeyField.Bounds = new CGRect(0, 0, View.Bounds.Width * .75f, 0);
            size = RockAuthKeyField.SizeThatFits(new CGSize(RockAuthKeyField.Bounds.Width, RockAuthKeyField.Bounds.Height));
            RockAuthKeyField.Bounds = new CGRect(RockAuthKeyField.Bounds.X, RockAuthKeyField.Bounds.Y, RockAuthKeyField.Bounds.Width, (float)System.Math.Ceiling(size.Height));

            RockAuthKeyField.Layer.Position = new CGPoint((View.Bounds.Width - RockAuthKeyField.Bounds.Width) / 2,
                                                          RockAuthKeyTitle.Frame.Bottom + 5);


            // Description
            RockUrlDesc.Layer.Position = new CGPoint(RockUrlField.Frame.Left, RockAuthKeyField.Frame.Bottom + 5);


            // set the blocker
            BlockerView.SetBounds(View.Bounds.ToRectF( ));

            // set the submit bounds and position
            Submit.SizeToFit( );
            Submit.Bounds         = new CGRect(0, 0, RockUrlField.Bounds.Width * .35f, Submit.Bounds.Height * 1.25f);
            Submit.Layer.Position = new CGPoint(RockUrlField.Frame.Left + ((RockUrlField.Bounds.Width - Submit.Bounds.Width) / 2),
                                                RockUrlDesc.Frame.Bottom + 60);

            // let the label stretch the entire width
            ResultLabel.Bounds = new CGRect(0, 0, View.Bounds.Width, 0);
            ResultLabel.SizeToFit( );
            ResultLabel.Frame = new CGRect(0, Submit.Frame.Bottom + 30, View.Bounds.Width, ResultLabel.Bounds.Height);
        }
Пример #4
0
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();


            // because there's no placeholder, we can't SizeToFit the URL Field, so we'll measure the font and then size it.
            RockUrlField.Bounds = new CGRect(0, 0, View.Bounds.Width * .75f, 0);
            CGSize size = RockUrlField.SizeThatFits(new CGSize(RockUrlField.Bounds.Width, RockUrlField.Bounds.Height));

            RockUrlField.Bounds = new CGRect(RockUrlField.Bounds.X, RockUrlField.Bounds.Y, RockUrlField.Bounds.Width, (float)System.Math.Ceiling(size.Height));


            // center the rock URL field and title
            RockUrlTitle.Layer.Position = new CGPoint((View.Bounds.Width - RockUrlField.Bounds.Width) / 2, View.Bounds.Height * .05f);
            RockUrlField.Layer.Position = new CGPoint((View.Bounds.Width - RockUrlField.Bounds.Width) / 2,
                                                      RockUrlTitle.Frame.Bottom + 10);



            // because there's no placeholder, we can't SizeToFit the URL Field, so we'll measure the font and then size it.
            RockAuthKeyField.Bounds = new CGRect(0, 0, View.Bounds.Width * .75f, 0);
            size = RockAuthKeyField.SizeThatFits(new CGSize(RockAuthKeyField.Bounds.Width, RockAuthKeyField.Bounds.Height));
            RockAuthKeyField.Bounds = new CGRect(RockAuthKeyField.Bounds.X, RockAuthKeyField.Bounds.Y, RockAuthKeyField.Bounds.Width, (float)System.Math.Ceiling(size.Height));


            // center the rock URL field and title
            RockAuthKeyTitle.Layer.Position = new CGPoint((View.Bounds.Width - RockAuthKeyField.Bounds.Width) / 2, RockUrlField.Frame.Bottom + 10);
            RockAuthKeyField.Layer.Position = new CGPoint((View.Bounds.Width - RockAuthKeyField.Bounds.Width) / 2, RockAuthKeyTitle.Frame.Bottom + 10);


            // set the submit bounds and position
            Sync.Bounds         = new CGRect(0, 0, RockAuthKeyField.Bounds.Width * .15f, Sync.Bounds.Height);
            Sync.Layer.Position = new CGPoint(RockAuthKeyField.Frame.Right - Sync.Bounds.Width, RockAuthKeyField.Frame.Bottom + 10);

            // let the label stretch the entire width
            SyncResultLabel.Bounds = new CGRect(0, 0, View.Bounds.Width, 0);
            SyncResultLabel.SizeToFit( );
            SyncResultLabel.Frame = new CGRect(0, Sync.Frame.Bottom + 20, View.Bounds.Width, SyncResultLabel.Bounds.Height);


            // set the campus table and center its label above it
            CampusesLabel.Layer.Position = new CGPoint(RockUrlTitle.Layer.Position.X, Sync.Frame.Bottom + 60);

            // table
            CampusTableView.Layer.Position = new CGPoint(RockUrlTitle.Layer.Position.X, CampusesLabel.Frame.Bottom);
            CampusTableView.Bounds         = new CGRect(0, 0, 200, 300);


            nfloat switchWidth = CampusSwitchLabel.Bounds.Width + CampusSwitch.Bounds.Width + 10;
            nfloat switchXPos  = (CampusTableView.Bounds.Width - switchWidth) / 2;

            CampusSwitchLabel.Layer.Position = new CGPoint(RockUrlTitle.Layer.Position.X + switchXPos, View.Bounds.Height * .85f);
            CampusSwitch.Layer.Position      = new CGPoint(CampusSwitchLabel.Frame.Right + 10, View.Bounds.Height * .85f);


            // set the template table and center ITS label as well
            TemplateLabel.Layer.Position = new CGPoint(View.Bounds.Width - 300, Sync.Frame.Bottom + 60);

            TemplateTableView.Layer.Position = new CGPoint(View.Bounds.Width - 300, TemplateLabel.Frame.Bottom);
            TemplateTableView.Bounds         = new CGRect(0, 0, 200, 300);


            // set the blocker
            BlockerView.SetBounds(View.Bounds.ToRectF( ));


            // set the Cancel / Save button toward the bottom
            Cancel.Bounds = new CGRect(0, 0, 100, Cancel.Bounds.Height);
            Save.Bounds   = new CGRect(0, 0, 100, Save.Bounds.Height);

            //nfloat buttonWidth = Cancel.Bounds.Width + Save.Bounds.Width + 10;

            Save.Layer.Position   = new CGPoint(View.Bounds.Width - 300, View.Bounds.Height * .85f);
            Cancel.Layer.Position = new CGPoint(Save.Frame.Right + 10, View.Bounds.Height * .85f);
        }