Exemplo n.º 1
0
        private void webBrowser_Talk_DocumentClick(object sender, HtmlElementEventArgs e)
        {
            HtmlElement clickedElement = webBrowser_Talk.Document.GetElementFromPoint(e.MousePosition);
            string      link           = null;

            if (clickedElement.TagName == "a" || clickedElement.TagName == "A")
            {
                link = clickedElement.GetAttribute("href");
            }
            else if (clickedElement.Parent != null)
            {
                if (clickedElement.Parent.TagName == "a" || clickedElement.Parent.TagName == "A")
                {
                    link = clickedElement.Parent.GetAttribute("href");
                }
            }

            if (link == null || link == string.Empty)
            {
                return;
            }

            Regex linkToAccount = new Regex("https://www.twitter.com/[a-zA-Z0-9_]+", RegexOptions.IgnoreCase);

            if (linkToAccount.IsMatch(link))
            {
                try
                {
                    string        screenName = link.Substring(24, link.Length - 24);
                    var           user       = this.tokens.Users.Lookup(screen_name => screenName);
                    Form_UserInfo f          = new Form_UserInfo(this.tokens, user[0], this.tokens.Account.VerifyCredentials(), this.parentForm);
                    f.Show();
                    return;
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
            }

            try
            {
                System.Diagnostics.Process.Start(link);
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
        private void listView_Users_MouseClick(object sender, MouseEventArgs e)
        {
            ListView lv = getFocusedListView();

            // 右クリック判定
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // フォーカス判定
            ListViewItem item = lv.FocusedItem;

            if (!lv.FocusedItem.Bounds.Contains(e.Location))
            {
                return;
            }

            User user = getUserFromScreenName(item.SubItems[0].Text);

            ContextMenuStrip cMenu = new ContextMenuStrip();

            // UserInfo
            ToolStripMenuItem menuItem_UserInfo = new ToolStripMenuItem();

            menuItem_UserInfo.Text   = "UserInfo";
            menuItem_UserInfo.Click += delegate
            {
                try
                {
                    Form_UserInfo f = new Form_UserInfo(this.tokens, user, this.myData, this.parentForm);
                    f.Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないユーザーです。",
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_UserInfo);

            cMenu.Show(Cursor.Position);
        }
Exemplo n.º 3
0
        private void shell()
        {
            logger.Debug("Shell open.");
            using (Form_Shell shell = new Form_Shell())
            {
                shell.ShowDialog();
                string command = shell.Command;
                logger.Debug("Command: {0}", command);

                switch(command)
                {
                    case "exit":
                        this.Close();
                        return;
                    case "restart":
                        logger.Debug("Restarting...");
                        if (this.disposable != null)
                        {
                            this.disposable.Dispose();
                            logger.Debug("Streaming has disposed.");
                        }
                        Application.Restart();
                        return;
                    case "reset all data":
                        Properties.Settings.Default.LastLoginUser = 0;
                        Properties.Settings.Default.AccessTokenList = null;
                        Properties.Settings.Default.Save();
                        logger.Debug("Account data has saved.");

                        logger.Debug("Restarting...");
                        Application.Restart();
                        return;
                    case "account":
                    case "ac":
                        manageAccount();
                        return;
                    case "info":
                        Form_UserInfo f = new Form_UserInfo(this.tokens, this.user, this.user, this);
                        f.Show();
                        return;
                    default:
                        break;
                }
                
                string[] commandArray = command.Split(' ');
                switch(commandArray[0])
                {
                    case "notify":
                        switch (commandArray[1])
                        {
                            case "on":
                                this.enabledNotify = true;
                                MessageBox.Show("notify: ON");
                                break;
                            case "off":
                                this.enabledNotify = false;
                                MessageBox.Show("notify: OFF");
                                break;
                            default:
                                break;
                        }
                        break;  // ?
                    case "account":
                    case "ac":
                        switch(commandArray[1])
                        {
                            case "add":
                                addAccount();
                                break;
                            case "-i":
                                int selectedIndex = 0;
                                if (int.TryParse(commandArray[2], out selectedIndex))
                                {
                                    if (Properties.Settings.Default.AccessTokenList.Count <= selectedIndex)
                                    {
                                        break;
                                    }

                                    if (Properties.Settings.Default.AccessTokenList[selectedIndex].Split(',')[0] == this.user.ScreenName)
                                    {
                                        break;
                                    }

                                    changeAccount(selectedIndex);
                                }
                                break;
                            default:
                                int num = 0;
                                string inputScreenName = commandArray[1];
                                foreach (string row in Properties.Settings.Default.AccessTokenList)
                                {
                                    string screenName = row.Split(',')[0];
                                    if (screenName == inputScreenName)
                                    {
                                        if (screenName == this.user.ScreenName)
                                        {
                                            break;
                                        }

                                        changeAccount(num);
                                        break;
                                    }
                                    num++;
                                }
                                string message = string.Format("Account @{0} has not been added.", inputScreenName);
                                MessageBox.Show(message,
                                    "Information.",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                                break;
                        }
                        break;  // ?
                    case "info":
                        if (command == "info")
                        {
                            Form_UserInfo f = new Form_UserInfo(this.tokens, this.user, this.user, this);
                            f.Show();
                            break;
                        }

                        string inputScreenName2 = command.Substring(5, command.Length - 5);
                        User inputUser = getUserFromScreenName(this.tokens, inputScreenName2);
                        if (inputUser != null)
                        {
                            Form_UserInfo f = new Form_UserInfo(this.tokens, inputUser, this.user, this);
                            f.Show();
                            break;
                        }

                        string message2 = string.Format("Account @{0} is not exist.", inputScreenName2);
                        MessageBox.Show(message2,
                            "Information.",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                        break;
                    default:
                        break;
                }
            }
        }
Exemplo n.º 4
0
        private void webBrowser_Detail_DocumentClick(object sender, HtmlElementEventArgs e)
        {
            HtmlElement clickedElement = webBrowser_Detail.Document.GetElementFromPoint(e.MousePosition);
            string link = null;
            if (clickedElement.TagName == "a" || clickedElement.TagName == "A")
            {
                link = clickedElement.GetAttribute("href");
            }
			else if (clickedElement.Parent != null)
			{
				if (clickedElement.Parent.TagName == "a" || clickedElement.Parent.TagName == "A")
				{
					link = clickedElement.Parent.GetAttribute("href");
				}
			}

			if (clickedElement.InnerText == "RT")
			{
				string tweetId = clickedElement.Parent.Parent.Parent.InnerHtml.Split(new string[] { " -->" }, StringSplitOptions.RemoveEmptyEntries)[0];
				tweetId = tweetId.Substring(5, tweetId.Length - 5);
				Status tweet = getTweetFromId(this.tokens, tweetId);

                retweet(tweet);
				return;
			}

			if (clickedElement.InnerText == "QT")
			{
                string tweetId = clickedElement.Parent.Parent.Parent.InnerHtml.Split(new string[] { " -->" }, StringSplitOptions.RemoveEmptyEntries)[0];
				tweetId = tweetId.Substring(5, tweetId.Length - 5);
				Status tweet = getTweetFromId(this.tokens, tweetId);

				quoteTweet(tweet);
				return;
			}

			if (clickedElement.InnerText == "☆" ||
                clickedElement.InnerText == "★")
			{
                string tweetId = clickedElement.Parent.Parent.Parent.InnerHtml.Split(new string[] { " -->" }, StringSplitOptions.RemoveEmptyEntries)[0];
				tweetId = tweetId.Substring(5, tweetId.Length - 5);
				Status tweet = getTweetFromId(this.tokens, tweetId);
                if (tweet.RetweetedStatus != null)
                {
                    tweet = tweet.RetweetedStatus;
                }

                favorite(tweet);
				return;
			}

            if (link == null || link == string.Empty)
            {
                return;
            }

            Regex linkToAccount = new Regex("https://www.twitter.com/[a-zA-Z0-9_]+", RegexOptions.IgnoreCase);
            if (linkToAccount.IsMatch(link))
            {
                try
                {
                    string screenName = link.Substring(24, link.Length - 24);
                    var user = this.tokens.Users.Lookup(screen_name => screenName);
                    Form_UserInfo f = new Form_UserInfo(this.tokens, user[0], this.user, this);
                    f.Show();
                    return;
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
            }

            try
            {
                System.Diagnostics.Process.Start(link);
            }
            catch
            {
            }
        }
Exemplo n.º 5
0
        private void listView_Timeline_MouseClick(object sender, MouseEventArgs e)
        {
            ListView lv = getFocusedListView();

            // 右クリック判定
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // フォーカス判定
            ListViewItem item = lv.FocusedItem;
            if (!lv.FocusedItem.Bounds.Contains(e.Location))
            {
                return;
            }

            Status tweet = getTweetFromId(this.tokens, item.SubItems[4].Text);
            if (tweet.RetweetedStatus != null)
            {
                tweet = tweet.RetweetedStatus;
            }

            ContextMenuStrip cMenu = new ContextMenuStrip();

            // UserInfo
            ToolStripMenuItem menuItem_UserInfo = new ToolStripMenuItem();
            menuItem_UserInfo.Text = "UserInfo";
            menuItem_UserInfo.Click += delegate
            {
                try
                {
                    Form_UserInfo f = new Form_UserInfo(this.tokens, tweet.User, this.user, this);
                    f.Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_UserInfo);

            // UserMarking
            ToolStripMenuItem menuItem_UserMarking = new ToolStripMenuItem();
            menuItem_UserMarking.Text = "Marking";
            menuItem_UserMarking.Click += delegate
            {
                try
                {
                    markUserInAllItem((long)tweet.User.Id);
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_UserMarking);

            if (tweet.InReplyToStatusId != null)
            {
                // Talk
                ToolStripMenuItem menuItem_Talk = new ToolStripMenuItem();
                menuItem_Talk.Text = "Talk";
                menuItem_Talk.Click += delegate
                {
                    try
                    {
                        List<Status> talk = getTalk(tweet);

                        Form_Talk f = new Form_Talk(this.tokens, talk, this);
                        f.Show();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("存在しないツイートです。",
                            "Error!!",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                };
                cMenu.Items.Add(menuItem_Talk);
            }

            // RT
            ToolStripMenuItem menuItem_RT = new ToolStripMenuItem();
            // menuItem_RT.Text = (bool)tweet.IsRetweeted ? "RT解除" : "RT";
            menuItem_RT.Text = "RT";
            menuItem_RT.Click += delegate
            {
                try
                {
                    retweet(tweet);
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_RT);

            // QT
            ToolStripMenuItem menuItem_QT = new ToolStripMenuItem();
            menuItem_QT.Text = "QT";
            menuItem_QT.Click += delegate
            {
                try
                {
                    quoteTweet(tweet);
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_QT);

            // favorte / Un-favorite
            ToolStripMenuItem menuItem_Favorite = new ToolStripMenuItem();
            menuItem_Favorite.Text = (bool)tweet.IsFavorited ? "Un-favorite" : "favorite";
            menuItem_Favorite.Click += delegate
            {
                try
                {
                    favorite(tweet);
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_Favorite);

            // delete
            if (tweet.User.ScreenName == this.user.ScreenName)
            {
                ToolStripMenuItem menuItem_Delete = new ToolStripMenuItem();
                menuItem_Delete.Text = "Delete";
                menuItem_Delete.Click += delegate
                {
                    try
                    {
                        this.tokens.Statuses.Destroy(id => tweet.Id);
                        lv.Items.RemoveAt(lv.SelectedIndices[0]);
                        string message = string.Format("Deleted: {0}",
                            tweet.Text);
                        changeStatus(message, NotificationStatus.DoDelete);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("存在しないツイートです。",
                            "Error!!",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                };
                cMenu.Items.Add(menuItem_Delete);
            }

            cMenu.Show(Cursor.Position);
        }
Exemplo n.º 6
0
        private void listView_Tweet_MouseClick(object sender, MouseEventArgs e)
        {
            ListView lv = getFocusedListView();

            // 右クリック判定
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // フォーカス判定
            ListViewItem item = lv.FocusedItem;

            if (!lv.FocusedItem.Bounds.Contains(e.Location))
            {
                return;
            }

            Status tweet = getTweetFromId(this.tokens, item.SubItems[2].Text);

            if (tweet.RetweetedStatus != null)
            {
                tweet = tweet.RetweetedStatus;
            }

            ContextMenuStrip cMenu = new ContextMenuStrip();

            // UserInfo
            ToolStripMenuItem menuItem_UserInfo = new ToolStripMenuItem();

            menuItem_UserInfo.Text   = "UserInfo";
            menuItem_UserInfo.Click += delegate
            {
                try
                {
                    Form_UserInfo f = new Form_UserInfo(this.tokens, tweet.User, this.myData, this.parentForm);
                    f.Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_UserInfo);

            if (tweet.InReplyToStatusId != null)
            {
                // Talk
                ToolStripMenuItem menuItem_Talk = new ToolStripMenuItem();
                menuItem_Talk.Text   = "Talk";
                menuItem_Talk.Click += delegate
                {
                    try
                    {
                        List <Status> talk = getTalk(tweet);

                        Form_Talk f = new Form_Talk(this.tokens, talk, this.parentForm);
                        f.Show();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("存在しないツイートです。",
                                        "Error!!",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                };
                cMenu.Items.Add(menuItem_Talk);
            }

            // RT
            ToolStripMenuItem menuItem_RT = new ToolStripMenuItem();

            // menuItem_RT.Text = (bool)tweet.IsRetweeted ? "RT解除" : "RT";
            menuItem_RT.Text   = "RT";
            menuItem_RT.Click += delegate
            {
                try
                {
                    retweet(tweet);
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_RT);

            // QT
            ToolStripMenuItem menuItem_QT = new ToolStripMenuItem();

            menuItem_QT.Text   = "QT";
            menuItem_QT.Click += delegate
            {
                try
                {
                    quoteTweet(tweet);
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_QT);

            // favorte / Un-favorite
            ToolStripMenuItem menuItem_Favorite = new ToolStripMenuItem();

            menuItem_Favorite.Text   = (bool)tweet.IsFavorited ? "Un-favorite" : "favorite";
            menuItem_Favorite.Click += delegate
            {
                try
                {
                    favorite(tweet);
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_Favorite);

            // delete
            if (tweet.User.ScreenName == this.tokens.Account.VerifyCredentials().ScreenName)
            {
                ToolStripMenuItem menuItem_Delete = new ToolStripMenuItem();
                menuItem_Delete.Text   = "Delete";
                menuItem_Delete.Click += delegate
                {
                    try
                    {
                        this.tokens.Statuses.Destroy(id => tweet.Id);
                        lv.Items.RemoveAt(lv.SelectedIndices[0]);
                        string message = string.Format("Deleted: {0}",
                                                       tweet.Text);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("存在しないツイートです。",
                                        "Error!!",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                };
                cMenu.Items.Add(menuItem_Delete);
            }

            cMenu.Show(Cursor.Position);
        }
Exemplo n.º 7
0
        private void webBrowser_Detail_DocumentClick(object sender, HtmlElementEventArgs e)
        {
            HtmlElement clickedElement = webBrowser_Detail.Document.GetElementFromPoint(e.MousePosition);
            string      link           = null;

            if (clickedElement.TagName == "a" || clickedElement.TagName == "A")
            {
                link = clickedElement.GetAttribute("href");
            }
            else if (clickedElement.Parent != null)
            {
                if (clickedElement.Parent.TagName == "a" || clickedElement.Parent.TagName == "A")
                {
                    link = clickedElement.Parent.GetAttribute("href");
                }
            }

            if (clickedElement.InnerText == "RT")
            {
                string tweetId = clickedElement.Parent.Parent.Parent.InnerHtml.Split(new string[] { " -->" }, StringSplitOptions.RemoveEmptyEntries)[0];
                tweetId = tweetId.Substring(5, tweetId.Length - 5);
                Status tweet = getTweetFromId(this.tokens, tweetId);

                retweet(tweet);
                return;
            }

            if (clickedElement.InnerText == "QT")
            {
                string tweetId = clickedElement.Parent.Parent.Parent.InnerHtml.Split(new string[] { " -->" }, StringSplitOptions.RemoveEmptyEntries)[0];
                tweetId = tweetId.Substring(5, tweetId.Length - 5);
                Status tweet = getTweetFromId(this.tokens, tweetId);

                quoteTweet(tweet);
                return;
            }

            if (clickedElement.InnerText == "☆" ||
                clickedElement.InnerText == "★")
            {
                string tweetId = clickedElement.Parent.Parent.Parent.InnerHtml.Split(new string[] { " -->" }, StringSplitOptions.RemoveEmptyEntries)[0];
                tweetId = tweetId.Substring(5, tweetId.Length - 5);
                Status tweet = getTweetFromId(this.tokens, tweetId);
                if (tweet.RetweetedStatus != null)
                {
                    tweet = tweet.RetweetedStatus;
                }

                favorite(tweet);
                return;
            }

            if (link == null || link == string.Empty)
            {
                return;
            }

            Regex linkToAccount = new Regex("https://www.twitter.com/[a-zA-Z0-9_]+", RegexOptions.IgnoreCase);

            if (linkToAccount.IsMatch(link))
            {
                try
                {
                    string        screenName = link.Substring(24, link.Length - 24);
                    var           user       = this.tokens.Users.Lookup(screen_name => screenName);
                    Form_UserInfo f          = new Form_UserInfo(this.tokens, user[0], this.myData, this.parentForm);
                    f.Show();
                    return;
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
            }

            try
            {
                System.Diagnostics.Process.Start(link);
            }
            catch
            {
            }
        }
Exemplo n.º 8
0
        private void listView_Users_MouseClick(object sender, MouseEventArgs e)
        {
            ListView lv = getFocusedListView();

            // 右クリック判定
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // フォーカス判定
            ListViewItem item = lv.FocusedItem;
            if (!lv.FocusedItem.Bounds.Contains(e.Location))
            {
                return;
            }

            User user = getUserFromScreenName(item.SubItems[0].Text);

            ContextMenuStrip cMenu = new ContextMenuStrip();

            // UserInfo
            ToolStripMenuItem menuItem_UserInfo = new ToolStripMenuItem();
            menuItem_UserInfo.Text = "UserInfo";
            menuItem_UserInfo.Click += delegate
            {
                try
                {
                    Form_UserInfo f = new Form_UserInfo(this.tokens, user, this.myData, this.parentForm);
                    f.Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないユーザーです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            };
            cMenu.Items.Add(menuItem_UserInfo);

            cMenu.Show(Cursor.Position);
        }
Exemplo n.º 9
0
        private void webBrowser_Talk_DocumentClick(object sender, HtmlElementEventArgs e)
        {
            HtmlElement clickedElement = webBrowser_Talk.Document.GetElementFromPoint(e.MousePosition);
            string link = null;
            if (clickedElement.TagName == "a" || clickedElement.TagName == "A")
            {
                link = clickedElement.GetAttribute("href");
            }
            else if (clickedElement.Parent != null)
            {
                if (clickedElement.Parent.TagName == "a" || clickedElement.Parent.TagName == "A")
                {
                    link = clickedElement.Parent.GetAttribute("href");
                }
            }

			if (link == null || link == string.Empty)
            {
                return;
            }

            Regex linkToAccount = new Regex("https://www.twitter.com/[a-zA-Z0-9_]+", RegexOptions.IgnoreCase);
            if (linkToAccount.IsMatch(link))
            {
                try
                {
                    string screenName = link.Substring(24, link.Length - 24);
                    var user = this.tokens.Users.Lookup(screen_name => screenName);
                    Form_UserInfo f = new Form_UserInfo(this.tokens, user[0], this.tokens.Account.VerifyCredentials(), this.parentForm);
                    f.Show();
                    return;
                }
                catch (Exception)
                {
                    MessageBox.Show("存在しないツイートです。",
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
            }

            try
            {
                System.Diagnostics.Process.Start(link);
            }
            catch
            {
            }
        }