Example #1
0
        private void twitterListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            // リストビューに選択がある場合
            if (twitterListView.SelectedIndices.Count == 1 && twitterListView.SelectedIndices[0] < twitterStatuses.Length)
            {
                Twitter.StatusInfomation status = twitterStatuses[twitterListView.SelectedIndices[0]];
                doingInfomationTextBox.Text = status.User.Name + "\r\n" + status.Text;

                if (profileIndexHashTable.ContainsKey(status.User.ProfileImageUrl) == true && (int)profileIndexHashTable[status.User.ProfileImageUrl] < profileBigImageList.Images.Count)
                {
                    twitterPictureBox.Image = (Image)profileBigImageList.Images[(int)profileIndexHashTable[status.User.ProfileImageUrl]];
                }
                else
                {
                    twitterPictureBox.Image = null;
                }
            }
            // リストビューに選択がない場合
            else
            {
                doingInfomationTextBox.Text = string.Empty;
                twitterPictureBox.Image     = null;
            }
        }
Example #2
0
        /// <summary>
        /// Stream内のXMLをステータス情報にパージングする
        /// </summary>
        /// <param name="st">Stream</param>
        /// <returns>ステータス情報</returns>
        private StatusInfomation[] PaeseStatuses(Stream st)
        {
            XmlTextReader reader = null;

            // ステータスのリスト
            ArrayList statuses = new ArrayList();

            try
            {
                reader = new XmlTextReader(st);

                // ステータス
                StatusInfomation status = null;
                // ユーザー
                UserInfomation user = null;
                // userタグの中にいるか
                bool inUserFlag = false;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.LocalName == "status")
                        {
                            status = new StatusInfomation();
                        } // End of status
                        else if (reader.LocalName == "created_at")
                        {
                            status.SetCreatedAt(reader.ReadString());
                        } // End of created_at
                        else if (reader.LocalName == "id")
                        {
                            status.Id = reader.ReadString();
                        } // End of id
                        else if (reader.LocalName == "text")
                        {
                            status.Text = reader.ReadString();
                        } // End of text
                        else if (reader.LocalName == "user")
                        {
                            inUserFlag  = true;
                            user        = new UserInfomation();
                            status.User = user;
                        } // End of user
                        else if (inUserFlag == true)
                        {
                            if (reader.LocalName == "id")
                            {
                                user.Id = reader.ReadString();
                            } // End of id
                            else if (reader.LocalName == "name")
                            {
                                user.Name = reader.ReadString();
                            } // End of name
                            else if (reader.LocalName == "screen_name")
                            {
                                user.ScreenName = reader.ReadString();
                            } // End of screen_name
                            else if (reader.LocalName == "location")
                            {
                                user.Location = reader.ReadString();
                            } // End of location
                            else if (reader.LocalName == "description")
                            {
                                user.Description = reader.ReadString();
                            } // End of description
                            else if (reader.LocalName == "profile_image_url")
                            {
                                try
                                {
                                    user.ProfileImageUrl = new Uri(reader.ReadString());
                                }
                                catch (UriFormatException)
                                {
                                    ;
                                }
                            } // End of profile_image_url
                            else if (reader.LocalName == "url")
                            {
                                try
                                {
                                    user.Url = new Uri(reader.ReadString());
                                }
                                catch (UriFormatException)
                                {
                                    ;
                                }
                            } // End of url
                            else if (reader.LocalName == "protected")
                            {
                                if (reader.ReadString() == Boolean.TrueString)
                                {
                                    user.ProtectedMyUpdate = true;
                                }
                                else
                                {
                                    user.ProtectedMyUpdate = false;
                                }
                            } // End of protected
                        }     // End of userタグの中にいるか
                    }
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        if (reader.LocalName == "status")
                        {
                            statuses.Add(status);
                        }
                        else if (reader.LocalName == "user")
                        {
                            inUserFlag = false;
                        }
                    }
                }
            }
            catch (WebException)
            {
                throw;
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch (IOException)
            {
                throw;
            }
            catch (UriFormatException)
            {
                throw;
            }
            catch (SocketException)
            {
                throw;
            }
            catch (XmlException)
            {
                throw;
            }
            catch (ArgumentException)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return((StatusInfomation[])statuses.ToArray(typeof(StatusInfomation)));
        }