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", false);
            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));
            });
        }
Example #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var publicElement = new BooleanElement("Public", false);

            Source.Root[Source.Root.Count - 1].Insert(0, publicElement);

            OnActivation(d => {
                d(this.WhenAnyValue(x => x.ViewModel.IsPublic).Subscribe(x => publicElement.Value = x));
                d(publicElement.Changed.Subscribe(x => ViewModel.IsPublic = x));
            });
        }
Example #3
0
        public Element ElementForRequirement(Requirement req)
        {
            var status = RequirementStatus.ContainsKey(req.Id)? RequirementStatus[req.Id] : new RequirementStatus()
            {
                UserId = Person.Id, RequirementId = req.Id
            };
            BooleanElement element = new BooleanElement(req.Display, status.DateCompleted.HasValue);

            element.ValueChanged += delegate {
                //todo, save
            };
            return(element);
        }
        public JobUninstallViewController(RootElement root, WorkflowNavigationController nav, UsedPartsNavigationController upnav, bool pushing) : base(root, pushing)
        {
            NavUsedParts = upnav;
            NavWorkflow  = nav;
            DBParts      = new List <Part>();
            DBAssemblies = new List <Assembly> ();
            DeactivateEditingMode();

            Section        WarrantySection = new Section("");
            BooleanElement warrantyElement = new BooleanElement("Warranty", false);

            warrantyElement.ValueChanged += delegate {
                this.NavWorkflow._tabs._jobRunTable.CurrentJob.Warranty = warrantyElement.Value;
            };
            WarrantySection.Add(warrantyElement);
            Root.Add(WarrantySection);

            Root.Add(new Section(""));

            PartsSection PartsUsedSection = new PartsSection("Parts used", this);

            PartsUsedSection.Add(new StyledStringElement("Tap here to add a part"));

            Root.Add(PartsUsedSection);

            using (var image = UIImage.FromBundle("Images/19-gear")) this.TabBarItem.Image = image;
            this.Title = "Uninstallation";

            ToolbarItems = new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.Reply),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Clear parts list", UIBarButtonItemStyle.Bordered, delegate { ClearPartsList(); }),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Action)
            };
            ToolbarItems[0].Clicked += delegate {
                if (NavUsedParts.Tabs._jobRunTable.CurrentJob.HasParent())                      // for child jobs, we jump to payment screen
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                }
                else                 // for main jobs we jump to pre-plumbing check
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[0];
                }
            };

            ToolbarItems[4].Clicked += delegate {
                NavUsedParts.Tabs.LastSelectedTab        = NavUsedParts.Tabs.SelectedIndex;
                NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];                 // jump to payment
            };
        }
Example #5
0
        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);
        }
Example #6
0
        Section CreateAircraftTypeSection()
        {
            Section section = new Section("Type of Aircraft")
            {
                (category = CreateCategoryElement(Aircraft.Category)),
                (classification = CreateClassificationElement(Aircraft.Category, classes)),
                (isComplex = new BooleanElement("Complex", Aircraft.IsComplex)),
                (isHighPerformance = new BooleanElement("High Performance", Aircraft.IsHighPerformance)),
                (isTailDragger = new BooleanElement("Tail Dragger", Aircraft.IsTailDragger)),
                (isSimulator = new BooleanElement("Simulator", Aircraft.IsSimulator)),
            };

            classification.RadioSelected = ClassificationToIndex(Aircraft.Classification);

            return(section);
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }
Example #9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var del = UIApplication.SharedApplication.Delegate as AppDelegate;

            BooleanElement leftMenuEnabled = new BooleanElement("Left menu enabled", del.Menu.LeftMenuEnabled);

            leftMenuEnabled.ValueChanged += (sender, e) => {
                del.Menu.LeftMenuEnabled = leftMenuEnabled.Value;
            };

            Root.Add(new Section()
            {
                new StyledStringElement("Home", () => { NavigationController.PushViewController(new HomeViewController(), true); }),
                leftMenuEnabled
            });
        }
Example #10
0
        protected void GotoBindingSamples(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "Binding Samples";

            var section1 = new TableViewSection(tb.Source);

            section1.Header = "Same element";
            section1.Footer = "Note that both elements update";

            var boolElement = new BooleanElement("Bool Value", false);

            section1.Add(boolElement);
            section1.Add(boolElement);

            this.rootController.PushViewController(tb, true);
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            var root = new RootElement("Discreet Sample")
            {
                new Section("Settings")
                {
                    (text2Show = new EntryElement("Text2Show:", "Some text here", "I'm so Discreet")),
                    new StringElement("Show", Show)
                    {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement("Hide", Hide)
                    {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement("Hide after 1 second", HideAfter1sec)
                    {
                        Alignment = UITextAlignment.Center
                    },
                    (topBottom = new BooleanElement("Top / Bottom", true)),
                    (showActivity = new BooleanElement("Show Activity?", true))
                }
            };

            dvc           = new DialogViewController(root);
            navController = new UINavigationController(dvc);

            window.RootViewController = navController;
            window.MakeKeyAndVisible();

            notificationView = new GCDiscreetNotificationView(text: text2Show.Value,
                                                              activity: showActivity.Value,
                                                              presentationMode: topBottom.Value ? GCDNPresentationMode.Top : GCDNPresentationMode.Bottom,
                                                              view: dvc.View);
            showActivity.ValueChanged += ChangeActivity;
            topBottom.ValueChanged    += ChangeTopBottom;
            text2Show.Changed         += HandleChanged;

            return(true);
        }
Example #12
0
        public GistCreateView()
        {
            this.WhenAnyValue(x => x.ViewModel.SaveCommand)
            .Select(x => x.ToBarButtonItem(UIBarButtonSystemItem.Save))
            .Subscribe(x => NavigationItem.RightBarButtonItem = x);

            _publicElement = new BooleanElement("Public", false, (e) => ViewModel.IsPublic = e.Value);
            this.WhenAnyValue(x => x.ViewModel.IsPublic).Subscribe(x => _publicElement.Value = x);

            this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => _descriptionElement.Value = x);
            _descriptionElement.ValueChanged += (sender, e) => ViewModel.Description = _descriptionElement.Value;

            _addFileElement.Image  = Octicon.Plus.ToImage();
            _addFileElement.Tapped = () => ViewModel.AddGistFileCommand.ExecuteIfCan();

            this.WhenAnyValue(x => x.ViewModel.Files)
            .Select(x => x.Changed)
            .Switch()
            .Select(_ => ViewModel.Files.Select(x => new FileElement(x)))
            .Subscribe(x => _fileSection.Reset(x));
        }
Example #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var model = _filterController.Filter.Clone();

            var save = new StringElement("Save as Default")
            {
                Accessory = UITableViewCellAccessory.None
            };

            save.Clicked.Subscribe(_ =>
            {
                _filterController.ApplyFilter(CreateFilterModel(), true);
                CloseViewController();
            });

            //Load the root
            var sections = new [] {
                new Section("Filter")
                {
                    (_filter = CreateEnumElement("Type", model.FilterType)),
                    (_open = new BooleanElement("Open?", model.Open)),
                    (_labels = new EntryElement("Labels", "bug,ui,@user", model.Labels)
                    {
                        TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
                    }),
                },
                new Section("Order By")
                {
                    (_sort = CreateEnumElement("Field", model.SortType)),
                    (_asc = new BooleanElement("Ascending", model.Ascending))
                },
                new Section()
                {
                    save,
                }
            };

            Root.Reset(sections);
        }
Example #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var root = _root.Value;

            TableView.Source          = new DialogTableViewSource(root);
            TableView.TableFooterView = new UIView();

            var deleteBranch = new BooleanElement("Delete Source Branch");
            var content      = new ExpandingInputElement("Merge Message (Optional)");

            var contentSection = new Section {
                deleteBranch, content
            };

            root.Reset(contentSection);

            OnActivation(disposable =>
            {
                this.WhenAnyValue(x => x.Message)
                .Subscribe(x => content.Value = x)
                .AddTo(disposable);

                content
                .Changed
                .Subscribe(x => Message = x)
                .AddTo(disposable);

                this.WhenAnyValue(x => x.DeleteSourceBranch)
                .Subscribe(x => deleteBranch.Value = x)
                .AddTo(disposable);

                deleteBranch
                .Changed
                .Subscribe(x => DeleteSourceBranch = x)
                .AddTo(disposable);
            });
        }
Example #15
0
        public Settings() : base(UITableViewStyle.Grouped, null)
        {
            var storage = SimpleStorage.EditGroup("preferences");

            Root     = new RootElement("Settings".t());
            _network = new Section("NetworkS".t());
            var notification = storage.Get("notifications");

            _notifications = new BooleanElement("NotificationsAllow".t(), Convert.ToBoolean(notification));
            _notifications.ValueChanged += (sender, e) => {
                if (_notifications.Value)
                {
                    storage.Put("notifications", "True");
                }
                else
                {
                    storage.Put("notifications", "False");
                }
            };
            _network.Add(_notifications);
            Root.Add(_network);
        }
Example #16
0
        public static Element GetElementFromObject(object model)
        {
            Element element = null;

            if (model == null)
            {
                element = new NullElement();
            }
            else
            {
                var type = model.GetType();

                if (Array.IndexOf(Constants.NumberTypes, type) >= 0)
                {
                    element = new NumberElement();
                }
                else if (Array.IndexOf(Constants.StringTypes, type) >= 0)
                {
                    element = new StringElement();
                }
                else if (Array.IndexOf(Constants.BooleanTypes, type) >= 0)
                {
                    element = new BooleanElement();
                }
                else if (typeof(IEnumerable).IsAssignableFrom(type))
                {
                    element = new ArrayElement();
                }
                else
                {
                    element = new ObjectElement();
                }

                element.PopulateElement(model);
            }

            return(element);
        }
Example #17
0
        public Pubnub_MessagingMain() : base(UITableViewStyle.Grouped, null)
        {
            EntryElement   entryChannelName = new EntryElement("Channel Name", "Enter Channel Name", "");
            EntryElement   entryCipher      = new EntryElement("Cipher", "Enter Cipher", "");
            BooleanElement bSsl             = new BooleanElement("Enable SSL", false);

            Root = new RootElement("Pubnub Messaging")
            {
                new Section("Basic Settings")
                {
                    entryChannelName,
                    bSsl
                },
                new Section("Enter cipher key for encryption. Leave blank for unencrypted transfer.")
                {
                    entryCipher
                },
                new Section()
                {
                    new StyledStringElement("Launch", () => {
                        if (String.IsNullOrWhiteSpace(entryChannelName.Value.Trim()))
                        {
                            new UIAlertView("Error!", "Please enter a channel name", null, "OK").Show();
                        }
                        else
                        {
                            new Pubnub_MessagingSub(entryChannelName.Value, entryCipher.Value, bSsl.Value);
                        }
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor       = UIColor.White,
                        Alignment       = UITextAlignment.Center
                    },
                }
            };
        }
Example #18
0
        public override void LoadView()
        {
            name          = new LimitedEntryElement("Name", "Enter the name of the pilot.", Pilot.Name);
            cfi           = new BooleanElement("Certified Flight Instructor", Pilot.IsCertifiedFlightInstructor);
            aifr          = new BooleanElement("Instrument Rated (Airplane)", Pilot.InstrumentRatings.HasFlag(InstrumentRating.Airplane));
            hifr          = new BooleanElement("Instrument Rated (Helicopter)", Pilot.InstrumentRatings.HasFlag(InstrumentRating.Helicopter));
            lifr          = new BooleanElement("Instrument Rated (Powered-Lift)", Pilot.InstrumentRatings.HasFlag(InstrumentRating.PoweredLift));
            certification = CreatePilotCertificationElement(Pilot.Certification);
            endorsements  = CreateEndorsementsElement(Pilot.Endorsements);
            birthday      = new DateEntryElement("Date of Birth", Pilot.BirthDate);
            medical       = new DateEntryElement("Last Medical Exam", Pilot.LastMedicalExam);
            review        = new DateEntryElement("Last Flight Review", Pilot.LastFlightReview);

            base.LoadView();

            Root.Add(new Section("Pilot Information")
            {
                name, birthday, certification, endorsements, aifr, hifr, lifr, cfi
            });
            Root.Add(new Section("Pilot Status")
            {
                medical, review
            });
        }
Example #19
0
        public SettingsController()
            : base(new RootElement("Settings"), true)
        {
            Settings = Settings.Instance;

            var section = new Section();

            Root.Add(section);

            var showListening = new BooleanElement("Show listening sockets", Settings.ShowListening);

            showListening.ValueChanged += (sender, e) => {
                Settings.ShowListening = showListening.Value;
            };
            section.Add(showListening);

            var showLocal = new BooleanElement("Show local connections", Settings.ShowLocal);

            showLocal.ValueChanged += (sender, e) => {
                Settings.ShowLocal = showLocal.Value;
            };
            section.Add(showLocal);

            var autoRefresh = new BooleanElement("Auto refresh", Settings.AutoRefresh);

            autoRefresh.ValueChanged += (sender, e) => {
                Settings.AutoRefresh = autoRefresh.Value;
            };
            section.Add(autoRefresh);

            var filterSection = new Section();

            Root.Add(filterSection);

            var usePortFilter = new BooleanElement("Use Port filter", Settings.UsePortFilter);

            usePortFilter.ValueChanged += (sender, e) => {
                Settings.UsePortFilter = usePortFilter.Value;
            };
            filterSection.Add(usePortFilter);

            var portFilter = new EntryElement("Port filter", "<port>", Settings.PortFilter.ToString());

            portFilter.Changed += (sender, e) => {
                int port;
                if (!int.TryParse(portFilter.Value, out port))
                {
                    portFilter.Value = Settings.PortFilter.ToString();
                }
                else
                {
                    Settings.PortFilter = port;
                }
            };
            filterSection.Add(portFilter);

            var spSection = new Section();

            Root.Add(spSection);

            var connectionLimit = new EntryElement("Connection limit", "<number>", Settings.ConnectionLimit.ToString());

            connectionLimit.Changed += (sender, e) => {
                int value;
                if (!int.TryParse(connectionLimit.Value, out value))
                {
                    connectionLimit.Value = Settings.ConnectionLimit.ToString();
                }
                else
                {
                    Settings.ConnectionLimit = value;
                }
            };
            spSection.Add(connectionLimit);

            var spIdle = new EntryElement("SP idle time", "<idle-time>", Settings.ServicePointIdleTime.ToString());

            spIdle.Changed += (sender, e) => {
                int value;
                if (!int.TryParse(spIdle.Value, out value))
                {
                    spIdle.Value = Settings.ServicePointIdleTime.ToString();
                }
                else
                {
                    Settings.ServicePointIdleTime = value;
                }
            };
            spSection.Add(spIdle);

            Settings.Modified += (sender, e) => InvokeOnMainThread(() => {
                var newPfValue = Settings.PortFilter.ToString();
                if (!string.Equals(portFilter.Value, newPfValue))
                {
                    portFilter.Value = newPfValue;
                    Root.Reload(portFilter, UITableViewRowAnimation.Automatic);
                }

                if (usePortFilter.Value != Settings.UsePortFilter)
                {
                    usePortFilter.Value = Settings.UsePortFilter;
                    Root.Reload(usePortFilter, UITableViewRowAnimation.Automatic);
                }
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var model = _filterController.Filter.Clone();

            var save = new StringElement("Save as Default")
            {
                Accessory = UITableViewCellAccessory.None
            };

            save.Clicked.Subscribe(_ =>
            {
                _filterController.ApplyFilter(CreateFilterModel(), true);
                CloseViewController();
            });

            //Load the root
            var root = new [] {
                new Section("Filter")
                {
                    (_open = new BooleanElement("Open?", model.Open)),
                    (_labels = new EntryElement("Labels", "bug,ui,@user", model.Labels)
                    {
                        TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
                    }),
                    (_mentioned = new EntryElement("Mentioned", "User", model.Mentioned)
                    {
                        TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
                    }),
                    (_creator = new EntryElement("Creator", "User", model.Creator)
                    {
                        TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
                    }),
                    (_assignee = new EntryElement("Assignee", "User", model.Assignee)
                    {
                        TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None
                    }),
                    (_milestone = new StringElement("Milestone", "None", UITableViewCellStyle.Value1)),
                },
                new Section("Order By")
                {
                    (_sort = CreateEnumElement("Field", model.SortType)),
                    (_asc = new BooleanElement("Ascending", model.Ascending))
                },
                new Section(string.Empty, "Saving this filter as a default will save it only for this repository.")
                {
                    save
                }
            };

            RefreshMilestone();

            _milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _milestone.Clicked.Subscribe(_ => {
                var ctrl = new IssueMilestonesFilterViewController(_user, _repo, _milestoneHolder != null);

                ctrl.MilestoneSelected = (title, num, val) => {
                    if (title == null && num == null && val == null)
                    {
                        _milestoneHolder = null;
                    }
                    else
                    {
                        _milestoneHolder = new IssuesFilterModel.MilestoneKeyValue {
                            Name = title, Value = val, IsMilestone = num.HasValue
                        }
                    };
                    RefreshMilestone();
                    NavigationController.PopViewController(true);
                };
                NavigationController.PushViewController(ctrl, true);
            });

            Root.Reset(root);
        }
    }
Example #21
0
        public void Config(Moment moment)
        {
            if (this.moment != null)
            {
                this.moment.SyncedChanged -= syncedChanged;
            }
            this.moment = moment;
            this.moment.SyncedChanged += syncedChanged;

            BooleanElement boolElement = new BooleanElement("Mark as Finished", this.moment.State == MomentState.Finished);

            boolElement.ValueChanged += (sender, e) => {
                if (boolElement.Value)
                {
                    this.moment.State = MomentState.Finished;
                }
                else
                {
                    this.moment.State = MomentState.InProgress;
                }
            };

            this.titleElement.Value   = moment.Title;
            this.commentElement.Value = moment.Comment;
            Root = new RootElement("Edit")
            {
                new Section("")
                {
                    new BasicViewElement(this.mapView, 120),
                    this.titleElement,
                    this.commentElement,
                    new StringElement("Erstellt:", moment.Date.ToString("H:mm:ss dd.MM.yy"))
                },

                new Section("Images")
                {
                    new BasicViewElement(imagesCollectionView, 120),
                    new StringElement("New Image", delegate {
                        var imagePicker = new PictureMomentViewController();
                        imagePicker.Config(moment);
                        var sheet = PictureMomentViewController.GetActionSheet(imagePicker, this.NavigationController, false);
                        sheet.ShowInView(this.TableView);
                        imagePicker.Finished += async(Moment obj) => {
                            Reload();
                            await Task.Delay(3000);
                            AppDelegate.MomentsManager.SaveMoments();
                            await AppDelegate.MomentsManager.SyncMoment(this.moment);
                        };
                    })
                },
                new Section("Videos")
                {
                    new BasicViewElement(videosCollectionView, 120),
                    new StringElement("New Video", delegate {
                        var imagePicker = new PictureMomentViewController();
                        imagePicker.Config(moment);
                        var sheet = PictureMomentViewController.GetActionSheet(imagePicker, this.NavigationController, true);
                        sheet.ShowInView(this.TableView);
                        imagePicker.Finished += (Moment obj) => {
                            Reload();
                            AppDelegate.MomentsManager.SaveMoments();
                            AppDelegate.MomentsManager.SyncMoment(this.moment);
                        };
                    })
                },
                new Section("Emojis")
                {
                    new BasicViewElement(emojiCollectionView, 120)
                },
            };
            Reload();
        }
Example #22
0
        public UIViewController GetViewController()
        {
#if TVOS
            var network = new StringElement(string.Format("Enabled: {0}", EnableNetwork));
#else
            var network = new BooleanElement("Enable", EnableNetwork);
#endif

            var host = new EntryElement("Host Name", "name", HostName);
            host.KeyboardType = UIKeyboardType.ASCIICapable;

            var port = new EntryElement("Port", "name", HostPort.ToString());
            port.KeyboardType = UIKeyboardType.NumberPad;

#if TVOS
            var sort = new StringElement(string.Format("Sort Names: ", SortNames));
#else
            var sort = new BooleanElement("Sort Names", SortNames);
#endif

            var root = new RootElement("Options")
            {
                new Section("Remote Server")
                {
                    network, host, port
                },
                new Section("Display")
                {
                    sort
                }
            };

            var dv = new DialogViewController(root, true)
            {
                Autorotate = true
            };
            dv.ViewDisappearing += delegate {
#if !TVOS
                EnableNetwork = network.Value;
#endif
                HostName = host.Value;
                ushort p;
                if (UInt16.TryParse(port.Value, out p))
                {
                    HostPort = p;
                }
                else
                {
                    HostPort = -1;
                }
#if !TVOS
                SortNames = sort.Value;
#endif

                var defaults = NSUserDefaults.StandardUserDefaults;
                defaults.SetBool(EnableNetwork, "network.enabled");
                defaults.SetString(HostName ?? String.Empty, "network.host.name");
                defaults.SetInt(HostPort, "network.host.port");
                defaults.SetBool(SortNames, "display.sort");
            };

            return(dv);
        }
Example #23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var saveCredentials = new BooleanElement("Save Credentials",
                                                     ViewModel.SaveCredentials, e => ViewModel.SaveCredentials = e.Value);

            ViewModel.WhenAnyValue(x => x.SaveCredentials).Subscribe(x => saveCredentials.Value = x);

            var showOrganizationsInEvents = new BooleanElement("Show Organizations in Events",
                                                               ViewModel.ShowOrganizationsInEvents, e => ViewModel.ShowOrganizationsInEvents = e.Value);

            ViewModel.WhenAnyValue(x => x.ShowOrganizationsInEvents).Subscribe(x => showOrganizationsInEvents.Value = x);

            var showOrganizations = new BooleanElement("List Organizations in Menu",
                                                       ViewModel.ExpandOrganizations, e => ViewModel.ExpandOrganizations = e.Value);

            ViewModel.WhenAnyValue(x => x.ExpandOrganizations).Subscribe(x => showOrganizations.Value = x);

            var repoDescriptions = new BooleanElement("Show Repo Descriptions",
                                                      ViewModel.ShowRepositoryDescriptionInList, e => ViewModel.ShowRepositoryDescriptionInList = e.Value);

            ViewModel.WhenAnyValue(x => x.ShowRepositoryDescriptionInList).Subscribe(x => repoDescriptions.Value = x);

            var startupView = new StringElement("Startup View", ViewModel.DefaultStartupViewName, UITableViewCellStyle.Value1);

            startupView.Tapped = () => ViewModel.GoToDefaultStartupViewCommand.ExecuteIfCan();
            ViewModel.WhenAnyValue(x => x.DefaultStartupViewName).Subscribe(x =>
            {
                startupView.Value = x;
                Root.Reload(startupView);
            });

            var syntaxHighlighter = new StringElement("Syntax Highlighter", ViewModel.SyntaxHighlighter, UITableViewCellStyle.Value1);

            syntaxHighlighter.Tapped = () => ViewModel.GoToSyntaxHighlighterCommand.ExecuteIfCan();
            ViewModel.WhenAnyValue(x => x.SyntaxHighlighter).Subscribe(x =>
            {
                syntaxHighlighter.Value = x;
                Root.Reload(syntaxHighlighter);
            });

            var applicationSection = new Section("Application", "Looking for application settings? They're located in the iOS settings application.");

            var version = UIDevice.CurrentDevice.SystemVersion.Split('.');
            var major   = Int32.Parse(version[0]);

            if (major >= 8)
            {
                applicationSection.Add(
                    new StringElement("Go To Application Settings",
                                      () => UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString))));
            }

            var accountSection = new Section("Account")
            {
                saveCredentials
            };

            var appearanceSection = new Section("Appearance")
            {
                showOrganizationsInEvents,
                showOrganizations,
                repoDescriptions,
                startupView,
                syntaxHighlighter
            };

            var aboutSection = new Section("About", "Thank you for downloading. Enjoy!")
            {
                new StringElement("Follow On Twitter", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/CodeHubapp"))),
                new StringElement("Rate This App", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codehub-github-for-ios/id707173885?mt=8"))),
                new StringElement("Source Code", () => ViewModel.GoToSourceCodeCommand.ExecuteIfCan()),
                new StringElement("App Version", ViewModel.Version)
            };

            Root.Reset(accountSection, appearanceSection, applicationSection, aboutSection);
        }
Example #24
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 44f;

            var vm = (IssueEditViewModel)ViewModel;

            var saveButton = new UIBarButtonItem {
                Image = Images.Buttons.SaveButton
            };

            NavigationItem.RightBarButtonItem = saveButton;

            var title      = new InputElement("Title", string.Empty, string.Empty);
            var assignedTo = new StringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
            var milestone  = new StringElement("Milestone", "None", UITableViewCellStyle.Value1);
            var labels     = new StringElement("Labels", "None", UITableViewCellStyle.Value1);
            var content    = new MultilinedElement("Description");
            var state      = new BooleanElement("Open", true);

            Root.Reset(new Section {
                title, assignedTo, milestone, labels
            }, new Section {
                state
            }, new Section {
                content
            });

            OnActivation(d =>
            {
                d(vm.Bind(x => x.IssueTitle, true).Subscribe(x => title.Value = x));
                d(title.Changed.Subscribe(x => vm.IssueTitle = x));

                d(assignedTo.Clicked.BindCommand(vm.GoToAssigneeCommand));
                d(milestone.Clicked.BindCommand(vm.GoToMilestonesCommand));
                d(labels.Clicked.BindCommand(vm.GoToLabelsCommand));

                d(vm.Bind(x => x.IsOpen, true).Subscribe(x => state.Value = x));
                d(vm.Bind(x => x.IsSaving).SubscribeStatus("Updating..."));

                d(state.Changed.Subscribe(x => vm.IsOpen = x));
                d(vm.Bind(x => x.Content, true).Subscribe(x => content.Details = x));

                d(vm.Bind(x => x.AssignedTo, true).Subscribe(x => {
                    assignedTo.Value = x == null ? "Unassigned" : x.Login;
                }));

                d(vm.Bind(x => x.Milestone, true).Subscribe(x => {
                    milestone.Value = x == null ? "None" : x.Title;
                }));

                d(vm.BindCollection(x => x.Labels, true).Subscribe(x => {
                    labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name));
                }));

                d(saveButton.GetClickedObservable().Subscribe(_ => {
                    View.EndEditing(true);
                    vm.SaveCommand.Execute(null);
                }));

                d(content.Clicked.Subscribe(_ => {
                    var composer = new MarkdownComposerViewController {
                        Title = "Issue Description", Text = content.Details
                    };
                    composer.NewComment(this, (text) => {
                        vm.Content = text;
                        composer.CloseComposer();
                    });
                }));
            });
        }
Example #25
0
        public Settings(DialogViewController parent) : base(UITableViewStyle.Grouped, null)
        {
            this.parent = parent;
            var aboutUrl  = NSUrl.FromFilename("about.html");
            int cellStyle = Util.Defaults.IntForKey("cellStyle");

            Root = new RootElement(Locale.GetText("Settings"))
            {
                MakeAccounts(),
                new Section()
                {
                    new RootElement(Locale.GetText("Settings"))
                    {
                        new Section(Locale.GetText("Style"))
                        {
                            (selfOnRight = new BooleanElement(Locale.GetText("My tweets on right"), (cellStyle & 1) == 0)),
                            (shadows = new BooleanElement(Locale.GetText("Avatar shadows"), (cellStyle & 2) == 0)),
                            (autoFav = new BooleanElement(Locale.GetText("Favorite on Retweet"), Util.Defaults.IntForKey("disableFavoriteRetweets") == 0)),
                            (compress = new RootElement(Locale.GetText("Image Compression"), new RadioGroup("group", Util.Defaults.IntForKey("sizeCompression")))
                            {
                                new Section()
                                {
                                    new RadioElement(Locale.GetText("Maximum")),
                                    new RadioElement(Locale.GetText("Medium")),
                                    new RadioElement(Locale.GetText("None"))
                                }
                            })
                        },
                        new Section(Locale.GetText("Inspiration"),
                                    Locale.GetText("Twitter is best used when you are\n" +
                                                   "inspired.  I picked music and audio\n" +
                                                   "that should inspire you to create\n" +
                                                   "clever tweets"))
                        {
                            (playMusic = new BooleanElement(Locale.GetText("Music on Composer"), Util.Defaults.IntForKey("disableMusic") == 0)),
                            (chicken = new BooleanElement(Locale.GetText("Chicken noises"), Util.Defaults.IntForKey("disableChickens") == 0)),
                        }
                    },
                    //new RootElement (Locale.GetText ("Services"))
                },

                new Section()
                {
                    new RootElement(Locale.GetText("About"))
                    {
                        new Section()
                        {
                            new HtmlElement(Locale.GetText("About and Credits"), aboutUrl),
                            new HtmlElement(Locale.GetText("Web site"), "http://tirania.org/tweetstation")
                        },
                        new Section()
                        {
                            Twitterista("migueldeicaza"),
                            Twitterista("itweetstation"),
                        },
                        new Section(Locale.GetText("Music"))
                        {
                            Twitterista("kmacleod"),
                        },
                        new Section(Locale.GetText("Conspirators"))
                        {
                            Twitterista("JosephHill"),
                            Twitterista("kangamono"),
                            Twitterista("lauradeicaza"),
                            Twitterista("mancha"),
                            Twitterista("mjhutchinson"),
                        },
                        new Section(Locale.GetText("Contributors"))
                        {
                            Twitterista("martinbowling"),
                            Twitterista("conceptdev"),
                        },
                        new Section(Locale.GetText("Includes X11 code from"))
                        {
                            Twitterista("escoz"),
                            Twitterista("praeclarum"),
                        }
                    }
                }
            };
        }
Example #26
0
        public Pubnub_MessagingMain() : base(UITableViewStyle.Grouped, null)
        {
            UIView labelView   = new UIView(new RectangleF(0, 0, this.View.Bounds.Width, 24));
            int    left        = 20;
            string hardwareVer = DeviceHardware.Version.ToString().ToLower();

            if (hardwareVer.IndexOf("ipad") >= 0)
            {
                left = 55;
            }

            labelView.AddSubview(new UILabel(new RectangleF(left, 10, this.View.Bounds.Width - left, 24))
            {
                Font            = UIFont.BoldSystemFontOfSize(16),
                BackgroundColor = UIColor.Clear,
                TextColor       = UIColor.FromRGB(76, 86, 108),
                Text            = "Basic Settings"
            });

            var headerMultipleChannels = new UILabel(new RectangleF(0, 0, this.View.Bounds.Width, 24))
            {
                Font            = UIFont.SystemFontOfSize(12),
                TextColor       = UIColor.Brown,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Center
            };

            headerMultipleChannels.Text = "Enter multiple channel names separated by comma";

            EntryElement entrySubscribeKey = new EntryElement("Subscribe Key", "Enter Subscribe Key", "demo");

            entrySubscribeKey.AutocapitalizationType = UITextAutocapitalizationType.None;
            entrySubscribeKey.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryPublishKey = new EntryElement("Publish Key", "Enter Publish Key", "demo");

            entryPublishKey.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryPublishKey.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entrySecretKey = new EntryElement("Secret Key", "Enter Secret Key", "demo");

            entrySecretKey.AutocapitalizationType = UITextAutocapitalizationType.None;
            entrySecretKey.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryChannelName = new EntryElement("Channel(s)", "Enter Channel Name", "");

            entryChannelName.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryChannelName.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryCipher = new EntryElement("Cipher", "Enter Cipher", "");

            entryCipher.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryCipher.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryProxyServer = new EntryElement("Server", "Enter Server", "");

            entryProxyServer.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryProxyServer.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryProxyPort = new EntryElement("Port", "Enter Port", "");

            EntryElement entryProxyUser = new EntryElement("Username", "Enter Username", "");

            entryProxyUser.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryProxyUser.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryProxyPassword = new EntryElement("Password", "Enter Password", "", true);

            EntryElement entryCustonUuid = new EntryElement("CustomUuid", "Enter Custom UUID", "");

            entryCustonUuid.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryCustonUuid.AutocorrectionType     = UITextAutocorrectionType.No;

            BooleanElement proxyEnabled = new BooleanElement("Proxy", false);

            BooleanElement sslEnabled = new BooleanElement("Enable SSL", false);

            Root = new RootElement("Pubnub Messaging")
            {
                new Section(labelView)
                {
                },
                new Section(headerMultipleChannels)
                {
                },
                new Section("Enter Subscribe Key.")
                {
                    entrySubscribeKey
                },
                new Section("Enter Publish key.")
                {
                    entryPublishKey
                },
                new Section("Enter Secret key.")
                {
                    entrySecretKey
                },
                new Section()
                {
                    entryChannelName,
                    sslEnabled
                },
                new Section("Enter cipher key for encryption. Leave blank for unencrypted transfer.")
                {
                    entryCipher
                },
                new Section("Enter custom UUID or leave blank to use the default UUID")
                {
                    entryCustonUuid
                },
                new Section()
                {
                    new RootElement("Proxy Settings", 0, 0)
                    {
                        new Section()
                        {
                            proxyEnabled
                        },
                        new Section("Configuration")
                        {
                            entryProxyServer,
                            entryProxyPort,
                            entryProxyUser,
                            entryProxyPassword
                        },
                    }
                },
                new Section()
                {
                    new StyledStringElement("Launch Example", () => {
                        bool errorFree = true;
                        errorFree      = ValidateAndInitPubnub(entryChannelName.Value, entryCipher.Value, sslEnabled.Value,
                                                               entryCustonUuid.Value, proxyEnabled.Value, entryProxyPort.Value,
                                                               entryProxyUser.Value, entryProxyServer.Value, entryProxyPassword.Value,
                                                               entrySubscribeKey.Value, entryPublishKey.Value, entrySecretKey.Value
                                                               );

                        if (errorFree)
                        {
                            new Pubnub_MessagingSub(entryChannelName.Value, entryCipher.Value, sslEnabled.Value, pubnub);
                        }
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor       = UIColor.White,
                        Alignment       = UITextAlignment.Center
                    },
                },

                /*new Section()
                 * {
                 *  new StyledStringElement ("Launch Speed Test", () => {
                 *      bool errorFree = true;
                 *      errorFree = ValidateAndInitPubnub(entryChannelName.Value, entryCipher.Value, sslEnabled.Value,
                 *                                        entryCustonUuid.Value, proxyEnabled.Value, entryProxyPort.Value,
                 *                                        entryProxyUser.Value, entryProxyServer.Value, entryProxyPassword.Value
                 *                                        );
                 *
                 *      if(errorFree)
                 *      {
                 *          new Pubnub_MessagingSpeedTest(entryChannelName.Value, entryCipher.Value, sslEnabled.Value, pubnub);
                 *      }
                 *  })
                 *  {
                 *      BackgroundColor = UIColor.Blue,
                 *      TextColor = UIColor.White,
                 *      Alignment = UITextAlignment.Center
                 *  },
                 * }*/
            };
        }
Example #27
0
        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);
        }
Example #28
0
        protected void GotoBindingSamples(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);
            tb.Title = "Binding Samples";

            var section1 = new TableViewSection(tb.Source);

            section1.Header = "Same element";
            section1.Footer = "Note that both elements update";

            var boolElement = new BooleanElement("Bool Value", false);
            section1.Add(boolElement);
            section1.Add(boolElement);

            this.rootController.PushViewController(tb, true);
        }
Example #29
0
        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));
                    floatElement.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);
        }
Example #30
0
        public static RootElement TestElements()
        {
            RootElement re1 = new RootElement("re1");

            Debug.WriteLine(re1.ToString());
            Section s1 = new Section();

            Debug.WriteLine(s1.ToString());
            //Section s2 = new Section(new Android.Views.View(a1));
            //Debug.WriteLine(s2.ToString());
            Section s3 = new Section("s3");

            Debug.WriteLine(s3.ToString());
            //Section s4 = new Section
            //					(
            //					  new Android.Views.View(a1)
            //					, new Android.Views.View(a1)
            //					);
            //Debug.WriteLine(s4.ToString());
            Section s5 = new Section("caption", "footer");

            Debug.WriteLine(s5.ToString());

            StringElement se1 = new StringElement("se1");

            Debug.WriteLine(se1.ToString());
            StringElement se2 = new StringElement("se2", delegate() { });

            Debug.WriteLine(se2.ToString());
            //StringElement se3 = new StringElement("se3", 4);
            StringElement se4 = new StringElement("se4", "v4");

            Debug.WriteLine(se4.ToString());
            //StringElement se5 = new StringElement("se5", "v5", delegate() { });

            // removed - protected (all with LayoutID)
            // StringElement se6 = new StringElement("se6", "v6", 4);
            // Debug.WriteLine(se6.ToString());

            // not cross platform!
            // TODO: make it!?!?!?
            // AchievementElement

            BooleanElement be1 = new BooleanElement("be1", true);

            Debug.WriteLine(be1.ToString());
            BooleanElement be2 = new BooleanElement("be2", false, "key");

            Debug.WriteLine(be2.ToString());

            // Abstract
            // BoolElement be3 = new BoolElement("be3", true);

            CheckboxElement cb1 = new CheckboxElement("cb1");

            Debug.WriteLine(cb1.ToString());
            CheckboxElement cb2 = new CheckboxElement("cb2", true);

            Debug.WriteLine(cb2.ToString());
            CheckboxElement cb3 = new CheckboxElement("cb3", false, "group1");

            Debug.WriteLine(cb3.ToString());
            CheckboxElement cb4 = new CheckboxElement("cb4", false, "subcaption", "group2");

            Debug.WriteLine(cb4.ToString());

            DateElement de1 = new DateElement("dt1", DateTime.Now);

            Debug.WriteLine(de1.ToString());

            // TODO: see issues
            // https://github.com/kevinmcmahon/MonoDroid.Dialog/issues?page=1&state=open
            EntryElement ee1 = new EntryElement("ee1", "ee1");

            Debug.WriteLine(ee1.ToString());
            EntryElement ee2 = new EntryElement("ee2", "ee2 placeholder", "ee2 value");

            Debug.WriteLine(ee2.ToString());
            EntryElement ee3 = new EntryElement("ee3", "ee3 placeholder", "ee3 value", true);

            Debug.WriteLine(ee3.ToString());

            FloatElement fe1 = new FloatElement("fe1");

            Debug.WriteLine(fe1.ToString());
            FloatElement fe2 = new FloatElement(-0.1f, 0.1f, 3.2f);

            Debug.WriteLine(fe2.ToString());
            FloatElement fe3 = new FloatElement
                               (
                null
                , null                                                         // no ctors new Android.Graphics.Bitmap()
                , 1.0f
                               );

            Debug.WriteLine(fe3.ToString());

            HtmlElement he1 = new HtmlElement("he1", "http://holisiticware.net");

            Debug.WriteLine(he1.ToString());


            // TODO: image as filename - cross-platform
            ImageElement ie1 = new ImageElement(null);

            Debug.WriteLine(ie1.ToString());

            // TODO: not in Kevin's MA.D
            // ImageStringElement

            MultilineElement me1 = new MultilineElement("me1");

            Debug.WriteLine(me1.ToString());
            MultilineElement me2 = new MultilineElement("me2", delegate() { });

            Debug.WriteLine(me2.ToString());
            MultilineElement me3 = new MultilineElement("me3", "me3 value");

            Debug.WriteLine(me3.ToString());

            RadioElement rde1 = new RadioElement("rde1");

            Debug.WriteLine(rde1.ToString());
            RadioElement rde2 = new RadioElement("rde1", "group3");

            Debug.WriteLine(rde2.ToString());

            // TODO: not in Kevin's MA.D
            // StyledMultilineElement

            TimeElement te1 = new TimeElement("TimeElement", DateTime.Now);

            Debug.WriteLine(te1.ToString());



            re1.Add(s1);
            //re1.Add(s2);
            re1.Add(s3);
            //re1.Add(s4);
            re1.Add(s5);

            return(re1);
        }
        //------------------------------------------------------------------------------
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            AssemblyClass.LoadSettings();

            var rootElement         = new RootElement("Advexp.Settings Standard-iOS sample");
            var jsonSettingsElement = new MultilineElement(AssemblyClass.GetJSON());

            var boolElement = new BooleanElement("bool value",
                                                 AssemblyClass.BoolValue);

            boolElement.ValueChanged += (object sender, System.EventArgs e) =>
            {
                AssemblyClass.BoolValue = boolElement.Value;

                UpdateJSON(rootElement, jsonSettingsElement);
                AssemblyClass.SaveSettings();
            };

            var stringElement = new EntryElement("string value", "string value",
                                                 AssemblyClass.StringValue);

            stringElement.AutocorrectionType = UITextAutocorrectionType.No;
            stringElement.Changed           += (object sender, EventArgs e) =>
            {
                AssemblyClass.StringValue = stringElement.Value;

                UpdateJSON(rootElement, jsonSettingsElement);
                AssemblyClass.SaveSettings();
            };

            var enumElement = new RootElement("enum value", new RadioGroup((int)AssemblyClass.EnumValue));

            Action <RadioElementEx, EventArgs> enumDelegate = (sender, e) =>
            {
                AssemblyClass.EnumValue = (SampleEnum)enumElement.RadioSelected;

                UpdateJSON(rootElement, jsonSettingsElement);
                AssemblyClass.SaveSettings();
            };

            var enumsSection = new RootElement("enum value", new RadioGroup((int)AssemblyClass.EnumValue))
            {
                new Section()
                {
                    new RadioElementEx("Zero", enumDelegate),
                    new RadioElementEx("One", enumDelegate),
                    new RadioElementEx("Two", enumDelegate),
                    new RadioElementEx("Three", enumDelegate),
                    new RadioElementEx("Four", enumDelegate),
                    new RadioElementEx("Five", enumDelegate),
                    new RadioElementEx("Six", enumDelegate),
                    new RadioElementEx("Seven", enumDelegate),
                    new RadioElementEx("Eight", enumDelegate),
                    new RadioElementEx("Nine", enumDelegate),
                    new RadioElementEx("Ten", enumDelegate),
                }
            };

            enumElement.Add(enumsSection);

            var rootSection = new Section()
            {
                boolElement,
                stringElement,
                enumElement,
                jsonSettingsElement,
            };

            rootElement.Add(rootSection);

            var rootVC = new DialogViewController(rootElement);
            var nav    = new UINavigationController(rootVC);

            Window.RootViewController = nav;
            Window.MakeKeyAndVisible();

            return(true);
        }
Example #32
0
        public JobUnitUpgrade(RootElement root, WorkflowNavigationController nav, UsedPartsNavigationController upnav, bool pushing) : base(root, pushing)
        {
            NavUsedParts = upnav;
            NavWorkflow  = nav;
            DBParts      = new List <Part>();
            DBAssemblies = new List <Assembly> ();
            DeactivateEditingMode();

            Section        WarrantySection = new Section(" ");
            BooleanElement warrantyElement = new BooleanElement("Warranty", false);

            warrantyElement.ValueChanged += delegate {
                // this.NavWorkflow._tabs._jobRunTable.CurrentJob.Warranty = warrantyElement.Value;
                ThisJob.Warranty = warrantyElement.Value;
                if (this.NavWorkflow._tabs._jobRunTable.CurrentJob.Warranty)
                {
                    this.AddJobReport(true);
                }
            };
            WarrantySection.Add(warrantyElement);
            Root.Add(WarrantySection);

            Section UnitUpgradeTypeSection = new Section("");

            UnitUpgradeTypeSection.Add(new StyledStringElement("Use standard parts", "", UITableViewCellStyle.Value1));
            Root.Add(UnitUpgradeTypeSection);

            PartsSection AdditionalPartsSection = new PartsSection("Parts used", this);

            AdditionalPartsSection.Add(new StyledStringElement("Tap here to add a part"));

            Root.Add(AdditionalPartsSection);
            using (var image = UIImage.FromBundle("Images/19-gear")) this.TabBarItem.Image = image;
            this.Title = "Unit upgrade";

            ToolbarItems = new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.Reply),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Clear parts list", UIBarButtonItemStyle.Bordered, delegate { ClearPartsList(); }),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Action)
            };
            ToolbarItems[0].Clicked += delegate {
                if (NavUsedParts.Tabs._jobRunTable.CurrentJob.HasParent())                      // for child jobs, we jump to payment screen
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                }
                else                 // for main jobs we jump to pre-plumbing check
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[0];
                }
            };

            ToolbarItems[4].Clicked += delegate {
                if (ThisJob.JobReportAttached)
                {
                    if (JobReportDataValid())                           // check that pressure and comment fields have been filled
                    {
                        foreach (Section section in Root)
                        {
                            if (section is JobReportSection)
                            {
                                (section as JobReportSection).jrd.Pressure = Convert.ToInt32((section.Elements[1] as EntryElement).Value);
                                (section as JobReportSection).jrd.Comment  = (section.Elements[4] as MultilineEntryElement).Value;

                                SaveJobReport((section as JobReportSection).jrd);

                                // save the service report
                                nav._tabs._jobService.PdfListOfIssues = (UIView)this.TableView;
                                nav._tabs._jobService.GenerateServicePDFPreview();
                                nav._tabs._jobService.RedrawServiceCallPDF(false);
                            }
                        }

                        NavUsedParts.Tabs.LastSelectedTab        = NavUsedParts.Tabs.SelectedIndex;
                        NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                    }
                }
                else
                {
                    NavUsedParts.Tabs.LastSelectedTab        = NavUsedParts.Tabs.SelectedIndex;
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                }

                /*
                 * // save the job report (if there is one)
                 * if (ThisJob.JobReportAttached)
                 *      foreach(Section section in Root)
                 *              if (section is JobReportSection)
                 *                      SaveJobReport ( (section as JobReportSection).jrd );
                 *
                 * NavUsedParts.Tabs.LastSelectedTab = NavUsedParts.Tabs.SelectedIndex;
                 * NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3]; // jump to payment
                 */
            };
        }
Example #33
0
 public Element Calculate(BooleanElement x, BooleanElement y, OperatorElement o)
 {
     switch (o.)
     {