Captures the information about mutually exclusive elements in a RootElement
コード例 #1
0
        public OptionsRootElement(Model.Options options)
            : base("Bedside Clock")
        {
            customFontNames = new string[] { "LCDMono" };
            standardFontNames = UIFont.FamilyNames.OrderBy(f => f).ToArray();

            use24Hour = new BooleanElement("24 hour", options.Use24Hour);
            showSeconds = new BooleanElement("Seconds", options.ShowSeconds);
            fontGroup = new RadioGroup(GetIndexForSelectedFont(options.Font));

            var customFontSection = new Section("Custom");
            customFontSection.AddAll(customFontNames.Select(f => new FontEntryElement(f)));

            var fontSection = new Section("Standard Fonts");
            fontSection.AddAll(standardFontNames.Select(f => new FontEntryElement(f)));

            Add(new Section("Clock Display") {
                new StringElement("Color", "Green"),
                new RootElement("Font", fontGroup) { customFontSection, fontSection },
                use24Hour,
                showSeconds
            });
            Add(new Section("Brightness") {
                new FloatElement(null, null, 0.5f)
            });
        }
コード例 #2
0
 RootElement CreateRoot()
 {
     nameElement = new EntryElement ("Name", "", "");
     scoreElement = new EntryElement ("Score", "", "");
     difficultyGroup = new RadioGroup (0);
     return new RootElement ("Parse"){
         new Section("Add a score!"){
             nameElement,
             scoreElement,
             new RootElement ("Difficulty",difficultyGroup){
                 new Section ("Difficulty"){
                     new RadioElement ("Easy"),
                     new RadioElement ("Medium"),
                     new RadioElement ("Hard"),
                 },
             },
         },
         new Section()
         {
             new StringElement("Submit Score",submitScore),
         },
         new Section()
         {
             new StringElement("View High Scores", viewHighScores),
         }
     };
 }
コード例 #3
0
ファイル: AppDelegate.cs プロジェクト: bjaminn/csunits
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            _window = new UIWindow (UIScreen.MainScreen.Bounds);

            _quantityGroup = new RadioGroup("Qty", 0);
            _fromUnitGroup = new RadioGroup("FromU", 0);
            _toUnitGroup = new RadioGroup("ToU", 0);

            var quantityRootElement = new RootElement("Quantity", _quantityGroup) { new Section() };
            quantityRootElement[0].AddAll(QuantityCollection.Quantities.Select(qty => {
                var elem = new EventHandlingRadioElement(qty.Quantity.DisplayName, "Qty");
                elem.OnSelected += OnQuantitySelected;
                return elem as Element;
            }));

            _rootElement = new RootElement ("Unit Converter")
            {
                new Section() { quantityRootElement },
                new Section("From") { new EntryElement("Amount", string.Empty, string.Empty),
                    new RootElement("Unit", _fromUnitGroup) { new Section() } },
                new Section("To") { new EntryElement("Amount", string.Empty, string.Empty),
                    new RootElement("Unit", _toUnitGroup) { new Section() } }
            };

            _rootVC = new DialogViewController(_rootElement);
            _nav = new UINavigationController(_rootVC);

            _window.RootViewController = _nav;
            _window.MakeKeyAndVisible();

            return true;
        }
コード例 #4
0
		public RootElement BuildRootWithLoop()
		{
			bankSelection = new RadioGroup (0);

			Section section = null;
			string lastLetter = "";
			RootElement root = new RootElement("Pick your bank", bankSelection);

			foreach(var name in data)
			{
				string currentFirstLetter = name.Substring(0,1);
				if (currentFirstLetter != lastLetter)
				{
					if (section != null && section.Count > 0) root.Add (section);

					lastLetter = currentFirstLetter;
					section = new Section(currentFirstLetter);
				}

				section.Add (new RadioElement(name));

			}

			if (section != null && section.Count > 0) root.Add (section);

			return root;

		}
コード例 #5
0
        public override void ViewDidLoad()
        {

            base.ViewDidLoad();
            
            // Perform any additional setup after loading the view
            var info = new RootElement("Info") {
                new Section() {
                    { eventname = new EntryElement("Event Name", "Enter the Name", null) },
                    { recipients = new EntryElement("Recipients' Names", "Enter the Recipients", null) },
                    { location = new EntryElement("Enter Location", "Enter the Location", null) }
                },

                new Section()
                {
                    { date = new DateElement("Pick the Date", DateTime.Now) },
                    { timeelement = new TimeElement("Pick the Time", DateTime.Now) },
                    { description = new EntryElement("Description", "Enter a Description", null) }
                },

                new Section()
                {
                    new RootElement("Type", category = new RadioGroup("Type of Event", 0)) {
                        new Section() {
                            new RadioElement ("Meeting", "Type of Event"),
                            new RadioElement ("Company Event", "Type of Event"),
                            new RadioElement ("Machine Maintenance", "Type of Event"),
                            new RadioElement ("Emergency", "Type of Event")
                        }
                    },
                    
                    new RootElement("Priority", priority = new RadioGroup ("priority", 0))
                    {
                        new Section()
                        {
                            new RadioElement("Low", "priority"),
                            new RadioElement("Medium", "priority"), 
                            new RadioElement("High", "priority")
                        }
                    }
                },
            };

            Root.Add(info);

            UIButton createEventBtn = UIButton.FromType(UIButtonType.RoundedRect);
            createEventBtn.SetTitle("Add Event", UIControlState.Normal);
            createEventBtn.Frame = new Rectangle(0, 0, 320, 44);
            int y = (int)((View.Frame.Size.Height - createEventBtn.Frame.Size.Height)/1.15);
            int x = ((int)(View.Frame.Size.Width - createEventBtn.Frame.Size.Width)) / 2;
            createEventBtn.Frame = new Rectangle(x, y, (int)createEventBtn.Frame.Width, (int)createEventBtn.Frame.Height);
            View.AddSubview(createEventBtn);


            createEventBtn.TouchUpInside += async (object sender, EventArgs e) =>
            {
                await createEvent(info);
            };
        }
コード例 #6
0
ファイル: SettingsView.cs プロジェクト: sbondini/BleChat
        private RootElement GetStatusRootView()
        {
            var statusNames = Enum.GetNames(typeof(UserStatuses));
            var radioElements = statusNames.Select(name => new RadioElement(name)).ToList();

            var radioSection = new Section();
            radioSection.AddAll(radioElements);

            return new RootElement("Status", _statusRadioGroup = new RadioGroup(_settings.StatusId)) {radioSection};
        }
コード例 #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var title = expense == null ? "New Expense" : "Edit Expense";
            this.Root = new RootElement(title)
              {
            new Section("Expense Details")
            {
              (name = new EntryElement("Name", "Expense Name", string.Empty)),
              (total = new EntryElement("Total", "1.00", string.Empty){KeyboardType = UIKeyboardType.DecimalPad}),
              (billable = new CheckboxElement("Billable", true)),
              new RootElement("Category", categories = new RadioGroup("category", 0))
              {
            new Section()
            {
              from category in viewModel.Categories
                select (Element) new RadioElement(category)
            }
              },
              (due = new DateElement("Due Date", DateTime.Now))
            },
            new Section("Notes")
            {
              (notes = new EntryElement(string.Empty, "Enter expense notes.", string.Empty))
            }

              };

            billable.Value = viewModel.Billable;
            name.Value = viewModel.Name;
            total.Value = viewModel.Total;
            notes.Caption = viewModel.Notes;
            categories.Selected = viewModel.Categories.IndexOf(viewModel.Category);
            due.DateValue = viewModel.Due;

            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, async delegate
            {
                viewModel.Category = viewModel.Categories[categories.Selected];
                viewModel.Name = name.Value;
                viewModel.Billable = billable.Value;
                viewModel.Due = due.DateValue;
                viewModel.Notes = notes.Caption;
                viewModel.Total = total.Value;

                await viewModel.ExecuteSaveExpenseCommand();
                if (!viewModel.CanNavigate)
                    return;
                NavigationController.PopToRootViewController(true);

            });
        }
コード例 #8
0
		public RootElement BuildRootWithLinq()
		{
			bankSelection = new RadioGroup (0);
			return new RootElement ("Pick your bank", bankSelection) {
				from name in data
				group name by name.Substring (0,1) into g
				orderby g.Key
				select new Section(g.Key)
				{
					from groupItem in g
						select (Element) new RadioElement(groupItem)
				}
			};
		}
コード例 #9
0
		public override void LoadView ()
		{
			base.LoadView ();

			//we need this to store the valid of the Preference item in
			RadioGroup preferenceGroup = new RadioGroup (0);

			//build the root
			var root = new RootElement ("Account")
			{
				//add a section for the top switch
				new Section
				{
					new BooleanElement("Airplane Mode", false)
				},
				new Section("Data Entry", "Your Credentials")
				{
					new EntryElement("Login", "Enter your email", ""),
					new EntryElement("Password", "Enter your password", "", true)
				},
				new Section("Travel Options")
				{
					new RootElement("Preference", preferenceGroup)
					{
						new Section()
						{
							new RadioElement("Aisle"),
							new RadioElement("Window"),
							new RadioElement("Centre")
						}
					}
				},
				new Section()
				{
					new StringElement("Press Me", () => {
						var alert = new UIAlertView ("Tapped", "Yes, you tapped it",
						                             null, "Ok");
						alert.Show ();
					})
				}

			};

			Root = root;

		}
コード例 #10
0
 protected RootElement CreateSection(List<string> listOfSources)
 {
     var items = new Section (GetSectionTitle ());
     if (!listOfSources.Any ()) {
         AddElementsInCaseOfEmptyList (items);
         return new RootElement ("") {
             items
         };
     }
     var rGroup = new RadioGroup (-1);
     foreach (var item in listOfSources) {
         var radioButton = new RadioElement (item);
         radioButton.Tapped += () => Upload (listOfSources[rGroup.Selected]);
         items.Add (radioButton);
     }
     return new RootElement ("", rGroup) { items };
 }
コード例 #11
0
ファイル: Chemical.cs プロジェクト: Bibo77/MADMUCfarm
        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);
        }
コード例 #12
0
ファイル: ItemPage.cs プロジェクト: ogazitt/zaplify
        private Element RenderEditItemField(Item item, Field field)
        {
            PropertyInfo pi = null;
            object currentValue = null;
            object container = null;

            // get the current field value.
            // the value can either be in a strongly-typed property on the item (e.g. Name),
            // or in one of the FieldValues
            try
            {
                // get the strongly typed property
                pi = item.GetType().GetProperty(field.Name);
                if (pi != null)
                {
                    // store current item's value for this field
                    currentValue = pi.GetValue(item, null);

                    // set the container - this will be the object that will be passed
                    // to pi.SetValue() below to poke new values into
                    container = item;
                }
            }
            catch (Exception)
            {
                // an exception indicates this isn't a strongly typed property on the Item
                // this is NOT an error condition
            }

            // if couldn't find a strongly typed property, this property is stored as a
            // FieldValue on the item
            if (pi == null)
            {
                // get current item's value for this field, or create a new FieldValue
                // if one doesn't already exist
                FieldValue fieldValue = item.GetFieldValue(field.ID, true);
                currentValue = fieldValue.Value;

                // get the value property of the current fieldvalue (this should never fail)
                pi = fieldValue.GetType().GetProperty("Value");
                if (pi == null)
                    return null;

                // set the container - this will be the object that will be passed
                // to pi.SetValue() below to poke new values into
                container = fieldValue;
            }

            // most elements will be Entry Elements - default to this
            EntryElement entryElement = new EntryElement(field.DisplayName, "", "");
            Element element = entryElement;

            bool notMatched = false;
            // render the right control based on the type
            switch (field.DisplayType)
            {
                case DisplayTypes.Text:
                    //StyledMultilineElement stringElement = new StyledMultilineElement(field.DisplayName, (string) currentValue);
                    entryElement.KeyboardType = UIKeyboardType.Default;
                    entryElement.Value = (string) currentValue;
                    entryElement.AutocorrectionType = UITextAutocorrectionType.Yes;
                    entryElement.Changed += delegate {
                        pi.SetValue(container, entryElement.Value, null); };
                    //element = stringElement;
                    break;
                case DisplayTypes.TextArea:
                    MultilineEntryElement multilineElement = new MultilineEntryElement(field.DisplayName, (string) currentValue) { Lines = 3 };
                    multilineElement.Changed += delegate { pi.SetValue(container, multilineElement.Value, null); };
                    //var multilineElement = new MultilineEntryElement3(field.DisplayName, (string) currentValue) { Editable = true };
                    //multilineElement.Changed += delegate { pi.SetValue(container, multilineElement.Value, null); };
                    element = multilineElement;
                    //entryElement.Value = (string) currentValue;
                    //entryElement.Changed += delegate { pi.SetValue(container, entryElement.Value, null); };
                    break;
                case DisplayTypes.Phone:
                    entryElement.Value = (string) currentValue;
                    entryElement.KeyboardType = UIKeyboardType.PhonePad;
                    entryElement.Changed += delegate { pi.SetValue(container, entryElement.Value, null); };
                    break;
                case DisplayTypes.Link:
                    entryElement.Value = (string) currentValue;
                    entryElement.KeyboardType = UIKeyboardType.Url;
                    entryElement.Changed += delegate { pi.SetValue(container, entryElement.Value, null); };
                    break;
                case DisplayTypes.Email:
                    entryElement.Value = (string) currentValue;
                    entryElement.KeyboardType = UIKeyboardType.EmailAddress;
                    entryElement.Changed += delegate { pi.SetValue(container, entryElement.Value, null); };
                    break;
                case DisplayTypes.Address:
                    entryElement.Value = (string) currentValue;
                    entryElement.AutocorrectionType = UITextAutocorrectionType.Yes;
                    entryElement.Changed += delegate { pi.SetValue(container, entryElement.Value, null); };
                    break;
                case DisplayTypes.Priority:
                    var priorities = new RadioGroup(field.DisplayName, 0);
                    priorities.Selected =
                        ((int?) currentValue) != null ?
                        (int) currentValue :
                        1;  // HACK: hardcode to "Normal" priority.  this should come from a table.
                    var priSection = new Section();
                    priSection.AddAll(
                        from pr in App.ViewModel.Constants.Priorities
                             select (Element) new RadioEventElement(pr.Name, field.DisplayName));
                    var priorityElement = new ThemedRootElement(field.DisplayName, priorities) { priSection };
                    // augment the radio elements with the right index and event handler
                    int i = 0;
                    foreach (var radio in priorityElement[0].Elements)
                    {
                        RadioEventElement radioEventElement = (RadioEventElement) radio;
                        int index = i++;
                        radioEventElement.OnSelected += delegate { pi.SetValue(container, index, null); };
                    }
                    element = priorityElement;
                    break;
                case DisplayTypes.Lists:
                    // create a collection of lists in this folder, and add the folder as the first entry
                    var lists = App.ViewModel.Items.
                        Where(li => li.FolderID == item.FolderID && li.IsList == true && li.ItemTypeID != SystemItemTypes.Reference).
                            OrderBy(li => li.Name).
                            ToObservableCollection();
                    lists.Insert(0, new Item()
                    {
                        ID = Guid.Empty,
                        Name = folder.Name
                    });
                    // a null value for the "list" field indicates a Folder as a parent (i.e. this item is a top-level item)
                    if (currentValue == null)
                        currentValue = Guid.Empty;
                    Item currentList = lists.FirstOrDefault(li => li.ID == (Guid) currentValue);
                    var listsGroup = new RadioGroup (field.DisplayName, 0);
                    listsGroup.Selected = Math.Max(lists.IndexOf(currentList), 0);
                    var listsSection = new Section();
                    listsSection.AddAll(
                        from l in lists
                            select (Element) new RadioEventElement(l.Name, field.DisplayName));
                    var listsElement = new ThemedRootElement(field.DisplayName, listsGroup) { listsSection };
                    // augment the radio elements with the right index and event handler
                    int index = 0;
                    foreach (var radio in listsElement[0].Elements)
                    {
                        int currentIndex = index;  // make a local copy for the closure
                        RadioEventElement radioEventElement = (RadioEventElement) radio;
                        radioEventElement.OnSelected += delegate(object sender, EventArgs e)
                        {
                            pi.SetValue(container, lists[currentIndex].ID, null);
                        };
                        index++;
                    }
                    element = listsElement;
                    break;
                case DisplayTypes.DatePicker:
                    DateTime? dateTime = String.IsNullOrEmpty((string) currentValue) ? (DateTime?) null : Convert.ToDateTime((string) currentValue);
                    DateEventElement dateElement = new DateEventElement(field.DisplayName, dateTime);
                    dateElement.ValueSelected += delegate
                    {
                        pi.SetValue(container, ((DateTime)dateElement.DateValue).ToString("yyyy/MM/dd"), null);
                        folder.NotifyPropertyChanged("FirstDue");
                        folder.NotifyPropertyChanged("FirstDueColor");
                    };
                    element = dateElement;
                    break;
                case DisplayTypes.DateTimePicker:
                    DateTime? dt = String.IsNullOrEmpty((string) currentValue) ? (DateTime?) null : Convert.ToDateTime((string) currentValue);
                    DateTimeEventElement dateTimeElement = new DateTimeEventElement(field.DisplayName, dt);
                    dateTimeElement.ValueSelected += (s, e) =>
                    {
                        pi.SetValue(container, dateTimeElement.DateValue == null ? null : ((DateTime) dateTimeElement.DateValue).ToString(), null);
                        folder.NotifyPropertyChanged("FirstDue");
                        folder.NotifyPropertyChanged("FirstDueColor");
                    };
                    element = dateTimeElement;
                    break;
                case DisplayTypes.Checkbox:
                    CheckboxElement checkboxElement = new CheckboxElement(field.DisplayName, currentValue == null ? false : (bool) currentValue);
                    checkboxElement.Tapped += delegate { pi.SetValue(container, checkboxElement.Value, null); };
                    element = checkboxElement;
                    break;
                case DisplayTypes.TagList:
                    // TODO
                    element = null;
                    break;
                case DisplayTypes.ImageUrl:
                    // TODO: wire up to picture picker, and upload to an image service
                    element = null;
                    break;
                case DisplayTypes.LinkArray:
                    var linkArrayElement = new MultilineEntryElement(field.DisplayName, (string) currentValue) { Lines = 3, AcceptReturns = true };
                    if (!String.IsNullOrEmpty((string) currentValue))
                    {
                        try
                        {
                            var linkList = JsonConvert.DeserializeObject<List<Link>>((string)currentValue);
                            linkArrayElement.Value = String.Concat(linkList.Select(l => l.Name != null ? l.Name + "," + l.Url + "\n" : l.Url + "\n").ToList());
                        }
                        catch (Exception)
                        {
                        }
                    }
                    linkArrayElement.Changed += delegate
                    {
                        // the expected format is a newline-delimited list of Name, Url pairs
                        var linkArray = linkArrayElement.Value.Split(new char[] { '\r','\n' }, StringSplitOptions.RemoveEmptyEntries);
                        var linkList = new List<Link>();
                        foreach (var link in linkArray)
                        {
                            var nameval = link.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            if (nameval.Length == 0)
                                continue;
                            if (nameval.Length == 1)
                                linkList.Add(new Link() { Url = nameval[0].Trim() });
                            else
                                linkList.Add(new Link() { Name = nameval[0].Trim(), Url = nameval[1].Trim() });
                        }
                        var json = JsonConvert.SerializeObject(linkList);
                        pi.SetValue(container, json, null);
                    };
                    element = linkArrayElement;
                    break;
                case DisplayTypes.Hidden:
                    // skip rendering
                    element = null;
                    break;
                case DisplayTypes.ContactList:
                    StringElement contactsElement = new StringElement(field.DisplayName);
                    Item currentContacts = CreateValueList(item, field, currentValue == null ? Guid.Empty : new Guid((string) currentValue));
                    contactsElement.Value = CreateCommaDelimitedList(currentContacts);
                    Item contacts = new Item()
                    {
                        Items = App.ViewModel.Items.
                            Where(it => it.ItemTypeID == SystemItemTypes.Contact && it.IsList == false).
                            Select(it => new Item() { Name = it.Name, FolderID = folder.ID, ItemTypeID = SystemItemTypes.Reference, ParentID = currentContacts.ID, ItemRef = it.ID }).
                            ToObservableCollection(),
                    };
                    contactsElement.Tapped += delegate
                    {
                        // put up the list picker dialog
                        ListPickerPage listPicker = new ListPickerPage(
                            SystemItemTypes.Contact,
                            editViewController.NavigationController,
                            contactsElement,
                            pi,
                            container,
                            field.DisplayName,
                            currentContacts,
                            contacts);
                        listPicker.PushViewController();
                    };
                    element = contactsElement;
                    break;
                case DisplayTypes.LocationList:
                    StringElement locationsElement = new StringElement(field.DisplayName);
                    Item currentLocations = CreateValueList(item, field, currentValue == null ? Guid.Empty : new Guid((string) currentValue));
                    locationsElement.Value = CreateCommaDelimitedList(currentLocations);
                    Item locations = new Item()
                    {
                        Items = App.ViewModel.Items.
                            Where(it => it.ItemTypeID == SystemItemTypes.Location && it.IsList == false).
                            Select(it => new Item() { Name = it.Name, FolderID = folder.ID, ItemTypeID = SystemItemTypes.Reference, ParentID = currentLocations.ID, ItemRef = it.ID }).
                            ToObservableCollection(),
                    };
                    locationsElement.Tapped += delegate
                    {
                        // put up the list picker dialog
                        ListPickerPage listPicker = new ListPickerPage(
                            SystemItemTypes.Location,
                            editViewController.NavigationController,
                            locationsElement,
                            pi,
                            container,
                            field.DisplayName,
                            currentLocations,
                            locations);
                        listPicker.PushViewController();
                    };
                    element = locationsElement;
                    break;
                case DisplayTypes.ItemTypes:
                    var itemTypePickerElement = new ItemTypePickerElement("Type", (Guid) currentValue);
                    itemTypePickerElement.OnSelected += (sender, e) => { pi.SetValue(container, itemTypePickerElement.SelectedItemType, null); };
                    element = itemTypePickerElement;
                    break;
                default:
                    notMatched = true;
                    break;
            }

            // if wasn't able to match field type by display type, try matching by FieldType
            if (notMatched == true)
            {
                switch (field.FieldType)
                {
                    case FieldTypes.String:
                    default:
                        entryElement.KeyboardType = UIKeyboardType.Default;
                        entryElement.Value = (string) currentValue;
                        entryElement.AutocorrectionType = UITextAutocorrectionType.Yes;
                        entryElement.Changed += delegate { pi.SetValue(container, entryElement.Value, null); };
                        break;
                    case FieldTypes.Integer:
                        entryElement.Value = (string) currentValue;
                        entryElement.KeyboardType = UIKeyboardType.NumberPad;
                        entryElement.Changed += delegate { pi.SetValue(container, entryElement.Value, null); };
                        break;
                    case FieldTypes.DateTime:
                        DateTime dateTime = currentValue == null ? DateTime.Now.Date : Convert.ToDateTime ((string) currentValue);
                        DateEventElement dateElement = new DateEventElement(field.DisplayName, dateTime);
                        dateElement.ValueSelected += delegate
                        {
                            pi.SetValue(container, ((DateTime)dateElement.DateValue).ToString("yyyy/MM/dd"), null);
                            folder.NotifyPropertyChanged("FirstDue");
                            folder.NotifyPropertyChanged("FirstDueColor");
                        };
                        element = dateElement;
                        break;
                    case FieldTypes.Boolean:
                        CheckboxElement checkboxElement = new CheckboxElement(field.DisplayName, currentValue == null ? false : (bool) currentValue);
                        checkboxElement.Tapped += delegate { pi.SetValue(container, checkboxElement.Value, null); };
                        element = checkboxElement;
                        break;
                }
            }

            return element;
        }
コード例 #13
0
		private void buildMediaCaptureSettingsElements()
		{
			audioCaptureEnabledElement = new BooleanElement("Record Audio", settings.AudioCaptureEnabled );
			audioCaptureEnabledElement.ValueChanged += delegate 
			{
				EnforceDependencies();	
			};
			videoCaptureEnabledElement = new BooleanElement("Record Video", settings.VideoCaptureEnabled );
			videoCaptureEnabledElement.ValueChanged += delegate 
			{
				EnforceDependencies();	
			};
			autoRecordNextMovieElement = new BooleanElement("Loop Recordings", settings.AutoRecordNextMovie );
			
			// duration choices
			noLimitElement = new RadioElement("Unlimited");
			oneMinuteLimitElement = new RadioElement("1 Minute");
			fiveMinuteLimitElement = new RadioElement("5 Minutes");
			tenMinuteLimitElement = new RadioElement("10 Minutes");
			thirtyMinuteLimitElement = new RadioElement("30 Minutes");
			int index = 0;
			int duration = settings.MaxMovieDurationInSeconds;
			if ( duration <= 0 )         { index = 0; }
			else if ( duration <= 60 )   { index = 1; }
			else if ( duration <= 300 )  { index = 2; }
			else if ( duration <= 600 )  { index = 3; }
			else if ( duration <= 1800 ) { index = 4; }
			
			durationLimitGroup = new RadioGroup("DurationGroup", index );
			durationElement = new RootElement("Maximum Time", durationLimitGroup )
			{
				new Section()
				{
					noLimitElement,
					oneMinuteLimitElement,
					fiveMinuteLimitElement,
					tenMinuteLimitElement,
					thirtyMinuteLimitElement
				}
			};
		}
コード例 #14
0
		private void buildImageCaptureSettingsElements()
		{
			imageCaptureEnabledElement = new BooleanElement("Capture", settings.ImageCaptureEnabled );
			imageCaptureEnabledElement.ValueChanged += delegate 
			{
				EnforceDependencies();
			};
			
			dontSaveImagesElement = new RadioElement("Don't Save");
			saveImagesToPhotoLibraryElement = new RadioElement("Photo Library");
			saveImagesToMyDocumentsElement = new RadioElement("My Documents");
			
			int index = 0;
			if ( settings.SaveCapturedImagesToPhotoLibrary )
			{
				index = 1;
			}
			else if ( settings.SaveCapturedImagesToMyDocuments )
			{
				index = 2;
			}
			saveImageGroup = new RadioGroup("SaveImagesGroup", index );
			saveImageElement = new RootElement("Save To", saveImageGroup )
			{
				new Section()
				{
					dontSaveImagesElement,
					saveImagesToPhotoLibraryElement,
					saveImagesToMyDocumentsElement
				}
			};
		}
コード例 #15
0
		private void buildCameraSettingsElements()
		{
			// camera
			fronCameraElement = new RadioElement("Front");
			backCameraElement = new RadioElement("Back");
			int index = (int)settings.Camera;
			cameraGroup = new RadioGroup("CameraGroup", index );
			cameraElement = new RootElement("Source Camera", cameraGroup)
			{
				new Section()
				{
					fronCameraElement,
					backCameraElement
				}
			};
			
			// resolution choices
			lowResElement = new RadioElement("Low");
			mediumResElement = new RadioElement("Medium");
			highResElement = new RadioElement("High");
			index = (int)settings.CaptureResolution;
			resolutionGroup = new RadioGroup("ResolutionGroup", index );
			resolutionElement = new RootElement("Resolution", resolutionGroup)
			{
				new Section()
				{
					lowResElement,
					mediumResElement,
					highResElement
				}
			};
		}
コード例 #16
0
        public override void ViewDidLoad()
        {

            base.ViewDidLoad();

            // Perform any additional setup after loading the view
            var info = new RootElement("Info") {
                new Section() {
                    { EditTextFirstName = new EntryElement("First Name", "", null) },
                    { EditTextLastName = new EntryElement("Last Name", "", null) },
                    { EditTextEmployeeID = new EntryElement("EmployeeID", "", null) },
                    { EditTextEmail = new EntryElement("Email", "", null) }
                },

                new Section()
                {
                    new RootElement("Department", SpinnerDepartment = new RadioGroup("Department", 0)) {
                        new Section() {

                                                new RadioElement ("Std Sw Eng","Department"),
                                                new RadioElement ("Automated Assembly","Department"),
                                                new RadioElement ("CIP Assembly","Department"),
                                                new RadioElement ("Cip Sort","Department"),
                                                new RadioElement ("CIP TN Administration","Department"),
                                                new RadioElement ("Cip Tn Heat Treat","Department"),
                                                new RadioElement ("Cip Tn Maintenanc","Department"),
                                                new RadioElement ("CIP TN Press","Department"),
                                                new RadioElement ("CIP TN Press2","Department"),
                                                new RadioElement ("CIP TN Press4","Department"),
                                                new RadioElement ("CIP TN Press5","Department"),
                                                new RadioElement ("CIP TN Press6","Department"),
                                                new RadioElement ("Cip Tn Quality As","Department"),
                                                new RadioElement ("CIP TN Tool Room","Department"),
                                                new RadioElement ("Cip Tn Toolroom2","Department"),
                                                new RadioElement ("Cip Tn Toolroom3","Department"),
                                                new RadioElement ("Cip Tn Toolroom4","Department"),
                                                new RadioElement ("CIP Tool Room","Department"),
                                                new RadioElement ("Customer Service","Department"),
                                                new RadioElement ("Design Engineer - MI","Department"),
                                                new RadioElement ("Distribution","Department"),
                                                new RadioElement ("Materials Control","Department"),
                                                new RadioElement ("Outsourcing","Department"),
                                                new RadioElement ("Plant Utility","Department"),
                                                new RadioElement ("QA Admin","Department"),
                                                new RadioElement ("Quality Assurance Auditor-Dir","Department"),
                                                new RadioElement ("Salaried Exempt","Department"),
                                                new RadioElement ("Supervisors","Department"),
                                                new RadioElement ("CIP TN Human Resources","Department"),
                                                new RadioElement ("CIP TN Office","Department"),
                                                new RadioElement ("CIP TN Administration","Department")
                        }
                    },

                    new RootElement("Privledge", SpinnerPrivledge = new RadioGroup ("Privledge", 0))
                    {
                        new Section()
                        {
                            new RadioElement("User", "Privledge"),
                            new RadioElement("Moderator", "Privledge"),
                            new RadioElement("Admin", "Privledge")
                        }
                    }                    
                },
            };

            Root.Add(info);

            UIButton createEmployeeBtn = UIButton.FromType(UIButtonType.RoundedRect);
            createEmployeeBtn.SetTitle("Add Employee", UIControlState.Normal);

            createEmployeeBtn.Frame = new Rectangle(0,0, 320, 44);
            int y = (int)((View.Frame.Size.Height - createEmployeeBtn.Frame.Size.Height) / 1.25 );
            int x = ((int)(View.Frame.Size.Width - createEmployeeBtn.Frame.Size.Width)) / 2;
            createEmployeeBtn.Frame = new Rectangle(x,y, (int)createEmployeeBtn.Frame.Width, (int)createEmployeeBtn.Frame.Height);
            View.AddSubview(createEmployeeBtn);


            createEmployeeBtn.TouchUpInside += async (object sender, EventArgs e) =>
            {
                await createEmployee(info);
            };
        }
コード例 #17
0
		public CalloutViewCtrl () : base(null)
		{
			this.CentersCheck = new CheckboxElement[Centers.Length];
			for (int i = 0; i < Centers.Length; i++) {
				var tmp = new CheckboxElement (Centers[i]);
				this.CentersCheck [i] = tmp;
			}

			this.FirstName = new EntryElement ("First Name", "Rocky", KeyStore.Get ("FirstName")) {
				TextAlignment = UITextAlignment.Right
			};

			this.LastName = new EntryElement ("Last Name", "D. Bull", KeyStore.Get ("LastName")) {
				TextAlignment = UITextAlignment.Right
			};

			this.Email = new EntryElement ("E-Mail", "*****@*****.**", KeyStore.Get ("Email")) {
				TextAlignment = UITextAlignment.Right,
				KeyboardType = UIKeyboardType.EmailAddress
			};

			OptionGroup = new RadioGroup ("type", 0);
			Callout = new RadioElement ("Call-Out", "type");
			Inlate = new RadioElement ("In Late", "type");

			StartDate = new DateElement ("Out On", DateTime.Today) {
				Alignment = UITextAlignment.Right
			};

			MultipleDays = new BooleanElement ("Out Multiple Days", false);
			EndDate = new DateElement ("Back On", DateTime.Today.AddDays (1)) { Alignment = UITextAlignment.Right };

			WhenInDate = new DateTimeElement ("Will Be In", DateTime.Today.AddHours (12)) { Alignment = UITextAlignment.Right };

			Explaination = new EntryElement ("Explaination", "reasons.", null) { TextAlignment = UITextAlignment.Right };

			Section Name = new Section () { FirstName, LastName, Email };
			Section Options = new Section () { Callout, Inlate };

			Section CalloutDates = new Section () { StartDate, MultipleDays };
			MultipleDays.ValueChanged += (sender, e) => {
				if (MultipleDays.Value) {
					CalloutDates.Add(EndDate);
				} else {
					CalloutDates.Remove(EndDate);
				}
			};

			Section LateDay = new Section () { WhenInDate };
			Callout.Tapped += delegate {
				this.Root.RemoveAt(2);
				this.Root.Insert(2, CalloutDates);
			};

			Inlate.Tapped += delegate {
				this.Root.RemoveAt(2);
				this.Root.Insert(2, LateDay);
			};

			this.Submit = new StringElement ("Submit") { Alignment = UITextAlignment.Center };
			this.Root = new RootElement ("Call-Out", OptionGroup) { 
				Name,
				Options,
				CalloutDates,
				new Section("Centers") {
					this.CentersCheck
				},
				new Section() { Explaination },
				new Section() { Submit }
			};


			this.Submit.Tapped += Submit_Tapped;

			this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, delegate {
				this.NavigationController.PopViewController(true);	
			});
		}
コード例 #18
0
		/// <summary>
		/// Initializes a RootElement that renders the summary based on the radio settings of the contained elements. 
		/// </summary>
		/// <param name="caption">
		/// The caption to ender
		/// </param>
		/// <param name="radio">
		/// The radio group that contains the radio information
		/// </param>
		public RootElement (string caption, RadioGroup radio) : base (caption)
		{
			this.radio = radio;
		}
コード例 #19
0
        /// <summary>
        /// Creates the UI for DialogViewController using Element API
        /// </summary>
        private void CreateUI()
        {
            EntryElement ageElement, weightElement, heightElement, waistElement, hipsElement = null,
            idealWeightElement, idealBMIElement, cholestrolElement, hdlElement, neckElement;
            StringElement calculateButtonElement;

            Section waistHipsSection = null;

            // Gender Group and Section
            var genderRadioGroup = new RadioGroup ("gender", 0);
            var femaleRadioElement = new DietRadioElement ("Female", "gender");
            var maleRadioElement = new DietRadioElement ("Male", "gender");
            var radioElementSection = new Section () {
                maleRadioElement,
                femaleRadioElement
            };

            // add hips element to wasit & hips section if female is selected
            femaleRadioElement.Tapped += delegate {
                if (!waistHipsSection.Elements.Contains (hipsElement = new NumericEntryElement ("Hips (in cm)", "ex. 88")))
                    waistHipsSection.Add (hipsElement);
            };

            // remove hips element if male is selected.
            maleRadioElement.Tapped += delegate {
                if (waistHipsSection.Elements.Contains (hipsElement))
                    waistHipsSection.Remove (hipsElement);
            };

            // Level of ActivityGroup & Section
            var levelOfActivityRadioGroup = new RadioGroup ("levelOfActivity", 2);
            var levelOfActivitySection = new Section () {
                new DietRadioElement (LevelOfActivity.Active.ToString(), "levelOfActivity"),
                new DietRadioElement (LevelOfActivity.Moderate.ToString(), "levelOfActivity"),
                new DietRadioElement (LevelOfActivity.Sedentary.ToString(), "levelOfActivity")
            };

            // Create Elements on the rootElement. This will be added to the DialogViewController's root.
            rootElement = new RootElement ("Diet Calculator") {
                new Section(){
                    (ageElement = new NumericEntryElement("Age","ex. 25"){ KeyboardType = UIKeyboardType.NumberPad }),
                    (new DietRootElement("Gender", genderRadioGroup){radioElementSection})
                },
                new Section("Height & Weight"){
                    (weightElement = new NumericEntryElement("Weight (in kg)","ex. 65")),
                    (heightElement = new NumericEntryElement("Height (in cm)","ex. 170"))
                },  (waistHipsSection = new Section ("Waist & Hips") {
                    (waistElement = new NumericEntryElement("Waist (in cm)", "ex. 47"))
                    /* hips element will be added here if female is selected*/
                }),
                new Section("Ideal Weight & BMI"){
                    (idealWeightElement = new NumericEntryElement("Ideal Weight (in kg)", "ex. 45")),
                    (idealBMIElement = new NumericEntryElement("Ideal BMI (in kg/m2)","ex. 18"))
                },
                new Section("Cholestrol & HDL"){
                    (cholestrolElement = new NumericEntryElement("Cholestrol (in mmol/L)", "ex. 5.17")),
                    (hdlElement = new NumericEntryElement("HDL (in mmol/L)","ex. 1.56"))
                },
                new Section("Neck"){
                    (neckElement = new NumericEntryElement("Neck (in cm)","ex. 30")),
                },
                new Section(){
                    new DietRootElement ("Level Of Activity", levelOfActivityRadioGroup) { levelOfActivitySection }
                },
                /* Calculate Button*/
                new Section()
                {
                    (calculateButtonElement = new DietStringElement("Calculate",
                        /* On Calculate Click create the resulting UI*/
                       delegate {
                        /* exising code from SL MVC project */
                        controller.SetAge( StringToNumberUtility.GetInt32( ageElement.Value, 0 ) );
                        controller.SetGender( genderRadioGroup.Selected == 0 ? true : false);
                        controller.SetWeight( StringToNumberUtility.GetDouble( weightElement.Value, 0.00 ) );
                        controller.SetHeight( StringToNumberUtility.GetDouble( heightElement.Value, 0.00 ) );
                        controller.SetWaist( StringToNumberUtility.GetDouble( waistElement.Value, 0.00 ) );
                        controller.SetHips( StringToNumberUtility.GetDouble((hipsElement == null ? null : hipsElement.Value), 0.00 ) );
                        controller.SetIdealWeight( StringToNumberUtility.GetDouble( idealWeightElement.Value, 0.00 ) );
                        controller.SetIdealBMI( StringToNumberUtility.GetDouble( idealBMIElement.Value, 0.00 ) );
                        controller.SetCholesterol( StringToNumberUtility.GetDouble( cholestrolElement.Value, 0.00 ) );
                        controller.SetHDL( StringToNumberUtility.GetDouble( hdlElement.Value, 0.00 ) );
                        controller.SetNeck( StringToNumberUtility.GetDouble( neckElement.Value, 0.00 ) );

                        var selectedActivity = levelOfActivitySection.Elements[levelOfActivityRadioGroup.Selected].Caption;
                        controller.SetActivity( ( LevelOfActivity )Enum.Parse(typeof(LevelOfActivity), selectedActivity ));

                         resultSection = new Section ("Results") {

                            new DietStringElement("Calories Per Day: ", model.CaloriesPerDay.ToString()),
                            new DietStringElement("Lean Body Mass: ", model.LeanBodyMass.ToString()),
                            new DietStringElement("Fat: ", model.PercentBodyFat.ToString() + " %"),
                            new DietStringElement("Waist Hips Label: ", model.WaistHipsRatio.ToString() + " cm"),
                            new DietStringElement("BMI Ratio: ", model.BMI.ToString()),
                            new DietStringElement("Cholestrol Ratio: ", model.CholesterolRatio.ToString() + " mmol/L"),
                            new DietStringElement("Waist Height Ratio: ", model.WaistHeightRatio.ToString() + " cm"),
                            new DietStringElement("Ideal Weight: ", model.IdealWeight.ToString() + " kg"),

                        };

                        resultDvc = new DietDialogViewController(new RootElement("Results"){ resultSection }, true);
                        nvc.PushViewController(resultDvc, true);

                    }))
                }
            };

            // subscribe to IdealBMI and IdealWeight changed events on the model to update the UI
            model.IdealBMIChanged += (sender, e) => {
                idealBMIElement.Value = e.IdealBMI.ToString();
            };

            model.IdealWeightChanged += (sender, e) => {
                idealWeightElement.Value = e.IdealWeight.ToString();
            };

            // Since Ideal BMI has to be calculated based on the Ideal weight, set all the fields in
            // the controller that are used for calcaulation
            idealWeightElement.Changed += (sender, e) => {

                controller.SetWeight( StringToNumberUtility.GetDouble( weightElement.Value, 0.00 ) );
                controller.SetHeight( StringToNumberUtility.GetDouble( heightElement.Value, 0.00 ) );

                controller.SetIdealWeight( StringToNumberUtility.GetDouble( idealWeightElement.Value, 0.00 ) );

            };
            idealBMIElement.Changed += (sender, e) => {
                controller.SetWeight( StringToNumberUtility.GetDouble( weightElement.Value, 0.00 ) );
                controller.SetHeight( StringToNumberUtility.GetDouble( heightElement.Value, 0.00 ) );
                controller.SetIdealBMI( StringToNumberUtility.GetDouble( idealBMIElement.Value, 0.00 ) );
            };

            calculateButtonElement.Alignment = UITextAlignment.Center;
        }
コード例 #20
0
ファイル: AddScout.cs プロジェクト: bobreck/Pack957
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);
            folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "CubScouts.db"));

            //Setup Map Types Radio Group
            RadioGroup myScoutTypes = new RadioGroup("scoutTypes",0);
            RadioElement rTiger = new RadioElement("Tiger","scoutTypes");
            RadioElement rWolf = new RadioElement("Wolf","scoutTypes");
            RadioElement rBear = new RadioElement("Bear","scoutTypes");
            RadioElement rWeblo = new RadioElement("Weblo","scoutTypes");

            Section myScoutTypesSection = new Section();
            myScoutTypesSection.Add(rTiger);
            myScoutTypesSection.Add(rWolf);
            myScoutTypesSection.Add(rBear);
            myScoutTypesSection.Add(rWeblo);

            EntryElement fn;
            EntryElement ln;
            EntryElement nn;
            RootElement st;
            EntryElement mn;
            EntryElement dn;
            EntryElement ea;
            EntryElement hp;
            EntryElement cp;
            Root = new RootElement ("Add Scout") {
                new Section ("Scout Info") {
                    (fn = new EntryElement("First Name","First Name","")),
                    (ln = new EntryElement("Last Name","Last Name","")),
                    (nn = new EntryElement("Nickname","Nickname","")),
                    (st = new RootElement("Den", myScoutTypes) {
                        myScoutTypesSection
                    }),
                    (mn = new EntryElement("Mom's Name","Mom's Name", "")),
                    (dn = new EntryElement("Dad's Name","Dad's Name", "")),
                    (ea = new EntryElement("Email Address","Email Address", "")),
                    (hp = new EntryElement("Home Phone", "(999) 999-9999", "")),
                    (cp = new EntryElement("Mobile Phone", "(999) 999-9999", "")),
                    new StringElement("Save",delegate {
                        CubScout newScout = new CubScout {FirstName = fn.Value.Trim(), LastName = ln.Value.Trim(),
                            Nickname = nn.Value.Trim (), ScoutType = st.RadioSelected.ToString(),
                            MomsName = mn.Value.Trim(), DadsName = dn.Value.Trim(), EmailAddress = ea.Value.Trim(),
                            HomePhone = hp.Value.Trim(), CellPhone = cp.Value.Trim()};
                        conn.InsertAsync (newScout).ContinueWith (t => {
                            Console.WriteLine ("New scout ID: {0}", newScout.Id);
                        });
                        fn.Value = "";
                        ln.Value = "";
                        nn.Value = "";
                        st.RadioSelected = 0;
                        mn.Value = "";
                        dn.Value = "";
                        ea.Value = "";
                        hp.Value = "";
                        cp.Value = "";
                        this.NavigationController.PopViewControllerAnimated(true);
                    }),
                },
            };
        }
コード例 #21
0
        static RootElement CreateClassificationElement(AircraftCategory category, RadioGroup classes)
        {
            int next = (int) category + Aircraft.CategoryStep;
            var root = new RootElement ("Class", classes);
            var section = new Section ();

            foreach (AircraftClassification value in Enum.GetValues (typeof (AircraftClassification))) {
                if ((int) value < (int) category)
                    continue;

                if ((int) value >= next)
                    break;

                section.Add (new RadioElement (value.ToHumanReadableName (), "AircraftClassification"));
            }

            root.Add (section);

            return root;
        }
コード例 #22
0
ファイル: CubScoutWeblos.cs プロジェクト: bobreck/Pack957
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);

            try
            {
                this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(UIImage.FromBundle("icons/399-list1"), UIBarButtonItemStyle.Plain, FlyoutNavigationHandler), true);

                folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "CubScouts.db"));
                if (!myDB.TableExists("CubScout")) {
                    conn.CreateTableAsync<CubScout>().ContinueWith (t => {
                        Console.WriteLine ("Table created!");
                    });
                }

                //Setup Map Types Radio Group
                RadioGroup myScoutTypes = new RadioGroup("scoutTypes",3);
                RadioElement rTiger = new RadioElement("Tiger","scoutTypes");
                RadioElement rWolf = new RadioElement("Wolf","scoutTypes");
                RadioElement rBear = new RadioElement("Bear","scoutTypes");
                RadioElement rWeblo = new RadioElement("Weblo","scoutTypes");

                Section myScoutTypesSection = new Section();
                myScoutTypesSection.Add(rTiger);
                myScoutTypesSection.Add(rWolf);
                myScoutTypesSection.Add(rBear);
                myScoutTypesSection.Add(rWeblo);

                secCurrentScouts = new Section ("Pack 957 Weblos");
                //MultilineElement scoutElement;

                //Call the reload method to re-populate the list.
                ReloadCubScouts(secCurrentScouts);

                //Setup text colors, etc.
            //				var headerAdd = new UILabel(new RectangleF(0,0,this.View.Bounds.Width-25,48)){
            //					Font = UIFont.BoldSystemFontOfSize (22),
            //					TextColor = UIColor.White,
            //					BackgroundColor = UIColor.Clear,
            //					Text = "Add"
            //				};

                EntryElement fn;
                EntryElement ln;
                EntryElement nn;
                RootElement st;
                EntryElement mn;
                EntryElement dn;
                EntryElement ea;
                EntryElement hp;
                EntryElement cp;
                Root = new RootElement ("Weblos") {
                    new Section ("Add") {
                        new RootElement ("Add Scout") {
                            new Section ("Your info") {
                                (fn = new EntryElement("First Name","First Name","")),
                                (ln = new EntryElement("Last Name","Last Name","")),
                                (nn = new EntryElement("Nickname","Nickname","")),
                                (st = new RootElement("Den", myScoutTypes) {
                                    myScoutTypesSection
                                }),
                                (mn = new EntryElement("Mom's Name","Mom's Name", "")),
                                (dn = new EntryElement("Dad's Name","Dad's Name", "")),
                                (ea = new EntryElement("Email Address","Email Address", "")),
                                (hp = new EntryElement("Home Phone", "(999) 999-9999", "")),
                                (cp = new EntryElement("Mobile Phone", "(999) 999-9999", "")),
                                new StringElement("Save",delegate {
                                    CubScout newScout = new CubScout {FirstName = fn.Value.Trim(), LastName = ln.Value.Trim(),
                                        Nickname = nn.Value.Trim (), ScoutType = st.RadioSelected.ToString(),
                                        MomsName = mn.Value.Trim(), DadsName = dn.Value.Trim(), EmailAddress = ea.Value.Trim(),
                                        HomePhone = hp.Value.Trim(), CellPhone = cp.Value.Trim()};
                                    conn.InsertAsync (newScout).ContinueWith (t => {
                                        Console.WriteLine ("New scout ID: {0}", newScout.Id);
                                    });
                                    fn.Value = "";
                                    ln.Value = "";
                                    nn.Value = "";
                                    st.RadioSelected = 3;
                                    mn.Value = "";
                                    dn.Value = "";
                                    ea.Value = "";
                                    hp.Value = "";
                                    cp.Value = "";
                                    this.NavigationController.PopViewControllerAnimated(true);
                                }),
                            },
                        }
                    },
                    secCurrentScouts,
                };
            }
            catch (Exception ex)
            {
                using (UIAlertView myAlert = new UIAlertView())
                {
                    myAlert.Message = ex.Message;
                    myAlert.Title = "Error!";
                    myAlert.AddButton("OK");
                    myAlert.Show();
                }
            }
            finally
            {

            }
        }
コード例 #23
0
 public MyRootElement(string caption, RadioGroup rgroup)
     : base(caption, rgroup)
 {
     SetDefaults();
 }
コード例 #24
0
ファイル: CubScoutTigers.cs プロジェクト: Clancey/Pack957
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);
            try
            {
                this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(UIImage.FromBundle("icons/399-list1"), UIBarButtonItemStyle.Plain, FlyoutNavigationHandler), true);

                folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "CubScouts.db"));
                if (!myDB.TableExists("CubScout")) {
                    conn.CreateTableAsync<CubScout>().ContinueWith (t => {
                        Console.WriteLine ("Table created!");
                    });
                }

                //Setup Map Types Radio Group
                RadioGroup myScoutTypes = new RadioGroup("scoutTypes",0);
                RadioElement rTiger = new RadioElement("Tiger","scoutTypes");
                RadioElement rWolf = new RadioElement("Wolf","scoutTypes");
                RadioElement rBear = new RadioElement("Bear","scoutTypes");
                RadioElement rWeblo = new RadioElement("Weblo","scoutTypes");

                Section myScoutTypesSection = new Section();
                myScoutTypesSection.Add(rTiger);
                myScoutTypesSection.Add(rWolf);
                myScoutTypesSection.Add(rBear);
                myScoutTypesSection.Add(rWeblo);

                secCurrentScouts = new Section ("Pack 957 Tigers");
                //MultilineElement scoutElement;

                //Call the reload method to re-populate the list.
                ReloadCubScouts(secCurrentScouts);

                EntryElement fn;
                EntryElement ln;
                EntryElement nn;
                RootElement st;
                Root = new RootElement ("Tigers") {
                    new Section ("Add") {
                        new RootElement ("Add Scout") {
                            new Section ("Your info") {
                                (fn = new EntryElement("First Name","First Name","")),
                                (ln = new EntryElement("Last Name","Last Name","")),
                                (nn = new EntryElement("Nickname","Nickname","")),
                                (st = new RootElement("Scout Types", myScoutTypes) {
                                    myScoutTypesSection
                                }),
                                new StringElement("Save",delegate {
                                    CubScout newScout = new CubScout {FirstName = fn.Value.Trim(), LastName = ln.Value.Trim(), Nickname = nn.Value.Trim (), ScoutType = st.RadioSelected.ToString()};
                                    conn.InsertAsync (newScout).ContinueWith (t => {
                                        Console.WriteLine ("New scout ID: {0}", newScout.Id);
                                    });
                                    fn.Value = "";
                                    ln.Value = "";
                                    nn.Value = "";
                                    st.RadioSelected = 0;
                                    this.NavigationController.PopViewControllerAnimated(true);
                                }),
                            },
                        }
                    },
                    secCurrentScouts,
                };
            }
            catch (Exception ex)
            {
                using (UIAlertView myAlert = new UIAlertView())
                {
                    myAlert.Message = ex.Message;
                    myAlert.Title = "Error!";
                    myAlert.AddButton("OK");
                    myAlert.Show();
                }
            }
            finally
            {

            }
        }
コード例 #25
0
ファイル: Seed.cs プロジェクト: Bibo77/MADMUCfarm
        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);
        }
コード例 #26
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Perform any additional setup after loading the view, typically from a nib.

            //DVC is the source one - the one we start with. Most of it's stuff is just setup

            dvc = new DialogViewController(null, false);

            var root = new RootElement("Hello there");
            var section = new Section();

            for(int i = 0; i < 10; i++)
            {
                //urgh, using lambas, so we need to capture a few things locally.
                //never sure if I have to do this with int's or not tho
                int locali = i;

                //make the local element, the one in the main list
                StyledStringElement localElement = null;
                localElement = new StyledStringElement("Hello " + i.ToString (), delegate {;

                    //when you tap on the item, make a new root,
                    // which is a radio list. Select item 1 (the second one) by default
                    // but only cos I want to, no real reason :)

                    RadioGroup radioGroup = new RadioGroup(1);

                    //create 3 elements. This is stupid code copy and paste, they all do the same thing
                    // I guess you'd make this from an array or database?
                    var childroot = new RootElement("child", radioGroup)
                    {
                        new Section()
                        {
                            // I've made a custom RadioElement (down the bottom)
                            // that, when selected, calls us back
                            new CheckedRadioElement("First", delegate(CheckedRadioElement cre) {
                                // .. and we dismiss the popover, grab the value out, and then tell the
                                // main dvc to reload/redisplay itself.
                                popOver.Dismiss(true);
                                localElement.Caption = cre.Caption;
                                dvc.ReloadData();
                            }),

                            // these 2 are the same - just other data. Use a database or an array :)
                            new CheckedRadioElement("Second", delegate(CheckedRadioElement cre) {
                                popOver.Dismiss(true);
                                localElement.Caption = cre.Caption;
                                dvc.ReloadData();
                            }),
                            new CheckedRadioElement("Third", delegate(CheckedRadioElement cre) {
                                popOver.Dismiss(true);
                                localElement.Caption = cre.Caption;
                                dvc.ReloadData();
                            })
                        }
                    };

                    //make the child DVC. This is the one which goes into the popover.
                    // false on the end, 'cos we are not pushing it into a UINavigationController
                    var childdvc = new DialogViewController(childroot, false);
                    childdvc.Style = UITableViewStyle.Plain;

                    //this does tho!
                    //get the rect of the last section
                    var newrootSize = childdvc.TableView.RectForSection (childroot.Count - 1);
                    //and make that the size. Or 700... which ever is smaller.
                    childdvc.ContentSizeForViewInPopover = new SizeF (300, Math.Min (newrootSize.Bottom, 700));

                    //make the popover and set its size
                    popOver = new UIPopoverController(childdvc);

                    //and show the popover. We ask the tableview for the rect of the item we selected.
                    // and in this case, we want to see it on the right (arrow == left)
                    popOver.PresentFromRect(dvc.TableView.RectForRowAtIndexPath(localElement.IndexPath), dvc.TableView, UIPopoverArrowDirection.Left, true);

                }) {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                };

                section.Add (localElement);
            }

            root.Add (section);

            dvc.Root = root;

            //temp view is because a normal DVC wants to take over the whole screen, we I'm constraining it to a 300x300 area, which I think is about
            // what you had. Thats the only reason tho.
            var tempView = new UIView(new RectangleF(10,10,300,300));
            tempView.AddSubview(dvc.TableView);

            View.Add (tempView);
        }