Пример #1
0
        private async void WindowLoaded(object sender, RoutedEventArgs e)
        {
            var songInfo = PipeListener.staticpipelistener.LastPlayedSong;

            _songcache = songInfo?.Clone() as SongInfo;
            if (songInfo == null)
            {
                await this.ShowMessageAsync("メッセージ", "現在何も再生されていません。\n(注:アプリケーションが起動する前に再生されていた曲は取得できません)");

                this.Close();
                return;
            }

            var isource = new Func <BitmapSource>(() =>
            {
                try
                {
                    if (!songInfo.IsAlbumArtAvaliable())
                    {
                        return(null);
                    }
                    return(GdiUtils.ToImageSource(songInfo.GetAlbumArt()));
                }
                catch
                {
                    return(null);
                }
            })();

            AlbumArtImage.Source = isource;
            TweetTextBox.Text    = TweetConverter.SongInfoToString(ConfigStore.StaticConfig.TweetFormat, songInfo);
            TweetTextBox.Focus();
        }
Пример #2
0
        private async void TweetButton_Click(object sender, EventArgs e)
        {
            if (Tokens == null)
            {
                ToolStripStatusLabel.Text = @"まだにんしょうしていません(X3)";
                return;
            }
            string text = TweetTextBox.Text;

            TweetTextBox.Clear();
            TweetTextBox.Focus();

            await ApplyCommandAndTweet(text);
        }
Пример #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            RepliedPokerToolStripMenuItem.Checked = Properties.Settings.Default.IsRepliedPokerChecked;
            string folder = AppDomain.CurrentDomain.BaseDirectory + "Setting";

            Directory.CreateDirectory(folder);
            string fileName = $@"{folder}\Account.cfg";

            fileName = Path.GetFullPath(fileName);

            if (File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    while (sr.Peek() >= 1)
                    {
                        var readLine = sr.ReadLine();
                        if (readLine != null)
                        {
                            string[] token = readLine.Split('|');
                            AccountComboBox.Items.Add($"{token[0]}({token[1]})");
                        }
                    }
                }
            }
            else
            {
                AccountComboBox.Items.Add("あかうんとせんたく");
            }
            AccountComboBox.SelectedIndex = 0;

            fileName = $@"{folder}\ScheduledTweets.json";
            if (File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
                {
                    string text = sr.ReadToEnd();
                    ScheduledTweetList = JsonConvert.DeserializeObject <List <ScheduledTweetClass> >(text);
                }
                using (StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8))
                {
                    sw.Write("");
                }
            }

            if (ScheduledTweetList == null)
            {
                ScheduledTweetList = new List <ScheduledTweetClass>();
            }

            fileName = $@"{folder}\Settings.json";
            if (File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
                {
                    string text = sr.ReadToEnd();
                    _kibotterSetting = JsonConvert.DeserializeObject <KIBOTTERSettingClass>(text);
                }
                Properties.Settings.Default.IsBlackTheme = _kibotterSetting.IsBlackTheme;
                if (_kibotterSetting.IsBlackTheme)
                {
                    ChangeThemeToBlack();
                }
            }

            if (_kibotterSetting == null)
            {
                _kibotterSetting = new KIBOTTERSettingClass();
                _kibotterSetting.ExperiencePoint = 0;
            }

            int left = Screen.PrimaryScreen.WorkingArea.Width - Width;
            int top  = Screen.PrimaryScreen.WorkingArea.Height - Height;

            DesktopBounds   = new Rectangle(left, top, Width, Height);
            FormBorderStyle = FormBorderStyle.FixedSingle;
            MaximumSize     = Size;

            TweetTextBox.AllowDrop = true;

            LiveTag = string.Empty;

            NewTimer();
            StartTimer();

            TweetTextBox.Focus();
        }
Пример #4
0
        //ここまで

        private void TweetButton_Click(object sender, EventArgs e)
        {
            if (Tokens == null)
            {
                StatusLabel.Text = "まだにんしょうしていません(X3)";
                return;
            }

            var text = TweetTextBox.Text.TrimEnd('\r', '\n');

            if (string.IsNullOrEmpty(text))
            {
                TweetTextBox.Clear();
                StatusLabel.Text = "しっぱいしました(X3)";
                TweetTextBox.Focus();
                return;
            }

            if (寿司モードToolStripMenuItem.Checked)
            {
                var sushiText = string.Empty;

                for (int i = 0; i < text.Length; i++)
                {
                    sushiText += "🍣";
                }

                text = sushiText;
            }
            else if (モールス信号ToolStripMenuItem.Checked)
            {
                MorseCode mc = new MorseCode();
                text = mc.ConvertToMorse(text);
                if (text == "error")
                {
                    StatusLabel.Text = "もーるすしんごうにできませんでした(X3)";
                    return;
                }
            }

            if (text == "!poker")
            {
                text = string.Empty;

                if (ポーカーのリプライ化ToolStripMenuItem.Checked)
                {
                    text = $"@KIBOUDIED \r\n";
                }

                text += CommandPoker();
            }
            else if (text == "!bill")
            {
                // IPアドレスを使ってるから心配ならいじるといいかも
                string ipAddress = string.Empty;

                IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName());
                foreach (IPAddress ip in ipEntry.AddressList)
                {
                    if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        ipAddress = ip.ToString();
                        break;
                    }
                }

                int IntegerIP = (int)(long.Parse(ipAddress.Replace(".", "")) / 1000);
                int bill      = (IntegerIP + int.Parse(DateTime.Now.ToString("yyyyMMdd"))) % 10000;

                text = $"本日のTwitter利用料 {bill:#,0}円";
            }

            // !nowをテキスト中に入れるとそこを時間に置き換える
            // 例:「なう(!now)」→「なう(2016/09/07 01:00:00)」
            int startIndex;

            if (0 <= (startIndex = text.IndexOf("!now")))
            {
                text = text.Remove(startIndex, 4).Insert(startIndex, DateTime.Now.ToString());
            }

            Tweet(text, 1);
        }
Пример #5
0
        public void Tweet(string text, int count)
        {
            const string completeText = "ついーとしました(:3)";
            const string failureText  = "しっぱいしました(X3)";

            string textWithCount = text;

            try
            {
                if (count != 1)
                {
                    textWithCount += $"({count}回目)";

                    if (textWithCount.Length > 140)
                    {
                        StatusLabel.Text = failureText;
                        TweetTextBox.Focus();
                        return;
                    }
                }

                ToolStripMenuItem a1 = (ToolStripMenuItem)menuStrip1.Items[1];
                try
                {
                    if (picturecounts - 1 == 0)
                    {
                        Tokens.Statuses.Update(status => textWithCount, in_reply_to_status_id => replyidstr.Text);
                        replyidstr.Text = "";
                    }
                    else if (picturecounts - 1 == 1)
                    {
                        MediaUploadResult first = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[1].Text));
                        Status            s     = Tokens.Statuses.Update(status: textWithCount, media_ids: new long[] { first.MediaId }, in_reply_to_status_id: long.Parse(replyidstr.Text));
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        picturecounts--;
                        picturecount.Text = (picturecounts - 1).ToString();
                        replyidstr.Text   = "";
                    }
                    else if (picturecounts - 1 == 2)
                    {
                        MediaUploadResult first  = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[1].Text));
                        MediaUploadResult second = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[2].Text));
                        Status            s      = Tokens.Statuses.Update(status: textWithCount, media_ids: new long[] { first.MediaId, second.MediaId });
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        picturecounts     = picturecounts - 2;
                        picturecount.Text = (picturecounts - 1).ToString();
                        replyidstr.Text   = "";
                    }
                    else if (picturecounts - 1 == 3)
                    {
                        MediaUploadResult first  = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[1].Text));
                        MediaUploadResult second = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[2].Text));
                        MediaUploadResult third  = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[3].Text));
                        Status            s      = Tokens.Statuses.Update(status: textWithCount, media_ids: new long[] { first.MediaId, second.MediaId, third.MediaId });
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        picturecounts     = picturecounts - 3;
                        picturecount.Text = (picturecounts - 1).ToString();
                        replyidstr.Text   = "";
                    }
                    else if (picturecounts - 1 == 4)
                    {
                        MediaUploadResult first  = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[1].Text));
                        MediaUploadResult second = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[2].Text));
                        MediaUploadResult third  = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[3].Text));
                        MediaUploadResult fourth = Tokens.Media.Upload(media: new FileInfo(@a1.DropDownItems[4].Text));
                        Status            s      = Tokens.Statuses.Update(status: textWithCount, media_ids: new long[] { first.MediaId, second.MediaId, third.MediaId, fourth.MediaId });
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        addPictureToolStripMenuItem.DropDownItems.RemoveAt(1);
                        picturecounts     = picturecounts - 4;
                        picturecount.Text = (picturecounts - 1).ToString();
                        replyidstr.Text   = "";
                    }
                }
                catch (Exception ex)
                {
                    StatusLabel.Text = failureText;
                }

                TweetTextBox.Clear();
                var resultText = completeText;

                if (count != 1)
                {
                    resultText += $"({count}回目)";
                }

                StatusLabel.Text = resultText;
                TweetTextBox.Focus();
            }
            catch
            {
                count++;
                Tweet(text, count);
            }
        }
Пример #6
0
 private void CharactersCountTextBlock_MouseEnter(object sender, MouseEventArgs e)
 {
     TweetTextBox.Focus();
 }