Insert() public method

public Insert ( int idx, UITableViewRowAnimation anim, IEnumerable newElements ) : int
idx int
anim UITableViewRowAnimation
newElements IEnumerable
return int
Ejemplo n.º 1
0
		public void DemoLoadMore () 
		{
			Section loadMore = new Section();
			loadMore.Add(new StringElement("Element 1"));
			loadMore.Add(new StringElement("Element 2"));
			loadMore.Add(new StringElement("Element 3"));
						
			
			loadMore.Add (new LoadMoreElement("Load More Elements...", "Loading Elements...", lme => {
				// Launch a thread to do some work
				ThreadPool.QueueUserWorkItem (delegate {
					
					// We just wait for 2 seconds.
					System.Threading.Thread.Sleep(2000);
				
					// Now make sure we invoke on the main thread the updates
					navigation.BeginInvokeOnMainThread(delegate {
						lme.Animating = false;
						loadMore.Insert(loadMore.Count - 1, new StringElement("Element " + (loadMore.Count + 1)),
				    		            new StringElement("Element " + (loadMore.Count + 2)),
				            		    new StringElement("Element " + (loadMore.Count + 3)));
					
					});
				});
				
			}, UIFont.BoldSystemFontOfSize(14.0f), UIColor.Blue));
							
			var root = new RootElement("Load More") {
				loadMore
			};
			
			var dvc = new DialogViewController (root, true);
			navigation.PushViewController (dvc, true);
		}
Ejemplo n.º 2
0
		private void SearchMoreKeywords(Section entries, CustomLoadMoreElement lme)
		{
			try
			{
				var images = SearchImages ();
				_foundImages.AddRange(images);
				
				int rowCount = 4;
				var newElements = new List<Images2Element>();
				for (int i = 0; i < images.Count; i += rowCount)
				{
					var imagesInfos = new List<ImageInfo>();
					for (int j = 0; j < rowCount; j++)
					{
						var imgInfo = new ImageInfo()
						{
							Img = (i + j < images.Count) ? images[i + j] : null,							
						};
						imagesInfos.Add(imgInfo);
					}
					
					newElements.Add(new Images2Element(imagesInfos, i));
				}
				
				InvokeOnMainThread(()=>
				{
					lme.Animating = false;
					entries.Insert(entries.Count - 1, UITableViewRowAnimation.None, newElements.ToArray());					
				});								
			}
			catch (Exception ex)
			{
				Util.LogException("SearchMoreKeywords", ex);
			}
		}
Ejemplo n.º 3
0
        private RootElement CreateRootElement()
        {
            var captionLabel = UIHelper.CreateLabel (
                "cross copy",
                true,
                32,
                32,
                UITextAlignment.Center,
                UIColor.Black
                );
            UILabel subcaptionLabel = UIHelper.CreateLabel (
                WELCOME_LABEL_TEXT,
                false,
                14,
                85,
                UITextAlignment.Center,
                lightTextColor
                );
            subcaptionLabel.Tag = 3;

            captionLabel.Frame = new Rectangle (0, 10, 320, 40);
            subcaptionLabel.Frame = new Rectangle (20, 55, 280, 100);
            UIView header = new UIView (new Rectangle (0, 0, 300, 145));
            header.AddSubviews (captionLabel, subcaptionLabel);

            var root = new RootElement ("Secrets")
            {
                new Section (header),
                (secretsSection = new Section ("Secrets")),
                new Section ()
                {
                    (secretEntry = new AdvancedEntryElement ("Secret", "enter new phrase", "", null))
                }
            };

            secretsSection.AddAll (from s in AppDelegate.HistoryData.Secrets select (Element)CreateImageButtonStringElement (s));

            secretEntry.AutocapitalizationType = UITextAutocapitalizationType.None;
            secretEntry.ShouldReturn += delegate {

                if (String.IsNullOrEmpty (secretEntry.Value))
                    return false;

                var newSecret = new Secret (secretEntry.Value);
                AppDelegate.HistoryData.Secrets.Add (newSecret);

                if (root.Count == 2)
                    root.Insert (1, secretsSection);

                secretsSection.Insert (
                    secretsSection.Elements.Count,
                    UITableViewRowAnimation.Fade,
                    CreateImageButtonStringElement (newSecret)
                    );
                secretEntry.Value = "";
                secretEntry.ResignFirstResponder (false);
                DisplaySecretDetail (newSecret);

                return true;
            };
            secretEntry.ReturnKeyType = UIReturnKeyType.Go;
            if (secretsSection.Count == 0) {
                secretEntry.BecomeFirstResponder (true);
                root.RemoveAt (1);
            }
            return root;
        }
Ejemplo n.º 4
0
        public void PopulateElements(LoadMoreElement lme, Section section, string typeLable, string valueLabel, UIKeyboardType entryKeyboardType, string deleteLabel, IList<string> labelList)
        {
            lme.Animating = false;

            var type = new StyledStringElement(typeLable) { Accessory = UITableViewCellAccessory.DetailDisclosureButton };
            section.Insert(section.Count - 1, type);
            var value = new EntryElement(null, valueLabel, null);
            value.KeyboardType = entryKeyboardType;
            section.Insert(section.Count - 1, value);

            var deleteButton = new StyledStringElement(deleteLabel)
            {
                TextColor = UIColor.Red,
            };

            deleteButton.Tapped += () =>
            {
                section.Remove(type);
                section.Remove(value);
                section.Remove(deleteButton);
            };

            // Show/Hide Delete Button
            var deleteButtonOn = false;
            type.AccessoryTapped += () =>
            {
                if (!deleteButtonOn)
                {
                    deleteButtonOn = true;
                    section.Insert(type.IndexPath.Row + 2, UITableViewRowAnimation.Bottom, deleteButton);
                }
                else
                {
                    deleteButtonOn = false;
                    section.Remove(deleteButton);
                }
            };

            type.Tapped += () =>
            {
                var labelScreen = new LabelListScreen(labelList);
                var navigation = new UINavigationController(labelScreen);
                NavigationController.PresentViewController(navigation, true, null);
            };
        }
Ejemplo n.º 5
0
		public UIViewController GetViewController ()
		{
			var menu = new RootElement ("Test Runner");
            
            var runMode = new Section("Run Mode");
            var interactiveCheckBox = new CheckboxElement("Enable Interactive Mode");
            interactiveCheckBox.Tapped += () => GraphicsTestBase.ForceInteractiveMode = interactiveCheckBox.Value;
            runMode.Add(interactiveCheckBox);
            menu.Add(runMode);

			Section main = new Section ("Loading test suites...");
			menu.Add (main);
			
			Section options = new Section () {
				new StyledStringElement ("Options", Options) { Accessory = UITableViewCellAccessory.DisclosureIndicator },
				new StyledStringElement ("Credits", Credits) { Accessory = UITableViewCellAccessory.DisclosureIndicator }
			};
			menu.Add (options);

			// large unit tests applications can take more time to initialize
			// than what the iOS watchdog will allow them on devices
			ThreadPool.QueueUserWorkItem (delegate {
				foreach (Assembly assembly in assemblies)
					Load (assembly, null);

				window.InvokeOnMainThread (delegate {

                    while (suite.Tests.Count == 1 && (suite.Tests[0] is TestSuite))
                        suite = (TestSuite)suite.Tests[0];

					foreach (TestSuite ts in suite.Tests) {
						main.Add (Setup (ts));
					}
					mre.Set ();
					
					main.Caption = null;
					menu.Reload (main, UITableViewRowAnimation.Fade);
					
					options.Insert (0, new StringElement ("Run Everything", Run));
					menu.Reload (options, UITableViewRowAnimation.Fade);
				});
				assemblies.Clear ();
			});
			
			var dv = new DialogViewController (menu) { Autorotate = true };

			// AutoStart running the tests (with either the supplied 'writer' or the options)
			if (AutoStart) {
				ThreadPool.QueueUserWorkItem (delegate {
					mre.WaitOne ();
					window.BeginInvokeOnMainThread (delegate {
						Run ();	
						// optionally end the process, e.g. click "Touch.Unit" -> log tests results, return to springboard...
						// http://stackoverflow.com/questions/1978695/uiapplication-sharedapplication-terminatewithsuccess-is-not-there
						if (TerminateAfterExecution)
							TerminateWithSuccess ();
					});
				});
			}
			return dv;
		}
Ejemplo n.º 6
0
		public UIViewController GetViewController ()
		{
			var menu = new RootElement ("Test Runner");
			
			Section main = new Section ("Loading test suites...");
			menu.Add (main);
			
			Section options = new Section () {
				new StyledStringElement ("Options", Options) { Accessory = UITableViewCellAccessory.DisclosureIndicator },
				new StyledStringElement ("Credits", Credits) { Accessory = UITableViewCellAccessory.DisclosureIndicator }
			};
			menu.Add (options);

			// large unit tests applications can take more time to initialize
			// than what the iOS watchdog will allow them on devices, so loading
			// must be done async.

			ThreadPool.QueueUserWorkItem ((v) => {
				LoadSync ();

				ExecuteOnMainThread (() =>
				{
					foreach (TestSuite ts in Suite.Tests) {
						main.Add (Setup (ts));
					}

					main.Caption = null;
					menu.Reload (main, UITableViewRowAnimation.Fade);

					options.Insert (0, new StringElement ("Run Everything", Run));
					menu.Reload (options, UITableViewRowAnimation.Fade);

					AutoRun ();
				});
			});

			return new DialogViewController (menu) { Autorotate = true };
		}
 void SetCaptionAndValue(Section section, int index, ref bool reload, string caption, string value)
 {
     if (index >= section.Count) {
         section.Insert (index, UITableViewRowAnimation.None, new StringElement (caption, value));
         reload = false;
     } else {
         StringElement element = section[index] as StringElement;
         element.Caption = caption;
         element.Value = value;
         Root.Reload (element, UITableViewRowAnimation.None);
     }
 }
Ejemplo n.º 8
0
		private Element CreateLoadMore(Section section)
		{
           var loadMore2 = new AddLoadMoreWithImageElement("Add keyword", ImageStore.DefaultImage, lme => {
				lme.FetchValue();
				if (!string.IsNullOrWhiteSpace(lme.Value))
				{			
					// Launch a thread to do some work
					ThreadPool.QueueUserWorkItem (delegate {
						try
						{
							var keyword = new Keyword()
							{
								Name = lme.Value,
								ParentId = _ImageID,
								//UserId = AppDelegateIPhone.AIphone.MainUser.Id,
								//Time = DateTime.UtcNow,
							};
							
							//	TODO : get the keyword id from the server. We need it
							//	TODO : for the deletion process
							AppDelegateIPhone.AIphone.KeywServ.PutNewKeyword(keyword);
						
							// Now make sure we invoke on the main thread the updates
							this.BeginInvokeOnMainThread(delegate {
								lme.Animating = false;
														
								var act = new KeywordElement(keyword.Name, keyword);
								section.Insert(1, act);
								lme.Value = null;							
							});
						}
						catch (Exception ex)
						{
							Util.LogException("Add keyword", ex);
							this.BeginInvokeOnMainThread(delegate {
								lme.Animating = false;
							});
						}					
					});
				}
				else
					lme.Animating = false;
				
			});
			
			return loadMore2;
		}
Ejemplo n.º 9
0
		private AddLoadMoreElement CreateLoadMore(Section section)
		{
           var loadMore2 = new AddLoadMoreElement("New keyword", lme => {
				lme.FetchValue();
				if (!string.IsNullOrWhiteSpace(lme.Value))
				{			
					ThreadPool.QueueUserWorkItem (delegate {						
						System.Threading.Thread.Sleep(200);					
						this.BeginInvokeOnMainThread(delegate {
							lme.Animating = false;
							section.Insert(1, new StringElement(lme.Value));							
							lme.Value = null;
						
						});
					
					});
				}
				else
					lme.Animating = false;
			});

			return loadMore2;
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Called only on user authentification
		/// </summary>
		private void AddNewCommentAsync(AddLoadMoreWithImageElement lme, Section section)
		{
			try
			{
				var comment = new Comment()
				{
					Name = lme.Value,
					ParentId = _ImageID,
					UserId = AppDelegateIPhone.AIphone.MainUser.Id,
					Time = DateTime.UtcNow,
				};
				
				AppDelegateIPhone.AIphone.CommentServ.PutNewComment(comment);
			
				// Now make sure we invoke on the main thread the updates
				this.BeginInvokeOnMainThread(delegate {
					lme.Animating = false;
											
					var uicomment = new UIComment()
					{
						Comment = comment,
						PhotoOwner = _photoOwner,
					};
					
					var act = new CommentElement(uicomment);
					section.Insert(1, act);
					lme.Value = null;							
				});
			}
			catch (Exception ex)
			{
				Util.LogException("Add comment", ex);
			}
		}