private void MainForm_Load(object sender, EventArgs e) { // 設定ファイルを読み込み // try { if (File.Exists(settingsFilePath) == true) { BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream(settingsFilePath, FileMode.Open); appSettings = (Settings)bf.Deserialize(fs); fs.Close(); twitterAuth = new TwitterLib.Authorization(twitterConsumerKey, twitterConsuemrSecret, appSettings.TwitterID, appSettings.TwitterTokenValue, appSettings.TwitterTokenSecret); twitterTL = new TwitterLib.TimeLine(twitterAuth); } } catch (Exception ex) { MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } // フォーム // this.Text = this.ProductName + " " + this.ProductVersion; // バージョン タブ // Label_ProductName.Text = this.ProductName + " Windows 版"; Label_ProductVersion.Text = "バージョン: " + this.ProductVersion; System.Reflection.AssemblyDescriptionAttribute asmdc = (System.Reflection.AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(System.Reflection.AssemblyDescriptionAttribute)); TextBox_License.Text = asmdc.Description; // Twitter タブ // TwitterTL_ThreadStart(); // ニコニコ動画 タブ // NicoVideo_ComboBox_Category.Items.AddRange(nicoVideoRanking.getCategoryList()); NicoVideo_ComboBox_Category.SelectedIndex = 0; NicoVideoRanking_ThreadStart(); // Pixiv タブ // Pixiv_ComboBox_CategorySearch.Items.AddRange(pixivRanking.getCategoryList()); Pixiv_ComboBox_CategorySearch.SelectedIndex = 0; PixivRanking_ThreadStart(); // 初音ミク タブ // HatsuneMiku_CheckBox_BGM.Enabled = Directory.Exists(Path.GetDirectoryName(hatsuneMikuBGMFilePath)) && File.Exists(hatsuneMikuBGMFilePath); HatsuneMiku_ThreadStart(); // Bad Apple // BadApple_CheckBox_BGM.Enabled = Directory.Exists(Path.GetDirectoryName(badAppleBGMFilePath)) && File.Exists(badAppleBGMFilePath); BadApple_ThreadStart(); try { // デバイスを接続 // myGLCD = new GraphicLCD(7, 6, 5, 4, 0, 1, 2, 3); myGLCD.Begin(); // GLCDサイズを設定 // GLCD_top = new Size(myGLCD.Width, myGLCD.Height); GLCD_wide = new Size(myGLCD.Height, myGLCD.Width); // 起動画像を表示 // GLCD_Draw(new Bitmap(startupImagePath)); } catch (Exception ex) { MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
/*** Twitter タブ ***/ private void Twitter_Button_Authorization_Click(object sender, EventArgs e) { try { // 認証キーを設定 // twitterAuth = new TwitterLib.Authorization(twitterConsumerKey, twitterConsuemrSecret); // 認証ページを開く // Process.Start(twitterAuth.getAuthUrl()); // 暗証番号入力フォームを開く // AuthForm f = new AuthForm(); if (f.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } // PINを設定 // twitterAuth.setPIN(f.PIN); f.Dispose(); // メッセージを表示 // MessageBox.Show("正常に登録されました。", "情報", MessageBoxButtons.OK, MessageBoxIcon.Information); // リストボックスを更新 // TwitterTL_Update(); // 設定を保存 // try { appSettings.TwitterID = twitterAuth.TwitterID; appSettings.TwitterTokenValue = twitterAuth.TwitterTokenValue; appSettings.TwitterTokenSecret = twitterAuth.TwitterTokenSecret; BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream(settingsFilePath, FileMode.Create); bf.Serialize(fs, appSettings); fs.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } }