private void InitializeComponent() { // initialize controls ListName = new EntryElement("Name", "", folderCopy.Name); // set up the item type listpicker ItemTypePicker = new ItemTypePickerElement("Folder Type", folderCopy.ItemTypeID); var root = new RootElement("Folder Properties") { new Section() { ListName, ItemTypePicker } }; // if this isn't a new folder, render the delete button if (folder != null) { var actionButtons = new ButtonListElement() { new Button() { Caption = "Delete", Background = "Images/redbutton.png", Clicked = DeleteButton_Click }, }; actionButtons.Margin = 0f; root.Add(new Section() { actionButtons }); } if (dvc == null) { // create and push the dialog view onto the nav stack dvc = new DialogViewController(UITableViewStyle.Grouped, root); dvc.Title = NSBundle.MainBundle.LocalizedString("Folder Properties", "Folder Properties"); dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { // save the item and trigger a sync with the service SaveButton_Click(null, null); }); dvc.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, delegate { NavigateBack(); }); dvc.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground); controller.PushViewController(dvc, true); } else { // refresh the dialog view controller with the new root var oldroot = dvc.Root; dvc.Root = root; oldroot.Dispose(); dvc.ReloadData(); } }
private void CreateAddButtons() { if (AddButtons == null) { AddButtons = new ButtonListElement[3]; } // get all the lists var entityRefItems = App.ViewModel.GetListsOrderedBySelectedCount(); lists = new List <ClientEntity>(); foreach (var entityRefItem in entityRefItems) { var entityType = entityRefItem.GetFieldValue(FieldNames.EntityType).Value; var entityID = new Guid(entityRefItem.GetFieldValue(FieldNames.EntityRef).Value); if (entityType == typeof(Folder).Name && App.ViewModel.Folders.Any(f => f.ID == entityID)) { lists.Add(App.ViewModel.Folders.Single(f => f.ID == entityID)); } if (entityType == typeof(Item).Name && App.ViewModel.Items.Any(i => i.ID == entityID)) { lists.Add(App.ViewModel.Items.Single(i => i.ID == entityID)); } } // create a list of buttons - one for each list buttonList = (from it in lists select new Button() { Background = "Images/darkgreybutton.png", Caption = it.Name, Clicked = AddButton_Click }).ToList(); // clear the button rows for (int i = 0; i < AddButtons.Length; i++) { AddButtons[i] = null; } // assemble the buttons into rows (maximum of six buttons and two rows) // if there are three or less buttons, one row // otherwise distribute evenly across two rows int count = Math.Min(buttonList.Count, MaxLists); int firstrow = count, secondrow = 0, addButtonsRow = 0; if (count > MaxLists / 2) { firstrow = count / 2; secondrow = count - firstrow; } if (firstrow > 0) { AddButtons[addButtonsRow++] = new ButtonListElement() { buttonList.Take(firstrow) }; } if (secondrow > 0) { AddButtons[addButtonsRow++] = new ButtonListElement() { buttonList.Skip(firstrow).Take(secondrow) }; } // create a last "row" of buttons containing only one "More..." button which will bring up the folder/list page AddButtons[addButtonsRow] = new ButtonListElement() { new Button() { Background = "Images/darkgreybutton.png", Caption = "More...", Clicked = (s, e) => { // assemble a page which contains a hierarchy of every folder and list, grouped by folder var title = String.IsNullOrEmpty(Name.Value) ? "Navigate to:" : "Add " + Name.Value + " to:"; ListsRootElement = new ThemedRootElement(title) { from f in App.ViewModel.Folders orderby f.Name ascending select new Section() { new StyledStringElement(f.Name, delegate { AddItem(f, null); // increment the selected count for this folder and sync if this isn't an actual Add ListMetadataHelper.IncrementListSelectedCount(App.ViewModel.PhoneClientFolder, f); // (do not sync for operations against $ClientSettings) //if (String.IsNullOrWhiteSpace(Name.Value)) // App.ViewModel.SyncWithService(); }) { Image = UIImageCache.GetUIImage("Images/appbar.folder.rest.png") }, from li in f.Items where li.IsList == true && li.ItemTypeID != SystemItemTypes.Reference orderby li.Name ascending select(Element) new StyledStringElement(" " + li.Name, delegate { AddItem(f, li); // increment the selected count for this list and sync if this isn't an actual Add ListMetadataHelper.IncrementListSelectedCount(App.ViewModel.PhoneClientFolder, li); // (do not sync for operations against $ClientSettings) //if (String.IsNullOrWhiteSpace(Name.Value)) // App.ViewModel.SyncWithService(); }) { Image = UIImageCache.GetUIImage("Images/179-notepad.png") } } }; var dvc = new DialogViewController(ListsRootElement, true); dvc.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground); dvc.NavigationItem.HidesBackButton = false; dialogViewController.NavigationController.PushViewController(dvc, true); } } }; }
private void InitializeComponent() { // initialize controls Name = new MultilineEntryElement("Name", "") { Lines = 3 }; Name.Changed += (sender, e) => { Name.FetchValue(); if (String.IsNullOrWhiteSpace(Name.Value)) { listsSection.Caption = "Navigate to list:"; } else { listsSection.Caption = "Add to list:"; } Name.GetImmediateRootElement().Reload(listsSection, UITableViewRowAnimation.None); }; listsSection = new Section("Navigate to list:"); var pushToTalkButton = new ButtonListElement() { new Button() { Background = "Images/redbutton.png", Caption = "Touch to speak", Clicked = SpeechButton_Click }, }; pushToTalkButton.Margin = 0f; // create the dialog var root = new RootElement("Add Item") { new Section() { Name, }, listsSection, new Section() { pushToTalkButton }, }; // create and push the dialog view onto the nav stack dialogViewController = new DialogViewController(root, false); //dialogViewController.NavigationItem.HidesBackButton = true; dialogViewController.Title = NSBundle.MainBundle.LocalizedString("Add Item", "Add Item"); // set up the "pull to refresh" feature dialogViewController.RefreshRequested += delegate { App.ViewModel.SyncCompleteArg = dialogViewController; App.ViewModel.SyncComplete += RefreshHandler; App.ViewModel.SyncWithService(); }; this.PushViewController(dialogViewController, false); }
private RootElement InitializeAccountSettings() { user = App.ViewModel.User; ThemedRootElement accountRootElement = null; // initialize the Account element based on whether connected or disconnected if (IsConnected) { // initialize account controls Email = new StringElement("Email", user.Email); // create unicode bullet characters for every character in the password var sb = new StringBuilder(); if (user != null && user.Password != null) { foreach (var c in user.Password) { sb.Append("\u25CF"); // \u2022 } } Password = new StringElement("Password", sb.ToString()); // create buttons var button = new ButtonListElement() { new Button() { Caption = "Disconnect", Background = "Images/darkgreybutton.png", Clicked = DisconnectUserButton_Click }, }; button.Margin = 0f; // create the account root element accountRootElement = new ThemedRootElement("Account") { new Section() { Email, Password, }, new Section() { button } }; } else { // initialize account controls Email = new EntryElement("Email", "Enter email", user != null ? user.Email : null); Password = new EntryElement("Password", "Enter password", user != null ? user.Password : null, true); var createButton = new ButtonListElement() { new Button() { Caption = "Create a new account", Background = "Images/darkgreybutton.png", Clicked = CreateUserButton_Click }, }; createButton.Margin = 0f; var connectButton = new ButtonListElement() { new Button() { Caption = "Connect to an existing account", Background = "Images/darkgreybutton.png", Clicked = ConnectUserButton_Click }, }; connectButton.Margin = 0f; // create the account root element accountRootElement = new ThemedRootElement("Account") { new Section() { Email, Password, }, new Section() { createButton, }, new Section() { connectButton } }; } return(accountRootElement); }
//========================================================================================== // //========================================================================================== public void OnEnter() { if (!_active) { _active = true; _canvasGroup.alpha = 1; _canvasGroup.interactable = true; _canvasGroup.blocksRaycasts = true; int level = GameManagerScript.Instance.ComputeLevel(GameManagerScript.Instance.TotalScore); //***** int numOfActiveButtons = 0; foreach (ButtonListElement element in _stageButtons) { if (level + 1 >= element.level) { element.button.interactable = true; numOfActiveButtons++; } else { element.button.interactable = false; } } if (numOfActiveButtons > 3) { _stageScrollbar.value = 0; } else { _stageScrollbar.value = 1; } //***** foreach (ButtonListElement element in _characterButtons) { if (level + 1 >= element.level) { element.button.interactable = true; } else { element.button.interactable = false; } } //***** if (GameManagerScript.Instance.CharacterName == null) { OnCharacterButton("Poulpe"); } else { OnCharacterButton(GameManagerScript.Instance.CharacterName); } //***** int selectedCharButtonIndex = 0; for (int i = 0; i < _characterButtons.Count; i++) { ButtonListElement element = _characterButtons[i]; if (GameManagerScript.Instance.CharacterName == element.name) { selectedCharButtonIndex = i; } } if (selectedCharButtonIndex >= 3) { _characterScrollbar.value = 1; } else { _characterScrollbar.value = 0; } } }