Ejemplo n.º 1
0
        private void ConversationsResult(object e)
        {
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(() => { ConversationsResult(e); }));
                return;
            }

            Conversations = JsonConvert.SerializeObject(e).DeserializeToList <Conversation>().ToList();

            if (Conversations.Count > 0)
            {
                NoChatsLabel?.Dispose();
            }

            foreach (Conversation conv in Conversations)
            {
                FriendBlock block = new FriendBlock(conv.Recipient, new Size(SideBarContainer.Width, 75));
                block.AppColor    = AppColor;
                block.MouseClick += ConversationBlock_MouseClick;
                block.Location    = new Point(0, SideBarContainer.Controls.Count * 75);
                SideBarContainer.Controls.Add(block);

                if (conv.Replies.Count > 0)
                {
                    Reply lastReply = conv.Replies[conv.Replies.Count - 1];

                    string timeStamp = lastReply.TimeStamp;
                    timeStamp = DateTime.Parse(timeStamp).ToString("h:mm tt");

                    block.LastMessage = lastReply.Message;
                    block.TimeStamp   = timeStamp;
                }
            }
        }
Ejemplo n.º 2
0
        private void FriendBlock_MouseClick(object sender, MouseEventArgs e)
        {
            FriendBlock block = sender as FriendBlock;

            if (block == null)
            {
                return;
            }
            if (block == SelectedFriend)
            {
                return;
            }

            if (SelectedFriend != null)
            {
                SelectedFriend.Selected = false;
            }

            SelectedFriend          = block;
            SelectedFriend.Selected = true;
        }
Ejemplo n.º 3
0
    public static Block[] StageLoad(string stagename)
    {
        string       path         = Application.dataPath + "/Resources/StageFiles/" + stagename + ".csv";
        FileInfo     fileInfo     = new FileInfo(path);
        FileStream   fileStream   = fileInfo.OpenRead();
        StreamReader streamReader = new StreamReader(fileStream);
        string       data         = streamReader.ReadToEnd();

#if UNITY_EDITOR
        Debug.Log(data);
#endif
        // 改行で分割(各ブロックごとに
        string[] enter = { "\n" };
        string[] arr   = data.Split(enter, StringSplitOptions.None);
        // 1行目のLength情報を取得
        string[] comma = { "," };
        string[] temp  = arr[0].Split(comma, StringSplitOptions.None);
        Block[]  stage = new Block[int.Parse(temp[1])];
        // 最後の改行を除くので-1
        for (int i = 1; i < arr.Length - 1; i++)
        {
            Block block = null;
            // それぞれ型名で書き出しているので型名で検索かければOK
            if (arr[i].IndexOf(nameof(GoalBlock)) >= 0)
            {
                block = GoalBlock.Instantiate();
            }
            else if (arr[i].IndexOf(nameof(NormalBlock)) >= 0)
            {
                block = NormalBlock.Instantiate();
            }
            else if (arr[i].IndexOf(nameof(CannotBlock)) >= 0)
            {
                block = CannotBlock.Instantiate();
            }
            else if (arr[i].IndexOf(nameof(AcidBlock)) >= 0)
            {
                block = AcidBlock.Instantiate();
            }
            else if (arr[i].IndexOf(nameof(FixedBlock)) >= 0)
            {
                block = FixedBlock.Instantiate();
            }
            // 矢印は方向プロパティも読み込む
            else if (arr[i].IndexOf(nameof(ArrowBlock)) >= 0)
            {
                string[] direction = arr[i].Split(comma, StringSplitOptions.None);
                block = ArrowBlock.Instantiate((ArrowBlock.Direction) int.Parse(direction[1]));
            }
            // 中間ブロックはレベルプロパティも読み込む
            else if (arr[i].IndexOf(nameof(FriendBlock)) >= 0)
            {
                string[] level = arr[i].Split(comma, StringSplitOptions.None);
                block = FriendBlock.Instantiate(int.Parse(level[1]));
            }
            // どれにも一致しなければファイル破損として扱う
            else
            {
                Debug.Log(stagename + " is corrupted!");
                Debug.Log(arr[i]);
                return(null);
            }
            stage[i - 1] = block;
        }
        return(stage);
    }
Ejemplo n.º 4
0
        private void ConversationBlock_MouseClick(object sender, MouseEventArgs e)
        {
            FriendBlock block = sender as FriendBlock;

            if (block == null)
            {
                return;
            }
            if (block == SelectedChat)
            {
                return;
            }

            if (SelectedChat != null)
            {
                SelectedChat.Selected = false;
            }

            SelectedChat          = block;
            SelectedChat.Selected = true;

            RecipientUser = SelectedChat.User;
            ChatInfo.Show();

            if (NoChatSelectedLabel.IsDisposed)
            {
                Invoke(new MethodInvoker(() =>
                {
                    InnerChatContainer.Controls.Clear();
                }));
            }

            ConversationID = -1;

            foreach (Reply reply in Conversations.Where(x => x.Recipient == RecipientUser).FirstOrDefault().Replies)
            {
                if (ConversationID == -1)
                {
                    ConversationID = reply.ConversationID;
                }

                MessageBlock msgBlock;

                if (reply.DataType == Reply.ContentType.Picture)
                {
                    msgBlock = new MessageBlock(reply.Links, reply.Message);
                }
                else
                {
                    msgBlock = new MessageBlock();
                }

                msgBlock.Message     = reply.Message;
                msgBlock.Sender      = reply.SenderID == CurrentUser.ID ? CurrentUser.UserName : RecipientUser.UserName;
                msgBlock.Date        = DateTime.Parse(reply.TimeStamp).ToString("h:mm tt");
                msgBlock.MaximumSize = new Size(((InnerChatContainer.Width - 20) / 2) - 20, int.MaxValue);

                Invoke(new MethodInvoker(() => { msgBlock.FormatSize(); InnerChatContainer.Controls.Add(msgBlock); }));
            }

            ResizeChat();

            NoChatSelectedLabel?.Dispose();
        }