A version of the StringElement that can be styled with a number of formatting options and can render images or background images either from UIImage parameters or by downloading them from the net.
Inheritance: StringElement, IImageUpdated, IColorizeBackground
Exemplo n.º 1
0
        private void OnSearchResultsPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "Value")
                return;

            var results = this.viewModel.SearchResults;
            if (results != null)
                return;

            var value = results.Value;
            if (value != null)
                return;

            InvokeOnMainThread (() => {
                this.resultsSection.Clear();
                this.resultsSection.AddAll (value.Select (p => {
                    StyledStringElement element = null;
                    element = new StyledStringElement (p.Nickname, () => {
                        if (element.Accessory == UITableViewCellAccessory.Checkmark) {
                            element.Accessory = UITableViewCellAccessory.None;
                            this.selected.Remove (p);
                        } else {
                            element.Accessory = UITableViewCellAccessory.Checkmark;
                            this.selected.Add (p);
                        }
                    });

                    if (p.Status != Status.Online)
                        element.Font = UIFont.ItalicSystemFontOfSize (element.Font.PointSize);

                    return element;
                }));
            });
        }
		private void Initialize()
		{
			var loginWithWidgetBtn = new StyledStringElement ("Login with Widget", this.LoginWithWidgetButtonClick) {
				Alignment = UITextAlignment.Center
			};

			var loginWithConnectionBtn = new StyledStringElement ("Login with Google", this.LoginWithConnectionButtonClick) {
				Alignment = UITextAlignment.Center
			};

			var loginBtn = new StyledStringElement ("Login", this.LoginWithUsernamePassword) {
				Alignment = UITextAlignment.Center
			};

			this.resultElement = new StyledMultilineElement (string.Empty, string.Empty, UITableViewCellStyle.Subtitle);

			var login1 = new Section ("Login");
			login1.Add (loginWithWidgetBtn);
			login1.Add (loginWithConnectionBtn);

			var login2 = new Section ("Login with user/password");
			login2.Add (this.userNameElement = new EntryElement ("User", string.Empty, string.Empty));
			login2.Add (this.passwordElement = new EntryElement ("Password", string.Empty, string.Empty, true));
			login2.Add (loginBtn);

			var result = new Section ("Result");
			result.Add(this.resultElement);

			this.Root.Add (new Section[] { login1, login2, result });
		}
Exemplo n.º 3
0
        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);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            paymentDelegate = new PaymentViewControllerDelegate ();
            paymentDelegate.OnScanCompleted += (viewController, cardInfo) => {

                if (cardInfo == null) {
                    elemCardNumber.Caption = "xxxx xxxx xxxx xxxx";
                    Console.WriteLine("Cancelled");
                } else {
                    elemCardNumber.Caption = cardInfo.CardNumber;
                }

                ReloadData();

                paymentViewController.DismissViewController(true, null);
            };

            elemCardNumber = new StyledStringElement ("xxxx xxxx xxxx xxxx");

            Root = new RootElement ("card.io") {
                new Section {
                    elemCardNumber,
                    new StyledStringElement("Enter your Credit Card", () => {
                        paymentViewController = new PaymentViewController(paymentDelegate);
                        paymentViewController.AppToken = "YOUR-APP-TOKEN";

                        NavigationController.PresentViewController(paymentViewController, true, null);
                    }) { Accessory = UITableViewCellAccessory.DisclosureIndicator }
                }
            };
        }
Exemplo n.º 5
0
        public override void ViewWillAppear(bool animated)
        {
            var logAsStr = String.Format ("welcome {0} {1}, you have {2} credits",
                            string.IsNullOrWhiteSpace (ConfigurationWorker.LastMessage) ? "" : "back",
                            RestManager.AuthenticationResult.FirstName,
                            RestManager.AuthenticationResult.NumberOfCredits);
            loggedAsElement = new StyledMultilineElement (logAsStr);
            loggedAsElement.Font = UIFont.SystemFontOfSize (11);
            loggedAsElement.TextColor = UIColor.DarkGray;
            loggedAsElement.Tapped += delegate{
                NavigationController.PopViewControllerAnimated (animated:true);
            };

            _currentCamperStr = ConfigurationWorker.LastCamper.ToString ();
            _currentCabinStr = ConfigurationWorker.LastCabin.ToString ();

            _chooseCamper = new StyledStringElement ("camper", _currentCamperStr);
            _chooseCamper.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _chooseCamper.Tapped += () => NavigationController.PushViewController (new ChooseCamperScreen (), true);

            _chooseCabin = new StyledStringElement ("bunk", _currentCabinStr);
            _chooseCabin.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _chooseCabin.Tapped += () => NavigationController.PushViewController (new ChooseCabinScreen (), true);
            Root = GetRoot ();

            base.ViewWillAppear (animated);
        }
        public void buildReport()
        {
            Root = new RootElement ("");
            var v = new UIView ();
            v.Frame = new RectangleF (10, 10, 600, 10);
            var dummy = new Section (v);
            Root.Add (dummy);
            var headerLabel = new UILabel (new RectangleF (10, 10, 800, 48)) {
                Font = UIFont.BoldSystemFontOfSize (18),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Owner Fee Target Progress"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 20, 800, 48);
            view.Add (headerLabel);
            Root.Add (new Section (view));

            //			NumberFormatInfo nfi = new CultureInfo ("en-US", false).NumberFormat;

            for (int i = 0; i < report.branches.Count; i++) {
                Branch branch = report.branches [i];
                Section s = new Section (branch.name);
                //var t1 = new StringElement(branch.name + " Branch Totals");
                //s.Add(t1);
                Root.Add (s);

                for (int j = 0; j < branch.owners.Count; j++) {
                    Owner o = branch.owners [j];
                    Section ownerSection = new Section (o.name);
                    ownerSection.Add (new BigFinanceElement ("Invoiced MTD Total:  ", o.invoicedMTDTotal));
                    StyledStringElement recMTD = new StyledStringElement ("Recorded MTD");
                    recMTD.BackgroundColor = UIColor.LightGray;
                    recMTD.TextColor = UIColor.White;
                    ownerSection.Add (recMTD);
                    ownerSection.Add (getElement (o.recordedMTD.achieved, "Achieved:  "));
                    ownerSection.Add (getElement (o.recordedMTD.estimatedTarget, "Estimated Target:  "));
                    ownerSection.Add (getElement (o.recordedMTD.invoicedDebits, "Invoiced Debits:  "));
                    ownerSection.Add (getElement (o.recordedMTD.unbilled, "Unbilled:  "));
                    ownerSection.Add (getElement (o.recordedMTD.total, "Total:  "));
                    //
                    StyledStringElement recYTD = new StyledStringElement ("Recorded YTD");
                    recYTD.BackgroundColor = UIColor.LightGray;
                    recYTD.TextColor = UIColor.White;
                    ownerSection.Add (recYTD);
                    ownerSection.Add (getElement (o.recordedYTD.achieved, "Achieved:  "));
                    ownerSection.Add (getElement (o.recordedYTD.estimatedTarget, "Estimated Target:  "));
                    ownerSection.Add (getElement (o.recordedYTD.invoiced, "Invoiced:  "));
                    ownerSection.Add (getElement (o.recordedYTD.unbilled, "Unbilled:  "));
                    ownerSection.Add (getElement (o.recordedYTD.total, "Total:  "));

                    Root.Add (ownerSection);

                }
            }
            for (var i = 0; i < 10; i++) {
                Root.Add (new Section (" "));
            }
        }
Exemplo n.º 7
0
		void Search (string what, string where)
		{
			var coord = here == null ? Parse (where) : here.Coordinate;

			MKCoordinateSpan span = new MKCoordinateSpan (0.25, 0.25);
			MKLocalSearchRequest request = new MKLocalSearchRequest ();
			request.Region = new MKCoordinateRegion (coord, span);
			request.NaturalLanguageQuery = what;

			MKLocalSearch search = new MKLocalSearch (request);
			search.Start (delegate (MKLocalSearchResponse response, NSError error) {
				// this is executed in the application main thread
				if (response == null || error != null)
					return;

				var section = new Section ("Search Results for " + what);
				results.Clear ();
				foreach (MKMapItem mi in response.MapItems) {
					results.Add (mi);
					var element = new StyledStringElement (mi.Name, mi.PhoneNumber, UITableViewCellStyle.Subtitle);
					element.Accessory = UITableViewCellAccessory.DisclosureIndicator;
					element.Tapped += () => { results [element.IndexPath.Row].OpenInMaps (); };
					section.Add (element);
				}

				var root = new RootElement ("MapKit Search Sample") { section };
				var dvc = new DialogViewController (root);
				(window.RootViewController as UINavigationController).PushViewController (dvc, true);
			});
		}
Exemplo n.º 8
0
		public override void ViewDidLoad()
		{
			Title = "Edit Issue";

			base.ViewDidLoad();

            var status = new StyledStringElement("Status", ViewModel.Status, UITableViewCellStyle.Value1);
            status.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            status.Tapped += () => 
            {
                var ctrl = new IssueAttributesView(IssueModifyViewModel.Statuses, ViewModel.Status) { Title = "Status" };
                ctrl.SelectedValue = x => ViewModel.Status = x.ToLower();
                NavigationController.PushViewController(ctrl, true);
            };

            var delete = new StyledStringElement("Delete", () => ViewModel.DeleteCommand.Execute(null), Images.BinClosed) { BackgroundColor = UIColor.FromRGB(1.0f, 0.7f, 0.7f) };
            delete.Accessory = UITableViewCellAccessory.None;

            Root[0].Insert(1, UITableViewRowAnimation.None, status);
            Root.Insert(Root.Count, UITableViewRowAnimation.None, new Section { delete });

            ViewModel.Bind(x => x.Status, x => {
                status.Value = x;
                Root.Reload(status, UITableViewRowAnimation.None);
            }, true);
		}
Exemplo n.º 9
0
        public override void ViewDidLoad()
        {
            Title = "Profile";

            base.ViewDidLoad();

            var header = new HeaderView();
            var set = this.CreateBindingSet<ProfileView, ProfileViewModel>();
            set.Bind(header).For(x => x.Title).To(x => x.Username).OneWay();
            set.Bind(header).For(x => x.Subtitle).To(x => x.User.Name).OneWay();
            set.Bind(header).For(x => x.ImageUri).To(x => x.User.AvatarUrl).OneWay();
            set.Apply();

            var followers = new StyledStringElement("Followers".t(), () => ViewModel.GoToFollowersCommand.Execute(null), Images.Heart);
            var following = new StyledStringElement("Following".t(), () => ViewModel.GoToFollowingCommand.Execute(null), Images.Following);
            var events = new StyledStringElement("Events".t(), () => ViewModel.GoToEventsCommand.Execute(null), Images.Event);
            var organizations = new StyledStringElement("Organizations".t(), () => ViewModel.GoToOrganizationsCommand.Execute(null), Images.Group);
            var repos = new StyledStringElement("Repositories".t(), () => ViewModel.GoToRepositoriesCommand.Execute(null), Images.Repo);
            var gists = new StyledStringElement("Gists", () => ViewModel.GoToGistsCommand.Execute(null), Images.Script);

            Root.Add(new [] { new Section(header), new Section { events, organizations, followers, following }, new Section { repos, gists } });

            if (!ViewModel.IsLoggedInUser)
                NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu());
        }
        public StyledStringElement getEntryForKey(DateTime key)
        {
            StyledStringElement newExercise = new StyledStringElement (key.ToString() + " - " + this._rmLog[key].ToString(), () => { EditEntryScreen (key); });
            newExercise.Accessory = UITableViewCellAccessory.DisclosureIndicator;

            return newExercise;
        }
      public override void ViewDidLoad()
      {
         base.ViewDidLoad();
         RootElement root = Root;
         root.UnevenRows = true;

         _imageView = new UIImageView(View.Frame);
         _messageElement = new StringElement("");

         _button = new StyledStringElement("", delegate
         {
            if (OnButtonClick != null)
            {
               if (_progressView == null)
                  _progressView = new ProgressView();

               _progressView.Show("Please wait",
                  delegate()
               {
                  OnButtonClick(this, new EventArgs());
               });
            }
         }
         );
         root.Add(new Section() {_button });
         root.Add(new Section() {_messageElement});
         root.Add(new Section() {_imageView});
      }
Exemplo n.º 12
0
		public void DemoStyled () 
		{
			var imageBackground = new Uri ("file://" + Path.GetFullPath ("background.png"));
			var image = ImageLoader.DefaultRequestImage (imageBackground, null);
			var small = image.Scale (new SizeF (32, 32));
			
			var imageIcon = new StyledStringElement ("Local image icon") {
				Image = small
			};
			var backgroundImage = new StyledStringElement ("Image downloaded") {
				BackgroundUri = new Uri ("http://www.google.com/images/logos/ps_logo2.png")
			};
			var localImage = new StyledStringElement ("Local image"){
				BackgroundUri = imageBackground
			};
			
			var backgroundSolid = new StyledStringElement ("Solid background") {
				BackgroundColor = UIColor.Green
			};
			var colored = new StyledStringElement ("Colored", "Detail in Green") {
				TextColor = UIColor.Yellow,
				BackgroundColor = UIColor.Red,
				DetailColor = UIColor.Green,
			};
			var sse = new StyledStringElement ("DetailDisclosureIndicator") { Accessory = UITableViewCellAccessory.DetailDisclosureButton };
			sse.AccessoryTapped += delegate {
				var alertController = UIAlertController.Create ("Accessory", "Accessory clicked", UIAlertControllerStyle.Alert);
				alertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, (obj) => { }));
				window.RootViewController.PresentViewController (alertController, true, () => { });
			};
			var root = new RootElement("Styled Elements") {
				new Section ("Image icon"){
					imageIcon
				},
				new Section ("Background") { 
					backgroundImage, backgroundSolid, localImage
				},
				new Section ("Text Color"){
					colored
				},
				new Section ("Cell Styles"){
					new StyledStringElement ("Default", "Invisible value", UITableViewCellStyle.Default),
					new StyledStringElement ("Value1", "Aligned on each side", UITableViewCellStyle.Value1),
					new StyledStringElement ("Value2", "Like the Addressbook", UITableViewCellStyle.Value2),
					new StyledStringElement ("Subtitle", "Makes it sound more important", UITableViewCellStyle.Subtitle),
					new StyledStringElement ("Subtitle", "Brown subtitle", UITableViewCellStyle.Subtitle) {
						 DetailColor = UIColor.Brown
					}
				},
				new Section ("Accessories"){
					new StyledStringElement ("DisclosureIndicator") { Accessory = UITableViewCellAccessory.DisclosureIndicator },
					new StyledStringElement ("Checkmark") { Accessory = UITableViewCellAccessory.Checkmark },
					sse
				}
			};
			
			var dvc = new DialogViewController (root, true);
			navigation.PushViewController (dvc, true);
		}
Exemplo n.º 13
0
		private void CreateTable()
		{
			var application = Mvx.Resolve<IApplicationService>();
			var vm = (SettingsViewModel)ViewModel;
			var currentAccount = application.Account;
            var accountSection = new Section("Account");

            accountSection.Add(new TrueFalseElement("Save Credentials".t(), !currentAccount.DontRemember, e =>
            { 
                currentAccount.DontRemember = !e.Value;
                application.Accounts.Update(currentAccount);
            }));

			var showOrganizationsInEvents = new TrueFalseElement("Show Organizations in Events".t(), currentAccount.ShowOrganizationsInEvents, e =>
			{ 
				currentAccount.ShowOrganizationsInEvents = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var showOrganizations = new TrueFalseElement("List Organizations in Menu".t(), currentAccount.ExpandOrganizations, e =>
			{ 
				currentAccount.ExpandOrganizations = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var repoDescriptions = new TrueFalseElement("Show Repo Descriptions".t(), currentAccount.ShowRepositoryDescriptionInList, e =>
			{ 
				currentAccount.ShowRepositoryDescriptionInList = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, MonoTouch.UIKit.UITableViewCellStyle.Value1)
			{ 
				Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
			};
			startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);

            if (vm.PushNotificationsActivated)
                accountSection.Add(new TrueFalseElement("Push Notifications".t(), vm.PushNotificationsEnabled, e => vm.PushNotificationsEnabled = e.Value));

			var totalCacheSizeMB = vm.CacheSize.ToString("0.##");
			var deleteCache = new StyledStringElement("Delete Cache".t(), string.Format("{0} MB", totalCacheSizeMB), MonoTouch.UIKit.UITableViewCellStyle.Value1);
			deleteCache.Tapped += () =>
			{ 
				vm.DeleteAllCacheCommand.Execute(null);
				deleteCache.Value = string.Format("{0} MB", 0);
				ReloadData();
			};

			var usage = new TrueFalseElement("Send Anonymous Usage".t(), vm.AnalyticsEnabled, e => vm.AnalyticsEnabled = e.Value);

			//Assign the root
			var root = new RootElement(Title);
            root.Add(accountSection);
			root.Add(new Section("Appearance") { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
			root.Add(new Section ("Internal") { deleteCache, usage });
			Root = root;

		}
Exemplo n.º 14
0
 private Element Generate(StudentGuideModel item)
 {
     var root=new RootElement(item.Title);
     var section=new Section(item.Title);
     root.Add (section);
     if (item.Phone!="") {
         var phoneStyle = new StyledStringElement("Contact Number",item.Phone) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
         };
         phoneStyle.Tapped+= delegate {
             UIAlertView popup = new UIAlertView("Alert","Do you wish to send a text or diall a number?",null,"Cancel","Text","Call");
             popup.Show();
             popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                 if (e.ButtonIndex==1) {
                     MFMessageComposeViewController msg = new MFMessageComposeViewController();
                     msg.Recipients=new string[] {item.Phone};
                     this.NavigationController.PresentViewController(msg,true,null);
                 } else if (e.ButtonIndex==2) {
                     AppDelegate.getControl.calling(item.Phone);
                 };
             };
         };
         section.Add(phoneStyle);
     };
     if (item.Email!="") {
         var style = new StyledStringElement("Contact Email",item.Email) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
         };
         style.Tapped += delegate {
             MFMailComposeViewController email = new MFMailComposeViewController();
             email.SetToRecipients(new string[] {item.Email});
             this.NavigationController.PresentViewController(email,true,null);
         };
         section.Add (style);
     }
     if (item.Address!="") {
         section.Add(new StyledMultilineElement(item.Address) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
         });
     }
     if (item.Description!="") {
         section.Add (new StyledMultilineElement(item.Description) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
             Alignment=UITextAlignment.Center,
         });
     }
     return root;
 }
Exemplo n.º 15
0
		private StyledStringElement CreateStringElement(User user)
		{
			var element = new StyledStringElement(user.Name, user.UserInfo) {Accessory = UITableViewCellAccessory.DisclosureIndicator};
			element.Tapped += () => OnUserSelected(user);
			user.UserInfoUpdated += (sender, args) =>
			{
				element.Value = user.UserInfo;
			    element.Caption = user.Name;
				Root.TableView.ReloadData();
			};
			return element;
		}
		public UITabBarControllerWithTabContainingDialogViewController ()
		{
			tab1 = new UIViewController ();
			tab1.Title = "Green";
			tab1.View.BackgroundColor = UIColor.Green;

			tab2 = new UIViewController ();
			tab2.Title = "Orange";
			tab2.View.BackgroundColor = UIColor.Orange;

			tab3 = new UIViewController ();
			tab3.Title = "Red";
			tab3.View.BackgroundColor = UIColor.Red;
			
			#region Additional Info
//			tab1.TabBarItem = new UITabBarItem (UITabBarSystemItem.History, 0); // sets image AND text
//			tab2.TabBarItem = new UITabBarItem ("Orange", UIImage.FromFile("Images/first.png"), 1);
//			tab3.TabBarItem = new UITabBarItem ();
//			tab3.TabBarItem.Image = UIImage.FromFile("Images/second.png");
//			tab3.TabBarItem.Title = "Rouge"; // this overrides tab3.Title set above
//			tab3.TabBarItem.BadgeValue = "4";
//			tab3.TabBarItem.Enabled = false;
			#endregion


			RootElement re4 = new RootElement ("");
			re4.UnevenRows = true;

			Section re4_sec = new Section("");
			re4.Add(re4_sec);
			DialogViewController tab4 = new DialogViewController (UITableViewStyle.Plain, re4);
			tab4.Title = "DialogViewController";

			// Sample Data
			List<SectionalInformation> list_si;
			list_si = SectionalInformationDataFactory.SectionalInformation (); 

			foreach (SectionalInformation si  in list_si)
			{
				StyledStringElement sse = new StyledStringElement(si.Name, si.Elapsed.ToString());

				re4_sec.Add(sse);
			}

			var tabs = new UIViewController[] {
				tab4, tab1, tab2, tab3
			};

			ViewControllers = tabs;

			SelectedViewController = tab4; // normally you would default to the left-most tab (ie. tab1)
		}
        public void EndTest (TestMethod test)
        {
	        string output = this.testLog.ToString();
	        BeginInvokeOnMainThread (() => {
                var element = new StyledStringElement (test.Name,
                    () => NavigationController.PushViewController (new TestViewController (test, output), true));

                if (!test.Passed)
                    element.TextColor = UIColor.Red;

				this.testsSection.Add (element);
	        });
        }
		public MainViewController ()
			: base(null)
		{
			_hostNameElement = new EntryElement ("Target", "google.com", "") { TextAlignment = UITextAlignment.Right };
			_pingButtonElement = new StyledStringElement ("Ping"){ Alignment = UITextAlignment.Center };
			_pingButtonElement.Tapped += OnPingButtonClicked;

			Root = new MonoTouch.Dialog.RootElement ("SimplePing") {
				new Section () { 
					_hostNameElement,
					_pingButtonElement,
				}
			};
		}
Exemplo n.º 19
0
        private void LoadTable()
        {
            var section = new Section();
            var projects = Data.Database.Main.Table<Project>();
            foreach (var p in projects)
            {
                var project = p;
                var element = new StyledStringElement(project.Name, () => Save(project));
                section.Add(element);
            }

            var root = new RootElement(Title) { section };
            Root = root;
        }
Exemplo n.º 20
0
        public override void ViewDidLoad()
        {
            Title = "Groups".t();
            NoItemsText = "No Groups".t();

            base.ViewDidLoad();

			var vm = (GroupsViewModel) ViewModel;
			BindCollection(vm.Organizations, x =>
			{
				var e = new StyledStringElement(x.Name);
				e.Tapped += () => vm.GoToGroupCommand.Execute(x);
				return e;
			});
        }
Exemplo n.º 21
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			dvc = new DialogViewController (new RootElement ("Audio Queue Offline Render Demo") {
				new Section ("Audio Queue Offline Render Demo") {
				(element = new StyledStringElement ("Render audio", RenderAudioAsync) { Alignment = UITextAlignment.Center }),
				}
			});
			
			element.Alignment = UITextAlignment.Center;
			
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.RootViewController = dvc;
			window.MakeKeyAndVisible ();
			
			return true;
		}
Exemplo n.º 22
0
        public override void ViewDidLoad()
        {
            NoItemsText = "No Notifications".t();
            Title = "Notifications".t();

            base.ViewDidLoad();

            _markHud = new Hud(View);
            _segmentBarButton.Width = View.Frame.Width - 10f;
            ToolbarItems = new [] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _segmentBarButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) };

            var vm = (NotificationsViewModel)ViewModel;
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.CheckButton, UIBarButtonItemStyle.Plain, (s, e) => vm.ReadAllCommand.Execute(null));
            vm.ReadAllCommand.CanExecuteChanged += (sender, e) => NavigationItem.RightBarButtonItem.Enabled = vm.ReadAllCommand.CanExecute(null);

            vm.Bind(x => x.IsMarking, x =>
            {
                if (x)
                    _markHud.Show("Marking...");
                else
                    _markHud.Hide();
            });

            BindCollection(vm.Notifications, x =>
            {
                var el = new StyledStringElement(x.Subject.Title, x.UpdatedAt.ToDaysAgo(), UITableViewCellStyle.Subtitle) { Accessory = UITableViewCellAccessory.DisclosureIndicator };

                var subject = x.Subject.Type.ToLower();
                if (subject.Equals("issue"))
                    el.Image = Images.Flag;
                else if (subject.Equals("pullrequest"))
                    el.Image = Images.Hand;
                else if (subject.Equals("commit"))
                    el.Image = Images.Commit;
                else if (subject.Equals("release"))
                    el.Image = Images.Tag;
                else
                    el.Image = Images.Notifications;

                el.Tapped += () => vm.GoToNotificationCommand.Execute(x);
                return el;
            });

            var set = this.CreateBindingSet<NotificationsView, NotificationsViewModel>();
            set.Bind(_viewSegment).To(x => x.ShownIndex);
            set.Apply();
        }
Exemplo n.º 23
0
		private void LoadBuddies()
		{
			InvokeOnMainThread (() => {
				Root.First().Clear();

				lock (this.viewModel.Buddies) {
					var section = Root.First();
					section.AddAll (this.viewModel.Buddies.Select (p => {
						var element = new StyledStringElement (p.Nickname);
						if (p.Status != Status.Online)
							element.Font = UIFont.ItalicSystemFontOfSize (element.Font.PointSize);

						return element;
					}));
				}
			});
		}
Exemplo n.º 24
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            EnableCrashReporting ();

            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            _button = new StyledStringElement("Test");
            _button.Tapped += delegate {
                throw new Exception("test");
            };

            _rootElement = new RootElement("HockeyTest"){new Section(){_button} };
            _rootVc = new DialogViewController(_rootElement);
            _nav = new UINavigationController(_rootVc);
            Window.RootViewController = _rootVc;
            Window.MakeKeyAndVisible();
            return true;
        }
Exemplo n.º 25
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
            	
			elemCardNumber = new StyledStringElement ("xxxx xxxx xxxx xxxx");

			Root = new RootElement ("card.io") {
				new Section {
					elemCardNumber,
					new StyledStringElement("Enter your Credit Card", () => {
                        paymentViewController = new CardIOPaymentViewController (this);

						NavigationController.PresentViewController(paymentViewController, true, null);
					}) { Accessory = UITableViewCellAccessory.DisclosureIndicator }
				}
			};
		}
Exemplo n.º 26
0
        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;
        }
Exemplo n.º 27
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var model = _filterController.Filter.Clone();

            //Load the root
            var root = new RootElement(Title) {
                new Section("Filter") {
                    (_open = new TrueFalseElement("Open?", model.Open)),
                    (_labels = new InputElement("Labels", "bug,ui,@user", model.Labels) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_mentioned = new InputElement("Mentioned", "User", model.Mentioned) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_creator = new InputElement("Creator", "User", model.Creator) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_assignee = new InputElement("Assignee", "User", model.Assignee) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_milestone = new StyledStringElement("Milestone", "None", UITableViewCellStyle.Value1)),
                },
                new Section("Order By") {
                    (_sort = CreateEnumElement("Field", model.SortType)),
                    (_asc = new TrueFalseElement("Ascending", model.Ascending))
                },
                new Section(string.Empty, "Saving this filter as a default will save it only for this repository.") {
                    new StyledStringElement("Save as Default", () =>{
                        _filterController.ApplyFilter(CreateFilterModel(), true);
                        CloseViewController();
                    }, Images.Size) { Accessory = UITableViewCellAccessory.None },
                }
            };

            RefreshMilestone();

            _milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _milestone.Tapped += () => {
                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.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(ctrl, true);
            };

            Root = root;
        }
 private void PersistentObjectChanged(PersistentObject obj)
 {
     if (IsViewLoaded)
     {
         if (obj.GetType() == typeof(UserCredentials))
         {
             if (_ownTimetable == null)
             {
                 _ownTimetable = new StyledStringElement(ApplicationSettings.Instance.UserCredentials.Name, OnOwnTapped){
                     Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator
                 };
                 Root.Add(new Section("Eigener Stundenplan"){_ownTimetable});
             }
             else
             {
                 _ownTimetable.Caption = ApplicationSettings.Instance.UserCredentials.Name;
             }
         }
         else if (obj.GetType() == typeof(UserTimetableList))
         {
             if (_otherTimetables == null)
             {
                 _otherTimetables = new Section("Andere Stundenpläne");
                 Root.Add(_otherTimetables);
             }
             if (!obj.Equals(_loadedList))
             {
                 _otherTimetables.Clear();
                 foreach (var o in ApplicationSettings.Instance.UserTimetablelist.Usernames)
                 {
                     var tmp = o;
                     _otherTimetables.Add(new StyledStringElement(o, () => {
                         OnTapped(tmp);
                     }){
                         Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator
                     });
                 }
                 _loadedList = new UserTimetableList(){
                     Usernames = new ObservableCollection<string>((obj as UserTimetableList).Usernames)
                 };
             }
         }
         this.ReloadData();
     }
 }
		public ExampleListViewController () : base (UITableViewStyle.Grouped, null)
		{

			Root = new RootElement ("Examples");

			var indexList = Path.Combine (NSBundle.MainBundle.BundlePath, "IndexList.json");

			//var json = JArray.Parse (File.ReadAllText (indexList));
			var json = JsonArray.Parse (File.ReadAllText (indexList));

			var titleList = new string[] {
				"ImageRecognition",
				"3dAndImageRecognition",
				"PointOfInterest",
				"ObtainPoiData",
				"BrowsingPois",
				"Video",
				"Demo"
			};


			for (int i = 0; i < titleList.Length; i++)
			{
				var title = titleList [i];

				var indexArr = (JsonArray)json [i];

				var section = new Section (title);

				foreach (var jobj in indexArr)
				{
					var elem = new StyledStringElement (jobj["Title"].ToString().Trim('"'), () =>
					{
						var path = jobj["Path"].ToString().Trim('"');
						var vc = jobj["ViewController"].ToString().Trim('"');
					
						arController = new ARViewController(path, false);
						NavigationController.PushViewController(arController, true);
					});
					section.Add (elem);
				}

				Root.Add (section);
			}
		}
Exemplo n.º 30
0
        public override void ViewDidLoad()
        {
            Title = "Files";
            NoItemsText = "No Files".t();

            base.ViewDidLoad();

            var vm = (PullRequestFilesViewModel) ViewModel;
            BindCollection(vm.Files, x =>
            {
                var name = x.Filename.Substring(x.Filename.LastIndexOf("/", System.StringComparison.Ordinal) + 1);
                var el = new StyledStringElement(name, x.Status, UITableViewCellStyle.Subtitle);
                el.Image = Images.File;
                el.Accessory = UITableViewCellAccessory.DisclosureIndicator;
				el.Tapped += () =>  vm.GoToSourceCommand.Execute(x);
                return el;
            });
        }
Exemplo n.º 31
0
        //
        // Creates one of the various StringElement classes, based on the
        // properties set.   It tries to load the most memory efficient one
        // StringElement, if not, it fallsback to MultilineStringElement or
        // StyledStringElement
        //
        static Element LoadString(JsonObject json, object data)
        {
            string   value = null;
            string   caption = value;
            string   background = null;
            NSAction ontap = null;
            NSAction onaccessorytap = null;
            int?     lines = null;
            UITableViewCellAccessory?accessory = null;
            UILineBreakMode?         linebreakmode = null;
            UITextAlignment?         alignment = null;
            UIColor textcolor = null, detailcolor = null;
            UIFont  font = null;
            UIFont  detailfont         = null;
            UITableViewCellStyle style = UITableViewCellStyle.Value1;

            foreach (var kv in json)
            {
                string kvalue = (string)kv.Value;
                switch (kv.Key)
                {
                case "caption":
                    caption = kvalue;
                    break;

                case "value":
                    value = kvalue;
                    break;

                case "background":
                    background = kvalue;
                    break;

                case "style":
                    style = ToCellStyle(kvalue);
                    break;

                case "ontap":
                case "onaccessorytap":
                    string sontap = kvalue;
                    int    p      = sontap.LastIndexOf('.');
                    if (p == -1)
                    {
                        break;
                    }
                    NSAction d = delegate {
                        string cname = sontap.Substring(0, p);
                        string mname = sontap.Substring(p + 1);
                        foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
                        {
                            Type type = a.GetType(cname);

                            if (type != null)
                            {
                                var mi = type.GetMethod(mname, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                                if (mi != null)
                                {
                                    mi.Invoke(null, new object [] { data });
                                }
                                break;
                            }
                        }
                    };
                    if (kv.Key == "ontap")
                    {
                        ontap = d;
                    }
                    else
                    {
                        onaccessorytap = d;
                    }
                    break;

                case "lines":
                    int res;
                    if (int.TryParse(kvalue, out res))
                    {
                        lines = res;
                    }
                    break;

                case "accessory":
                    accessory = ToAccessory(kvalue);
                    break;

                case "textcolor":
                    textcolor = ParseColor(kvalue);
                    break;

                case "linebreak":
                    linebreakmode = ToLinebreakMode(kvalue);
                    break;

                case "font":
                    font = ToFont(kvalue);
                    break;

                case "subtitle":
                    value = kvalue;
                    style = UITableViewCellStyle.Subtitle;
                    break;

                case "detailfont":
                    detailfont = ToFont(kvalue);
                    break;

                case "alignment":
                    alignment = ToAlignment(kvalue);
                    break;

                case "detailcolor":
                    detailcolor = ParseColor(kvalue);
                    break;

                case "type":
                    break;

                default:
                    Console.WriteLine("Unknown attribute: '{0}'", kv.Key);
                    break;
                }
            }
            if (caption == null)
            {
                caption = "";
            }
            if (font != null || style != UITableViewCellStyle.Value1 || detailfont != null || linebreakmode.HasValue || textcolor != null || accessory.HasValue || onaccessorytap != null || background != null || detailcolor != null)
            {
                StyledStringElement styled;

                if (lines.HasValue)
                {
                    styled       = new StyledMultilineElement(caption, value, style);
                    styled.Lines = lines.Value;
                }
                else
                {
                    styled = new StyledStringElement(caption, value, style);
                }
                if (ontap != null)
                {
                    styled.Tapped += ontap;
                }
                if (onaccessorytap != null)
                {
                    styled.AccessoryTapped += onaccessorytap;
                }
                if (font != null)
                {
                    styled.Font = font;
                }
                if (detailfont != null)
                {
                    styled.SubtitleFont = detailfont;
                }
                if (detailcolor != null)
                {
                    styled.DetailColor = detailcolor;
                }
                if (textcolor != null)
                {
                    styled.TextColor = textcolor;
                }
                if (accessory.HasValue)
                {
                    styled.Accessory = accessory.Value;
                }
                if (linebreakmode.HasValue)
                {
                    styled.LineBreakMode = linebreakmode.Value;
                }
                if (background != null)
                {
                    if (background.Length > 1 && background [0] == '#')
                    {
                        styled.BackgroundColor = ParseColor(background);
                    }
                    else
                    {
                        styled.BackgroundUri = new Uri(background);
                    }
                }
                if (alignment.HasValue)
                {
                    styled.Alignment = alignment.Value;
                }
                return(styled);
            }
            else
            {
                StringElement se;
                if (lines == 0)
                {
                    se = new MultilineElement(caption, value);
                }
                else
                {
                    se = new StringElement(caption, value);
                }
                if (alignment.HasValue)
                {
                    se.Alignment = alignment.Value;
                }
                if (ontap != null)
                {
                    se.Tapped += ontap;
                }
                return(se);
            }
        }