Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        private RootElement RenderEditItem(Item item, bool renderListInfo)
        {
            // get itemType for this item
            ItemType itemType = null;
            try
            {
                itemType = App.ViewModel.ItemTypes.Single(it => it.ID == item.ItemTypeID);
            }
            catch (Exception)
            {
                // if can't find the folder type, use the first
                itemType = App.ViewModel.ItemTypes[0];
            }

            // render the primary fields
            Section primarySection = RenderEditItemFields(item, itemType, true);

            // HACK: insert a dummy element inside the primary section.  This dummy element
            // implements IElementSizing and returns a 0-sized cell (so it is invisible).
            // This is to work around an issue in MT.Dialog where it doesn't honor IElementSizing
            // on elements that are added after a dialog is already drawn.  This element must be
            // inserted after the first element but before the last element, to avoid losing the
            // rounded rectangle look of the first and last elements of a Section.
            if (primarySection.Count > 0)
                primarySection.Insert(1, new DummyElement());

            // render more button
            var moreButton = new Button() { Background = "Images/darkgreybutton.png", Caption = "more details" };
            var sse = new ButtonListElement() { Margin = 0f };
            sse.Buttons.Add(moreButton);
            var moreSection = new Section() { sse };

            // render save/delete buttons
            var actionButtons = new ButtonListElement()
            {
                //new Button() { Caption = "Save", Background = "Images/greenbutton.png", Clicked = SaveButton_Click },
                new Button() { Caption = "Delete", Background = "Images/redbutton.png", Clicked = DeleteButton_Click },
            };
            actionButtons.Margin = 0f;

            // create the dialog with the primary section
            RootElement editRoot = new RootElement(item.Name)
            {
                primarySection,
                moreSection,
                new Section() { actionButtons },
            };

            moreButton.Clicked += (s, e) =>
            {
                // remove the "more" button
                editRoot.Remove(moreSection);

                // render the non-primary fields as a new section
                editRoot.Insert(1, RenderEditItemFields(item, itemType, false));

                // create a separate section with the advanced information (parent, type)
                var advancedSection = new Section();

                Field field = new Field() { Name = "ParentID", DisplayName = "List", DisplayType = DisplayTypes.Lists };
                advancedSection.Add(RenderEditItemField(item, field));

                field = new Field() { Name = "ItemTypeID", DisplayName = "Type", DisplayType = DisplayTypes.ItemTypes };
                advancedSection.Add(RenderEditItemField(item, field));

                editRoot.Insert(2, advancedSection);
            };

            return editRoot;
        }
Esempio n. 3
0
        private void InitializeComponent()
        {
            // initialize controls
            ListName = new EntryElement("Name", "", listCopy.Name);

            // set up the parent list picker
            ParentListPicker = new ParentListPickerElement("Parent", list);

            // set up the item type picker
            ItemTypePicker = new ItemTypePickerElement("Type", listCopy.ItemTypeID);

            var root = new RootElement("List Properties")
            {
                new Section()
                {
                    ListName,
                    ParentListPicker,
                    ItemTypePicker,
                    //list == null ? ListCheckbox : null
                }
            };

            // if this isn't a new list, render the delete button
            if (list != 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 ("List Properties", "List 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();
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
                    }
                }
            };
        }
Esempio n. 6
0
        private UIBarButtonItem CreateSortButton()
        {
            // if haven't loaded the sort image yet, do so now
            if (sortButtonImage == null)
                sortButtonImage = UIImageCache.GetUIImage("Images/appbar.sort.rest.png");

            // clicking the sort button and its event handler, which creates a new DialogViewController to host the sort picker
            var sortButton = new UIBarButtonItem(sortButtonImage, UIBarButtonItemStyle.Plain, delegate {
                // create the remove button
                var removeButton = new Button()
                {
                    Caption = "Remove Sort",
                    Background = "Images/darkgreybutton.png",
                };
                var removeButtonList = new ButtonListElement() { removeButton };
                removeButtonList.Margin = 0f;

                // find the current sort field if any
                var itemType = App.ViewModel.ItemTypes.Single(it => it.ID == Source.List.ItemTypeID);
                var fields = itemType.Fields.Where(f => f.IsPrimary == true).ToList();
                var selectedSortIndex = 0;
                if (Source.OrderBy != null && fields.Any(f => f.DisplayName == Source.OrderBy))
                {
                    var selectedSortField = fields.Single(f => f.DisplayName == Source.OrderBy);
                    selectedSortIndex = Math.Max(fields.IndexOf(selectedSortField), 0);
                }

                // create the sort picker
                var sortPickerSection = new Section();
                sortPickerSection.AddAll(from f in fields select (Element) new RadioElement(f.DisplayName));
                var sortPicker = new ThemedRootElement("Sort by", new RadioGroup(null, selectedSortIndex)) { sortPickerSection };

                // create the "Choose Sort" form
                var root = new ThemedRootElement("Choose Sort")
                {
                    new Section() { sortPicker },
                    new Section() { removeButtonList },
                };

                // create the DVC and add a "Done" button and handler
                var dvc = new DialogViewController(root);
                dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate
                {
                    // store the current listbox and orderby field, and re-render the list
                    var field = fields[sortPicker.RadioSelected];
                    Source.OrderBy = field.Name;

                    // store the sort order
                    ListMetadataHelper.StoreListSortOrder(
                        App.ViewModel.PhoneClientFolder,
                        Source.List.ID == Guid.Empty ? (ClientEntity) Source.Folder : (ClientEntity) Source.List,
                        Source.OrderBy);

                    // sync with the service
                    // (do not sync for operations against $ClientSettings)
                    //App.ViewModel.SyncWithService();

                    // return to parent
                    dvc.NavigationController.PopViewControllerAnimated(true);
                });
                dvc.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground);

                // add the click handler for the remove button
                removeButton.Clicked += delegate
                {
                    // clear the sort
                    Source.OrderBy = null;

                    // store the sort order
                    ListMetadataHelper.StoreListSortOrder(
                        App.ViewModel.PhoneClientFolder,
                        Source.List.ID == Guid.Empty ? (ClientEntity) Source.Folder : (ClientEntity) Source.List,
                        null);

                    // sync with the service
                    // (do not sync for operations against $ClientSettings)
                    //App.ViewModel.SyncWithService();

                    // return to parent
                    dvc.NavigationController.PopViewControllerAnimated(true);
                };

                // display the form
                this.NavigationController.PushViewController(dvc, true);
            });

            return sortButton;
        }