public override void Init(Texture2D appIcon, string postFix, float scaleFactor)
        {
            this.appIcon = appIcon;

            this.postFix = postFix;

            this.scaleFactor = scaleFactor;

            frameGroupConference = ((GameObject)Instantiate(prfbGUIFrameGroupConference)).GetComponent<FresviiGUIFrame>();

            frameGroupConference.Init(appIcon, postFix, scaleFactor, FASGui.GuiDepthBase);

            frameGroupConference.transform.parent = this.transform;

            frameGroupConference.Position = Vector2.zero;

            CurrentFrame = frameGroupConference;
        }
        public void Draw(Rect position)
        {
            if (Player != null)
            {
                if (Player.User != null)
                {
                    if (!string.IsNullOrEmpty(Player.User.ProfileImageUrl) && userIcon == null && !userIconLoading)
                    {
                        LoadUserIcon();
                    }
                    else if (Player.User.ProfileImageUrl != userProfileUrl && !userIconLoading)
                    {
                        FresviiGUIManager.Instance.resourceManager.ReleaseTexture(userProfileUrl);

                        LoadUserIcon();
                    }
                }
            }

            CalcLayout(position.width);

            GUI.BeginGroup(position);

            GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width, position.height), palette, texCoordsBackground);

            //  UserIcon -----------------------
            if (Event.current.type == EventType.Repaint)
            {
                userMask.color = new Color(1f, 1f, 1f, 1f);

                Graphics.DrawTexture(userIconPosition, ((userIcon == null) ? userIconDefault : userIcon), userMask);
            }

            if (buttonUserIcon.IsTap(Event.current, userIconPosition))
            {
                if (Player != null)
                {
                    if (Player.User != null)
                    {
                        if (nextFrame == null)
                        {
                            if (Player.User.Id == FAS.CurrentUser.Id)
                            {
                                nextFrame = ((GameObject)Instantiate(prfbGUIFrameMyProfile)).GetComponent<FresviiGUIFrame>();
                            }
                            else
                            {
                                nextFrame = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                                nextFrame.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(Player.User);
                            }

                            nextFrame.Init(null, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, parentFrame.GuiDepth - 100);
                        }

                        nextFrame.transform.parent = this.transform;

                        nextFrame.SetDraw(true);

                        nextFrame.PostFrame = parentFrame;

                        parentFrame.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                        {
                            parentFrame.SetDraw(false);
                        });

                        nextFrame.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
                    }
                }
            }

            //  User name -----------------------
            if (Player != null)
            {
                contentUserName = new GUIContent(Player.User.Name);

                if (frameMatchMaking.State != FresviiGUIMatchMaking.Mode.Matching)
                {
                    guiStyleUserName.alignment = TextAnchor.MiddleLeft;

                    if (Player.User.Id == FAS.CurrentUser.Id)
                    {
                        GUI.Label(userNamePosition, contentUserName, guiStyleUserName);

                        GUI.DrawTexture(tagPosition, frameMatchMaking.textureTagYou);

                        GUI.Label(tagPosition, tagString, guiStyleTag);
                    }
                    else
                    {
                        GUI.Label(userNamePosition, contentUserName, guiStyleUserName);
                    }
                }
                else
                {
                    if (Player.User.Id == FAS.CurrentUser.Id)
                    {
                        guiStyleUserName.alignment = TextAnchor.MiddleLeft;

                        GUI.Label(userNamePosition, contentUserName, guiStyleUserName);

                        GUI.DrawTexture(tagPosition, frameMatchMaking.textureTagYou);

                        GUI.Label(tagPosition, tagString, guiStyleTag);
                    }
                    else
                    {
                        guiStyleUserName.alignment = TextAnchor.LowerLeft;

                        GUI.Label(playerNamePosition, contentUserName, guiStyleUserName);

                        if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Invited)
                        {
                            GUI.Label(palyerStatusPosition, FresviiGUIText.Get("PlayerStatusInvited"), guiStylePlayerStatus);
                        }
                        else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Accepted)
                        {
                            GUI.Label(palyerStatusPosition, FresviiGUIText.Get("PlayerStatusAccepted"), guiStylePlayerStatus);
                        }
                        else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Cancelled)
                        {
                            GUI.Label(palyerStatusPosition, FresviiGUIText.Get("PlayerStatusCancelled"), guiStylePlayerStatus);
                        }
                        else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Matching)
                        {
                            GUI.Label(palyerStatusPosition, FresviiGUIText.Get("PlayerStatusMatching"), guiStylePlayerStatus);
                        }
                        else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Declined)
                        {
                            GUI.Label(palyerStatusPosition, FresviiGUIText.Get("PlayerStatusDeclined"), guiStylePlayerStatus);
                        }
                    }
                }
            }
            else if (frameMatchMaking.State == FresviiGUIMatchMaking.Mode.Setting)
            {
                contentUserName = new GUIContent(FresviiGUIText.Get("InviteFriend"));

                GUI.Label(userNamePosition, contentUserName, guiStyleText);
            }
            else if (frameMatchMaking.State == FresviiGUIMatchMaking.Mode.Matching && Player == null)
            {
                contentUserName = new GUIContent(FresviiGUIText.Get("AutoMatch"));

                GUI.Label(userNamePosition, contentUserName, guiStyleText);
            }

            GUI.EndGroup();

            if (buttonCard.IsTap(Event.current, position) && frameMatchMaking.State == FresviiGUIMatchMaking.Mode.Setting)
            {
                frameMatchMaking.SelectFriends();
            }
        }
        public void Draw(float cardWidth)
        {
            if(deleteAnimationDone) return;

            if(Thread.User != null)
            {
                if (!string.IsNullOrEmpty(Thread.User.ProfileImageUrl) && userIcon == null && !userIconLoading)
                {
                    LoadUserIcon();
                }
                else if (userProfileUrl != Thread.User.ProfileImageUrl && !userIconLoading)
                {
                    FresviiGUIManager.Instance.resourceManager.ReleaseTexture(userProfileUrl);

                    LoadUserIcon();
                }
            }

            menuButtonPosition = new Rect(cardWidth - menuButtonMargin - FresviiGUIForum.TexForumMenu.width, menuButtonMargin, FresviiGUIForum.TexForumMenu.width, FresviiGUIForum.TexForumMenu.height);

            menuButtonHitPosition = new Rect(cardWidth - 44f * scaleFactor, 0f, 44f * scaleFactor, 44f * scaleFactor);

            userNamePosition.width = cardWidth - userNamePosition.x - menuButtonHitPosition.width;

            SetUserName();

            Rect drawPosition = GetPosition();

            if (drawPosition.y + drawPosition.height < 0 || drawPosition.y > Screen.height)
            {
                return;
            }

            Event e = Event.current;

            Color origColor = GUI.color;

            GUI.color = new Color(origColor.r, origColor.g, origColor.b, cardAlpha);

            if ((!string.IsNullOrEmpty(Thread.Comment.ImageThumbnailUrl) || Thread.Comment.VideoState != Fresvii.AppSteroid.Models.Comment.VideoStatus.NA) && clipImage == null && !clipImageLoading)
            {
                ClipImageLoad();
            }

            //  Update proc
            if(Thread.User != null)
            {
                if (contentUserName.text != Thread.User.Name || preCardWidth != cardWidth)
                {
                    SetUserName();
                }
            }

            if (contentCommentText.text != Thread.Comment.Text || preCardWidth != cardWidth)
            {
                SetCommentText(cardWidth);
            }

            GUI.BeginGroup(position);

            //	background
            GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width, position.height), palette, texCoordsLine);

            GUI.DrawTextureWithTexCoords(new Rect(position.width * 0.5f - lineWidth * 0.5f, position.height - bottomButtonHeight, lineWidth, bottomButtonHeight), palette, texCoordsLine);

            GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width, position.height - bottomButtonHeight - lineWidth), palette, texCoordsBackground);

            GUI.DrawTextureWithTexCoords(new Rect(0f, position.height - bottomButtonHeight, position.width, bottomButtonHeight), palette, texCoordsBackground);

            if(buttonUserIcon.IsTap(e, userIconHitPosition))
            //if (buttonUserIcon.IsTap(e, userIconPosition, userIconHitPosition, FresviiGUIButton.ButtonType.TextureOnly, textureUserIcon, textureUserIcon, textureUserIcon))
            {
                if(Application.internetReachability == NetworkReachability.NotReachable){

                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"),delegate(bool del) { });

                    return;
                }

                if (frameProfile == null)
                {
                    if (Thread.User.Id == FAS.CurrentUser.Id)
                    {
                        frameProfile = ((GameObject)Instantiate(prfbGUIFrameMyProfile)).GetComponent<FresviiGUIFrame>();
                    }
                    else
                    {
                        frameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                        frameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(Thread.User);
                    }

                    frameProfile.Init(null, postFix, scaleFactor, Forum.GuiDepth);

                    frameProfile.transform.parent = this.transform;
                 }

                Forum.GoToUserProfile(frameProfile);
            }

            //  User Name
            GUI.Label(userNamePosition, contentUserName, guiStyleUserName);

            // Menu button
            if(buttonMenu.IsTap(e, menuButtonPosition, menuButtonHitPosition, FresviiGUIButton.ButtonType.TextureOnly, FresviiGUIForum.TexForumMenu, FresviiGUIForum.TexForumMenu, FresviiGUIForum.TexForumMenuH))
            {
                List<string> buttons = new List<string>();

                buttons.Add((IsSubscribed()) ? FresviiGUIText.Get("Unsubscribe") : FresviiGUIText.Get("Subscribe"));

                if(IsMine())
                    buttons.Add(FresviiGUIText.Get("Delete"));

                popUpBaloonMenu = ((GameObject)Instantiate(Resources.Load("GuiPrefabs/PopUpBalloonMenu"))).GetComponent<Fresvii.AppSteroid.Gui.PopUpBalloonMenu>();

                Vector2 popupBalloonPosition = popUpOffset + new Vector2(scrollViewRect.x + menuButtonPosition.x, scrollViewRect.y - Forum.forumTopMenu.height + menuButtonPosition.y) + FresviiGUIFrame.OffsetPosition;

                popUpBaloonMenu.Show(buttons.ToArray(), popupBalloonPosition, scaleFactor, postFix, Forum.GuiDepth - 10, Color.black, Color.white, Color.white, delegate(string selectedButton)
                {
                    if (selectedButton == FresviiGUIText.Get("Unsubscribe"))
                    {
                        this.Unsubscribe();
                    }
                    else if (selectedButton == FresviiGUIText.Get("Subscribe"))
                    {
                        this.Subscribe();
                    }
                    else if (selectedButton == FresviiGUIText.Get("Delete"))
                    {
                        this.DeleteThread(false);
                    }
                });
            }

            if (popUpBaloonMenu != null)
            {
                popUpBaloonMenu.SetPosition(popUpOffset + new Vector2(scrollViewRect.x + position.x + menuButtonPosition.x, scrollViewRect.y - Forum.forumTopMenu.height + position.y + menuButtonPosition.y + FresviiGUIFrame.OffsetPosition.y));
            }

            //  -----------------------
            System.TimeSpan ts = Thread.CreateTimeSpan();

            GUIContent contentTimeSpan;

            if (ts.Days > 1)
                contentTimeSpan = new GUIContent(ts.Days + " " + FresviiGUIText.Get("days") + FresviiGUIText.Get("ago"));
            else if (ts.Days > 0)
                contentTimeSpan = new GUIContent(ts.Days + " " + FresviiGUIText.Get("day") + FresviiGUIText.Get("ago"));
            else if (ts.Hours > 1)
                contentTimeSpan = new GUIContent(ts.Hours + " " + FresviiGUIText.Get("hours") + FresviiGUIText.Get("ago"));
            else if (ts.Hours > 0)
                contentTimeSpan = new GUIContent(ts.Hours + " " + FresviiGUIText.Get("hour") + FresviiGUIText.Get("ago"));
            else if (ts.Minutes > 1)
                contentTimeSpan = new GUIContent(ts.Minutes + " " + FresviiGUIText.Get("minutes") + FresviiGUIText.Get("ago"));
            else if (ts.Minutes > 0)
                contentTimeSpan = new GUIContent(ts.Minutes + " " + FresviiGUIText.Get("minute") + FresviiGUIText.Get("ago"));
            else
                contentTimeSpan = new GUIContent(FresviiGUIText.Get("now"));

            timespanPosition.width = guiStyleTimeSpan.CalcSize(contentTimeSpan).x;

            GUI.Label(timespanPosition, contentTimeSpan, guiStyleTimeSpan);

            likeCountIconPosition.x = timespanPosition.x + timespanPosition.width + margin;

            GUI.DrawTexture(likeCountIconPosition, FresviiGUIForum.TexForumLikeS);

            likeCountLabelPosition.x = likeCountIconPosition.x + FresviiGUIForum.TexForumLikeS.width + miniMargin;

            GUIContent contentLabelLikeCount = new GUIContent(Thread.Comment.LikeCount.ToString());

            GUI.Label(likeCountLabelPosition, contentLabelLikeCount, guiStyleTimeSpan);

            commentCountIconPosition.x = likeCountLabelPosition.x + guiStyleTimeSpan.CalcSize(contentLabelLikeCount).x + margin;

            GUI.DrawTexture(commentCountIconPosition, FresviiGUIForum.TexForumCommentS);

            commentCountLabelPosition.x = commentCountIconPosition.x + FresviiGUIForum.TexForumCommentS.width + miniMargin;

            GUI.Label(commentCountLabelPosition, Thread.CommentCount.ToString(), guiStyleTimeSpan);

            //  -----------------------
            GUI.Label(commentTextPosition, contentCommentText, guiStyleCommentText);

            if (clipImage != null)
            {
                Color tmpColor = GUI.color;

                GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, Mathf.Min(cardAlpha, clipAlpha));

                clipImagePosition.x = drawPosition.width * 0.5f - imageHeight * 0.5f;

                clipImagePosition.width = clipImagePosition.height = imageHeight;

                GUI.DrawTexture(clipImagePosition, clipImage, ScaleMode.ScaleAndCrop);

                GUI.color = tmpColor;

                if (IsVideo && clipAlpha >= 0.9f && Thread.Comment.VideoState != Fresvii.AppSteroid.Models.Comment.VideoStatus.Removed)
                {
                    videoPlaybackIconPosition = new Rect(clipImagePosition.x + 0.4f * clipImagePosition.width, clipImagePosition.y + 0.4f * clipImagePosition.height, 0.2f * clipImagePosition.width, 0.2f * clipImagePosition.height);

                    GUI.DrawTexture(videoPlaybackIconPosition, FresviiGUIForum.TexVideoPlaybackIcon, ScaleMode.ScaleToFit);
                }

                if (dataUploading)
                {
                    progressBarPosition = new Rect(clipImagePosition.x, clipImagePosition.y + clipImagePosition.height - scaleFactor * 1.0f, clipImagePosition.width * dataUploadingProgress, scaleFactor * 1.0f);

                    GUI.DrawTextureWithTexCoords(progressBarPosition, palette, texCoodsProgressBar);
                }
            }

            // Line
            //GUI.DrawTextureWithTexCoords(new Rect(0, position.height - bottomButtonHeight - lineWidth, position.width, lineWidth), palette, texCoordsLine);

            // Comment button
            if (!string.IsNullOrEmpty(Thread.Id))
            {
                Texture2D texComenntButton = FresviiGUIForum.TexForumCommentL;

                Rect commentButtonPosition = new Rect(position.width * 0.25f - texComenntButton.width * 0.5f, position.height - 0.5f * bottomButtonHeight - texComenntButton.height * 0.5f, texComenntButton.width, texComenntButton.height);

                Rect commentButtonHitPosition = new Rect(0f, position.height - bottomButtonHeight, position.width * 0.5f, bottomButtonHeight);

                if (buttonComment.IsTap(e, commentButtonPosition, commentButtonHitPosition, FresviiGUIButton.ButtonType.TextureOnly, FresviiGUIForum.TexForumCommentL, FresviiGUIForum.TexForumCommentL, FresviiGUIForum.TexForumCommentLH))
                {
                    if (frameThread == null)
                    {
                        frameThread = ((GameObject)Instantiate(prfbGUIFrameThread)).GetComponent<FresviiGUIThread>();

                        frameThread.SetThread(this);

                        frameThread.Init(null, postFix, scaleFactor, Forum.GuiDepth);

                        frameThread.transform.parent = this.transform;
                    }

                    Forum.GoToThread(frameThread, true);
                }
            }

            Texture2D texLikeButton = (isLike) ? FresviiGUIForum.TexForumLikeLH : FresviiGUIForum.TexForumLikeL;

            Rect likeButtonHitPosition = new Rect(position.width * 0.5f, position.height - bottomButtonHeight, position.width * 0.5f, bottomButtonHeight);

            Rect likeButtonPosition = new Rect(position.width * 0.75f - texLikeButton.width * 0.5f, position.height - 0.5f * bottomButtonHeight - texLikeButton.height * 0.5f, texLikeButton.width, texLikeButton.height);

            if(buttonLike.IsTap(e, likeButtonPosition, likeButtonHitPosition, FresviiGUIButton.ButtonType.TextureOnly, texLikeButton, texLikeButton, texLikeButton))
            {
                isLike = !isLike;

                if (isLike)
                {
                    Thread.Comment.LikeCount++;

                    StartCoroutine(ThreadLikeCoroutine());
                }
                else
                {
                    if (Thread.Comment.LikeCount > 0) Thread.Comment.LikeCount--;

                    StartCoroutine(ThreadUnlikeCoroutine());
                }

                if (frameThread != null)
                {
                    if (frameThread.Thread.Id == Thread.Id)
                    {
                        if (frameThread.cards.Count > 0)
                        {
                            frameThread.cards[0].isLike = isLike;
                            if (isLike)
                            {
                                frameThread.cards[0].Comment.LikeCount++;
                            }
                            else
                            {
                                if (frameThread.cards[0].Comment.LikeCount > 0)
                                {
                                    frameThread.cards[0].Comment.LikeCount--;
                                }
                            }
                        }
                    }
                }
            }

            // Line
            GUI.DrawTextureWithTexCoords(new Rect(position.width * 0.5f - lineWidth * 0.5f, position.height - bottomButtonHeight, lineWidth, bottomButtonHeight), palette, texCoordsLine);

            if (buttonCard.IsTap(e, new Rect(0, 0, position.width, position.height)) && !string.IsNullOrEmpty(Thread.Id))
            {
                if(Application.internetReachability == NetworkReachability.NotReachable){

                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"),delegate(bool del) { });

                    return;
                }

                if (frameThread == null)
                {
                    frameThread = ((GameObject)Instantiate(prfbGUIFrameThread)).GetComponent<FresviiGUIThread>();

                    frameThread.SetThread(this);

                    frameThread.Init(null, postFix, scaleFactor, Forum.GuiDepth);

                    frameThread.transform.parent = this.transform;
                }
                else
                {
                    frameThread.gameObject.SetActive(true);
                }

                Forum.GoToThread(frameThread, true);
            }

            //  User Icon
            if (Event.current.type == EventType.Repaint)
            {
                userIconMaterial.color = new Color(1f, 1f, 1f, cardAlpha);

                Graphics.DrawTexture(userIconPosition, ((userIcon == null) ? userIconDefault : userIcon), userIconMaterial);
            }

            GUI.EndGroup();

            GUI.color = origColor;

            preCardWidth = cardWidth;
        }
        private IEnumerator WaitForSend(Fresvii.AppSteroid.Models.Group group)
        {
            while (imageSending || commentSending) yield return 1;

            loadingSpinner.Hide();

            ControlLock = false;

            Back();

            if (!IsCreateFromPairGroup)
            {
                PostFrame.gameObject.GetComponent<FresviiGUIGroupMessage>().GoToGroupChat(group);
            }
            else
            {
                if (frameChat != null)
                    Destroy(frameChat);

                frameChat = ((GameObject)Instantiate(prfbFrameChat)).GetComponent<FresviiGUIFrame>();

                frameChat.gameObject.GetComponent<FresviiGUIChat>().SetGroup(group);

                frameChat.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, this.PostFrame.GuiDepth - 1);

                frameChat.transform.parent = this.transform;

                frameChat.SetDraw(true);

                frameChat.PostFrame = this.PostFrame;

                this.ControlLock = true;

                this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                {
                    this.SetDraw(false);

                    this.ControlLock = false;
                });

                frameChat.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
            }
        }
        private void GoToGroupMessage(bool animation)
        {
            frameGroupList = ((GameObject)Instantiate(prfbGroupList)).GetComponent<FresviiGUIFrame>();

            frameGroupList.transform.parent = this.transform;

            frameGroupList.Init(null, postFix, this.scaleFactor, this.GuiDepth - 1);

            frameGroupList.SetDraw(true);

            frameGroupList.PostFrame = this;

            if (animation)
            {
                this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), moveDelayTime, delegate()
                {
                    this.SetDraw(false);
                });

                frameGroupList.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, moveDelayTime, delegate() { });
            }
            else
            {
                this.Position = new Vector2(-Screen.width, 0.0f);

                this.SetDraw(false);

                frameGroupList.Position = Vector2.zero;
            }
        }
        public override void Init(Texture2D appIcon, string postFix, float scaleFactor, int guiDepth)
        {
            this.GuiDepth = guiDepth;

            this.scaleFactor = scaleFactor;

            this.postFix = postFix;

            textureCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.MainBackground);

            userProfileTopMenu = GetComponent<FresviiGUIMyProfileTopMenu>();

            tabBar = GetComponent<FresviiGUITabBar>();

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleLabelUserName.font = null;
                guiStyleLabelUserName.fontStyle = FontStyle.Bold;
                guiStyleLabelUserProfile.font = null;
                guiStyleButtonFriend.font = null;
                guiStyleButtonMessage.font = null;
                guiStyleFriendNotification.font = null;
                guiStyleFriendMenuTitle.font = null;
                guiStyleFriendMenuTitle.fontStyle = FontStyle.Bold;
                guiStyleLabelUserCode.font = null;
            }

            palette = FresviiGUIColorPalette.Palette;

            userProfileTopMenu.Init(appIcon, postFix, scaleFactor,this, GuiDepth - 1);

            tabBar.Init(postFix, scaleFactor, this.GuiDepth - 1);

            sideMargin *= scaleFactor;
            vMargin *= scaleFactor;
            margin *= scaleFactor;
            miniMargin *= scaleFactor;
            profileImageBgMargin *= scaleFactor;
            myProfileImageSize *= scaleFactor;
            topMargin *= scaleFactor;
            friendNotificationHeight *= scaleFactor;
            friendMenuTitleBarHeight *= scaleFactor;
            hMargin *= scaleFactor;
            loadingSpinnerSize *= scaleFactor;

            profileImageSize *= scaleFactor;

            guiStyleLabelUserName.fontSize = (int)(guiStyleLabelUserName.fontSize * scaleFactor);
            guiStyleLabelUserName.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.ProfileUserName);

            guiStyleLabelUserCode.fontSize = (int)(guiStyleLabelUserCode.fontSize * scaleFactor);

            guiStyleLabelUserCode.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.ProfileUserName);

            guiStyleLabelUserProfile.fontSize = (int)(guiStyleLabelUserProfile.fontSize * scaleFactor);
            guiStyleLabelUserProfile.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.ProfileDescription);
            
            guiStyleFriendNotification.fontSize = (int)(guiStyleFriendNotification.fontSize * scaleFactor);
            guiStyleFriendNotification.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.ProfileNotificationText);
            
            guiStyleFriendMenuTitle.fontSize = (int)(guiStyleFriendMenuTitle.fontSize * scaleFactor);

            guiStyleFriendMenuTitle.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.ProfileFriendBarText);

            guiStyleFriendMenuTitle.padding = FresviiGUIUtility.RectOffsetScale(guiStyleFriendMenuTitle.padding, scaleFactor);

            textureMyProfileDefault = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.UserTextureName + postFix, false);

            texCoordsNotificationBg = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.ProfileNotificationBackground);

            texCoordsFriendTitleBg = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.ProfileFriendBarBackground);

            texCoordsFriendTitleBgH = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.ProfileFriendBarBackgroundH);

            texCoordsFriendTitleLine = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.ProfileFriendBarLine);

            textureRight = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.RightIconTextureName + postFix, false);

            scrollPosition = Vector2.zero;

            frameMyProfileEdit = ((GameObject)Instantiate(prfbGUIFrameMyProfileEdit)).GetComponent<FresviiGUIFrame>();

            guiEdit = frameMyProfileEdit.gameObject.GetComponent<FresviiGUIMyProfileEdit>();

            frameMyProfileEdit.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, GuiDepth - 20);
            
            frameMyProfileEdit.GetComponent<FresviiGUIMyProfileEdit>().SetGUIMyProfile(this);
            
            frameMyProfileEdit.transform.parent = this.transform;
            
            frameMyProfileEdit.SetDraw(false);
           
            textureMyProfileCircle = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.UserCircleTextureName + postFix, false);

            loadingSpinnerPosition = new Rect(Screen.width * 0.5f - loadingSpinnerSize.x * 0.5f, Screen.height * 0.5f - loadingSpinnerSize.y * 0.5f, loadingSpinnerSize.x, loadingSpinnerSize.y);

            loadingSpinner = Fresvii.AppSteroid.Gui.LoadingSpinner.Show(loadingSpinnerPosition, FASGui.GuiDepthBase);

            GetAccout();

            SetScrollSlider(scaleFactor * 2.0f);

            requestLabelContent = new GUIContent(FresviiGUIText.Get("FriendRequests"));

            friendCountLabelContent = new GUIContent(FresviiGUIText.Get("Friends"));

            videoListLabelContent = new GUIContent(FresviiGUIText.Get("Videos"));

            directMessageListLabelContent = new GUIContent(FresviiGUIText.Get("DirectMessages"));
            
        }
        private void GoToVideoList(bool animation)
        {
            frameVideoList = ((GameObject)Instantiate(prfbGUIFrameVideoList)).GetComponent<FresviiGUIFrame>();

            FresviiGUIVideoList fresviiGUIVideoList = frameVideoList.gameObject.GetComponent<FresviiGUIVideoList>();

            fresviiGUIVideoList.IsModal = false;

            fresviiGUIVideoList.mode = FresviiGUIVideoList.Mode.Share;

            frameVideoList.transform.parent = this.transform;

            frameVideoList.Init(null, postFix, this.scaleFactor, this.GuiDepth - 1);

            frameVideoList.SetDraw(true);

            frameVideoList.PostFrame = this;

            if (animation)
            {
                this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), moveDelayTime, delegate()
                {
                    this.SetDraw(false);
                });

                frameVideoList.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, moveDelayTime, delegate() { });
            }
            else
            {
                frameVideoList.Position = Vector2.zero;

                this.SetDraw(false);
            }
        }
        public void Draw(Rect position, bool tagDraw)
        {
            if (!this.gameObject.activeInHierarchy) return;

            if (rank.Score.User != null)
            {
                if (rank.Score.User.Id == FAS.CurrentUser.Id)
                {
                    if (FAS.CurrentUser.ProfileImageUrl != userProfileUrl && !userIconLoading)
                    {
                        FresviiGUIManager.Instance.resourceManager.ReleaseTexture(userProfileUrl);

                        LoadUserIcon();
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(rank.Score.User.ProfileImageUrl) && userIcon == null && !userIconLoading && !iconError)
                    {
                        LoadUserIcon();
                    }
                    else if (rank.Score.User.ProfileImageUrl != userProfileUrl && !userIconLoading && !iconError)
                    {
                        FresviiGUIManager.Instance.resourceManager.ReleaseTexture(userProfileUrl);

                        LoadUserIcon();
                    }
                }
            }

            CalcLayout(position.width);

            GUI.BeginGroup(position);

            GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width, position.height), palette, texCoordsBackground);

            //  rank
            if (rank.Ranking < 4)
            {
                GUI.DrawTexture(medalPosition, frameLeaderboard.textureMedal);
            }

            GUI.Label(rankPosition, rank.Ranking.ToString(), guiStyleRank);

            //  UserIcon -----------------------
            if (Event.current.type == EventType.Repaint)
            {
                userMask.color = new Color(1f, 1f, 1f, 1.0f);

                Graphics.DrawTexture(userIconPosition, ((userIcon == null) ? userIconDefault : userIcon), userMask);
            }

            //  User name -----------------------
            GUI.Label(userNamePosition, contentUserName, guiStyleUserName);

            GUI.Label(scoreLabelPosition, rank.Score.FormattedValue, guiStyleScore);

            if (tagDraw)
            {
                if (tagKind == TagKind.Friend)
                {
                    GUI.DrawTexture(tagPosition, frameLeaderboard.textureTagFriend);

                    GUI.Label(tagPosition, tagString, guiStyleTag);
                }
                else if (tagKind == TagKind.You)
                {
                    GUI.DrawTexture(tagPosition, frameLeaderboard.textureTagYou);

                    GUI.Label(tagPosition, tagString, guiStyleTag);
                }
            }

            GUI.EndGroup();

            if (buttonCard.IsTap(Event.current, position))
            {
                if (rank.Score.User != null)
                {
                    if (nextFrameProfile == null)
                    {
                        if (rank.Score.User.Id == FAS.CurrentUser.Id)
                        {
                            nextFrameProfile = ((GameObject)Instantiate(prfbGUIFrameMyProfile)).GetComponent<FresviiGUIFrame>();
                        }
                        else
                        {
                            nextFrameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                            nextFrameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(rank.Score.User);
                        }

                        nextFrameProfile.Init(null, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, FASGui.GuiDepthBase);

                        nextFrameProfile.transform.parent = this.transform;
                    }

                    nextFrameProfile.SetDraw(true);

                    nextFrameProfile.PostFrame = parentFrameProfile;

                    parentFrameProfile.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                    {
                        parentFrameProfile.SetDraw(false);
                    });

                    nextFrameProfile.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
                }
            }
        }
        void OnCallButtonTapped(Fresvii.AppSteroid.Models.Group group)
        {

#if !UNITY_EDITOR
            if(group.MembersCount > 4)
            {
				Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("GroupConferenceMemberLimitation"), delegate(bool del)
                {

				});

				return;
            }
#endif

            ControlLock = true;

            frameGroupConference = ((GameObject)Instantiate(prfbGUIFrameGroupCall)).GetComponent<FresviiGUIGroupConference>();

            frameGroupConference.gameObject.GetComponent<FresviiGUIGroupConference>().SetGroup(group);

            frameGroupConference.transform.parent = this.transform;

            frameGroupConference.PostFrame = this;

            frameGroupConference.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, this.GuiDepth - 10);

            frameGroupConference.SetDraw(true);

            frameGroupConference.Tween(new Vector2(0.0f, Screen.height), Vector2.zero, delegate()
            {
                this.SetDraw(false);

                ControlLock = false;
            });

        }
        public static void Show(FresviiGUIFrame postFrame, int guiDepth, Action<Fresvii.AppSteroid.Models.Video, Texture2D> callback, Mode mode = Mode.Select, Action shownCallback = null)
        {
            if(mode == FresviiGUIVideoList.Mode.FromUploded)
            {
                guiDepth += 1000;
            }

            FresviiGUIVideoList frameVideoList = ((GameObject)Instantiate(Resources.Load("GuiPrefabs/FresviiGUIFrameVideoList"))).GetComponent<FresviiGUIVideoList>();

            frameVideoList.IsModal = true;

            FresviiGUIManager.SetParameters();

            frameVideoList.Init(FASConfig.Instance.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, guiDepth);

            frameVideoList.PostFrame = postFrame;

            frameVideoList.SetCallback(callback);

            frameVideoList.SetDraw(true);

            frameVideoList.mode = mode;

            frameVideoList.Tween(new Vector2(0.0f, Screen.height), Vector2.zero, delegate()
            {
                if(postFrame != null)
                    postFrame.SetDraw(false);

                if(shownCallback != null)
                    shownCallback();
            });
        }
        public void Init(Fresvii.AppSteroid.Models.Friend friend, float scaleFactor, FresviiGUIFrame frameParent, Texture2D textureCheckMark, Action<Fresvii.AppSteroid.Models.User, Action<bool>> AddFriend, Action<Fresvii.AppSteroid.Models.User> RemoveFriend)
        {
            this.friend = friend;

            this.frameParent = frameParent;

            this.textureCheckMark = textureCheckMark;

            this.AddFriend = AddFriend;

            this.RemoveFriend = RemoveFriend;

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleUserName.font = null;
                guiStyleUserName.fontStyle = FontStyle.Bold;
            }

            userIconPosition = FresviiGUIUtility.RectScale(userIconPosition, scaleFactor);
            userNamePosition = FresviiGUIUtility.RectScale(userNamePosition, scaleFactor);

            sideMargin = userIconPosition.x;

            cardHeight *= scaleFactor;

            guiStyleUserName.fontSize = (int)(guiStyleUserName.fontSize * scaleFactor);

            palette = FresviiGUIColorPalette.Palette;

            guiStyleUserName.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardUserName);

            texCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardBackground);

            textureCoordsSeparateLine = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardSeperateLine2);

            seperateLinePosition = FresviiGUIUtility.RectScale(seperateLinePosition, scaleFactor);

            GetUser();
        }
        public void OnCallButtonTapped()
        {
            if (Group == null) return;

            if (!(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer))
                return;

            if(Group.MembersCount > 4)
            {
                Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("GroupConferenceMemberLimitation"), delegate(bool del)
                {

                });

                return;
            }

            //DialogManager.Instance.SetLabel(FresviiGUIText.Get("Yes"), FresviiGUIText.Get("No"), FresviiGUIText.Get("Close"));

            Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSelectDialog(FresviiGUIText.Get("ConfirmToCall"), FresviiGUIText.Get("Yes"), FresviiGUIText.Get("No"), (del)=>
            //DialogManager.Instance.ShowSelectDialog(FresviiGUIText.Get("ConfirmToCall"), delegate(bool del)
            {
                if (del)
                {
                    ControlLock = true;

                    frameGroupConference = ((GameObject)Instantiate(prfbGUIFrameGroupCall)).GetComponent<FresviiGUIGroupConference>();

                    frameGroupConference.gameObject.GetComponent<FresviiGUIGroupConference>().SetGroup(this.Group);

                    frameGroupConference.transform.parent = this.transform;

                    frameGroupConference.PostFrame = this;

                    frameGroupConference.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, this.GuiDepth - 10);

                    frameGroupConference.SetDraw(true);

                    frameGroupConference.Tween(new Vector2(0.0f, Screen.height), Vector2.zero, delegate()
                    {
                        this.SetDraw(false);

                        ControlLock = false;

                        frameGroupConference.ControlLock = false;
                    });
                }
            });
        }
        public void OnProfileTapped()
        {
            if (Group.Pair)
            {
                frameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                if (Other != null)
                {
                    frameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(Other);
                }
                else
                {
                    foreach (Fresvii.AppSteroid.Models.Member member in Group.Members)
                    {
                        if (member.Id != FAS.CurrentUser.Id)
                        {
                            Other = member.ToUser();
                        }
                    }

                    frameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(Other);
                }

                Debug.Log(Other.Id + ", " + Other.ProfileImageUrl);

                frameProfile.Init(null, postFix, scaleFactor, this.GuiDepth - 10);

                frameProfile.transform.parent = this.transform;

                frameProfile.SetDraw(true);

                frameProfile.PostFrame = this;

                this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                {
                    this.SetDraw(false);
                });

                frameProfile.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
            }
        }
        public void OnEditMemberTapped()
        {
            if (Group == null) return;

            ControlLock = true;

            frameEditGroupMember = ((GameObject)Instantiate(prfbGUIFrameGroupEditMember)).GetComponent<FresviiGUIEditGroupMember>();

            frameEditGroupMember.transform.parent = this.transform;

            frameEditGroupMember.PostFrame = this;

            frameEditGroupMember.GetComponent<FresviiGUIEditGroupMember>().Group = this.Group;

            frameEditGroupMember.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, this.GuiDepth - 10);

            frameEditGroupMember.SetDraw(true);

            frameEditGroupMember.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate()
            {
                this.SetDraw(false);

                ControlLock = false;
            });
        }
        public void Init(string postFix, float scaleFactor, int guiDepth, FresviiGUIFrame parentFrame, Action<string, Texture2D, Fresvii.AppSteroid.Models.Video> callback)
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleAddButton.font = null;
                guiStyleSendButton.font = null;
                guiStyleTextFiled.font = null;
                guiStyleTextFiledLabel.font = null;
            }

            this.parentFrame = parentFrame;
            this.callback = callback;
            this.scaleFactor = scaleFactor;
            this.GuiDepth = guiDepth;
            this.scaleFactor = scaleFactor;
            this.postFix = postFix;

            palette = FresviiGUIColorPalette.Palette;

            texCoordsMenu = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.TextfieldBackground);

            texCoordsBorderLine = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.TextfieldTopLine);

            this.addButton = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.IconAddButtonTextureName + postFix, false);

            this.addButtonH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.IconAddButtonHTextureName + postFix, false);

            this.sendButton = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.Button04TextureName + postFix, false);

            this.sendButtonD = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.Button04DTextureName + postFix, false);

            this.sendButtonH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.Button04HTextureName + postFix, false);

            this.textFiled = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.TextFiledTextureName + postFix, false);

            height *= scaleFactor;

            margin *= this.scaleFactor;
            miniMargin *= this.scaleFactor;
            hMargin *= this.scaleFactor;
            sendButtonSize *= this.scaleFactor;

            guiStyleTextFiled.fontSize = (int)(guiStyleTextFiled.fontSize * this.scaleFactor);
            guiStyleSendButton.fontSize = (int)(guiStyleSendButton.fontSize * this.scaleFactor);
            guiStyleTextFiled.contentOffset *= this.scaleFactor;

            guiStyleAddButton.normal.background = addButton;
            guiStyleAddButton.active.background = guiStyleAddButton.hover.background = guiStyleAddButton.focused.background = addButtonH;

            textInputField = "";

            buttonTextUnableColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.TextfieldSendTextUnable);

            buttonTextEnableColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.TextfieldSendTextEnable);

            buttonTextHitColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.TextfieldSendTextTapped);
        }
        public void Init(Fresvii.AppSteroid.Models.Rank rank, float scaleFactor, FresviiGUIFrame parentFrame)
        {
            this.rank = rank;

            this.parentFrameProfile = parentFrame;

            frameLeaderboard = parentFrame.gameObject.GetComponent<FresviiGUILeaderboard>();

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleUserName.font = null;

                guiStyleUserName.fontStyle = FontStyle.Bold;

                guiStyleRank.font = null;

                guiStyleRank.fontStyle = FontStyle.Bold;

                guiStyleScore.font = null;

                guiStyleTag.font = null;
            }

            rankPosition = FresviiGUIUtility.RectScale(rankPosition, scaleFactor);

            medalPosition = FresviiGUIUtility.RectScale(medalPosition, scaleFactor);

            userIconPosition = FresviiGUIUtility.RectScale(userIconPosition, scaleFactor);

            userNamePosition = FresviiGUIUtility.RectScale(userNamePosition, scaleFactor);

            scoreLabelPosition = FresviiGUIUtility.RectScale(scoreLabelPosition, scaleFactor);

            sideMargin = userIconPosition.x;

            cardHeight *= scaleFactor;

            guiStyleRank.fontSize = (int)(guiStyleRank.fontSize * scaleFactor);

            guiStyleUserName.fontSize = (int)(guiStyleUserName.fontSize * scaleFactor);

            guiStyleScore.fontSize = (int)(guiStyleScore.fontSize * scaleFactor);

            guiStyleTag.fontSize = (int)(guiStyleTag.fontSize * scaleFactor);

            guiStyleTag.padding = FresviiGUIUtility.RectOffsetScale(guiStyleTag.padding, scaleFactor);

            palette = FresviiGUIColorPalette.Palette;

            guiStyleUserName.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardText1);

            guiStyleRank.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardText1);

            guiStyleScore.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardText2);

            texCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardBackground);

            if (rank.Score.User == null)
            {
                FASLeaderboard.GetScore(frameLeaderboard.Leaderboard.Id, rank.Score.Id, delegate(Fresvii.AppSteroid.Models.Score score, Fresvii.AppSteroid.Models.Error error)
                {
                    if (error == null)
                    {
                        rank.Score = score;

                        SetTag();
                    }
                    else
                    {
                        if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error)
                        {
                            Debug.LogError(error.ToString());
                        }
                    }
                });
            }
            else
            {
                SetTag();
            }
        }
        void OnGUI()
        {
            GUI.DrawTextureWithTexCoords(backgroundRect, FresviiGUIColorPalette.Palette, textureCoordsBackground);

			if(user == null) return;

            if (!hasError)
            {
                GUI.depth = GuiDepth;

                GUI.BeginGroup(baseRect);

                GUI.BeginGroup(scrollViewRect);

       			//	User Image
                GUI.DrawTexture(userImagePosition, (textureUserProfile == null) ? textureUserProfileDefault : textureUserProfile, ScaleMode.ScaleToFit);

                Color tmp = GUI.color;

                GUI.color = bgColor;

                GUI.DrawTexture(userImagePosition, textureUserProfileMask, ScaleMode.ScaleToFit);

                GUI.color = tmp;

                GUI.DrawTexture(userImagePosition, textureUserProfileCircle, ScaleMode.ScaleToFit);

                //  User name
                GUI.Label(userNamePosition, userNameContent, guiStyleLabelUserName);

                if (!string.IsNullOrEmpty(user.Description))
                {
                    GUI.Label(userDescriptionPosition, userDescriptionContent, guiStyleLabelUserProfile);
                }

                if (user.Official)
                {
                    GUI.EndGroup();

                    GUI.EndGroup();

                    return;
                }

                Event e = Event.current;

                //  Holding  - menu apper
                if (userNamePosition.Contains(e.mousePosition) && FASGesture.IsHolding && !FASGesture.IsDragging && !ControlLock)
                {
                    List<string> buttons = new List<string>();

                    buttons.Add(FresviiGUIText.Get("Copy"));

                    Vector2 postion = new Vector2(baseRect.x + scrollViewRect.x + userNamePosition.x + userNamePosition.width * 0.5f, baseRect.y + scrollViewRect.y + userNamePosition.y);

                    ControlLock = true;

                    popOverBalloonMenu = Fresvii.AppSteroid.Gui.PopOverBalloonMenu.Show(scaleFactor, postFix, this.GuiDepth - 30, postion, buttons.ToArray(), (selectedButton) =>
                    {
                        ControlLock = false;

                        if (selectedButton == FresviiGUIText.Get("Copy"))
                        {
                            Fresvii.AppSteroid.Util.Clipboard.SetText(user.Name);
                        }
                    });

                    popOverBalloonMenu.Name = "UserName";
                }      

                // User Code
                GUI.Label(userCodePosition, userCodeContent, guiStyleLabelUserCode);


                //  Holding  - menu apper
                if (userCodePosition.Contains(e.mousePosition) && FASGesture.IsHolding && !FASGesture.IsDragging && !ControlLock)
                {
                    List<string> buttons = new List<string>();

                    buttons.Add(FresviiGUIText.Get("Copy"));

                    Vector2 postion = new Vector2(baseRect.x + scrollViewRect.x + userCodePosition.x + userCodePosition.width * 0.5f, baseRect.y + scrollViewRect.y + userCodePosition.y);

                    ControlLock = true;

                    popOverBalloonMenu = Fresvii.AppSteroid.Gui.PopOverBalloonMenu.Show(scaleFactor, postFix, this.GuiDepth - 30, postion, buttons.ToArray(), (selectedButton) =>
                    {
                        ControlLock = false;

                        if (selectedButton == FresviiGUIText.Get("Copy"))
                        {
                            Fresvii.AppSteroid.Util.Clipboard.SetText(user.UserCode);
                        }
                    });

                    popOverBalloonMenu.Name = "UserCode";
                }

                if (userInfoEnable)
                {
                    #region Friend button

                    if (user.FriendStatus == Fresvii.AppSteroid.Models.User.FriendStatuses.Requesting)
                    {
						guiStyleButtonFriend.normal.textColor = btnNegativeColor;

                        buttonFriend.IsTap(e, friendButtonPosition, friendButtonPosition, FresviiGUIButton.ButtonType.FrameAndLabel, textureButton03, textureButton03, textureButton03, FresviiGUIText.Get("RequestSent"), guiStyleButtonFriend);
                    }
                    /*else if (user.FriendStatus == User.FriendStatuses.Requested)
                    {
						guiStyleButtonFriend.normal.textColor = btnNegativeColor;

						buttonFriend.IsTap(e, friendButtonPosition, friendButtonPosition, FresviiGUIButton.ButtonType.FrameAndLabel, textureButton03, textureButton03, textureButton03, FresviiGUIText.Get("Requested"), guiStyleButtonFriend);
                    }*/
                    else if (user.FriendStatus == Fresvii.AppSteroid.Models.User.FriendStatuses.Friend)
                    {
						guiStyleButtonFriend.normal.textColor = btnPositiveColor;

                        if (buttonFriend.IsTap(e, friendButtonPosition, friendButtonPosition, FresviiGUIButton.ButtonType.FrameAndLabel, textureButton01, textureButton01H, textureButton01H, FresviiGUIText.Get("Unfriend"), guiStyleButtonFriend))
                        {
                            Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("Unfriend"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

                            Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSelectDialog(FresviiGUIText.Get("ConfirmUnfriend"), delegate(bool del)
                            {
#if UNITY_EDITOR
                                if (true)
#else
                            	if(del)
#endif
                                {
                                    if (Application.internetReachability == NetworkReachability.NotReachable)
                                    {
                                        Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), delegate(bool _del) { });
                                    }
                                    else
                                    {
                                        FASFriendship.UnFriend(this.user.Id, delegate(Fresvii.AppSteroid.Models.Error error)
                                        {
                                            if (error == null)
                                            {
                                                user.SetFriendStatus(Fresvii.AppSteroid.Models.FriendshipRequest.Statuses.none.ToString());

                                                DeletePairGroupMessages(user.Id, deleteGroupRetryCount, deleteGroupRetryInterval);
                                            }
                                            else
                                            {
                                                if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error)
                                                {
                                                    Debug.LogError(error.ToString());
                                                }

                                                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("UnknownError"), delegate(bool _del) { });
                                            }
                                        });
                                    }
                                }
                            });

                        }
                    }
                    else
                    {
						guiStyleButtonFriend.normal.textColor = btnPositiveColor;

                        if (buttonFriend.IsTap(e, friendButtonPosition, friendButtonPosition, FresviiGUIButton.ButtonType.FrameAndLabel, textureButton01, textureButton01H, textureButton01H, FresviiGUIText.Get("AddFriend"), guiStyleButtonFriend))
                        {
                            if (Application.internetReachability == NetworkReachability.NotReachable)
                            {
                                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), delegate(bool del) { });
                            }
                            else
                            {
                                user.SetFriendStatus(Fresvii.AppSteroid.Models.FriendshipRequest.Statuses.requesting.ToString());

                                FASFriendship.SendFriendshipRequest(this.user.Id, delegate(Fresvii.AppSteroid.Models.FriendshipRequest friendshipRequest, Fresvii.AppSteroid.Models.Error error)
                                {
                                    if (error == null)
                                    {
                                        user.SetFriendStatus(friendshipRequest.Status.ToString());
                                    }
                                    else
                                    {
                                        if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error)
                                            Debug.LogError(error.ToString());

                                        Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("UnknownError"), delegate(bool del) { });

                                        user.SetFriendStatus(Fresvii.AppSteroid.Models.FriendshipRequest.Statuses.none.ToString());
                                    }
                                });
                            }
                        }
                    }
                }
                #endregion

                #region Message button

                if (buttonMessage.IsTap(e, messageButtonPosition, messageButtonPosition, FresviiGUIButton.ButtonType.TextureOnly, textureIconMessage, textureIconMessage, textureIconMessage))                  
                {
                    if (Application.internetReachability == NetworkReachability.NotReachable)
                    {
                        Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), delegate(bool del) { });
                    }
                    else
                    {
                        FresviiGUIFrame framePairChat = ((GameObject)Instantiate(prfbGUIFramePairChat)).GetComponent<FresviiGUIFrame>();

                        framePairChat.transform.parent = this.transform;

                        framePairChat.gameObject.GetComponent<FresviiGUIChat>().SetPairUser(this.user);

                        framePairChat.Init(null, postFix, scaleFactor, this.GuiDepth - 1);

                        framePairChat.SetDraw(true);

                        framePairChat.PostFrame = this;

                        this.tabBar.enabled = false;

                        this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), moveDelayTime, delegate()
                        {
                            this.SetDraw(false);
                        });

                        framePairChat.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, moveDelayTime, delegate() { });
                    }
                }

                GUI.Label(messageLabelPosition, messageLabelContent, guiStyleButtonLabel);

                #endregion

                #region Call button

#if GROUP_CONFERENCE
                if (!user.Official)
                {
                    bool isCalling = FASConference.IsCalling();

                    Texture2D textureCall = (isCalling) ? textureIconCallD : textureIconCall;

                    if (buttonMessage.IsTap(e, callButtonPosition, callButtonPosition, FresviiGUIButton.ButtonType.TextureOnly, textureCall, textureCall, textureCall))
                    {

#if !UNITY_EDITOR
					if (isCalling)
                    {
						Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

						Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("VoiceChatAlredayExists"), delegate(bool del) { });

                        return;
                    }
#endif
                        if (Application.internetReachability == NetworkReachability.NotReachable)
                        {
                            Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), delegate(bool del) { });
                        }
                        else
                        {
                            loadingSpinnerPosition = new Rect(Screen.width * 0.5f - loadingSpinnerSize.x * 0.5f, Screen.height * 0.5f - loadingSpinnerSize.y * 0.5f, loadingSpinnerSize.x, loadingSpinnerSize.y);

                            loadingSpinner = Fresvii.AppSteroid.Gui.LoadingSpinner.Show(loadingSpinnerPosition, this.GuiDepth - 10);

                            FASGroup.CreatePair(user.Id, delegate(Fresvii.AppSteroid.Models.Group group, Fresvii.AppSteroid.Models.Error error)
                            {
                                if (error != null)
                                {
                                    loadingSpinner.Hide();

                                    if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error)
                                    {
                                        Debug.LogError("CreatePair : " + error.ToString());
                                    }

                                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog("Error : CreatePair " + error.ToString(), delegate(bool del) { });
                                }
                                else
                                {
                                    loadingSpinner.Hide();

                                    group.FetchMembers(delegate(Fresvii.AppSteroid.Models.Error error2)
                                    {
                                        if (error2 != null)
                                        {
                                            if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error)
                                            {
                                                Debug.LogError("FetchMembers : " + error.ToString());
                                            }

                                            Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("OK"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

                                            if (error.Code == (int)Fresvii.AppSteroid.Models.Error.ErrorCode.NetworkNotReachable)
                                            {
                                                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), delegate(bool del) { });
                                            }
                                            else
                                            {
                                                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(error.Detail, delegate(bool del) { });
                                            }
                                        }
                                        else
                                        {
                                            OnCallButtonTapped(group);
                                        }
                                    });
                                }
                            });
                        }
                    }

                    GUI.Label(callLabelPosition, callLabelContent, guiStyleButtonLabel);
                }
#endif

                #endregion

                //  User FriendTitleBar
                if (friendCountLabelContent != null)
                {
                    GUI.DrawTextureWithTexCoords(friendMenuTitleBarPosition, palette, buttonFriendList.IsActive ? texCoordsFriendTitleBgH : texCoordsFriendTitleBg);

                    GUI.Label(friendMenuTitleBarPosition, friendCountLabelContent, guiStyleFriendMenuTitle);

                    GUI.DrawTexture(friendMenuRightIconPosition, textureRight);
                }

#if UNITY_IOS
                //  VideoTitleBar
                if (FASConfig.Instance.videoEnable)
                {
                    GUI.DrawTextureWithTexCoords(videoTitleBarPosition, palette, buttonVideoList.IsActive ? texCoordsFriendTitleBgH : texCoordsFriendTitleBg);

                    GUI.Label(videoTitleBarPosition, videoListLabelContent, guiStyleFriendMenuTitle);

                    GUI.DrawTexture(videoRightIconPosition, textureRight);

                    if (buttonVideoList.IsTap(e, videoTitleBarPosition))
                    {
                        GoToVideoList(true);
                    }
                }
#endif

                if(buttonFriendList.IsTap(e, friendMenuTitleBarPosition))
                {
                    frameFriendList = ((GameObject)Instantiate(prfbFriendList)).GetComponent<FresviiGUIFrame>();

                    frameFriendList.transform.parent = this.transform;

                    frameFriendList.gameObject.GetComponent<FresviiGUIFriendList>().SetUser(this.user);

                    frameFriendList.Init(null, postFix, scaleFactor, this.GuiDepth - 1);

                    frameFriendList.SetDraw(true);

                    frameFriendList.PostFrame = this;

                    this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                    {
                        this.SetDraw(false);
                    });

                    frameFriendList.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });

                }

                GUI.EndGroup();

                GUI.EndGroup();
            }
        }       
        public void GoToDirectMessage(bool animation)
        {
            if (frameDirectMessage != null)
                Destroy(frameDirectMessage.gameObject);

            frameDirectMessage = ((GameObject)Instantiate(prfbFrameDirectMessage)).GetComponent<FresviiGUIFrame>();

            frameDirectMessage.gameObject.GetComponent<FresviiGUIDirectMessage>().DirectMessage = this.DirectMessage;

            frameDirectMessage.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, parentFrame.GuiDepth - 1);

            frameDirectMessage.transform.parent = this.transform;

            frameDirectMessage.SetDraw(true);

            frameDirectMessage.PostFrame = parentFrame;

            frameDirectMessage.ControlLock = true;

            /*if (parentFrame.tabBar != null)
            {
                frameGroupMessage.tabBar.enabled = false;
            }*/

            parentFrame.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
            {
                parentFrame.SetDraw(false);

                parentFrame.ControlLock = false;
            });

            frameDirectMessage.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });

            if (DirectMessage.Unread)
            {
                DirectMessage.Unread = false;

                FresviiGUIManager.Instance.UnreadDirectMessageCount--;
            }
        }
        public void Init(Fresvii.AppSteroid.Models.Friend friend, float scaleFactor, FresviiGUIFrame parentFrame)
        {
            this.friend = friend;
            this.parentFrameProfile = parentFrame;

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleUserName.font = null;
                guiStyleUserName.fontStyle = FontStyle.Bold;
                guiStyleTag.font = null;
            }

            userIconPosition = FresviiGUIUtility.RectScale(userIconPosition, scaleFactor);
            userNamePosition = FresviiGUIUtility.RectScale(userNamePosition, scaleFactor);

            sideMargin = userIconPosition.x;

            cardHeight *= scaleFactor;

            guiStyleUserName.fontSize = (int)(guiStyleUserName.fontSize * scaleFactor);

            palette = FresviiGUIColorPalette.Palette;

            guiStyleUserName.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardUserName);

            guiStyleTag.fontSize = (int)(guiStyleTag.fontSize * scaleFactor);

            guiStyleTag.padding = FresviiGUIUtility.RectOffsetScale(guiStyleTag.padding, scaleFactor);

            guiStyleTag.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardBackground);

            texCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardBackground);

            texCoordsSeperateLine = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardSeperateLine1);

            GetUser ();
        }
        public void GoToFriendRequests()
        {
            frameFriendRequests = ((GameObject)Instantiate(prfbGUIFrameFriendRequests)).GetComponent<FresviiGUIFriendRequests>();

            frameFriendRequests.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, GuiDepth - 10);

            frameFriendRequests.GetComponent<FresviiGUIFriendRequests>().SetGUIMyProfile(this);

            frameFriendRequests.transform.parent = this.transform;

            frameFriendRequests.SetDraw(true);

            tabBar.enabled = false;

            this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), moveDelayTime, delegate()
            {
                this.SetDraw(false);
            });

            frameFriendRequests.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, moveDelayTime, delegate() { });
        }
        public void Draw(Rect position, bool drawSeperateLine)
        {
            if (user != null)
            {
                if (!string.IsNullOrEmpty(user.ProfileImageUrl) && userIcon == null && !userIconLoading && !iconError)
                {
                    LoadUserIcon();
                }
                else if (user.ProfileImageUrl != userProfileUrl && !userIconLoading && !iconError)
                {
                    FresviiGUIManager.Instance.resourceManager.ReleaseTexture(userProfileUrl);

                    LoadUserIcon();
                }
            }

            CalcLayout(position.width);

            GUI.BeginGroup(position);

            //  Line
            if (drawSeperateLine)
            {
                GUI.DrawTextureWithTexCoords(cardSeperateLinePosition, palette, texCoordsSeperateLine);

                // Background
                GUI.DrawTextureWithTexCoords(new Rect(cardSeperateLinePosition.x, 0, cardSeperateLinePosition.width, position.height - 1.0f), palette, texCoordsBackground);
                GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width - cardSeperateLinePosition.width, position.height), palette, texCoordsBackground);
            }
            else
            {
                // Background
                GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width, position.height), palette, texCoordsBackground);
            }

            //  UserIcon -----------------------
            if (Event.current.type == EventType.Repaint)
            {
                userIconMask.color = new Color(1f, 1f, 1f, 1f);

                Graphics.DrawTexture(userIconPosition, (userIcon == null ? userIconDefault : userIcon), userIconMask);
            }

            //  User name -----------------------
            GUI.Label(userNamePosition, contentUserName, guiStyleUserName);

            if (isMe)
            {
                GUI.DrawTexture(tagPosition, textureTagYou);

                GUI.Label(tagPosition, tagString, guiStyleTag);
            }

            GUI.EndGroup();

            if (buttonCard.IsTap(Event.current, position))
            {
                if (this.user != null)
                {
                    if (nextFrameProfile == null)
                    {
                        if (this.user.Id == FAS.CurrentUser.Id)
                        {
                            nextFrameProfile = ((GameObject)Instantiate(prfbGUIFrameMyProfile)).GetComponent<FresviiGUIFrame>();
                        }
                        else
                        {
                            nextFrameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                            nextFrameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(user);
                        }

                        nextFrameProfile.Init(null, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, FASGui.GuiDepthBase);

                        nextFrameProfile.transform.parent = this.transform;
                    }

                    nextFrameProfile.SetDraw(true);

                    nextFrameProfile.PostFrame = parentFrameProfile;

                    parentFrameProfile.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                    {
                        parentFrameProfile.SetDraw(false);
                    });

                    nextFrameProfile.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
                }
            }
        }
        void OnGUI()
        {
            GUI.DrawTextureWithTexCoords(backgroundRect, FresviiGUIColorPalette.Palette, textureCoordsBackground);

            if (isReady)
            {
                GUI.BeginGroup(baseRect);

				GUI.BeginGroup(scrollViewRect);

                //	User Image
                if (Event.current.type == EventType.Repaint)
                {
                    userMask.color = Color.white;

                    Graphics.DrawTexture(userImagePosition, (textureMyProfile == null) ? textureMyProfileDefault : textureMyProfile, userMask);
                }
                
                Event e = Event.current;

                GUI.DrawTexture(userImagePosition, textureMyProfileCircle);

                //  User Name
                GUI.Label(userNamePosition, userNameContent, guiStyleLabelUserName);

                //  Holding  - menu apper
                if (userNamePosition.Contains(e.mousePosition) && FASGesture.IsHolding && !FASGesture.IsDragging && !ControlLock)
                {
                    List<string> buttons = new List<string>();

                    buttons.Add(FresviiGUIText.Get("Copy"));

                    Vector2 postion = new Vector2(baseRect.x + scrollViewRect.x + userNamePosition.x + userNamePosition.width * 0.5f, baseRect.y + scrollViewRect.y + userNamePosition.y);

                    ControlLock = true;

                    popOverBalloonMenu = Fresvii.AppSteroid.Gui.PopOverBalloonMenu.Show(scaleFactor, postFix, this.GuiDepth - 30, postion, buttons.ToArray(), (selectedButton) =>
                    {
                        ControlLock = false;

                        if (selectedButton == FresviiGUIText.Get("Copy"))
                        {
                            Fresvii.AppSteroid.Util.Clipboard.SetText(currentUser.Name);
                        }
                    });

                    popOverBalloonMenu.Name = "UserName";
                }      

                // User Code
                GUI.Label(userCodePosition, userCodeContent, guiStyleLabelUserCode);

                //  Holding  - menu apper
                if (userCodePosition.Contains(e.mousePosition) && FASGesture.IsHolding && !FASGesture.IsDragging && !ControlLock)
                {
                    List<string> buttons = new List<string>();

                    buttons.Add(FresviiGUIText.Get("Copy"));

                    Vector2 postion = new Vector2(baseRect.x + scrollViewRect.x + userCodePosition.x + userCodePosition.width * 0.5f, baseRect.y + scrollViewRect.y + userCodePosition.y);

                    ControlLock = true;

                    popOverBalloonMenu = Fresvii.AppSteroid.Gui.PopOverBalloonMenu.Show(scaleFactor, postFix, this.GuiDepth - 30, postion, buttons.ToArray(), (selectedButton) =>
                    {
                        ControlLock = false;

                        if (selectedButton == FresviiGUIText.Get("Copy"))
                        {
                            Fresvii.AppSteroid.Util.Clipboard.SetText(currentUser.UserCode);
                        }
                    });

                    popOverBalloonMenu.Name = "UserCode";
                }      

                //  User Description
                GUI.Label(userDescriptionPosition, currentUser.Description, guiStyleLabelUserProfile);

                //  User FriendTitleBar
                GUI.DrawTextureWithTexCoords(friendMenuTitleBarPosition, palette, buttonFriendList.IsActive ? texCoordsFriendTitleBgH : texCoordsFriendTitleBg);

                GUI.Label(friendMenuTitleBarPosition, friendCountLabelContent, guiStyleFriendMenuTitle);

                GUI.DrawTexture(friendMenuRightIconPosition, textureRight);

                if (buttonFriendList.IsTap(e, friendMenuTitleBarPosition))
                {
                    frameFriendList = ((GameObject)Instantiate(prfbFriendList)).GetComponent<FresviiGUIFrame>();

                    frameFriendList.transform.parent = this.transform;

                    frameFriendList.gameObject.GetComponent<FresviiGUIFriendList>().SetUser(currentUser);

                    frameFriendList.Init(null, postFix, this.scaleFactor, this.GuiDepth - 1);

                    frameFriendList.SetDraw(true);

                    frameFriendList.PostFrame = this;

                    this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), moveDelayTime, delegate()
                    {
                        this.SetDraw(false);
                    });

                    frameFriendList.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, moveDelayTime, delegate() { });
                }

                //  RequestTitleBar
                GUI.DrawTextureWithTexCoords(requestTitleBarPosition, palette, buttonFriendshipRequestList.IsActive ? texCoordsFriendTitleBgH : texCoordsFriendTitleBg);

                GUI.Label(requestTitleBarPosition, requestLabelContent, guiStyleFriendMenuTitle);

                GUI.DrawTexture(requestRightIconPosition, textureRight);

                if (buttonFriendshipRequestList.IsTap(e, requestTitleBarPosition))
                {
                    GoToFriendRequests();
                }

#if UNITY_IOS
                //  VideoTitleBar
                if (FASConfig.Instance.videoEnable)
                {
                    GUI.DrawTextureWithTexCoords(videoTitleBarPosition, palette, buttonVideoList.IsActive ? texCoordsFriendTitleBgH : texCoordsFriendTitleBg);

                    GUI.Label(videoTitleBarPosition, videoListLabelContent, guiStyleFriendMenuTitle);

                    GUI.DrawTexture(videoRightIconPosition, textureRight);

                    if (buttonVideoList.IsTap(e, videoTitleBarPosition))
                    {
                        GoToVideoList(true);
                    }
                }
#endif

                //  DirectMessageTitleBar
                GUI.DrawTextureWithTexCoords(directMessageTitleBarPosition, palette, buttonDirectMessageList.IsActive ? texCoordsFriendTitleBgH : texCoordsFriendTitleBg);

                GUI.Label(directMessageTitleBarPosition, directMessageListLabelContent, guiStyleFriendMenuTitle);

                GUI.DrawTexture(directMessageRightIconPosition, textureRight);

                if (buttonDirectMessageList.IsTap(e, directMessageTitleBarPosition))
                {
                    GoToDirectMessageList(true);
                }

                GUI.EndGroup(); // scroll view rect               

                GUI.EndGroup(); // base rect

                //	Notification
                if (RequestedFriendsListMeta != null)
                {
                    if (RequestedFriendsListMeta.TotalCount > 0)
                    {
                        GUI.DrawTextureWithTexCoords(friendNotificationPosition, palette, texCoordsNotificationBg);

                        string friendRequestMessage = FresviiGUIText.Get("FriendRequestCount").Replace("#", RequestedFriendsListMeta.TotalCount.ToString());

                        GUI.Label(friendNotificationPosition, friendRequestMessage, guiStyleFriendNotification);

                        if (buttonFriendNotification.IsTap(Event.current, friendNotificationPosition))
                        {
                            GoToFriendRequests();
                        }
                    }
                }
            }
        }
        public void Draw(Rect position, bool drawSeperateLine)
        {
            if (user != null)
            {
                if (!userIconLoaded && !userIconLoading)
                {
                    StartCoroutine(UserIconLoad());
                }
                else if (userIconLoaded && user.ProfileImageUrl != userProfileUrl)
                {
                    StartCoroutine(UserIconLoad());
                }
            }

            CalcLayout(position.width);

            Event e = Event.current;

            if (position.Contains(e.mousePosition) && FASGesture.IsHolding && !FASGesture.IsDragging && !frameEditGroupMembers.ControlLock)
            {
                List<string> buttons = new List<string>();

                buttons.Add(FresviiGUIText.Get("Delete"));

                frameEditGroupMembers.ControlLock = true;

                actionSheet = Fresvii.AppSteroid.Gui.ActionSheet.Show(this.scaleFactor, this.postFix, frameEditGroupMembers.GuiDepth - 10, buttons.ToArray(), (selectedButton) =>
                {
                    frameEditGroupMembers.ControlLock = false;

                    if (selectedButton == FresviiGUIText.Get("Delete"))
                    {
                        if (ValidateDelete())
                        {
                            if (!(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer))
                            {
                                OnCardGone();
                            }
                            else
                            {

                                Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel(FresviiGUIText.Get("Delete"), FresviiGUIText.Get("Cancel"), FresviiGUIText.Get("Close"));

                                Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSelectDialog(FresviiGUIText.Get("ConfirmRemoveMember"), delegate(bool del)
                                {
                                    if (del)
                                    {
                                        OnCardGone();
                                    }
                                });
                            }
                        }
                    }
                });
            }

            isSlide = (FASGesture.IsTouching && position.Contains(e.mousePosition) && FASGesture.DragDirec == FASGesture.DragDirection.Horizontal);

            if (FASGesture.IsTouchBegin && cardXOffset > 0 && !position.Contains(e.mousePosition))
            {
                isClose = true;

                isSlide = false;
            }

            Rect slidedPosition = new Rect(position.x - cardXOffset, position.y, position.width + cardXOffset, position.height);

            GUI.DrawTextureWithTexCoords(position, palette, texCoordsBackground);

            GUI.BeginGroup(slidedPosition);

            //  Delete button
            buttonDeletePostion = new Rect(slidedPosition.width - deleteButtonWidth, 0, deleteButtonWidth, cardHeight);

            GUI.DrawTextureWithTexCoords(buttonDeletePostion, palette, textureCoordsDelete);

            if(!isDelete && cardXOffset > 0)
                GUI.Label(buttonDeletePostion, FresviiGUIText.Get("Delete"), guiStyleDelete);

            if (cardXOffset == deleteButtonWidth)
            {
                if (e.type == EventType.MouseUp && buttonDeletePostion.Contains(e.mousePosition) && !FASGesture.IsDragging && !isDelete && !frameEditGroupMembers.ControlLock)
                {
                    e.Use();

                    if (ValidateDelete())
                    {
                        DeleteAnimation();
                    }
                    else
                    {
                        isClose = true;
                    }
                }
            }

            if (e.type == EventType.MouseUp && cardPosition.Contains(e.mousePosition) && !FASGesture.IsDragging && !isDelete && !frameEditGroupMembers.ControlLock)
            {
                e.Use();

                if (cardXOffset > 0)
                {
                    isClose = true;
                }
                else if(!frameEditGroupMembers.CardIsOpen)
                {
                    if (this.user != null)
                    {
                        if (nextFrameProfile == null)
                        {
                            nextFrameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                            nextFrameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(user);

                            nextFrameProfile.Init(null, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, FASGui.GuiDepthBase);

                            nextFrameProfile.transform.parent = this.transform;
                        }

                        nextFrameProfile.SetDraw(true);

                        nextFrameProfile.PostFrame = frameEditGroupMembers;

                        frameEditGroupMembers.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                        {
                            frameEditGroupMembers.SetDraw(false);
                        });

                        nextFrameProfile.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
                    }
                }
            }

            GUI.DrawTextureWithTexCoords(cardPosition, palette, texCoordsBackground);

            GUI.DrawTexture(buttonRightPosition, buttonRightIcon);

            if(drawSeperateLine)
                GUI.DrawTextureWithTexCoords(seperateLinePosition, palette, textureCoordsSeparateLine);

            //  UserIcon -----------------------
            if (Event.current.type == EventType.Repaint)
            {
                userMask.color = new Color(1f, 1f, 1f, 1.0f);

                Graphics.DrawTexture(userIconPosition, ((userIcon == null) ? userIconDefault : userIcon), userMask);
            }

            //  User name -----------------------
            GUI.Label(userNamePosition, contentUserName, guiStyleUserName);

            GUI.EndGroup();
        }
        public void GoToGroupChat(bool animation)
        {
            if (frameChat != null)
                Destroy(frameChat.gameObject);

            frameChat = ((GameObject)Instantiate(prfbFrameChat)).GetComponent<FresviiGUIFrame>();

            frameChat.gameObject.GetComponent<FresviiGUIChat>().SetGroup(this.Group);

            frameChat.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, frameGroupMessage.GuiDepth - 1);

            frameChat.transform.parent = this.transform;

            frameChat.SetDraw(true);

            frameChat.PostFrame = frameGroupMessage;

            frameGroupMessage.ControlLock = true;

            if (frameGroupMessage.tabBar != null)
            {
                frameGroupMessage.tabBar.enabled = false;
            }

            if (animation)
            {
                frameGroupMessage.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                {
                    frameGroupMessage.SetDraw(false);

                    frameGroupMessage.ControlLock = false;
                });

                frameChat.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
            }
            else
            {
                frameGroupMessage.Tween(new Vector2(-Screen.width, 0.0f), new Vector2(-Screen.width, 0.0f), delegate()
                {
                    frameGroupMessage.SetDraw(false);

                    frameGroupMessage.ControlLock = false;
                });

                frameChat.Tween(Vector2.zero, Vector2.zero, delegate() { });
            }

            frameChat.gameObject.GetComponent<FresviiGUIChat>().OnAddGroupMessage += OnAddGroupMessage;
        }
        public void OnCreateButtonTapped()
        {
            ControlLock = true;

            frameGroupMessageCreate = ((GameObject)Instantiate(prfbGUIFrameGroupMessageCreate)).GetComponent<FresviiGUIGroupMessageCreate>();

            frameGroupMessageCreate.transform.parent = this.transform;

            frameGroupMessageCreate.PostFrame = this;

            frameGroupMessageCreate.Init(FresviiGUIManager.appIcon, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, this.GuiDepth - 10);

            frameGroupMessageCreate.SetDraw(true);

            frameGroupMessageCreate.Tween(new Vector2(0.0f, Screen.height), Vector2.zero, delegate()
            {
                this.SetDraw(false);

                ControlLock = false;
            });
        }
        public void GoToUserProfile(Fresvii.AppSteroid.Models.User user)
        {
            if (user.Id == FAS.CurrentUser.Id)
            {
                nextFrameProfile = ((GameObject)Instantiate(prfbGUIFrameMyProfile)).GetComponent<FresviiGUIFrame>();
            }
            else
            {
                nextFrameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                nextFrameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(user);
            }

            nextFrameProfile.Init(null, FresviiGUIManager.postFix, FresviiGUIManager.scaleFactor, FASGui.GuiDepthBase);

            nextFrameProfile.transform.parent = this.transform;

            nextFrameProfile.SetDraw(true);

            nextFrameProfile.PostFrame = this;

            this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
            {
                this.SetDraw(false);
            });

            nextFrameProfile.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
        }
        public override void Init(Texture2D appIcon, string postFix, float scaleFactor, int guiDepth)
        {
            this.GuiDepth = guiDepth;

            textureCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.MainBackground);

            loadingSpinnerPlace = LoadingSpinnerPlace.Center;

            loadingSpinnerPosition = new Rect(Screen.width * 0.5f - loadingSpinnerSize.x * 0.5f, Screen.height * 0.5f - loadingSpinnerSize.y * 0.5f, loadingSpinnerSize.x, loadingSpinnerSize.y);

            loadingSpinner = Fresvii.AppSteroid.Gui.LoadingSpinner.Show(loadingSpinnerPosition, FASGui.GuiDepthBase);

            forumTopMenu = GetComponent<FresviiGUIForumTopMenu>();

            tabBar = GetComponent<FresviiGUITabBar>();

            forumTopMenu.Init(appIcon, postFix, scaleFactor, FresviiGUIText.Get("Forum"));

            tabBar.Init(postFix, scaleFactor, this.GuiDepth - 1);

            this.scaleFactor = scaleFactor;
            this.verticalMargin = verticalMargin * scaleFactor;
            this.reloadHeight *= scaleFactor;
            this.sideMargin *= scaleFactor;
            this.loadingSpinnerSize *= scaleFactor;
            this.postFix = postFix;

            TexForumCommentS = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumCommentSTextureName + postFix, false);
            TexForumCommentSH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumCommentSHTextureName + postFix, false);

            TexForumLikeS = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumLikeSTextureName + postFix, false);
            TexForumLikeSH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumLikeSHTextureName + postFix, false);

            TexForumCommentL = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumCommentLTextureName + postFix, false);
            TexForumCommentLH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumCommentLHTextureName + postFix, false);

            TexForumLikeL = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumLikeLTextureName + postFix, false);
            TexForumLikeLH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumLikeLHTextureName + postFix, false);

            TexForumLikeM = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumLikeMTextureName + postFix, false);
            TexForumLikeMH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumLikeMHTextureName + postFix, false);

            TexForumMenu = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumMenuTextureName + postFix, false);

            TexForumMenuH = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.ForumMenuHTextureName + postFix, false);

            TexVideoPlaybackIcon = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.VideoPlaybackIconTextureName, false);

            TexVideoIcon = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.VideoIconTextureName, false);

            FASForum.GetForumThreadsFromCache(OnGetForumThreads);

            GetForumThreads();

            Initialized = true;

            frameCreateThread = ((GameObject)Instantiate(prfbGUIFrameCreateThread)).GetComponent<FresviiGUIFrame>();

            frameCreateThread.transform.parent = this.transform;

            frameCreateThread.Init(appIcon, postFix, scaleFactor, this.GuiDepth - 10);

            frameCreateThread.PostFrame = this;

            frameCreateThread.SetDraw(false);

            tabBar.GuiDepth = this.GuiDepth - 1;

            SetScrollSlider(scaleFactor * 2.0f);
        }
        public void GoToUserProfile(FresviiGUIFrame frameProfile)
        {
            frameProfile.SetDraw(true);

            frameProfile.PostFrame = this;

            this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
            {
                this.SetDraw(false);
            });

            frameProfile.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
        }
        public void Init(float scaleFactor, FresviiGUIFrame parentFrame, FresviiGUIMatchMaking frameMatchMaking)
        {
            this.parentFrame = parentFrame;

            this.transform.parent = parentFrame.transform;

            this.frameMatchMaking = frameMatchMaking;

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleUserName.font = null;

                guiStyleUserName.fontStyle = FontStyle.Bold;

                guiStyleText.font = null;

                guiStyleTag.font = null;

                guiStylePlayerStatus.font = null;
            }

            userIconPosition = FresviiGUIUtility.RectScale(userIconPosition, scaleFactor);

            tagPosition = FresviiGUIUtility.RectScale(tagPosition, scaleFactor);

            userNamePosition = FresviiGUIUtility.RectScale(userNamePosition, scaleFactor);

            playerNamePosition = FresviiGUIUtility.RectScale(playerNamePosition, scaleFactor);

            palyerStatusPosition = FresviiGUIUtility.RectScale(palyerStatusPosition, scaleFactor);

            sideMargin = userIconPosition.x;

            cardHeight *= scaleFactor;

            guiStyleUserName.fontSize = (int)(guiStyleUserName.fontSize * scaleFactor);

            guiStyleText.fontSize = (int)(guiStyleText.fontSize * scaleFactor);

            guiStyleTag.fontSize = (int)(guiStyleTag.fontSize * scaleFactor);

            guiStyleTag.padding = FresviiGUIUtility.RectOffsetScale(guiStyleTag.padding, scaleFactor);

            guiStylePlayerStatus.fontSize = (int)(guiStylePlayerStatus.fontSize * scaleFactor);

            palette = FresviiGUIColorPalette.Palette;

            guiStylePlayerStatus.normal.textColor = guiStyleUserName.normal.textColor = guiStyleText.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardUserName);

            texCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardBackground);

            if (frameMatchMaking.State == FresviiGUIMatchMaking.Mode.Setting)
            {
                contentUserName = new GUIContent(FresviiGUIText.Get("InviteFriend"));
            }
            else if (frameMatchMaking.State == FresviiGUIMatchMaking.Mode.Matching)
            {
                contentUserName = new GUIContent(FresviiGUIText.Get("AutoMatch"));
            }

            guiStyleTag.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardBackground);

            tagString = FresviiGUIText.Get("You");
        }