示例#1
0
		/// <summary>
		/// Called only on user authentification
		/// </summary>
		private Element CreateLoadMore(Section section)
		{
           var loadMore2 = new AddLoadMoreWithImageElement("Add comment", ImageStore.DefaultImage, lme => {
				lme.FetchValue();
				if (!string.IsNullOrWhiteSpace(lme.Value))
				{			
					// Launch a thread to do some work
					ThreadPool.QueueUserWorkItem (delegate {
							AddNewCommentAsync(lme, section);
					});
				}
				else
					lme.Animating = false;
				
			});
			
			return loadMore2;
		}
示例#2
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;
		}
示例#3
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);
			}
		}