/// <summary> /// Invoked when it comes time to set the root so the child classes can create their own menus /// </summary> private void OnCreateMenu(RootElement root) { var addGistSection = new Section(); root.Add(addGistSection); addGistSection.Add(new MenuElement("New Gist", () => { var gistController = new CreateGistController(); gistController.Created = (id) => { NavigationController.PushViewController(new GistInfoController(id), true); }; var navController = new UINavigationController(gistController); PresentViewController(navController, true, null); }, Images.Buttons.NewGist)); var gistMenuSection = new Section() { HeaderView = new MenuSectionView("Gists") }; root.Add(gistMenuSection); gistMenuSection.Add(new MenuElement("My Gists", () => NavigationController.PushViewController(new MyGistsController(), true), Images.Buttons.MyGists)); gistMenuSection.Add(new MenuElement("Starred", () => NavigationController.PushViewController(new StarredGistsController(), true), Images.Buttons.Star2)); gistMenuSection.Add(new MenuElement("Public", () => NavigationController.PushViewController(new PublicGistsController(), true), Images.Buttons.Public)); // var labelSection = new Section() { HeaderView = new MenuSectionView("Tags") }; // root.Add(labelSection); // labelSection.Add(new MenuElement("Add New Tag", () => { }, null)); var moreSection = new Section() { HeaderView = new MenuSectionView("Info") }; root.Add(moreSection); moreSection.Add(new MenuElement("About", () => NavigationController.PushViewController(new AboutController(), true), Images.Buttons.Info)); moreSection.Add(new MenuElement("Feedback & Support", () => { var config = UserVoice.UVConfig.Create("http://gistacular.uservoice.com", "lYY6AwnzrNKjHIkiiYbbqA", "9iLse96r8yki4ZKknfHKBlWcbZAH9g8yQWb9fuG4"); UserVoice.UserVoice.PresentUserVoiceInterface(this, config); }, Images.Buttons.Feedback)); moreSection.Add(new MenuElement("Logout", Logout, Images.Buttons.Logout)); }
private void LoadTable() { var imageCount = Data.Database.Main.Table<ProjectImage>().Count(); var allPatternsButton = new StyledElement("All UI Images", imageCount.ToString(), UITableViewCellStyle.Value1); if (imageCount > 0) { allPatternsButton.Accessory = UITableViewCellAccessory.DisclosureIndicator; allPatternsButton.Tapped += () => NavigationController.PushViewController(new LocalViewPatternsViewController() { Title = "All" }, true); } var section = new Section("Albums"); var projects = Data.Database.Main.Table<Project>(); foreach (var p in projects) { var project = p; var element = new ProjectElement(project); if (Data.Database.Main.Table<ProjectImage>().Where(a => a.ProjectId == project.Id).Count() > 0) { element.Accessory = UITableViewCellAccessory.DisclosureIndicator; element.Tapped += () => { NavigationController.PushViewController(new LocalViewPatternsViewController(project.Id) { Title = project.Name }, true); }; } section.Add(element); } var root = new RootElement(Title) { new Section() { allPatternsButton }, section }; Root = root; }
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 = "Branch Matter Analysis" }; var view = new UIViewBordered (); view.Frame = new RectangleF (10, 20, 800, 48); view.Add (headerLabel); Root.Add (new Section (view)); // for (int i = 0; i < report.branches.Count; i++) { Branch branch = report.branches [i]; Section s = new Section (branch.name + " Branch Totals"); Root.Add (s); // if (branch.branchTotals.matterActivity != null) { var matterActivitySection = new Section (); var mTitle = new TitleElement ("Matter Activity"); matterActivitySection.Add (mTitle); matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.active, "Active Matters: ")); matterActivitySection.Add (new NumberElement ( branch.branchTotals.matterActivity.deactivated, "Deactivated Matters: " )); matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.newWork, "New Work: ")); matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.workedOn, "Worked On: ")); matterActivitySection.Add (new NumberElement (branch.branchTotals.matterActivity.noActivity, "No Activity: ")); matterActivitySection.Add (new StringElement ("No Activity Duration: " + branch.branchTotals.matterActivity.noActivityDuration)); Root.Add (matterActivitySection); } // if (branch.branchTotals.matterBalances != null) { var matterBalancesSection = new Section (); var mTitle = new TitleElement ("Matter Balances"); matterBalancesSection.Add (mTitle); matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.business, S.GetText (S.BUSINESS) + ": ")); matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.trust, S.GetText (S.TRUST_BALANCE) + ": ")); matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.investment, S.GetText (S.INVESTMENTS) + ": ")); matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.unbilled, "Unbilled: ")); matterBalancesSection.Add (getElement (branch.branchTotals.matterBalances.pendingDisbursements, "Pending Disb.: ")); Root.Add (matterBalancesSection); } } for (var i = 0; i < 10; i++) { Root.Add (new Section (" ")); } }
public ProvisioningDialog() : base(UITableViewStyle.Grouped, null) { Root = new RootElement ("GhostPractice Mobile"); var topSec = new Section ("Welcome"); topSec.Add (new StringElement ("Please enter activation code")); activation = new EntryElement ("Code", "Activation Code", "999998-zcrdbrkqwogh"); topSec.Add (activation); var submit = new StringElement ("Send Code"); submit.Alignment = UITextAlignment.Center; submit.Tapped += delegate { if (activation.Value == null || activation.Value == string.Empty) { new UIAlertView ("Device Activation", "Please enter activation code", null, "OK", null).Show (); return; } if (!isBusy) { getAsyncAppAndPlatform (); } else { Wait (); } }; topSec.Add (submit); Root.Add (topSec); UIImage img = UIImage.FromFile ("Images/launch_small.png"); UIImageView v = new UIImageView (new RectangleF (0, 0, 480, 600)); v.Image = img; Root.Add (new Section (v)); }
public void DemoHeadersFooters () { var section = new Section () { HeaderView = new UIImageView (UIImage.FromFile ("caltemplate.png")), #if !__TVOS__ FooterView = new UISwitch (new RectangleF (0, 0, 80, 30)), #endif // !__TVOS__ }; // Fill in some data var linqRoot = new RootElement ("LINQ source"){ from x in new string [] { "one", "two", "three" } select new Section (x) { from y in "Hello:World".Split (':') select (Element) new StringElement (y) } }; section.Add (new RootElement ("Desert", new RadioGroup ("desert", 0)){ new Section () { new RadioElement ("Ice Cream", "desert"), new RadioElement ("Milkshake", "desert"), new RadioElement ("Chocolate Cake", "desert") }, }); var root = new RootElement ("Headers and Footers") { section, new Section () { linqRoot } }; var dvc = new DialogViewController (root, true); navigation.PushViewController (dvc, true); }
// Load the list of lists and setup their events private Task RefreshAsync() { AppDelegate.AddActivity(); return this.db.Table<List>().ToListAsync().ContinueWith (t => { if (t.Exception != null) { BeginInvokeOnMainThread (ReloadComplete); AppDelegate.FinishActivity(); ShowError (t.Exception.Flatten().InnerException); return; } Section section = new Section(); section.AddAll (t.Result.Select (l => new StringElement (l.Name, () => { var tasks = new TasksViewController (this.db, l); NavigationController.PushViewController (tasks, true); }) ).Cast<Element>()); InvokeOnMainThread (() => { Root.Clear(); Root.Add (section); ReloadComplete(); AppDelegate.FinishActivity(); }); }); }
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 EnumChoiceElement <T> CreateEnumElement <T>(string title, T value) where T : struct, IConvertible { var element = new EnumChoiceElement <T>(title, value); element.Tapped += () => { var ctrl = new DialogViewController(new RootElement(title), true); ctrl.Title = title; ctrl.Style = MonoTouch.UIKit.UITableViewStyle.Grouped; var sec = new MonoTouch.Dialog.Section(); foreach (var x in System.Enum.GetValues(typeof(T)).Cast <System.Enum>()) { sec.Add(new MonoTouch.Dialog.StyledStringElement(x.Description(), () => { element.Value = (T)Enum.ToObject(typeof(T), x); NavigationController.PopViewControllerAnimated(true); }) { Accessory = object.Equals(x, element.Value) ? MonoTouch.UIKit.UITableViewCellAccessory.Checkmark : MonoTouch.UIKit.UITableViewCellAccessory.None }); } ctrl.Root = new MonoTouch.Dialog.RootElement(title) { sec }; NavigationController.PushViewController(ctrl, true); }; return(element); }
public OrderView(IntPtr handle) : base(handle) { Pushing = true; var deliveryLocationList = new Section(); deliveryLocationList.AddAll(from i in ViewModel.DeliveryLocationList select new RadioElement(i)); var titleList = new Section(); titleList.AddAll(from i in ViewModel.TitleList select new RadioElement(i)); var m = ViewModel; Root = new RootElement("Order") { new Section() { new RootElement("Deliver", new RadioGroup(0)) { deliveryLocationList } .Bind(bp, () => m.DeliveryLocation, listProperty: () => m.DeliveryLocationList) }, new Section() { new RootElement("Title", new RadioGroup(0)) { titleList } .Bind(bp, () => m.Title, listProperty: () => m.TitleList), new EntryElement("Name" , "First name", "") .Bind(bp, () => m.FirstName), // Note that you MUST specify "" for the initial element value; any other value will update the viewmodel property in a 2-way binding. new EntryElement(null , "Middle name", "").Bind(bp, () => m.MiddleName), new EntryElement(null , "Last name", "") .Bind(bp, () => m.LastName), new EntryElement("Address", "Street", "") .Bind(bp, () => m.Street), new EntryElement(null , "Zip", "") .Bind(bp, () => m.Zip), new EntryElement(null , "City", "") .Bind(bp, () => m.City), new EntryElement(null , "Country", "") .Bind(bp, () => m.Country), new EntryElement("Email" , "", "") .Bind(bp, () => m.Email), new EntryElement("Mobile" , "", "") .Bind(bp, () => m.Mobile), new EntryElement("Phone" , "", "") .Bind(bp, () => m.Phone) } }; }
private void FoundResults(ParseObject[] array, NSError error) { var easySection = new Section("Easy"); var mediumSection = new Section("Medium"); var hardSection = new Section("Hard"); var objects = array.Select(x=> x.ToObject<GameScore>()).OrderByDescending(x=> x.Score).ToList(); foreach(var score in objects) { var element = new StringElement(score.Player,score.Score.ToString("#,###")); switch(score.Dificulty) { case GameDificulty.Easy: easySection.Add(element); break; case GameDificulty.Medium: mediumSection.Add(element); break; case GameDificulty.Hard: hardSection.Add (element); break; } } Root = new RootElement("High Scores") { easySection, mediumSection, hardSection, }; }
public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); var what = new EntryElement ("What ?", "e.g. pizza", String.Empty); var where = new EntryElement ("Where ?", "here", String.Empty); var section = new Section (); if (CLLocationManager.LocationServicesEnabled) { lm = new CLLocationManager (); lm.LocationsUpdated += delegate (object sender, CLLocationsUpdatedEventArgs e) { lm.StopUpdatingLocation (); here = e.Locations [e.Locations.Length - 1]; var coord = here.Coordinate; where.Value = String.Format ("{0:F4}, {1:F4}", coord.Longitude, coord.Latitude); }; section.Add (new StringElement ("Get Current Location", delegate { lm.StartUpdatingLocation (); })); } section.Add (new StringElement ("Search...", async delegate { await SearchAsync (what.Value, where.Value); })); var root = new RootElement ("MapKit Search Sample") { new Section ("MapKit Search Sample") { what, where }, section }; window.RootViewController = new UINavigationController (new DialogViewController (root, true)); window.MakeKeyAndVisible (); return true; }
public SelectBin(int startBin) : base(UITableViewStyle.Grouped, null) { this.Pushing = true; Root = new RootElement ("Bin "+startBin+" - "+(startBin+14)) {}; //var bins = DBConnection.getBins(startBin); var section = new Section () { }; for(int i=0;i<15;i++){ var newBinID=startBin+i; var theBinElem=new StringElement("Bin "+newBinID,()=>{ Console.WriteLine("BinID is"+ newBinID); var theBin=new ModifyBin(newBinID); this.NavigationController.PushViewController(theBin,true); }); section.Add(theBinElem); } /* foreach(Bin bin in bins){ var newBinID=bin.binID; var theBinElem=new StringElement("Bin "+newBinID,()=>{ Console.WriteLine("BinID is"+ newBinID); var theBin=new ModifyBin(newBinID); this.NavigationController.PushViewController(theBin,true); }); section.Add(theBinElem); } */ Root.Add(section); }
public RepMaxView(Exercise exerciseToShow) : base("RepMaxView", null) { this._exercise = exerciseToShow; this._share = new RMShare(this); largestRMValue = 0.0; string dbname = "onerm.db"; string documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // This goes to the documents directory for your app string dbPath = Path.Combine (documents, dbname); db = new SQLiteConnection (dbPath); this.LoadRecords(); this._logRoot = new RootElement ("Records"); this._dvc = new DialogViewController (UITableViewStyle.Plain, this._logRoot, false); // load data from list this._logSect = new Section (); foreach (RmLog rm in this._rms) { StringElement recordString = new StringElement (rm.Weight.ToString(), rm.DateLogged.ToShortDateString()); this._logSect.Add(recordString); } this._logRoot.Add(this._logSect); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching (UIApplication app, NSDictionary options) { exampleInfoList = ExampleLibrary.Examples.GetList(); // create a new window instance based on the screen size window = new UIWindow (UIScreen.MainScreen.Bounds); navigation = new UINavigationController(); var root = new RootElement ("OxyPlot Example Browser"); var section = new Section (); section.AddAll (exampleInfoList .GroupBy (e => e.Category) .OrderBy (g => g.Key) .Select (g => (Element)new StyledStringElement (g.Key, delegate { DisplayCategory (g.Key); }) { Accessory = UITableViewCellAccessory.DisclosureIndicator })); root.Add (section); var dvc = new DialogViewController (root, true); navigation.PushViewController(dvc, true); window.RootViewController = navigation; // make the window visible window.MakeKeyAndVisible (); return true; }
RootElement GenerateRoot() { var favs = AppDelegate.UserData.GetFavoriteCodes(); var root = new RootElement ("Favorites".GetText()) { from s in MonkeySpace.Core.ConferenceManager.Sessions.Values.ToList () //AppDelegate.ConferenceData.Sessions where favs.Contains(s.Code ) group s by s.Start.Ticks into g orderby g.Key select new Section (HomeViewController.MakeCaption ("", new DateTime (g.Key))) { from hs in g select (Element) new SessionElement (hs) }}; if(favs.Count == 0) { /** * var logoView = new UIImageView(UIImage.FromFile("100x100_icon.png")); logoView.Alpha = .5f; logoView.Frame = new RectangleF(0,42,320,100); NavigationController.NavigationBar.Layer.AddSublayer(logoView.Layer); **/ var section = new Section("Whoops, Star a few sessions first!".GetText()); root.Add(section); } return root; }
public RootElement BuildRootWithLoop() { bankSelection = new RadioGroup (0); Section section = null; string lastLetter = ""; RootElement root = new RootElement("Pick your bank", bankSelection); foreach(var name in data) { string currentFirstLetter = name.Substring(0,1); if (currentFirstLetter != lastLetter) { if (section != null && section.Count > 0) root.Add (section); lastLetter = currentFirstLetter; section = new Section(currentFirstLetter); } section.Add (new RadioElement(name)); } if (section != null && section.Count > 0) root.Add (section); return root; }
public ParentListPickerElement(string caption, Item list) : base(caption, new RadioGroup(null, 0)) { lists = new List<Item>(); foreach (var f in App.ViewModel.Folders.OrderBy(f => f.SortOrder)) { lists.Add(new Item() { Name = f.Name, FolderID = f.ID, ID = Guid.Empty }); var s = new Section() { new RadioElement(f.Name, f.Name) }; // get all the lists in this folder except for the current list (if passed in) var folderlists = f.Items. Where(li => li.IsList == true && li.ItemTypeID != SystemItemTypes.Reference && (list == null || li.ID != list.ID)). OrderBy(li => li.Name).ToList(); foreach (var l in folderlists) lists.Add(l); var radioButtons = folderlists.Select(li => (Element) new RadioElement(" " + li.Name, f.Name)).ToList(); s.AddAll(radioButtons); this.Add(s); }; Item thisList = null; Guid listID = list != null && list.ParentID != null ? (Guid) list.ParentID : Guid.Empty; if (list != null && lists.Any(li => li.FolderID == list.FolderID && li.ID == listID)) thisList = lists.First(li => li.FolderID == list.FolderID && li.ID == listID); this.RadioSelected = thisList != null ? Math.Max(lists.IndexOf(thisList, 0), 0) : 0; }
public void RefreshCustomers() { this.Root.Clear(); this.Root.Add(new Section("") { new StringElement("Refresh", RefreshCustomers) }); var json = NSUserDefaults.StandardUserDefaults.StringForKey("customers"); if(string.IsNullOrWhiteSpace(json) == false) { Customers = JsonSerializer.DeserializeFromString<IEnumerable<Customer>>(json).ToList(); } if(Customers.Any()) { var section = new Section("Customers"); foreach(var customer in Customers) { var desc = string.Format("Customer Name: {0} -- Address: {1}", customer.Name, customer.Address); section.Add(new StringElement(desc)); } this.Root.Add(section); } using (var pool = new NSAutoreleasePool()) { pool.BeginInvokeOnMainThread(()=>{ this.ReloadData(); }); } }
// This method is invoked when the application has loaded its UI and its ready to run public override bool FinishedLaunching(UIApplication app, NSDictionary options) { load(); string[] s; mainMenu = new Section("Blogs", "Click for a new Account"); for(int i = 0; i < titles.Count; i++){ s = titles.ElementAt(i); var a = new Account( s[0], s[1], s[2] ); accounts.Add( a ); a.SetDelegate(this); mainMenu.Add( a.GetRoot() ); } var nb = new StringElement("new Account", NewBlog); nb.Alignment = UITextAlignment.Center; mainMenu.Add( nb ); var dv = new ExtDialogViewController ( new RootElement("Blogs"){ mainMenu } ) { Autorotate = true, DisableUpsideDown = true }; window.AddSubview (navigation.View); navigation.PushViewController (dv, true); window.MakeKeyAndVisible (); return true; }
public async override void ViewDidLoad () { base.ViewDidLoad (); // Open the folder for reading await Folder.OpenAsync (FolderAccess.ReadOnly); // Get the message summaries var summaries = await Folder.FetchAsync (0, -1, MessageSummaryItems.UniqueId | MessageSummaryItems.Envelope | MessageSummaryItems.InternalDate); var sectionMessages = new Section (); // Loop through all the message summaries foreach (var s in summaries) { // Add an item to the UI section/list sectionMessages.Add (new MessageElement (async (viewController, tableView, indexPath) => { // When a message is selected, fetch the actual message by UID var msg = await Folder.GetMessageAsync (summaries [indexPath.Row].UniqueId.Value); // Show the message details view controller viewMessageViewController = new MessageViewController (msg); NavigationController.PushViewController (viewMessageViewController, true); }) { Sender = s.Envelope.Sender.ToString (), Subject = s.Envelope.Subject, Body = "", Date = s.Envelope.Date.Value.LocalDateTime, NewFlag = false, MessageCount = 0, }); } Root.Clear (); Root.Add (sectionMessages); }
private void displayGenrePicker() { Section section = new Section(); foreach(string g in mCacheGenres) { section.Add(new CheckboxElement(g, true)); } var viewController = new DialogViewController ( new RootElement ("Select genres", new RadioGroup (0)){ section }, true); viewController.OnSelection += (NSIndexPath obj) => { string value = mCacheGenres[obj.Item]; if(mSelectedGenres.Contains(value)) { mSelectedGenres.Remove(value); } else { mSelectedGenres.Add(value); } if(mSelectedGenres.Count == 0 || mSelectedGenres.Count == mCacheGenres.Count) { ButtonGenre.SetTitle("All", UIControlState.Normal); } else { ButtonGenre.SetTitle(mSelectedGenres.Count+" selected", UIControlState.Normal); } }; NavigationController.PushViewController (viewController, true); }
public override void LoadView() { base.LoadView(); Utility = new XMUtilities(); Utility.SetCallback (new XMUtilityCallback (OurCallback)); var operandSection = new Section("Operands") { new EntryElement("Name: ", "", ""), new EntryElement("Operand One: ", "", ""), new EntryElement("Operand Two: ", "", ""), }; var operationSection = new Section("Operations") { new StringElement("Add", Handle_AddOperation), new StringElement("Multiply", Handle_MultiplyOperation), new StringElement("Hello", Handle_HelloOperation), new StringElement("Invoke Callback", Handle_InvokeCallback), }; var resultSection = new Section("Result") { new StringElement(@"") }; var customViewSection = new Section("More Bindings") { new StringElement("Go to CustomView!", () => { var c = new CustomViewController(); this.NavigationController.PushViewController(c, true); }) }; this.Root.Add(new Section[] { operandSection, operationSection, resultSection, customViewSection }); }
public override void LoadView() { base.LoadView(); _CustomView = new XMCustomView(); // This is the custom event we bound. // This is sometimes preferable to specifying a delegate. _CustomView.ViewWasTouched += Handle_CustomViewViewWasTouched; // The XMCustomViewDelegate we bound // If we specify this it will OVERRIDE the event handler we specified // _CustomView.Delegate = new CustomViewDelegate(); // The XMCustomView Name Property _CustomView.Name = @"Anuj"; // The instance method uses a frame calculation. _CustomView.Frame = new RectangleF(10, 25, 200, 200); // The instance method we bound. _CustomView.CustomizeViewWithText(string.Format(@"Yo {0}, I hurd you like bindings! MonoTouch makes it super easy with BTOUCH. Try it out!", _CustomView.Name ?? "Dawg")); var section = new Section("Custom View") { new CustomViewElement(_CustomView), }; this.Root.Add(section); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Forms.Init (); Window = new UIWindow(UIScreen.MainScreen.Bounds); rootElement = new RootElement("View.iOS - NetAtmo"); textSection = new Section(); buttonSection = new Section() { new StringElement("Refresh", () => { Refresh(); }) }; Refresh(); rootElement.Add(buttonSection); rootElement.Add(textSection); var rootVC = new DialogViewController(rootElement); var nav = new UINavigationController(rootVC); Window.RootViewController = nav; Window.MakeKeyAndVisible(); return true; }
/// <summary> /// Populates the page with sessions, grouped by time slot /// that are marked as 'favorite' /// </summary> protected override void PopulateTable() { // get the sessions from the database var sessions = BL.Managers.SessionManager.GetSessions (); var favs = BL.Managers.FavoritesManager.GetFavorites(); // extract IDs from Favorites query List<string> favoriteIDs = new List<string>(); foreach (var f in favs) favoriteIDs.Add (f.SessionKey); // build list, matching the Favorite.SessionKey with actual // Session.Key rows - which might have moved if the data changed var root = new RootElement ("Favorites") { from s in sessions where favoriteIDs.Contains(s.Key) group s by s.Start.Ticks into g orderby g.Key select new Section (new DateTime (g.Key).ToString ("dddd HH:mm")) { from hs in g select (Element) new SessionElement (hs) }}; if(root.Count == 0) { var section = new Section("No favorites") { new StyledStringElement("Touch the star to favorite a session") }; root.Add(section); } Root = root; }
// Creates the dynamic content from the twitter results RootElement CreateDynamicContent (XDocument doc) { var users = doc.XPathSelectElements ("./statuses/status/user").ToArray (); var texts = doc.XPathSelectElements ("./statuses/status/text").Select (x=>x.Value).ToArray (); var people = doc.XPathSelectElements ("./statuses/status/user/name").Select (x=>x.Value).ToArray (); var section = new Section (); var root = new RootElement ("Tweets") { section }; for (int i = 0; i < people.Length; i++){ var line = new RootElement (people [i]) { new Section ("Profile"){ new StringElement ("Screen name", users [i].XPathSelectElement ("./screen_name").Value), new StringElement ("Name", people [i]), new StringElement ("oFllowers:", users [i].XPathSelectElement ("./followers_count").Value) }, new Section ("Tweet"){ new StringElement (texts [i]) } }; section.Add (line); } return root; }
public override void ViewDidLoad() { base.ViewDidLoad(); RootElement root = Root; root.UnevenRows = true; UIImageView imageView = new UIImageView(View.Frame); //StringElement messageElement = new StringElement(""); Section imageSection = new Section() {imageView}; root.Add(new Section() { new StyledStringElement("Process", delegate { using (Mat resized = DrawSubdivision.Draw(Math.Min( (int) View.Frame.Width, (int) View.Frame.Height) , 20)) //using (Image<Bgr, Byte> resized = result.Resize((int)View.Frame.Width, (int)View.Frame.Height, Emgu.CV.CvEnum.INTER.CV_INTER_NN, true)) { imageView.Frame = new RectangleF(PointF.Empty, resized.Size); imageView.Image = resized.ToUIImage(); } //messageElement.Value = String.Format("Detection Time: {0} milliseconds.", processingTime); //messageElement.GetImmediateRootElement().Reload(messageElement, UITableViewRowAnimation.Automatic); imageView.SetNeedsDisplay(); this.ReloadData(); } )}); //root.Add(new Section() {messageElement}); root.Add(imageSection); }
public TankMix_History_Fill(List<Fill> Fills,int F) : base(UITableViewStyle.Grouped, null) { this.Pushing = true; Root = new RootElement ("Fills"); var Section = new Section (); for(int i=1; i<=F; i++) { var btn = new StringElement ("Fill "+i, string.Empty); btn.Tapped += () => { //this.NavigationController.PushViewController(new TankMix_CalculationCreateFill (Convert.ToInt32(btn.Caption.Split(' ')[1]),Fills,F),true); var index = Convert.ToInt32(btn.Caption.Split(' ')[1])-1; try{ this.NavigationController.PushViewController(new TankMix_CalculationCreateNewFill(Fills[index],index+1),true); }catch{ new UIAlertView ("Error", "This fill has no data !", null, "Continue").Show (); } }; Section.Add (btn); } Root.Add (Section); }
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 }); }
public override void LoadView () { base.LoadView (); var root = new RootElement ("TARP Banks"); var section = new Section () { (usOnlyToggle = new BooleanElement("Show only US banks", false)) }; root.Add (section); //make a section from the banks. Keep a reference to it root.Add ((bankListSection = BuildBankSection (usOnlyToggle.Value))); //if the toggle changes, reload the items usOnlyToggle.ValueChanged += (sender, e) => { var newListSection = BuildBankSection(usOnlyToggle.Value); root.Remove(bankListSection, UITableViewRowAnimation.Fade); root.Insert(1, UITableViewRowAnimation.Fade, newListSection); bankListSection = newListSection; }; Root = root; }
public override void ViewDidLoad() { base.ViewDidLoad(); _MainSection = new Section() { new ActivityElement() }; Root = new RootElement("Markers") { _MainSection }; // Simple demo of a progress HUD. Doesn't actually do anything useful. // Added after question from audience. MTMBProgressHUD progress = new MTMBProgressHUD() { DimBackground = true, LabelText = "Doing something.", }; View.Add(progress); progress.Show(animated: true); Task.Factory.StartNew(() => { Thread.Sleep(2000); InvokeOnMainThread(() => { progress.Hide(animated: true); }); }); mapController = new MapViewController(); mapController.NewMarkerCreated += (object sender, MarkerAddedEventArgs e) => { InvokeOnMainThread(() => { _Database.SaveMarker(e.MarkerInfo); RefreshMarkers(); }); }; RefreshMarkers(); }
protected override void AddElementsInCaseOfEmptyList(MonoTouch.Dialog.Section items) { if (!supplier.CredentialsStorage.IsLoggedIn) { base.AddElementsInCaseOfEmptyList(items); return; } var createTemplateSuggestion = new MultilineElement("Sources was't found. Tap to create source spreadsheet at your Google Drive "); createTemplateSuggestion.Tapped += () => { this.ExecuteAsync(supplier.CreateTemplate, () => { PopulateSources(); var dialod = new UIAlertView("Done", "Spreadsheet with name MemorizeIt was created at your Google Drive", null, "I got it!", null); dialod.Show(); }); }; items.Add(createTemplateSuggestion); }
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; NSAction 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]); }; } } string 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, AutocapitalizationType = ea.AutocapitalizationType, AutocorrectionType = ea.AutocorrectionType, ClearButtonMode = ea.ClearButtonMode } } ; 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) { ((StringElement)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; } CaptionAttribute 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++; } int 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) { foreach (object attr in attrs) { if (attr is RadioSelectionAttribute) { last_radio_index = mi; break; } } } 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); }
void LoadSectionElements(Section section, JsonArray array, object data) { if (array == null) { return; } for (int i = 0; i < array.Count; i++) { Element element = null; try { var json = array [i] as JsonObject; if (json == null) { continue; } var type = GetString(json, "type"); switch (type) { case "bool": case "boolean": element = LoadBoolean(json); break; case "entry": case "password": element = LoadEntry(json, type == "password"); break; case "string": element = LoadString(json, data); break; case "root": element = FromJson(this, json, data); break; case "radio": element = LoadRadio(json, data); break; case "checkbox": element = LoadCheckbox(json, data); break; case "datetime": case "date": case "time": element = LoadDateTime(json, type); break; case "html": element = LoadHtmlElement(json); break; default: Error("json element at {0} contain an unknown type `{1}', json {2}", i, type, json); break; } if (element != null) { var id = GetString(json, "id"); if (id != null) { AddMapping(id, element); } } } catch (Exception e) { Console.WriteLine("Error processing Json {0}, exception {1}", array, e); } if (element != null) { section.Add(element); } } }