Пример #1
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            var message = new EntryElement("Message", "Type your message here", "");
            var sendMessage = new StyledStringElement("Send Message")
            {
                Alignment = UITextAlignment.Center,
                BackgroundColor = UIColor.Green
            };
            var receivedMessages = new Section();
            var root = new RootElement("")
            {
                new Section() { message, sendMessage },
                receivedMessages
            };

            var connection = new Connection("http://localhost:8081/echo");

            sendMessage.Tapped += delegate
            {
                if (!string.IsNullOrWhiteSpace(message.Value) && connection.State == ConnectionState.Connected)
                {
                    connection.Send("iOS: " + message.Value);

                    message.Value = "";
                    message.ResignFirstResponder(true);
                }
            };

            connection.Received += data =>
            {
                InvokeOnMainThread(() =>
                    receivedMessages.Add(new StringElement(data)));
            };

            connection.Start().ContinueWith(task =>
                connection.Send("iOS: Connected"));

            var viewController = new DialogViewController(root);
            window.RootViewController = viewController;

            window.MakeKeyAndVisible ();

            return true;
        }
Пример #2
0
        private RootElement CreateRootElement()
        {
            var captionLabel = UIHelper.CreateLabel (
                "cross copy",
                true,
                32,
                32,
                UITextAlignment.Center,
                UIColor.Black
                );
            UILabel subcaptionLabel = UIHelper.CreateLabel (
                WELCOME_LABEL_TEXT,
                false,
                14,
                85,
                UITextAlignment.Center,
                lightTextColor
                );
            subcaptionLabel.Tag = 3;

            captionLabel.Frame = new Rectangle (0, 10, 320, 40);
            subcaptionLabel.Frame = new Rectangle (20, 55, 280, 100);
            UIView header = new UIView (new Rectangle (0, 0, 300, 145));
            header.AddSubviews (captionLabel, subcaptionLabel);

            var root = new RootElement ("Secrets")
            {
                new Section (header),
                (secretsSection = new Section ("Secrets")),
                new Section ()
                {
                    (secretEntry = new AdvancedEntryElement ("Secret", "enter new phrase", "", null))
                }
            };

            secretsSection.AddAll (from s in AppDelegate.HistoryData.Secrets select (Element)CreateImageButtonStringElement (s));

            secretEntry.AutocapitalizationType = UITextAutocapitalizationType.None;
            secretEntry.ShouldReturn += delegate {

                if (String.IsNullOrEmpty (secretEntry.Value))
                    return false;

                var newSecret = new Secret (secretEntry.Value);
                AppDelegate.HistoryData.Secrets.Add (newSecret);

                if (root.Count == 2)
                    root.Insert (1, secretsSection);

                secretsSection.Insert (
                    secretsSection.Elements.Count,
                    UITableViewRowAnimation.Fade,
                    CreateImageButtonStringElement (newSecret)
                    );
                secretEntry.Value = "";
                secretEntry.ResignFirstResponder (false);
                DisplaySecretDetail (newSecret);

                return true;
            };
            secretEntry.ReturnKeyType = UIReturnKeyType.Go;
            if (secretsSection.Count == 0) {
                secretEntry.BecomeFirstResponder (true);
                root.RemoveAt (1);
            }
            return root;
        }
Пример #3
0
        public Selection(String farmName,String fieldName,int fieldID)
            : base(UITableViewStyle.Grouped, null)
        {
            this.Pushing = true;
            LocalStorage.getLocalStorageManager ().createTable ();
            Root = new RootElement (farmName+"  "+fieldName) {};

            var section0 = new Section ("Field Info:") { };
            var acreElem=new EntryElement("Acre: ","Enter field size here",DBConnection.getFieldAcre(fieldID).ToString());
            acreElem.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            acreElem.ShouldReturn+=()=>{acreElem.ResignFirstResponder(true);return true;};
            var noteElem=new SimpleMultilineEntryElement("Note",DBConnection.getFieldNote(fieldID));
            noteElem.Editable=true;
            //noteElem.ShouldReturn+=()=>{noteElem.ResignFirstResponder(true);return true;};
            var btnSave=new StringElement("Save",()=>{
                try{
                    DBConnection.updateAcre(fieldID,Int32.Parse(acreElem.Value));
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for acre!", null, "Continue").Show ();
                    return;
                }

                try{
                    DBConnection.updateNote(fieldID,noteElem.Value);
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for note!", null, "Continue").Show ();
                    return;
                }
                UIAlertView alert = new UIAlertView ();
                alert.Title = "Success";
                alert.Message = "Your Data Has Been Saved";
                alert.AddButton("OK");
                alert.Show();
            });

            section0.Add(acreElem);
            section0.Add(noteElem);
            section0.Add(btnSave);
            Root.Add(section0);

            SQLiteConnection sql = DBConnection.initialDB();

            var section = new Section ("choose the action you want to do") { };
            var seed=new StringElement("Seed",()=>{
                //add code here Wen

                this.NavigationController.PushViewController(new Seed(fieldID),true);
            });
            var chemical=new StringElement("Chemical",()=>{
                //add code here Wen
                this.NavigationController.PushViewController(new Chemical(fieldID),true);
            });

            var harvest=new StringElement("Harvest",()=>{
                //add code here khaled
                this.NavigationController.PushViewController(new Harvest(fieldID, sql),true);
            });
            var cultivation=new StringElement("Cultivation",()=>{
                //add code here khaled
                this.NavigationController.PushViewController(new Cultivation(fieldID, sql),true);
            });
            var soilTest=new StringElement("Soil Test",()=>{
                //add code here khaled
                this.NavigationController.PushViewController(new SoilTest(fieldID, sql),true);
            });

            section.Add (seed);
            section.Add(chemical);
            section.Add(harvest);
            section.Add (cultivation);
            section.Add(soilTest);
            Root.Add(section);
        }
        public EntryElement getNumberElement(double amount, string caption)
        {
            EntryElement e = new EntryElement (caption, "", amount.ToString ("N", Stripper.GetNumberFormatInfo ()));
            e.ResignFirstResponder (true);

            return e;
        }
Пример #5
0
        public ModifyBin(int binNum)
            : base(UITableViewStyle.Grouped, null)
        {
            Root = new RootElement ("Bin " + binNum) { };
            this.Pushing = true;

            var theBins = DBConnection.getBin(binNum);

            var section=new Section(){};
            EntryElement binSizeElem=new EntryElement("..",null,null);
            EntryElement bushelElem=new EntryElement("..",null,null);
            EntryElement cropElem=new EntryElement("..",null,null);
            EntryElement moisterElem=new EntryElement("..",null,null);
            //var binNumElem=new MultilineElement("Bin # ",binNum.ToString());
            //section.Add(binNumElem);
            foreach(Bin theBin in theBins){
                binSizeElem=new EntryElement("Bin Size: ","Enter bin size here",theBin.binSize.ToString());
                binSizeElem.ShouldReturn+=()=>{binSizeElem.ResignFirstResponder(true);   return true;};
                bushelElem=new EntryElement("Bushel : ","Enter bushel here",theBin.bushel.ToString());
                bushelElem.ShouldReturn+=()=>{bushelElem.ResignFirstResponder(true);   return true;};
                cropElem=new EntryElement("Crop Kind: ","Enter crop kind in this bin here",theBin.crop);
                cropElem.ShouldReturn+=()=>{cropElem.ResignFirstResponder(true);   return true;};
                moisterElem=new EntryElement("% Moister: ","Enter % moister of this bin here",theBin.moister);
                moisterElem.ShouldReturn+=()=>{cropElem.ResignFirstResponder(true);   return true;};
                section.Add (binSizeElem);
                section.Add (bushelElem);
                section.Add (cropElem);
                section.Add (moisterElem);
            }
            Root.Add(section);

            UIBarButtonItem update = new UIBarButtonItem (UIBarButtonSystemItem.Save);
            this.NavigationItem.RightBarButtonItem =update;
            update.Clicked+=(s,ev)=>{
                try{
                    DBConnection.updateBinSize(binNum,Int32.Parse(binSizeElem.Value));
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for bin size!", null, "Continue").Show ();
                    return;
                }
                try{
                    DBConnection.updateBinBushel(binNum,Int32.Parse(bushelElem.Value));
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for bushel!", null, "Continue").Show ();
                    return;
                }
                try{
                    DBConnection.updateBinCrop(binNum,cropElem.Value);
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for crop kind!", null, "Continue").Show ();
                    return;
                }
                try{
                    DBConnection.updateBinMoister(binNum,moisterElem.Value);
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for moister!", null, "Continue").Show ();
                    return;
                }

                UIAlertView alert = new UIAlertView ();
                alert.Title = "Success";
                alert.Message = "Your Data Has Been Saved";
                alert.AddButton("OK");

                alert.Clicked += delegate {
                    this.NavigationController.PopViewControllerAnimated(true);
                } ;
                alert.Show();
            };

            /*var section2=new Section(){};
            var update=new StringElement("Save",()=>{
                try{
                    DBConnection.updateBinSize(binNum,Int32.Parse(binSizeElem.Value));
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for bin size!", null, "Continue").Show ();
                    return;
                }
                try{
                    DBConnection.updateBinBushel(binNum,Int32.Parse(bushelElem.Value));
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for bushel!", null, "Continue").Show ();
                    return;
                }
                try{
                    DBConnection.updateBinCrop(binNum,cropElem.Value);
                }
                catch(Exception e){
                    new UIAlertView ("Error", "Wrong input format for crop kind!", null, "Continue").Show ();
                    return;
                }
                new UIAlertView ("Success", "Data has been saved", null, "Continue").Show ();
            });
            section2.Add(update);
            Root.Add (section2);
            */
        }
Пример #6
0
        public Cultivation(int num, SQLiteConnection s)
            : base(UITableViewStyle.Grouped, null)
        {
            sql = s;
            sql.CreateTable<CultivationData> ();

            fieldID = num;

            date = new DateElement (null, DateTime.Today);
            implement = new EntryElement (null, "Which implement was used?", null);
            depth = new FloatElementEx (0);

            notes = new SimpleMultilineEntryElement (null, null);

            depth.UseCaptionForValueDisplay = true;
            depth.ShowCaption = true;
            depth.MinValue = 0;
            depth.MaxValue = 2;

            implement.ShouldReturn += delegate {
                implement.ResignFirstResponder (true);
                return true;
            };

            notes.Editable = true;

            this.Title = "Cultivation";
            this.Pushing = true;
            this.NavigationItem.SetRightBarButtonItem (
                new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender,args) => {
                // button was clicked

                var cultivationData = new CultivationData {
                    DbField = fieldID,
                    DbDate = date.DateValue,
                    DbImplement = implement.Value,
                    DbDepth = depth.Value,
                    DbNotes = notes.Value
                };

                //insert to database
                sql.Insert (cultivationData);

                UIAlertView alert = new UIAlertView ();
                alert.Title = "Success";
                alert.Message = "Your Data Has Been Saved";
                alert.AddButton("OK");

                alert.Clicked += delegate {
                    this.NavigationController.PopViewControllerAnimated(true);
                } ;
                alert.Show();
            })
                , true);

            Root = new RootElement (null) {
                new Section ("Date"){
                    date,
                },
                new Section ("Implement Used"){
                    implement,
                },
                new Section("Depth (in)"){
                    depth,
                },
                new Section ("Notes"){
                    notes,
                },
            };
        }
Пример #7
0
        public void initializeUserInterface()
        {
            // 0. Chemical Template

            chemicalTemplateDict = new Dictionary<string, ChemicalTemplate> ();
            chemicalTemplateDict = LocalStorage.getLocalStorageManager ().loadChemicalTemplate();

            Section chemicalTemplateS = new Section ("Chemical Template");
            chemicalTemplate = new RadioGroup (0);

            Section stSection = new Section ();
            foreach(var templateName in chemicalTemplateDict){
                var t = new myRadioElement(templateName.Value.templateName);
                t.OnSelected += delegate(object sender, EventArgs e) {

                    InvokeOnMainThread(()=>{
                        loadValueFromTemplate(t.Caption);
                    });
                };
                stSection .Add(t);
            }
            RootElement stRoot = new RootElement ("Chemical Template", chemicalTemplate) { };
            stRoot.Add(stSection);
            chemicalTemplateS.Add (stRoot);

            // 1. Chemical Date
            Section chemicalDateS = new Section ("Chemical Date");
            chemicalDate = new DateElement ("", DateTime.Now);
            chemicalDateS.Add (this.chemicalDate);

            // 2. Implemented Used
            Section implementedUsedS = new Section ("Implemented Used");
            tools = new EntryElement (" ","Tools","");
            tools.ShouldReturn += delegate {
                tools.ResignFirstResponder(true);
                return true;
            };
            tools.ReturnKeyType = UIReturnKeyType.Done;
            implementedUsedS.Add (tools);

            // 3. Seed Type
            Section chemicalTypeS = new Section ("Chemical Types");

            chemicalTypes = new EntryElement (" ", "Chemical Types", "");
            chemicalTypes.ShouldReturn += delegate {
                chemicalTypes.ResignFirstResponder(true);
                return true;
            };
            chemicalTypes.ReturnKeyType = UIReturnKeyType.Done;
            chemicalTypeS.Add (chemicalTypes);

            // 4. chemical Rate
            Section chemicalRateS = new Section ("Chemical Rate (L/ac)");
            chemicalRate = new EntryElement (" ", "Chemical Rates", "");
            chemicalRate.ShouldReturn += delegate {
                chemicalRate.ResignFirstResponder(true);
                return true;
            };
            chemicalRate.ReturnKeyType = UIReturnKeyType.Done;
            chemicalRateS.Add (chemicalRate);

            // 5. Note
            Section noteS = new Section ("Notes");
            note = new SimpleMultilineEntryElement ("", " ") { Editable = true };
            noteS.Add (note);

            Root.Add (chemicalTemplateS);
            Root.Add (chemicalDateS);
            Root.Add (implementedUsedS);
            Root.Add (chemicalTypeS);
            Root.Add (chemicalRateS);
            Root.Add (noteS);
        }
Пример #8
0
        public SignInViewController()
            : base(UITableViewStyle.Grouped, new RootElement ("Crisis Checkin"), false)
        {
            webService = WebServiceFactory.Create ();

            username = new EntryElement ("Email", "*****@*****.**", "") {
                KeyboardType = UIKeyboardType.EmailAddress,
                AutocorrectionType = UITextAutocorrectionType.No
            };
            password = new EntryElement ("Password", "password", "", true) {
                AutocorrectionType = UITextAutocorrectionType.No
            };

            Root = new RootElement ("Crisis Checkin") {
                new Section ("Already have an account?") {
                    username,
                    password,
                    new StyledStringElement ("Sign In", async () => {

                        username.ResignFirstResponder (true);
                        password.ResignFirstResponder (true);

                        //TODO: Show progress HUD
                        ProgressHud.Show ("Signing In");

                        // You have to fetch values first from MonoTouch.Dialog elements
                        username.FetchValue ();
                        password.FetchValue ();

                        // Actually sign in
                            var r = await webService.SignInAsync(new SignInRequest {
                            Username = username.Value,
                            Password = password.Value
                        });

                        if (!r.Succeeded) {
                            // Show failure message
                            Utility.ShowError ("Sign In Failed", "Invalid Username or Password");
                            return;
                        }

                        // Store our credentials for future web service calls
                        AppDelegate.Settings.SignedInUsername = username.Value;
                        AppDelegate.Settings.SignedInPassword = password.Value;

                        //TODO: Hide progress hud
                        ProgressHud.Dismiss ();

                        // Navigate to commitments after successfuly login
                        commitmentsViewController = new CommitmentsViewController ();
                        NavigationController.PushViewController (commitmentsViewController, true);

                    }) {
                        Alignment = UITextAlignment.Center
                    }
                },
                new Section ("Don't have an account yet?") {
                    new StyledStringElement ("Create an Account", () => {

                        // Navigate to registration controller
                        registerViewController = new RegisterViewController();
                        NavigationController.PushViewController (registerViewController, true);

                    }) {
                        Alignment = UITextAlignment.Center
                    }
                }
            };
        }
Пример #9
0
        public void initializeUserInterface()
        {
            // 0. Seed Templates
            seedTemplateDict = new Dictionary<string, SeedTemplate> ();
            seedTemplateDict = LocalStorage.getLocalStorageManager ().loadSeedTemplate ();

            Section seedTemplateS = new Section ("Seed Template");
            seedTemplate = new RadioGroup (0);

            Section stSection = new Section ();
            foreach(var templateName in seedTemplateDict){
                var t = new myRadioElement(templateName.Value.templateName);
                t.OnSelected += delegate(object sender, EventArgs e) {

                    InvokeOnMainThread(()=>{
                        loadValueFromTemplate(t.Caption);
                    });
            };
                stSection .Add(t);
            }
            RootElement stRoot = new RootElement ("Seed Template", seedTemplate) { };
            stRoot.Add(stSection);

            seedTemplateS.Add (stRoot);

            // 1. Seed Date
            Section seedDateS = new Section ("Seed Date");
            this.seedDate = new DateElement ("", DateTime.Now);
            seedDateS.Add (this.seedDate);

            // 2. Seed Type
            Section seedTypeS = new Section ("Seed Types");

            seedTypes = new EntryElement (" ", "Seed Types", "");
            seedTypes.ShouldReturn += delegate {
                seedTypes.ResignFirstResponder(true);
                return true;
            };
            seedTypes.ReturnKeyType = UIReturnKeyType.Done;
            seedTypeS.Add (seedTypes);

            // 3. Seeding Depth
            Section seedDepthS = new Section ("Seeding Depth (in)");
            //			seedDepth = new FloatElementEx (0, lockable: false) {
            //				ShowCaption = true,
            //				UseCaptionForValueDisplay = true,
            //				MaxValue = 2,
            //			};
            seedDepth = new EntryElement(" ","Seed Depth", "");
            seedDepth.ShouldReturn += delegate {
                seedDepth.ResignFirstResponder(true);
                return true;
            };
            seedDepth.ReturnKeyType = UIReturnKeyType.Done;
            seedDepthS.Add(seedDepth);

            // 4. Implemented Used
            Section implementedUsedS = new Section ("Implemented Used");
            tools = new EntryElement (" ","Tools","");
            tools.ShouldReturn += delegate {
                tools.ResignFirstResponder(true);
                return true;
            };
            tools.ReturnKeyType = UIReturnKeyType.Done;
            implementedUsedS.Add (tools);

            // 5. Variety Name
            Section varietyNameS = new Section ("Variety Name");
            varietyName = new EntryElement (" ","Enter Variety Name","");
            varietyName.ReturnKeyType = UIReturnKeyType.Done;
            varietyName.ShouldReturn += delegate {

                varietyName.ResignFirstResponder(true);
                return true;
            };
            varietyNameS.Add (varietyName);

            // 6. Seed Rate
            Section seedRateS = new Section ("Seed Rate (lb/ac)");
            seedRate = new FloatElementEx (0, lockable: false) {
                ShowCaption = true,
                UseCaptionForValueDisplay = true,
                MaxValue = 300,
            };
            seedRateS.Add(seedRate);

            // 7. Seed Treatment
            Section seedTreatmentS = new Section ("Seed Treatment");
            seedTreatment = new  EntryElement (" ","Enter Seed Treatment","");
            seedTreatment.ReturnKeyType = UIReturnKeyType.Done;

            seedTreatmentS.Add (seedTreatment);

            // 8. NH3
            Section NH3S = new Section ("NH3 (lb/ac)");
            NH3 = new FloatElementEx (0, lockable: false) {
                ShowCaption = true,
                UseCaptionForValueDisplay = true,
                MaxValue = 120,
            };
            NH3S.Add (NH3);

            // 9. 11-52-20
            Section _11S = new Section ("11-52-20 (lb/ac)");
            _11 = new FloatElementEx (0, lockable: false) {
                ShowCaption = true,
                UseCaptionForValueDisplay = true,
                MaxValue = 100,
            };
            _11S.Add(_11);

            // 10. Note
            Section noteS = new Section ("Notes");

            note = new SimpleMultilineEntryElement ("", " ") { Editable = true };
            noteS.Add (note);

            Root.Add (seedTemplateS);
            Root.Add (seedDateS);
            Root.Add (seedTypeS);
            Root.Add (implementedUsedS);
            Root.Add (seedDepthS);
            Root.Add (varietyNameS);
            Root.Add (seedRateS);
            Root.Add (seedTreatmentS);
            Root.Add (NH3S);
            Root.Add (_11S);
            Root.Add (noteS);
        }
Пример #10
0
        public Harvest(int num, SQLiteConnection s)
            : base(UITableViewStyle.Grouped, null)
        {
            sql = s;
            //Create the db table for this viewcontroller.
            sql.CreateTable<HarvestData> ();
            //The field Id passed to this controller. Represents a unique field on a farm.
            fieldID = num;
            //The Elements with their variables
            date = new DateElement (null, DateTime.Today);
            implement = new EntryElement (null, "Which implement was used?", null);
            yield = new FloatElementEx (0);
            moisture = new FloatElementEx (0);
            bin = new EntryElement (null, "Enter Bin #", null);
            notes = new SimpleMultilineEntryElement (null, null);

            //Specify element details
            yield.UseCaptionForValueDisplay = true;
            yield.ShowCaption = true;
            yield.MinValue = 0;
            yield.MaxValue = 120;

            moisture.UseCaptionForValueDisplay = true;
            moisture.ShowCaption = true;
            moisture.MinValue = 0;
            moisture.MaxValue = 25;
            notes.Editable = true;

            implement.ShouldReturn += delegate {
                implement.ResignFirstResponder (true);
                return true;
            };
            bin.ShouldReturn += delegate {
                bin.ResignFirstResponder (true);
                return true;
            };

            this.Title = "Harvest";
            this.Pushing = true;

            //Create the save button
            this.NavigationItem.SetRightBarButtonItem (
                new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender,args) => {

                //Create table row with data.
                var harvestData = new HarvestData {
                    DbField = fieldID,
                    DbDate = date.DateValue,
                    DbImplement = implement.Value,
                    DbYield = yield.Value,
                    DbMoisture = moisture.Value,
                    DbBin = bin.Value,
                    DbNotes = notes.Value
                };
                //insert to database
                sql.Insert (harvestData);

                UIAlertView alert = new UIAlertView ();
                alert.Title = "Success";
                alert.Message = "Your Data Has Been Saved";
                alert.AddButton("OK");

                alert.Clicked += delegate {
                    this.NavigationController.PopViewControllerAnimated(true);
                } ;
                alert.Show();
            })
                , true);

            //Create the GUI
            Root = new RootElement (null) {
                new Section ("Date"){
                    date,
                },
                new Section("Implement Used") {
                    implement,
                },
                new Section("Yield (bushel / acre)"){
                    yield,
                },
                new Section("Moisture (%)"){
                    moisture,
                },
                new Section ("Bin"){
                    bin,
                },
                new Section("Notes") {
                    notes,
                },
            };
        }