protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var bindings = this.CreateInlineBindingTarget<FirstViewModel>(); var passwordElement = new EntryElement("Password", "Enter Password").Bind(bindings, vm => vm.PasswordProperty); passwordElement.Password = true; Root = new RootElement("Example Root") { new Section("Your details") { new EntryElement("Login", "Enter Login name").Bind(bindings, vm => vm.TextProperty), passwordElement, }, new Section("Your options") { new BooleanElement("Remember me?").Bind(bindings, vm => vm.SwitchThis), new CheckboxElement("Upgrade?").Bind(bindings, vm => vm.CheckThis), }, new Section("Action") { new ButtonElement("Go").Bind(bindings, element => element.SelectedCommand, vm => vm.GoCommand) }, new Section("Debug out:") { new StringElement("Login is:").Bind(bindings, vm => vm.TextProperty), new StringElement("Password is:").Bind(bindings, vm => vm.PasswordProperty), new StringElement("Remember is:").Bind(bindings, vm => vm.SwitchThis), new StringElement("Upgrade is:").Bind(bindings, vm => vm.CheckThis), }, }; }
void InitializeComponents() { countriesViewController = new CountriesViewController(); countriesViewController.CountrySelected += CountriesViewController_CountrySelected; var networkInfo = new CTTelephonyNetworkInfo(); var carrier = networkInfo.SubscriberCellularProvider; var countryCode = carrier.IsoCountryCode.ToUpper(); var countryName = CountriesManager.SharedInstance.Countries [countryCode]; var countryFlag = CountriesManager.SharedInstance.CountryFlags [countryCode]; var phoneCode = CountriesManager.SharedInstance.PhoneCodes [countryCode]; phoneCode = phoneCode == string.Empty ? "" : $"+{phoneCode}"; lblCountry = new StringElement($"{countryFlag} {countryName}", () => OpenViewController(countriesViewController)) { Alignment = UITextAlignment.Center }; txtPhoneNumber = new EntryElement(phoneCode, "Enter you phone number", string.Empty) { TextAlignment = UITextAlignment.Left, KeyboardType = UIKeyboardType.PhonePad }; btnVerify = new StyledStringElement("Send Verification Code", SendVerificationCode) { Alignment = UITextAlignment.Center, Font = UIFont.FromName("System-Bold", 13), BackgroundColor = UIColor.White }; Root = new RootElement("Phone Number Authentication") { new Section("Tap to change the country") { lblCountry, txtPhoneNumber }, new Section { btnVerify } }; indicatorView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge) { Frame = new CGRect(0, 0, 128, 128), BackgroundColor = UIColor.FromRGBA(127, 127, 127, 127), HidesWhenStopped = true, TranslatesAutoresizingMaskIntoConstraints = false }; View.Add(indicatorView); ApplyContraintsToIndicator(); }
public override void ViewDidLoad() { base.ViewDidLoad(); var eleFirstName = new EntryElement(string.Empty, "Fornavn", this.ViewModel.FirstName) { AutocapitalizationType = UITextAutocapitalizationType.Words, AutocorrectionType = UITextAutocorrectionType.No }; var eleLastName = new EntryElement(string.Empty, "Efternavn", this.ViewModel.LastName) { AutocapitalizationType = UITextAutocapitalizationType.Words, AutocorrectionType = UITextAutocorrectionType.No }; var eleEmail = new EntryElement(string.Empty, "Email", this.ViewModel.Email) { KeyboardType = UIKeyboardType.EmailAddress, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }; var elePassword = new EntryElement(string.Empty, "Kodeord", this.ViewModel.Password, true); var elePasswordRepeat = new EntryElement(string.Empty, "Gentag kodeord", this.ViewModel.PasswordRepeat, true); var eleUsername = new EntryElement(string.Empty, "Brugernavn", this.ViewModel.Username) { AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }; this.Root = new RootElement("Registrer") { new Section("Personlige oplysninger") { eleFirstName, eleLastName, }, new Section("Konto oplysninger") { eleEmail, elePassword, elePasswordRepeat, eleUsername } }; eleFirstName.BindText(this.ViewModel, vm => vm.FirstName); eleLastName.BindText(this.ViewModel, vm => vm.LastName); eleEmail.BindText(this.ViewModel, vm => vm.Email); elePassword.BindText(this.ViewModel, vm => vm.Password); elePasswordRepeat.BindText(this.ViewModel, vm => vm.PasswordRepeat); eleUsername.BindText(this.ViewModel, vm => vm.Username); }
void PopulateTable() { var location = new EntryElement("Location", "where are you?", Location); var code = new EntryElement("Code", "your secret code", Secret); location.Changed += (object sender, EventArgs e) => { Location = location.Value; Changed(); }; code.Changed += (object sender, EventArgs e) => { Secret = code.Value; Changed(); }; var clear = new StyledStringElement("Clear the crews") { TextColor = UIColor.White, BackgroundColor = UIColor.Red }; clear.Tapped += async() => { int button = await ShowAlert("Really?", "This will remove all the crews so far. Are you *absolutely* sure?", "Cancel", "Yes, I'm sure"); if (button == 1 && Clear != null) { Clear(); } }; var save = new StyledStringElement("Force Save") { TextColor = UIColor.DarkGray, BackgroundColor = UIColor.Green }; save.Tapped += () => Save(); var status = new Section("Save status:"); foreach (var stat in _saveStatuses) { status.Add(new StyledStringElement(string.Format("{0}: {1}", stat.Repo, stat.Success), stat.Success ? stat.WriteTime.ToShortTimeString() : "never written")); } Root = new RootElement("Settings") { new Section("Where are you?") { location, code }, new Section("Save") { save }, new Section("Clear") { clear }, status }; }
public override void ViewDidLoad() { base.ViewDidLoad(); var typeElement = new StringElement("Type", string.Empty, UITableViewCellStyle.Value1); var stateElement = new StringElement("State", string.Empty, UITableViewCellStyle.Value1); var fieldElement = new StringElement("Field", string.Empty, UITableViewCellStyle.Value1); var ascElement = new BooleanElement("Ascending"); var labelElement = new EntryElement("Labels", "bug,ui,@user", string.Empty) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }; var filterSection = new Section("Filter") { typeElement, stateElement, labelElement }; var orderSection = new Section("Order By") { fieldElement, ascElement }; var searchSection = new Section(); var footerButton = new TableFooterButton("Search!"); searchSection.FooterView = footerButton; var source = new DialogTableViewSource(TableView); TableView.Source = source; source.Root.Add(filterSection, orderSection, searchSection); OnActivation(d => { d(typeElement.Clicked.InvokeCommand(ViewModel.SelectFilterTypeCommand)); d(stateElement.Clicked.InvokeCommand(ViewModel.SelectStateCommand)); d(fieldElement.Clicked.InvokeCommand(ViewModel.SelectSortCommand)); d(footerButton.Clicked.InvokeCommand(ViewModel.SaveCommand)); d(ascElement.Changed.Subscribe(x => ViewModel.Ascending = x)); d(labelElement.Changed.Subscribe(x => ViewModel.Labels = x)); d(this.WhenAnyValue(x => x.ViewModel.FilterType).Subscribe(x => typeElement.Value = x.Humanize())); d(this.WhenAnyValue(x => x.ViewModel.State).Subscribe(x => stateElement.Value = x.Humanize())); d(this.WhenAnyValue(x => x.ViewModel.Labels).Subscribe(x => labelElement.Value = x)); d(this.WhenAnyValue(x => x.ViewModel.SortType).Subscribe(x => fieldElement.Value = x.Humanize())); d(this.WhenAnyValue(x => x.ViewModel.Ascending).Subscribe(x => ascElement.Value = x)); d(this.WhenAnyValue(x => x.ViewModel.DismissCommand) .ToBarButtonItem(Images.Cancel, x => NavigationItem.LeftBarButtonItem = x)); d(this.WhenAnyValue(x => x.ViewModel.SaveCommand) .ToBarButtonItem(Images.Search, x => NavigationItem.RightBarButtonItem = x)); }); }
public void Test_EditEntryParams_EntryRecord() { EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false); EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle); h.AddEntry(e, false); Assert.AreEqual(h.GetList()[0].Title, "DuckDuckGo", "Expected and Actual Title mismatch"); Assert.AreEqual(h.GetList()[0].Url, "http://www.duckduckgo.com", "Expected and Actual Title mismatch"); h.EditEntry("DuckDuckGo", "DifferentTitle", "http://www.google.com", false); Assert.AreEqual(h.GetList()[0].Title, "DifferentTitle", "Expected and Actual Title mismatch"); Assert.AreEqual(h.GetList()[0].Url, "http://www.google.com", "Expected and Actual Title mismatch"); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow(UIScreen.MainScreen.Bounds); var message = new EntryElement("Message", "Type your message here", ""); var sendMessage = new StyledStringElement("Send Message") { Alignment = UITextAlignment.Center, BackgroundColor = UIColor.Green }; var receivedMessages = new Section(); var root = new RootElement("") { new Section() { message, sendMessage }, receivedMessages }; var connection = new Connection("http://localhost:8081/echo"); sendMessage.Tapped += delegate { if (!string.IsNullOrWhiteSpace(message.Value) && connection.State == ConnectionState.Connected) { connection.Send("iOS: " + message.Value); message.Value = ""; message.ResignFirstResponder(true); } }; connection.Received += data => { InvokeOnMainThread(() => receivedMessages.Add(new StringElement(data))); }; connection.Start().ContinueWith(task => connection.Send("iOS: Connected")); var viewController = new DialogViewController(root); window.RootViewController = viewController; window.MakeKeyAndVisible(); return(true); }
public MessageDetailsView(AppWindow window, string fileName) : base(new RootElement(fileName == null ? "New Message" : fileName), true) { try { _window = window; MailMessage msg = fileName == null ? null : new MailMessage(Path.Combine(MessageListView.MyMailsDir, fileName)); _date = new ReadonlyTextElement("Date", msg == null || msg.Date == null ? DateTime.Now.ToString() : msg.Date.ToString()); _from = new EntryElement("From", "Enter from email-address", msg == null ? "" : msg.From.ToString()); _to = new EntryElement("To", "Enter recipient email-addresses", msg == null ? "" : msg.To.ToString()); _subject = new EntryElement("Subject", "Enter subject", msg == null ? "" : msg.Subject); Section header = new Section("Header") { _date, _from, _to, _subject }; Root.Add(header); Section bodySection = new Section("Body"); _body = new UITextView(new CoreGraphics.CGRect(3, 0, _window.Bounds.Width - 26, 80)); bodySection.Add(_body); if (msg != null) { _body.Text = msg.BodyText; } Root.Add(bodySection); UIButton connectButton = UIButton.FromType(UIButtonType.System); connectButton.SetTitle("Configure SMTP and Send", UIControlState.Normal); connectButton.Frame = new CoreGraphics.CGRect(0, 0, _window.Screen.Bounds.Width - 20, 40); connectButton.TouchUpInside += Send; Section buttonSection = new Section(); buttonSection.Add(connectButton); Root.Add(buttonSection); } catch (Exception ex) { Util.ShowException(ex); } }
public void PopulateElements(LoadMoreElement lme, Section section, string typeLable, string valueLabel, UIKeyboardType entryKeyboardType, string deleteLabel, IList <string> labelList) { lme.Animating = false; var type = new StyledStringElement(typeLable) { Accessory = UITableViewCellAccessory.DetailDisclosureButton }; section.Insert(section.Count - 1, type); var value = new EntryElement(null, valueLabel, null); value.KeyboardType = entryKeyboardType; section.Insert(section.Count - 1, value); var deleteButton = new StyledStringElement(deleteLabel) { TextColor = UIColor.Red, }; deleteButton.Tapped += () => { section.Remove(type); section.Remove(value); section.Remove(deleteButton); }; // Show/Hide Delete Button var deleteButtonOn = false; type.AccessoryTapped += () => { if (!deleteButtonOn) { deleteButtonOn = true; section.Insert(type.IndexPath.Row + 2, UITableViewRowAnimation.Bottom, deleteButton); } else { deleteButtonOn = false; section.Remove(deleteButton); } }; type.Tapped += () => { var labelScreen = new LabelListScreen(labelList); var navigation = new UINavigationController(labelScreen); NavigationController.PresentViewController(navigation, true, null); }; }
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(); NavigationController.PopToRootViewController(true); }); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { _window = new UIWindow(UIScreen.MainScreen.Bounds); _rootElement = new RootElement("To Do List") { new Section() }; _rootVC = new DialogViewController(_rootElement); _nav = new UINavigationController(_rootVC); _addButton = new UIBarButtonItem(UIBarButtonSystemItem.Add); _rootVC.NavigationItem.RightBarButtonItem = _addButton; _addButton.Clicked += (sender, e) => { ++n; var task = new Task { Name = "task " + n, DueDate = DateTime.Now }; var element = new EntryElement(task.Name, "Enter task description", task.Description); var dateElement = new FutureDateElement("Due Date", task.DueDate); var taskElement = (Element) new RootElement(task.Name) { new Section() { element }, new Section() { dateElement }, new Section("Demo Retrieving Element Value") { new StringElement("Output Task Description", delegate { Console.WriteLine(element.Value); }) } }; _rootElement [0].Add(taskElement); }; _window.RootViewController = _nav; _window.MakeKeyAndVisible(); return(true); }
private static void SetEntryProperties(string stream, long eventNumber, DateTime timestamp, Uri requestedUrl, EntryElement entry) { var escapedStreamId = Uri.EscapeDataString(stream); entry.SetTitle(eventNumber + "@" + stream); entry.SetId(HostName.Combine(requestedUrl, "/streams/{0}/{1}", escapedStreamId, eventNumber)); entry.SetUpdated(timestamp); entry.SetAuthor(AtomSpecs.Author); entry.AddLink("edit", HostName.Combine(requestedUrl, "/streams/{0}/{1}", escapedStreamId, eventNumber)); entry.AddLink("alternate", HostName.Combine(requestedUrl, "/streams/{0}/{1}", escapedStreamId, eventNumber)); }
private RootElement CreateRoot() { var apiElement = new EntryElement("Key", "Enter API key", _currentUser.ApiKey); apiElement.Changed += HandleChangedApiKey; return(new RootElement("Settings") { new Section(null, "API key as activated on AgileZen.com") { apiElement } }); }
public static void CategoryPage(Category category, Action refresh) { var title = new EntryElement("Название", "", category.Title); var root = new RootElement("Категория") { new Section() { title } }; var dv = new DialogViewController(root, true); dv.ViewDisappearing += delegate { category.Title = title.Value; DataLayer.PutCategory(category); refresh(); }; var deleteButton = new UIBarButtonItem(UIBarButtonSystemItem.Trash); deleteButton.Clicked += delegate { UIAlertView alert = new UIAlertView("Удаление", "Вы точно хотите удалить?", null, "Да", new string[] { "Нет" }); alert.Clicked += (s, b) => { if (b.ButtonIndex == 0) { Task.Factory.StartNew( () => { DataLayer.DeleteCategory(category); } ).ContinueWith( t => { newOperationController.PopViewControllerAnimated(true); }, TaskScheduler.FromCurrentSynchronizationContext() ); } }; alert.Show(); }; dv.NavigationItem.RightBarButtonItem = deleteButton; newOperationController.PushViewController(dv, true); }
public void ResetToDefaults(bool resetFee) { ClearPartsList(); this.DeactivateEditingMode(); if (resetFee) { SetCurrentJobFeeToDefault(); } EntryElement pressureElement = (this.Root[0].Elements[0] as EntryElement); pressureElement.Value = String.Empty; dvcSO = new SaleOptionsDVC(null, false, true, this.NavUsedParts.Tabs._jobRunTable, this); }
public RequestEditViewController(Request request) : base(null, true) { this.request = request; name = new EntryElement("Name", "Enter name", request.Name); url = new EntryElement("Url", "Enter url", request.Url); Root = new RootElement("Request edit") { new Section { name, url, }, }; }
public RegisterFile() { Entries = new SubRISC.RegisterFile.EntryElement[EntryCount]; for (int i = 0; i < EntryCount; i++) { Entries[i] = new EntryElement() { Content = 0, ReadAccessCount = 0, WriteAccessCount = 0 }; } Read0_IFace = CreateInputface <ReadCommand>(); Read1_IFace = CreateInputface <ReadCommand>(); Write_IFace = CreateInputface <WriteCommand>(); Read0_OFace = CreateAsyncOutputface <uint>(); Read1_OFace = CreateAsyncOutputface <uint>(); PreviousRead0 = new SubRISC.RegisterFile.ReadCommand() { Enabled = false, No = -1 }; PreviousRead1 = new SubRISC.RegisterFile.ReadCommand() { Enabled = false, No = -1 }; Read0_OFace.SetFunc(() => { ReadCommand rCmd = Read0_IFace.Get(); WriteCommand wCmd = Write_IFace.Get(); int no = rCmd.No % EntryCount; return(wCmd.Enabled && wCmd.No == no ? wCmd.Value : Entries[no].Content); }); Read1_OFace.SetFunc(() => { ReadCommand rCmd = Read1_IFace.Get(); WriteCommand wCmd = Write_IFace.Get(); int no = rCmd.No % EntryCount; return(wCmd.Enabled && wCmd.No == no ? wCmd.Value : Entries[no].Content); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var typeElement = new StringElement("Type", () => ViewModel.SelectFilterTypeCommand.ExecuteIfCan()); typeElement.Style = UITableViewCellStyle.Value1; var stateElement = new StringElement("State", () => ViewModel.SelectStateCommand.ExecuteIfCan()); stateElement.Style = UITableViewCellStyle.Value1; var labelElement = new EntryElement("Labels", "bug,ui,@user", string.Empty) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }; labelElement.Changed += (sender, e) => ViewModel.Labels = labelElement.Value; var fieldElement = new StringElement("Field", () => ViewModel.SelectSortCommand.ExecuteIfCan()); fieldElement.Style = UITableViewCellStyle.Value1; var ascElement = new BooleanElement("Ascending", false, x => ViewModel.Ascending = x.Value); var filterSection = new Section("Filter") { typeElement, stateElement, labelElement }; var orderSection = new Section("Order By") { fieldElement, ascElement }; var searchSection = new Section(); searchSection.FooterView = new TableFooterButton("Search!", () => ViewModel.SaveCommand.ExecuteIfCan()); var source = new DialogTableViewSource(TableView); TableView.Source = source; source.Root.Add(filterSection, orderSection, searchSection); this.WhenAnyValue(x => x.ViewModel.FilterType).Subscribe(x => typeElement.Value = x.Humanize()); this.WhenAnyValue(x => x.ViewModel.State).Subscribe(x => stateElement.Value = x.Humanize()); this.WhenAnyValue(x => x.ViewModel.Labels).Subscribe(x => labelElement.Value = x); this.WhenAnyValue(x => x.ViewModel.SortType).Subscribe(x => fieldElement.Value = x.Humanize()); this.WhenAnyValue(x => x.ViewModel.Ascending).Subscribe(x => ascElement.Value = x); }
public void Test_EditEntryObject_EntryRecord() { EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false); EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle); h.AddEntry(e, false); Assert.AreEqual(h.GetList()[0].Title, "DuckDuckGo", "Expected and Actual Title mismatch"); Assert.AreEqual(h.GetList()[0].Url, "http://www.duckduckgo.com", "Expected and Actual Title mismatch"); EntryElement u = new EntryElement("http://www.google.com", "DuckDuckGo", CompareBy.AlphabetTitle); h.EditEntry(u, false); Assert.AreEqual(h.GetList()[0].Title, "DuckDuckGo", "Expected and Actual Title mismatch"); Assert.AreEqual(h.GetList()[0].Url, "http://www.google.com", "Expected and Actual Title mismatch"); Assert.AreEqual(h.GetList().Count, 1, "List size of 1 expected"); }
public void Test_EventRemoveEntry_EntryRecord() { bool eventTriggered = false; EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false); h.EntryChanged += delegate { eventTriggered = true; }; EntryElement e = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle); Assert.AreEqual(eventTriggered, false, "The event should not have triggered"); h.AddEntry(e, false); Assert.AreEqual(eventTriggered, true, "The event should have triggered"); eventTriggered = false; Assert.AreEqual(eventTriggered, false, "The event should not have triggered"); h.RemoveEntry("DuckDuckGo", false, true); Assert.AreEqual(eventTriggered, true, "The event should have triggered"); }
private void D_Changed1(object sender, EventArgs e) { EntryElement ent = (EntryElement)sender; //Find the location for question var location = ent.Parent.Parent.Caption; if (!quesAnswers.ContainsKey(location + "~" + ent.Caption)) { quesAnswers.Add(location + "~" + ent.Caption, ent.Value); } else { quesAnswers[location + "~" + ent.Caption] = ent.Value; } }
public void EchoDicomServer() { RootElement root = null; Section resultSection = null; var hostEntry = new EntryElement("Host", "Host name of the DICOM server", "server"); var portEntry = new EntryElement("Port", "Port number", "104"); var calledAetEntry = new EntryElement("Called AET", "Called application AET", "ANYSCP"); var callingAetEntry = new EntryElement("Calling AET", "Calling application AET", "ECHOSCU"); var echoButton = new StyledStringElement("Click to test", delegate { if (resultSection != null) { root.Remove(resultSection); } string message; var echoFlag = DoEcho(hostEntry.Value, Int32.Parse(portEntry.Value), calledAetEntry.Value, callingAetEntry.Value, out message); var echoImage = new ImageStringElement(String.Empty, echoFlag ? new UIImage("yes-icon.png") : new UIImage("no-icon.png")); var echoMessage = new StringElement(message); resultSection = new Section(String.Empty, "C-ECHO result") { echoImage, echoMessage }; root.Add(resultSection); }) { Alignment = UITextAlignment.Center, BackgroundColor = UIColor.Blue, TextColor = UIColor.White }; root = new RootElement("Echo DICOM server") { new Section { hostEntry, portEntry, calledAetEntry, callingAetEntry }, new Section { echoButton }, }; var dvc = new DialogViewController(root, true) { Autorotate = true }; navigation.PushViewController(dvc, true); }
protected override void OnCreate(Bundle bundle) { Options options = AndroidRunner.Runner.Options; remote = new BooleanElement("Remote Server", options.EnableNetwork); host_name = new EntryElement("HostName", string.Empty, options.HostName); host_port = new EntryElement("Port", string.Empty, options.HostPort.ToString()); Root = new RootElement("Options") { new Section { remote, host_name, host_port } }; base.OnCreate(bundle); }
public UIViewController GetViewController() { var network = new BooleanElement("Remote Server", EnableNetwork); var host = new EntryElement("Host Name", "name", HostName); host.KeyboardType = UIKeyboardType.ASCIICapable; var port = new EntryElement("Port", "name", HostPort.ToString()); port.KeyboardType = UIKeyboardType.NumberPad; var root = new RootElement("Options") { new Section() { network, host, port } }; var dv = new DialogViewController(root, true) { Autorotate = true }; dv.ViewDisappearing += delegate { EnableNetwork = network.Value; HostName = host.Value; ushort p; if (UInt16.TryParse(port.Value, out p)) { HostPort = p; } else { HostPort = -1; } var defaults = NSUserDefaults.StandardUserDefaults; defaults.SetBool(EnableNetwork, "network.enabled"); defaults.SetString(HostName ?? String.Empty, "network.host.name"); defaults.SetInt(HostPort, "network.host.port"); }; return(dv); }
public SupportPopupViewController() : base(UITableViewStyle.Grouped, null) { password = new EntryElement("Password", "Support password", String.Empty, true); showScreen = new CheckboxElement("Show support screen", false); confirm = new StyledStringElement("Confirm", delegate { Confirm(); }); confirm.BackgroundColor = UIColor.DarkGray; confirm.TextColor = UIColor.White; Root = new RootElement("SupportPopupViewController") { new Section("Support") { password, showScreen, confirm }, }; }
public void CancelFind(object obj) { OnDisplay = new ObservableCollection <EntryElement>(); ObservableCollection <Entry> Data = new ObservableCollection <Entry>(context.Entrys); for (int i = 0; i < Data.Count(); ++i) { EntryElement x = new EntryElement(); x.EntryDate = Data[i].Entry_date; x.EntryDateStr = x.EntryDate.ToString("dd.MM.yyyy HH:mm tt"); x.EntryID = Data[i].EntryID; x.UserID = Data[i].UserID; User y = (from z in context.Users where z.UserID == x.UserID select z).FirstOrDefault(); x.UserName = y.UserName; OnDisplay.Add(x); } }
public static Section CreateDialogSection(out EntryElement name) { Section entrySection = new Section(); #if MONOANDROID //TODO: Clean up the interface of Android.Dialog name = new EntryElement("Name", string.Empty); #else name = new EntryElement("Name", "enter name", null); #endif entrySection.Add(name); entrySection.Add(new BooleanElement("Is Cool", false)); entrySection.Add(new FloatElement(null, null, 50)); entrySection.Add(new DateElement("Today", DateTime.Now)); return entrySection; }
void PopulateTable() { var race = new StyledStringElement("Vets Head 2014") { TextColor = UIColor.LightGray, BackgroundColor = UIColor.Black };; var location = new EntryElement("Location", "where are you?", Location); var code = new EntryElement("Code", "your secret code", Secret); location.Changed += (object sender, EventArgs e) => { Location = location.Value; }; code.Changed += (object sender, EventArgs e) => { Secret = code.Value; }; var submit = new StyledStringElement("Submit") { TextColor = UIColor.DarkGray, BackgroundColor = UIColor.LightGray }; submit.Tapped += () => { if (!string.IsNullOrEmpty(Location) && !string.IsNullOrEmpty(Secret)) { Changed(Location, Secret); } }; Root = new RootElement("Settings") { new Section() { new StringElement(string.Empty) }, new Section("Race") { race }, new Section("Who are you?") { location, code }, new Section("Proceed") { submit } }; }
public ContactListController(MainScreenGroup parent, GroupDetailElement smsGroup = null) : base(true, ToolbarItemOption.Refresh, false) { this.EnableSearch = true; this.AutoHideSearch = true; this.Parent = parent; this.smsGroup = smsGroup; Root = new RootElement(Settings.GetLocalizedString("Contact List", LocalizedKey)); this.isEditing = this.smsGroup != null; Section groupName = new Section(Settings.GenerateHeaderFooter("Group Name", LocalizedKey), Settings.GenerateHeaderFooter("The name that will best describe your group", LocalizedKey)); groupName.IsSearchable = false; nameElement = new EntryElement( Settings.GetLocalizedString("Name", LocalizedKey), Settings.GetLocalizedString("Group Name", LocalizedKey), smsGroup != null && smsGroup.Sms != null ? smsGroup.Sms.Name : ""); nameElement.ClearButtonMode = UITextFieldViewMode.WhileEditing; groupName.Add(nameElement); //SegmentedSection contactSection = new SegmentedSection("Contacts"); contactSection.FooterView = Settings.GenerateHeaderFooter("Displays only contacts that have a mobile phone set", LocalizedKey); contactSection.SegmentedControl.InsertSegment( Settings.GetLocalizedString("All", LocalizedKey), 0, true); contactSection.SegmentedControl.InsertSegment( Settings.GetLocalizedString("None", LocalizedKey), 1, true); contactSection.SegmentedControl.ValueChanged += HandleContactSectionSegmentedControlTouchUpInside; ThreadPool.QueueUserWorkItem((e) => { InvokeOnMainThread(() => { Initialize(); this.ReloadData(); }); }); Root.Add(groupName); Root.Add(contactSection); UIBarButtonItem done = new UIBarButtonItem(UIBarButtonSystemItem.Done); done.Clicked += HandleDoneClicked; this.NavigationItem.RightBarButtonItem = done; }
public override void ViewDidLoad() { base.ViewDidLoad(); _CookieJar = NSHttpCookieStorage.SharedStorage; foreach (var cookie in _CookieJar.Cookies) { _CookieJar.DeleteCookie(cookie); } JsFiles = new DirectoryInfo(Path.Combine(NSBundle.MainBundle.BundlePath, @"js")) .GetFiles("*.js", SearchOption.AllDirectories) .ToDictionary(x => x.Name, x => File.ReadAllText(x.FullName)); Client = new RestClient(@"https://signin.crm.dynamics.com/portal/signin/signin.aspx"); var req = new RestRequest(); req.AddHeader("User-Agent", @"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.5 Safari/535.2"); Response = Client.Execute(req); _WebView = new UIWebView(); _WebView.LoadFinished += HandleWebViewLoadFinished; _WebView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _WebView.MultipleTouchEnabled = true; _UserNameElement = new EntryElement("UserName: "******"", "*****@*****.**"); _PasswordElement = new EntryElement("Password: "******"", "mscrm2011"); _OrganizationElement = new EntryElement("Organization:", "", "emergedata"); _SubmitElement = new StringElement("Submit", Handle_SubmitButtonClicked); _SubmitElement.Alignment = UITextAlignment.Center; var section = new Section("Login") { _UserNameElement, _PasswordElement, _OrganizationElement, _SubmitElement, }; this.Root.Add(section); }
public void Test_GetIndex_EntryRecord() { EntryRecord h = new EntryRecord("Test", CompareBy.AlphabetTitle, false); EntryElement e1 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo", CompareBy.AlphabetTitle); EntryElement e2 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo2", CompareBy.AlphabetTitle); EntryElement e3 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo3", CompareBy.AlphabetTitle); EntryElement e4 = new EntryElement("http://www.duckduckgo.com", "DuckDuckGo4", CompareBy.AlphabetTitle); h.AddEntry(e1, false); h.AddEntry(e2, false); h.AddEntry(e3, false); h.AddEntry(e4, false); Assert.AreEqual(h.GetIndex("DuckDuckGo3"), 2, "Expected and Actual index mismatch"); Assert.AreEqual(h.GetIndex("DuckDuckGo4"), 3, "Expected and Actual index mismatch"); Assert.AreEqual(h.GetIndex("DuckDuckGo"), 0, "Expected and Actual index mismatch"); Assert.AreEqual(h.GetIndex("DuckDuckGo2"), 1, "Expected and Actual index mismatch"); }
public static Section CreateDialogSection(out EntryElement name) { Section entrySection = new Section(); #if MONOANDROID //TODO: Clean up the interface of Android.Dialog name = new EntryElement("Name", string.Empty); #else name = new EntryElement("Name", "enter name", null); #endif entrySection.Add(name); entrySection.Add(new BooleanElement("Is Cool", false)); entrySection.Add(new FloatElement(null, null, 50)); entrySection.Add(new DateElement("Today", DateTime.Now)); return(entrySection); }
public static Section[] BuildDialogSections(Contact c) { // init to default values string fName = string.Empty; string lName = string.Empty; string phoneNumber = string.Empty; string emailAddress = string.Empty; string address = string.Empty; // update values if a contact was passed in if (c != null) { if (!string.IsNullOrEmpty(c.FirstName)) fName = c.FirstName; if (!string.IsNullOrEmpty(c.LastName)) lName = c.LastName; if (!string.IsNullOrEmpty(c.Phone)) phoneNumber = c.Phone; if (!string.IsNullOrEmpty(c.Email)) emailAddress = c.Email; if (!string.IsNullOrEmpty(c.Address)) address = c.Address; } // build dialog section List<Section> sections = new List<Section>(); var name = new Section() { Caption = "Individual" }; sections.Add(name); var ee = new EntryElement("First Name", null, fName); name.Add(new EntryElement("First Name", null, fName) { KeyboardType = UIKeyboardType.NamePhonePad }); var phoneSec = new Section() { Caption = "Phone Numbers" }; sections.Add(phoneSec); //TODO: Add a button which adds a new row phoneSec.Add(new EntryElement("Work", null, phoneNumber) { KeyboardType = UIKeyboardType.PhonePad }); // email var emailSec = new Section() { Caption = "Email Addresses" }; sections.Add(emailSec); emailSec.Add(new EntryElement("Work", null, emailAddress) { KeyboardType = UIKeyboardType.EmailAddress }); // addresses var addressSec = new Section() { Caption = "Addresses" }; sections.Add(addressSec); addressSec.Add(new MultilineEntryElement("Home", address)); return sections.ToArray(); }
private void Populate(object callbacks, object o, RootElement root) { MemberInfo last_radio_index = null; var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Section section = null; foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) continue; string caption = null; object[] attrs = mi.GetCustomAttributes(false); bool skip = false; foreach (var attr in attrs) { if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute) skip = true; else if (attr is CaptionAttribute) caption = ((CaptionAttribute)attr).Caption; else if (attr is SectionAttribute) { if (section != null) root.Add(section); var sa = attr as SectionAttribute; section = new Section(sa.Caption, sa.Footer); } } if (skip) continue; if (caption == null) caption = MakeCaption(mi.Name); if (section == null) section = new Section(); Element element = null; if (mType == typeof(string)) { PasswordAttribute pa = null; AlignmentAttribute align = null; EntryAttribute ea = null; object html = null; Action invoke = null; bool multi = false; foreach (object attr in attrs) { if (attr is PasswordAttribute) pa = attr as PasswordAttribute; else if (attr is EntryAttribute) ea = attr as EntryAttribute; else if (attr is MultilineAttribute) multi = true; else if (attr is HtmlAttribute) html = attr; else if (attr is AlignmentAttribute) align = attr as AlignmentAttribute; if (attr is OnTapAttribute) { string mname = ((OnTapAttribute)attr).Method; if (callbacks == null) { throw new Exception( "Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor"); } var method = callbacks.GetType().GetMethod(mname); if (method == null) throw new Exception("Did not find method " + mname); invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); }; } } var value = (string)GetValue(mi, o); if (pa != null) element = new EntryElement(caption, pa.Placeholder, value, true); else if (ea != null) element = new EntryElement(caption, ea.Placeholder, value) { KeyboardType = ea.KeyboardType }; else if (multi) element = new MultilineElement(caption, value); else if (html != null) element = new HtmlElement(caption, value); else { var selement = new StringElement(caption, value); element = selement; if (align != null) selement.Alignment = align.Alignment; } if (invoke != null) (element).Tapped += invoke; } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (float)GetValue(mi, o)) { Caption = caption }; element = floatElement; foreach (object attr in attrs) { if (attr is RangeAttribute) { var ra = attr as RangeAttribute; floatElement.MinValue = ra.Low; floatElement.MaxValue = ra.High; floatElement.ShowCaption = ra.ShowCaption; } } } else if (mType == typeof(bool)) { bool checkbox = false; foreach (object attr in attrs) { if (attr is CheckboxAttribute) checkbox = true; } if (checkbox) element = new CheckboxElement(caption, (bool)GetValue(mi, o)); else element = new BooleanElement(caption, (bool)GetValue(mi, o)); } else if (mType == typeof(DateTime)) { var dateTime = (DateTime)GetValue(mi, o); bool asDate = false, asTime = false; foreach (object attr in attrs) { if (attr is DateAttribute) asDate = true; else if (attr is TimeAttribute) asTime = true; } if (asDate) element = new DateElement(caption, dateTime); else if (asTime) element = new TimeElement(caption, dateTime); else element = new DateTimeElement(caption, dateTime); } else if (mType.IsEnum) { var csection = new Section(); ulong evalue = Convert.ToUInt64(GetValue(mi, o), null); int idx = 0; int selected = 0; foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static)) { ulong v = Convert.ToUInt64(GetValue(fi, null)); if (v == evalue) selected = idx; var ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute; csection.Add(new RadioElement(ca != null ? ca.Caption : MakeCaption(fi.Name))); idx++; } element = new RootElement(caption, new RadioGroup(null, selected)) { csection }; } else if (mType == typeof(UIImage)) { element = new ImageElement((UIImage)GetValue(mi, o)); } else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType)) { var csection = new Section(); int count = 0; if (last_radio_index == null) throw new Exception("IEnumerable found, but no previous int found"); foreach (var e in (IEnumerable)GetValue(mi, o)) { csection.Add(new RadioElement(e.ToString())); count++; } var selected = (int)GetValue(last_radio_index, o); if (selected >= count || selected < 0) selected = 0; element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index)) { csection }; last_radio_index = null; } else if (typeof(int) == mType) { if (attrs.OfType<RadioSelectionAttribute>().Any()) { last_radio_index = mi; } } else { var nested = GetValue(mi, o); if (nested != null) { var newRoot = new RootElement(caption); Populate(callbacks, nested, newRoot); element = newRoot; } } if (element == null) continue; section.Add(element); mappings[element] = new MemberAndInstance(mi, o); } root.Add(section); }