private void CommentPropertyChanged() { try { if (viewModel.Comment != null) { if (!viewModel.DoUpdate && !viewModel.IsShowPostOptions) { var comment = viewModel.Comment; AddCommentToView(comment); } else if (viewModel.DoUpdate && !viewModel.IsShowPostOptions) { var commentItemsControl = ScrollViewElement.FindByName <StackLayout>("CommentItems"); var commentFound = commentsIndexValueList.Where(x => x.Comment.PostFeedID == viewModel.Comment.PostFeedID).FirstOrDefault(); if (commentFound != null) { commentFound.Comment = viewModel.Comment; } commentItemsControl.Children[commentFound.Index].FindByName <Label>("CommentLabel").Text = commentFound.Comment.ContentText; viewModel.DoUpdate = false; } } } catch (Exception ex) { if (!(ex.Source == "Xamarin.Forms.Core")) { throw; } } }
private void AddButtons() { for (int i = 0; i < itemList.Count; i++) { ScrollViewItem item = itemList[i]; GameObject newButton = ObjectPool.GetObject(); //Pool에서 가져온다. newButton.transform.SetParent(contentPanel); newButton.transform.localPosition = Vector3.zero; newButton.transform.localScale = Vector3.one; ScrollViewElement element = newButton.GetComponent <ScrollViewElement>(); element.Setup(item, this); // 초기화. } }
private void SelectedCommentPropertyChanged() { //chito. if the like is the parent post feed inside the details page, the no of supports doesnt work var commentItemsControl3 = ScrollViewElement.FindByName <StackLayout>("CommentItems"); if (commentsIndexValueList != null) { var commentFound3 = commentsIndexValueList.Where(x => x.Comment.PostFeedID == viewModel.SelectedComment.PostFeedID).FirstOrDefault(); if (commentFound3 != null) { commentFound3.Comment = viewModel.SelectedComment; commentItemsControl3.BindingContext = viewModel.SelectedComment; commentItemsControl3.Children[commentFound3.Index].FindByName <Label>("supportCount").Text = viewModel.SelectedComment.NoOfSupports.ToString() + " Supports"; } } }
private void DeleteCommentOption_Tapped(object sender, EventArgs e) { try { var commentItemsControl = ScrollViewElement.FindByName <StackLayout>("CommentItems"); var commentFound = commentsIndexValueList.Where(x => x.Comment.PostFeedID == viewModel.Comment.PostFeedID).FirstOrDefault(); var childrenStack = commentItemsControl.Children; commentItemsControl.Children.Remove(childrenStack[commentFound.Index]); commentsIndexValueList.Remove(commentFound); var mainPostCommentCount = ScrollViewElement.FindByName <Label>("parentCommentCount"); mainPostCommentCount.Text = childrenStack.Count + " Comments"; } catch (Exception ex) { viewModel.SendErrorToHockeyApp(ex); } }
private void AddCommentToView(Entity.PostFeed currentComment) { try { var commentItemsControl = ScrollViewElement.FindByName <StackLayout>("CommentItems"); commentItemsControl.Children.Add(new CommentItemTemplate { BindingContext = currentComment }); var moreOptionsGesture = commentItemsControl.Children[commentItemsControl.Children.Count - 1].FindByName <TapGestureRecognizer>("moreOptionsSupportGesture"); moreOptionsGesture.Command = viewModel.ShowPostOptionsCommand; moreOptionsGesture.CommandParameter = currentComment; var supportgesture = commentItemsControl.Children[commentItemsControl.Children.Count - 1].FindByName <TapGestureRecognizer>("commentItemSupportGesture"); supportgesture.Command = viewModel.SupportCommand; supportgesture.CommandParameter = currentComment; supportgesture.Tapped += SupportGesture_Tapped; if (commentsIndexValueList == null) { commentsIndexValueList = new List <CommentsIndexValue>(); } commentsIndexValueList.Add(new CommentsIndexValue { Comment = currentComment, Index = commentsIndexValueList.Count, IsLocallySaved = false }); var ellipsisContainer = commentItemsControl.Children.Last().FindByName <ContentView>("EllipsisContainer"); var ellipsisiCon = ellipsisContainer.FindByName <Label>("Ellipsis"); ellipsisiCon.IsVisible = false; if (currentComment.IsSelfPosted) { var grid = (CommentItemTemplate)ellipsisContainer.Parent; grid.IsEnabled = false; grid.Opacity = 0.25; } } catch (Exception ex) { viewModel.SendErrorToHockeyApp(ex); } }
private void SetupComments() { try { var comments = viewModel.CurrentPostFeed.Comments; if (comments != null && comments.Count > 0) { var commentItemsControl = ScrollViewElement.FindByName <StackLayout>("CommentItems"); commentsIndexValueList = new List <CommentsIndexValue>(); int index = 0; CommentItemTemplate widget; foreach (var comment in comments) { commentsIndexValueList.Add(new CommentsIndexValue { Comment = comment, Index = index, IsLocallySaved = true }); ++index; widget = new CommentItemTemplate { BindingContext = comment }; commentItemsControl.Children.Add(widget); var supportGesture = widget.FindByName <TapGestureRecognizer>("commentItemSupportGesture"); supportGesture.Command = viewModel.SupportCommand; supportGesture.CommandParameter = comment; supportGesture.Tapped += SupportGesture_Tapped; var moreOptionsGesture = widget.FindByName <TapGestureRecognizer>("moreOptionsSupportGesture"); moreOptionsGesture.Command = viewModel.ShowPostOptionsCommand; moreOptionsGesture.CommandParameter = comment; } } } catch (Exception ex) { viewModel.SendErrorToHockeyApp(ex); } }
public int TryGetIndexOwn(ScrollViewElement target) { if (target == null) { return(-1); } var vp = gameObject.FindChild("Viewport"); var cnt = vp.FindChild("Content"); var elements = cnt.ActiveChildren().Select((e) => { return(e.GetComponent <ScrollViewElement>()); }); int count = 0; foreach (var e in elements) { if (target == e) { return(count); } ++count; } return(-1); }
private void CurrentPostFeedPropertyChanged() { try { if (viewModel.LatestPostUpdatedPostFeedId > 0) { commentsIndexValueList.ToList().Last().Comment.PostFeedID = viewModel.LatestPostUpdatedPostFeedId; commentsIndexValueList.ToList().Last().Comment = viewModel.CurrentPostFeed.Comments.Last(); viewModel.LatestPostUpdatedPostFeedId = 0; var commentStack = ScrollViewElement.FindByName <StackLayout>("CommentItems"); var ellipsisContainer = commentStack.Children[commentsIndexValueList.ToList().Last().Index].FindByName <ContentView>("EllipsisContainer"); var ellipsis = ellipsisContainer.FindByName <Label>("Ellipsis"); var commentLabel = commentStack.Children[commentsIndexValueList.ToList().Last().Index].FindByName <Label>("CommentLabel"); commentsIndexValueList.ToList().Last().IsLocallySaved = true; Device.BeginInvokeOnMainThread(() => { var grid = (CommentItemTemplate)ellipsisContainer.Parent; grid.IsEnabled = true; grid.Opacity = 1; ellipsis.IsVisible = true; }); } var mainPostLikeCount = ScrollViewElement.FindByName <Label>("MainPostLikeCounter"); mainPostLikeCount.Text = viewModel.CurrentPostFeed.NoOfSupports.ToString() + " Supports"; } catch (Exception ex) { if (!(ex.Source == "Xamarin.Forms.Core")) { throw; } } }
protected override void Init() { mElement1 = GetComponent <ScrollViewElement>(); Assert.IsNotNull(mElement1); Assert.IsNotNull(mManager); }