Initialize() public method

public Initialize ( string token, string tokenSecret, string username, long userId ) : void
token string
tokenSecret string
username string
userId long
return void
Exemplo n.º 1
0
        public void BeginSelection_BlankTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                var eventCalled = false;
                mediaSelector.BeginSelecting += (o, e) => eventCalled = true;

                mediaSelector.BeginSelection();

                Assert.True(eventCalled);

                Assert.True(mediaSelector.Visible);
                Assert.True(mediaSelector.Enabled);

                // 1 ページ目のみ選択可能な状態
                var pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1" }, pages.Cast<object>().Select(x => x.ToString()));

                // 1 ページ目が表示されている
                Assert.Equal("1", mediaSelector.ImagePageCombo.Text);
                Assert.Equal("", mediaSelector.ImagefilePathText.Text);
                Assert.Null(mediaSelector.ImageSelectedPicture.Image);
            }
        }
Exemplo n.º 2
0
        public void Initialize_yfrogTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector())
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "yfrog");

                // 投稿先に yfrog が選択されている
                Assert.Equal("yfrog", mediaSelector.ImageServiceCombo.Text);

                // ページ番号が初期化された状態
                var pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1" }, pages.Cast<object>().Select(x => x.ToString()));

                // 代替テキストの入力欄が非表示の状態
                Assert.False(mediaSelector.AlternativeTextPanel.Visible);
            }
        }
Exemplo n.º 3
0
        public void ImagePathInput_ReplaceMemoryImageMediaItemTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                using (var bitmap = new Bitmap(width: 200, height: 200))
                {
                    mediaSelector.BeginSelection(bitmap);
                }

                // 既に入力されているファイルパスの画像
                var image1 = mediaSelector.ImageSelectedPicture.Image;

                // 内部で保持されている MemoryImageMediaItem を取り出す
                var selectedMedia = mediaSelector.ImagePageCombo.SelectedItem;
                var mediaProperty = selectedMedia.GetType().GetProperty("Item");
                var mediaItem = (MemoryImageMediaItem)mediaProperty.GetValue(selectedMedia);

                // 別の画像のファイルパスを入力
                mediaSelector.ImagefilePathText.Text = Path.GetFullPath("Resources/re1.png");
                TestUtils.Validate(mediaSelector.ImagefilePathText);

                // 入力したパスの画像が表示される
                using (var imageStream = File.OpenRead("Resources/re1.png"))
                using (var image2 = MemoryImage.CopyFromStream(imageStream))
                {
                    Assert.Equal(image2, mediaSelector.ImageSelectedPicture.Image);
                }

                // 最初に入力されていたファイルパスの表示用の MemoryImage は破棄される
                Assert.True(image1.IsDisposed);

                // 参照されなくなった MemoryImageMediaItem も破棄される
                Assert.True(mediaItem.IsDisposed);
            }
        }
Exemplo n.º 4
0
        public void ImageServiceChange_Test()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                Assert.Equal("Twitter", mediaSelector.ServiceName);

                mediaSelector.BeginSelection(new[] { "Resources/re.gif", "Resources/re1.png" });

                // 3 ページ目まで選択可能な状態
                var pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1", "2", "3" }, pages.Cast<object>().Select(x => x.ToString()));
                Assert.True(mediaSelector.ImagePageCombo.Enabled);

                var eventCalled = false;
                mediaSelector.SelectedServiceChanged += (o, e) => eventCalled = true;

                // 投稿先を yfrog に変更
                mediaSelector.ImageServiceCombo.SelectedIndex =
                    mediaSelector.ImageServiceCombo.Items.IndexOf("yfrog");

                Assert.True(eventCalled); // SelectedServiceChanged イベントが呼ばれる

                // 1 ページ目のみ選択可能な状態 (Disabled)
                pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1" }, pages.Cast<object>().Select(x => x.ToString()));
                Assert.False(mediaSelector.ImagePageCombo.Enabled);

                // 投稿先を Twitter に変更
                mediaSelector.ImageServiceCombo.SelectedIndex =
                    mediaSelector.ImageServiceCombo.Items.IndexOf("Twitter");

                // 2 ページ目まで選択可能な状態
                pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1", "2" }, pages.Cast<object>().Select(x => x.ToString()));
                Assert.True(mediaSelector.ImagePageCombo.Enabled);
            }
        }
Exemplo n.º 5
0
        public void ImagePathInput_Test()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");
                mediaSelector.BeginSelection();

                // 画像のファイルパスを入力
                mediaSelector.ImagefilePathText.Text = Path.GetFullPath("Resources/re1.png");
                TestUtils.Validate(mediaSelector.ImagefilePathText);

                // 入力したパスの画像が表示される
                using (var imageStream = File.OpenRead("Resources/re1.png"))
                using (var image = MemoryImage.CopyFromStream(imageStream))
                {
                    Assert.Equal(image, mediaSelector.ImageSelectedPicture.Image);
                }

                // 2 ページ目まで選択可能な状態
                var pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1", "2" }, pages.Cast<object>().Select(x => x.ToString()));
            }
        }
Exemplo n.º 6
0
        public void ImagePathInput_ReplaceFileMediaItemTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                mediaSelector.BeginSelection(new[] { "Resources/re.gif" });

                // 既に入力されているファイルパスの画像
                var image1 = mediaSelector.ImageSelectedPicture.Image;

                // 別の画像のファイルパスを入力
                mediaSelector.ImagefilePathText.Text = Path.GetFullPath("Resources/re1.png");
                TestUtils.Validate(mediaSelector.ImagefilePathText);

                // 入力したパスの画像が表示される
                using (var imageStream = File.OpenRead("Resources/re1.png"))
                using (var image2 = MemoryImage.CopyFromStream(imageStream))
                {
                    Assert.Equal(image2, mediaSelector.ImageSelectedPicture.Image);
                }

                // 最初に入力されていたファイルパスの表示用の MemoryImage は破棄される
                Assert.True(image1.IsDisposed);
            }
        }
Exemplo n.º 7
0
        public void PageChange_AlternativeTextTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                var images = new[] { "Resources/re.gif", "Resources/re1.png" };
                mediaSelector.BeginSelection(images);

                // 1 ページ目
                mediaSelector.ImagePageCombo.SelectedIndex = 0;
                mediaSelector.AlternativeTextBox.Text = "Page 1";
                mediaSelector.ValidateChildren();

                // 2 ページ目
                mediaSelector.ImagePageCombo.SelectedIndex = 1;
                mediaSelector.AlternativeTextBox.Text = "Page 2";
                mediaSelector.ValidateChildren();

                // 3 ページ目 (新規ページ)
                mediaSelector.ImagePageCombo.SelectedIndex = 2;
                mediaSelector.AlternativeTextBox.Text = "Page 3";
                mediaSelector.ValidateChildren();

                mediaSelector.ImagePageCombo.SelectedIndex = 0;
                Assert.Equal("Page 1", mediaSelector.AlternativeTextBox.Text);

                mediaSelector.ImagePageCombo.SelectedIndex = 1;
                Assert.Equal("Page 2", mediaSelector.AlternativeTextBox.Text);

                // 画像が指定されていないページは入力した代替テキストも保持されない
                mediaSelector.ImagePageCombo.SelectedIndex = 2;
                Assert.Equal("", mediaSelector.AlternativeTextBox.Text);
            }
        }
Exemplo n.º 8
0
        public void PageChange_ImageDisposeTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                var images = new[] { "Resources/re.gif", "Resources/re1.png" };
                mediaSelector.BeginSelection(images);

                mediaSelector.ImagePageCombo.SelectedIndex = 0;

                // 1 ページ目
                var page1Image = mediaSelector.ImageSelectedPicture.Image;

                mediaSelector.ImagePageCombo.SelectedIndex = 1;

                // 2 ページ目
                var page2Image = mediaSelector.ImageSelectedPicture.Image;
                Assert.True(page1Image.IsDisposed); // 前ページの画像が破棄されているか

                mediaSelector.ImagePageCombo.SelectedIndex = 2;

                // 3 ページ目 (新規ページ)
                Assert.True(page2Image.IsDisposed); // 前ページの画像が破棄されているか
            }
        }
Exemplo n.º 9
0
        public void PageChange_Test()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                var images = new[] { "Resources/re.gif", "Resources/re1.png" };
                mediaSelector.BeginSelection(images);

                mediaSelector.ImagePageCombo.SelectedIndex = 0;

                // 1 ページ目
                Assert.Equal("1", mediaSelector.ImagePageCombo.Text);
                Assert.Equal(Path.GetFullPath("Resources/re.gif"), mediaSelector.ImagefilePathText.Text);

                using (var imageStream = File.OpenRead("Resources/re.gif"))
                using (var image = MemoryImage.CopyFromStream(imageStream))
                {
                    Assert.Equal(image, mediaSelector.ImageSelectedPicture.Image);
                }

                mediaSelector.ImagePageCombo.SelectedIndex = 1;

                // 2 ページ目
                Assert.Equal("2", mediaSelector.ImagePageCombo.Text);
                Assert.Equal(Path.GetFullPath("Resources/re1.png"), mediaSelector.ImagefilePathText.Text);

                using (var imageStream = File.OpenRead("Resources/re1.png"))
                using (var image = MemoryImage.CopyFromStream(imageStream))
                {
                    Assert.Equal(image, mediaSelector.ImageSelectedPicture.Image);
                }

                mediaSelector.ImagePageCombo.SelectedIndex = 2;

                // 3 ページ目 (新規ページ)
                Assert.Equal("3", mediaSelector.ImagePageCombo.Text);
                Assert.Equal("", mediaSelector.ImagefilePathText.Text);
                Assert.Null(mediaSelector.ImageSelectedPicture.Image);
            }
        }
Exemplo n.º 10
0
        public void EndSelection_Test()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");
                mediaSelector.BeginSelection(new[] { "Resources/re.gif" });

                var displayImage = mediaSelector.ImageSelectedPicture.Image; // 表示中の画像

                var eventCalled = false;
                mediaSelector.EndSelecting += (o, e) => eventCalled = true;

                mediaSelector.EndSelection();

                Assert.True(eventCalled);

                Assert.False(mediaSelector.Visible);
                Assert.False(mediaSelector.Enabled);

                Assert.True(displayImage.IsDisposed);
            }
        }
Exemplo n.º 11
0
        public void BeginSelection_MultiImageTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                var images = new[] { "Resources/re.gif", "Resources/re1.png" };
                mediaSelector.BeginSelection(images);

                // 3 ページ目まで選択可能な状態
                var pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1", "2", "3" }, pages.Cast<object>().Select(x => x.ToString()));

                // 1 ページ目が表示されている
                Assert.Equal("1", mediaSelector.ImagePageCombo.Text);
                Assert.Equal(Path.GetFullPath("Resources/re.gif"), mediaSelector.ImagefilePathText.Text);

                using (var imageStream = File.OpenRead("Resources/re.gif"))
                using (var image = MemoryImage.CopyFromStream(imageStream))
                {
                    Assert.Equal(image, mediaSelector.ImageSelectedPicture.Image);
                }
            }
        }
Exemplo n.º 12
0
        public void BeginSelection_MemoryImageTest()
        {
            using (var twitter = new Twitter())
            using (var mediaSelector = new MediaSelector { Visible = false, Enabled = false })
            {
                twitter.Initialize("", "", "", 0L);
                mediaSelector.Initialize(twitter, TwitterConfiguration.DefaultConfiguration(), "Twitter");

                var eventCalled = false;
                mediaSelector.BeginSelecting += (o, e) => eventCalled = true;

                using (var bitmap = new Bitmap(width: 200, height: 200))
                {
                    mediaSelector.BeginSelection(bitmap);
                }

                Assert.True(eventCalled);

                Assert.True(mediaSelector.Visible);
                Assert.True(mediaSelector.Enabled);

                // 2 ページ目まで選択可能な状態
                var pages = mediaSelector.ImagePageCombo.Items;
                Assert.Equal(new[] { "1", "2" }, pages.Cast<object>().Select(x => x.ToString()));

                // 1 ページ目が表示されている
                Assert.Equal("1", mediaSelector.ImagePageCombo.Text);
                Assert.True(Regex.IsMatch(mediaSelector.ImagefilePathText.Text, @"^<>MemoryImage://\d+.png$"));

                using (var bitmap = new Bitmap(width: 200, height: 200))
                using (var image = MemoryImage.CopyFromImage(bitmap))
                {
                    Assert.Equal(image, mediaSelector.ImageSelectedPicture.Image);
                }
            }
        }
Exemplo n.º 13
0
        private void TweenMain_Load(object sender, EventArgs e)
        {
            _ignoreConfigSave = true;
            this.Visible = false;

            if (MyApplication.StartupOptions.ContainsKey("d"))
                MyCommon.TraceFlag = true;

            InitializeTraceFrag();

            //Win32Api.SetProxy(HttpConnection.ProxyType.Specified, "127.0.0.1", 8080, "user", "pass")

            MyCommon.TwitterApiInfo.AccessLimitUpdated += TwitterApiStatus_AccessLimitUpdated;
            Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

            Regex.CacheSize = 100;

            //発言保持クラス
            _statuses = TabInformations.GetInstance();

            //アイコン設定
            LoadIcons();
            this.Icon = MainIcon;              //メインフォーム(TweenMain)
            NotifyIcon1.Icon = NIconAt;      //タスクトレイ
            TabImage.Images.Add(TabIcon);    //タブ見出し

            //<<<<<<<<<設定関連>>>>>>>>>
            ////設定読み出し
            LoadConfig();

            // 現在の DPI と設定保存時の DPI との比を取得する
            var configScaleFactor = this._cfgLocal.GetConfigScaleFactor(this.CurrentAutoScaleDimensions);

            // UIフォント設定
            var fontUIGlobal = this._cfgLocal.FontUIGlobal;
            if (fontUIGlobal != null)
            {
                OTBaseForm.GlobalFont = fontUIGlobal;
                this.Font = fontUIGlobal;
            }

            //不正値チェック
            if (!MyApplication.StartupOptions.ContainsKey("nolimit"))
            {
                if (this._cfgCommon.TimelinePeriod < 15 && this._cfgCommon.TimelinePeriod > 0)
                    this._cfgCommon.TimelinePeriod = 15;

                if (this._cfgCommon.ReplyPeriod < 15 && this._cfgCommon.ReplyPeriod > 0)
                    this._cfgCommon.ReplyPeriod = 15;

                if (this._cfgCommon.DMPeriod < 15 && this._cfgCommon.DMPeriod > 0)
                    this._cfgCommon.DMPeriod = 15;

                if (this._cfgCommon.PubSearchPeriod < 30 && this._cfgCommon.PubSearchPeriod > 0)
                    this._cfgCommon.PubSearchPeriod = 30;

                if (this._cfgCommon.UserTimelinePeriod < 15 && this._cfgCommon.UserTimelinePeriod > 0)
                    this._cfgCommon.UserTimelinePeriod = 15;

                if (this._cfgCommon.ListsPeriod < 15 && this._cfgCommon.ListsPeriod > 0)
                    this._cfgCommon.ListsPeriod = 15;
            }

            if (!Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.Timeline, this._cfgCommon.CountApi))
                this._cfgCommon.CountApi = 60;
            if (!Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.Reply, this._cfgCommon.CountApiReply))
                this._cfgCommon.CountApiReply = 40;

            if (this._cfgCommon.MoreCountApi != 0 && !Twitter.VerifyMoreApiResultCount(this._cfgCommon.MoreCountApi))
                this._cfgCommon.MoreCountApi = 200;
            if (this._cfgCommon.FirstCountApi != 0 && !Twitter.VerifyFirstApiResultCount(this._cfgCommon.FirstCountApi))
                this._cfgCommon.FirstCountApi = 100;

            if (this._cfgCommon.FavoritesCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.Favorites, this._cfgCommon.FavoritesCountApi))
                this._cfgCommon.FavoritesCountApi = 40;
            if (this._cfgCommon.ListCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.List, this._cfgCommon.ListCountApi))
                this._cfgCommon.ListCountApi = 100;
            if (this._cfgCommon.SearchCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.PublicSearch, this._cfgCommon.SearchCountApi))
                this._cfgCommon.SearchCountApi = 100;
            if (this._cfgCommon.UserTimelineCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.UserTimeline, this._cfgCommon.UserTimelineCountApi))
                this._cfgCommon.UserTimelineCountApi = 20;

            //廃止サービスが選択されていた場合ux.nuへ読み替え
            if (this._cfgCommon.AutoShortUrlFirst < 0)
                this._cfgCommon.AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu;

            TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost;
            this.tw = new Twitter(this.twitterApi);

            //認証関連
            if (string.IsNullOrEmpty(this._cfgCommon.Token)) this._cfgCommon.UserName = "";
            tw.Initialize(this._cfgCommon.Token, this._cfgCommon.TokenSecret, this._cfgCommon.UserName, this._cfgCommon.UserId);

            _initial = true;

            Networking.Initialize();

            bool saveRequired = false;
            bool firstRun = false;

            //ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など)
            if (string.IsNullOrEmpty(tw.Username))
            {
                saveRequired = true;
                firstRun = true;

                //設定せずにキャンセルされたか、設定されたが依然ユーザー名が未設定ならプログラム終了
                if (ShowSettingDialog(showTaskbarIcon: true) != DialogResult.OK ||
                    string.IsNullOrEmpty(tw.Username))
                {
                    Application.Exit();  //強制終了
                    return;
                }
            }

            //Twitter用通信クラス初期化
            Networking.DefaultTimeout = TimeSpan.FromSeconds(this._cfgCommon.DefaultTimeOut);
            Networking.UploadImageTimeout = TimeSpan.FromSeconds(this._cfgCommon.UploadImageTimeout);
            Networking.SetWebProxy(this._cfgLocal.ProxyType,
                this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort,
                this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword);
            Networking.ForceIPv4 = this._cfgCommon.ForceIPv4;

            TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost;
            tw.RestrictFavCheck = this._cfgCommon.RestrictFavCheck;
            tw.ReadOwnPost = this._cfgCommon.ReadOwnPost;
            tw.TrackWord = this._cfgCommon.TrackWord;
            TrackToolStripMenuItem.Checked = !String.IsNullOrEmpty(tw.TrackWord);
            tw.AllAtReply = this._cfgCommon.AllAtReply;
            AllrepliesToolStripMenuItem.Checked = tw.AllAtReply;
            ShortUrl.Instance.DisableExpanding = !this._cfgCommon.TinyUrlResolve;
            ShortUrl.Instance.BitlyId = this._cfgCommon.BilyUser;
            ShortUrl.Instance.BitlyKey = this._cfgCommon.BitlyPwd;

            // アクセストークンが有効であるか確認する
            // ここが Twitter API への最初のアクセスになるようにすること
            try
            {
                this.tw.VerifyCredentials();
            }
            catch (WebApiException ex)
            {
                MessageBox.Show(this, string.Format(Properties.Resources.StartupAuthError_Text, ex.Message),
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            //サムネイル関連の初期化
            //プロキシ設定等の通信まわりの初期化が済んでから処理する
            ThumbnailGenerator.InitializeGenerator();

            var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance;
            imgazyobizinet.Enabled = this._cfgCommon.EnableImgAzyobuziNet;
            imgazyobizinet.DisabledInDM = this._cfgCommon.ImgAzyobuziNetDisabledInDM;

            Thumbnail.Services.TonTwitterCom.GetApiConnection = () => this.twitterApi.Connection;

            //画像投稿サービス
            ImageSelector.Initialize(tw, this.tw.Configuration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);

            //ハッシュタグ/@id関連
            AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@");
            HashSupl = new AtIdSupplement(_cfgCommon.HashTags, "#");
            HashMgr = new HashtagManage(HashSupl,
                                    _cfgCommon.HashTags.ToArray(),
                                    _cfgCommon.HashSelected,
                                    _cfgCommon.HashIsPermanent,
                                    _cfgCommon.HashIsHead,
                                    _cfgCommon.HashIsNotAddToAtReply);
            if (!string.IsNullOrEmpty(HashMgr.UseHash) && HashMgr.IsPermanent) HashStripSplitButton.Text = HashMgr.UseHash;

            //アイコンリスト作成
            this.IconCache = new ImageCache();
            this.tweetDetailsView.IconCache = this.IconCache;

            //フォント&文字色&背景色保持
            _fntUnread = this._cfgLocal.FontUnread;
            _clUnread = this._cfgLocal.ColorUnread;
            _fntReaded = this._cfgLocal.FontRead;
            _clReaded = this._cfgLocal.ColorRead;
            _clFav = this._cfgLocal.ColorFav;
            _clOWL = this._cfgLocal.ColorOWL;
            _clRetweet = this._cfgLocal.ColorRetweet;
            _fntDetail = this._cfgLocal.FontDetail;
            _clDetail = this._cfgLocal.ColorDetail;
            _clDetailLink = this._cfgLocal.ColorDetailLink;
            _clDetailBackcolor = this._cfgLocal.ColorDetailBackcolor;
            _clSelf = this._cfgLocal.ColorSelf;
            _clAtSelf = this._cfgLocal.ColorAtSelf;
            _clTarget = this._cfgLocal.ColorTarget;
            _clAtTarget = this._cfgLocal.ColorAtTarget;
            _clAtFromTarget = this._cfgLocal.ColorAtFromTarget;
            _clAtTo = this._cfgLocal.ColorAtTo;
            _clListBackcolor = this._cfgLocal.ColorListBackcolor;
            _clInputBackcolor = this._cfgLocal.ColorInputBackcolor;
            _clInputFont = this._cfgLocal.ColorInputFont;
            _fntInputFont = this._cfgLocal.FontInputFont;

            _brsBackColorMine = new SolidBrush(_clSelf);
            _brsBackColorAt = new SolidBrush(_clAtSelf);
            _brsBackColorYou = new SolidBrush(_clTarget);
            _brsBackColorAtYou = new SolidBrush(_clAtTarget);
            _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget);
            _brsBackColorAtTo = new SolidBrush(_clAtTo);
            //_brsBackColorNone = new SolidBrush(Color.FromKnownColor(KnownColor.Window));
            _brsBackColorNone = new SolidBrush(_clListBackcolor);

            // StringFormatオブジェクトへの事前設定
            //sf.Alignment = StringAlignment.Near;             // Textを近くへ配置(左から右の場合は左寄せ)
            //sf.LineAlignment = StringAlignment.Near;         // Textを近くへ配置(上寄せ)
            //sf.FormatFlags = StringFormatFlags.LineLimit;    // 
            sfTab.Alignment = StringAlignment.Center;
            sfTab.LineAlignment = StringAlignment.Center;

            InitDetailHtmlFormat();

            //Regex statregex = new Regex("^0*");
            this.recommendedStatusFooter = " [TWNv" + Regex.Replace(MyCommon.FileVersion.Replace(".", ""), "^0*", "") + "]";

            _history.Add(new PostingStatus());
            _hisIdx = 0;
            this.inReplyTo = null;

            //各種ダイアログ設定
            SearchDialog.Owner = this;
            UrlDialog.Owner = this;

            //新着バルーン通知のチェック状態設定
            NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop;
            this.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked;

            //新着取得時のリストスクロールをするか。trueならスクロールしない
            ListLockMenuItem.Checked = _cfgCommon.ListLock;
            this.LockListFileMenuItem.Checked = _cfgCommon.ListLock;
            //サウンド再生(タブ別設定より優先)
            this.PlaySoundMenuItem.Checked = this._cfgCommon.PlaySound;
            this.PlaySoundFileMenuItem.Checked = this._cfgCommon.PlaySound;

            this.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert;
            this.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText;

            //ウィンドウ設定
            this.ClientSize = ScaleBy(configScaleFactor, _cfgLocal.FormSize);
            _mySize = this.ClientSize; // サイズ保持(最小化・最大化されたまま終了した場合の対応用)
            _myLoc = _cfgLocal.FormLocation;
            //タイトルバー領域
            if (this.WindowState != FormWindowState.Minimized)
            {
                this.DesktopLocation = _cfgLocal.FormLocation;
                Rectangle tbarRect = new Rectangle(this.Location, new Size(_mySize.Width, SystemInformation.CaptionHeight));
                bool outOfScreen = true;
                if (Screen.AllScreens.Length == 1)    //ハングするとの報告
                {
                    foreach (Screen scr in Screen.AllScreens)
                    {
                        if (!Rectangle.Intersect(tbarRect, scr.Bounds).IsEmpty)
                        {
                            outOfScreen = false;
                            break;
                        }
                    }
                    if (outOfScreen)
                    {
                        this.DesktopLocation = new Point(0, 0);
                        _myLoc = this.DesktopLocation;
                    }
                }
            }
            this.TopMost = this._cfgCommon.AlwaysTop;
            _mySpDis = ScaleBy(configScaleFactor.Height, _cfgLocal.SplitterDistance);
            _mySpDis2 = ScaleBy(configScaleFactor.Height, _cfgLocal.StatusTextHeight);
            if (_cfgLocal.PreviewDistance == -1)
            {
                _mySpDis3 = _mySize.Width - ScaleBy(this.CurrentScaleFactor.Width, 150);
                if (_mySpDis3 < 1) _mySpDis3 = ScaleBy(this.CurrentScaleFactor.Width, 50);
                _cfgLocal.PreviewDistance = _mySpDis3;
            }
            else
            {
                _mySpDis3 = ScaleBy(configScaleFactor.Width, _cfgLocal.PreviewDistance);
            }
            MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline;
            //this.Tween_ClientSizeChanged(this, null);
            this.PlaySoundMenuItem.Checked = this._cfgCommon.PlaySound;
            this.PlaySoundFileMenuItem.Checked = this._cfgCommon.PlaySound;
            //入力欄
            StatusText.Font = _fntInputFont;
            StatusText.ForeColor = _clInputFont;

            // SplitContainer2.Panel2MinSize を一行表示の入力欄の高さに合わせる (MS UI Gothic 12pt (96dpi) の場合は 19px)
            this.StatusText.Multiline = false; // _cfgLocal.StatusMultiline の設定は後で反映される
            this.SplitContainer2.Panel2MinSize = this.StatusText.Height;

            // 必要であれば、発言一覧と発言詳細部・入力欄の上下を入れ替える
            SplitContainer1.IsPanelInverted = !this._cfgCommon.StatusAreaAtBottom;

            //全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定)
            if (this._cfgCommon.UnreadManage == false)
            {
                ReadedStripMenuItem.Enabled = false;
                UnreadStripMenuItem.Enabled = false;
            }

            //リンク先URL表示部の初期化(画面左下)
            StatusLabelUrl.Text = "";
            //状態表示部の初期化(画面右下)
            StatusLabel.Text = "";
            StatusLabel.AutoToolTip = false;
            StatusLabel.ToolTipText = "";
            //文字カウンタ初期化
            lblLen.Text = this.GetRestStatusCount(this.FormatStatusText("")).ToString();

            this.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space";
            CopySTOTMenuItem.ShortcutKeyDisplayString = "Ctrl+C";
            CopyURLMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+C";
            CopyUserIdStripMenuItem.ShortcutKeyDisplayString = "Shift+Alt+C";

            // SourceLinkLabel のテキストが SplitContainer2.Panel2.AccessibleName にセットされるのを防ぐ
            // (タブオーダー順で SourceLinkLabel の次にある PostBrowser が TabStop = false となっているため、
            // さらに次のコントロールである SplitContainer2.Panel2 の AccessibleName がデフォルトで SourceLinkLabel のテキストになってしまう)
            this.SplitContainer2.Panel2.AccessibleName = "";

            ////////////////////////////////////////////////////////////////////////////////
            var sortOrder = (SortOrder)_cfgCommon.SortOrder;
            var mode = ComparerMode.Id;
            switch (_cfgCommon.SortColumn)
            {
                case 0:    //0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
                case 5:
                case 6:
                    //ソートしない
                    mode = ComparerMode.Id;  //Idソートに読み替え
                    break;
                case 1:  //ニックネーム
                    mode = ComparerMode.Nickname;
                    break;
                case 2:  //本文
                    mode = ComparerMode.Data;
                    break;
                case 3:  //時刻=発言Id
                    mode = ComparerMode.Id;
                    break;
                case 4:  //名前
                    mode = ComparerMode.Name;
                    break;
                case 7:  //Source
                    mode = ComparerMode.Source;
                    break;
            }
            _statuses.SetSortMode(mode, sortOrder);
            ////////////////////////////////////////////////////////////////////////////////

            ApplyListViewIconSize(this._cfgCommon.IconSize);

            //<<<<<<<<タブ関連>>>>>>>
            // タブの位置を調整する
            SetTabAlignment();

            //デフォルトタブの存在チェック、ない場合には追加
            if (this._statuses.GetTabByType<HomeTabModel>() == null)
                this._statuses.AddTab(new HomeTabModel());

            if (this._statuses.GetTabByType<MentionsTabModel>() == null)
                this._statuses.AddTab(new MentionsTabModel());

            if (this._statuses.GetTabByType<DirectMessagesTabModel>() == null)
                this._statuses.AddTab(new DirectMessagesTabModel());

            if (this._statuses.GetTabByType<FavoritesTabModel>() == null)
                this._statuses.AddTab(new FavoritesTabModel());

            if (this._statuses.GetTabByType<MuteTabModel>() == null)
                this._statuses.AddTab(new MuteTabModel());

            foreach (var tab in _statuses.Tabs.Values)
            {
                // ミュートタブは表示しない
                if (tab.TabType == MyCommon.TabUsageType.Mute)
                    continue;

                if (!AddNewTab(tab, startup: true))
                    throw new TabException(Properties.Resources.TweenMain_LoadText1);
            }

            _curTab = ListTab.SelectedTab;
            _curItemIndex = -1;
            _curList = (DetailsListView)_curTab.Tag;

            if (this._cfgCommon.TabIconDisp)
            {
                ListTab.DrawMode = TabDrawMode.Normal;
            }
            else
            {
                ListTab.DrawMode = TabDrawMode.OwnerDrawFixed;
                ListTab.DrawItem += ListTab_DrawItem;
                ListTab.ImageList = null;
            }

            if (this._cfgCommon.HotkeyEnabled)
            {
                //////グローバルホットキーの登録
                HookGlobalHotkey.ModKeys modKey = HookGlobalHotkey.ModKeys.None;
                if ((this._cfgCommon.HotkeyModifier & Keys.Alt) == Keys.Alt)
                    modKey |= HookGlobalHotkey.ModKeys.Alt;
                if ((this._cfgCommon.HotkeyModifier & Keys.Control) == Keys.Control)
                    modKey |= HookGlobalHotkey.ModKeys.Ctrl;
                if ((this._cfgCommon.HotkeyModifier & Keys.Shift) == Keys.Shift)
                    modKey |= HookGlobalHotkey.ModKeys.Shift;
                if ((this._cfgCommon.HotkeyModifier & Keys.LWin) == Keys.LWin)
                    modKey |= HookGlobalHotkey.ModKeys.Win;

                _hookGlobalHotkey.RegisterOriginalHotkey(this._cfgCommon.HotkeyKey, this._cfgCommon.HotkeyValue, modKey);
            }

            if (this._cfgCommon.IsUseNotifyGrowl)
                gh.RegisterGrowl();

            StatusLabel.Text = Properties.Resources.Form1_LoadText1;       //画面右下の状態表示を変更

            SetMainWindowTitle();
            SetNotifyIconText();

            if (!this._cfgCommon.MinimizeToTray || this.WindowState != FormWindowState.Minimized)
            {
                this.Visible = true;
            }

            //タイマー設定
            TimerTimeline.AutoReset = true;
            TimerTimeline.SynchronizingObject = this;
            //Recent取得間隔
            TimerTimeline.Interval = 1000;
            TimerTimeline.Enabled = true;
            //更新中アイコンアニメーション間隔
            TimerRefreshIcon.Interval = 200;
            TimerRefreshIcon.Enabled = true;

            _ignoreConfigSave = false;
            this.TweenMain_Resize(null, null);
            if (saveRequired) SaveConfigsAll(false);

            foreach (var ua in this._cfgCommon.UserAccounts)
            {
                if (ua.UserId == 0 && ua.Username.ToLowerInvariant() == tw.Username.ToLowerInvariant())
                {
                    ua.UserId = tw.UserId;
                    break;
                }
            }

            if (firstRun)
            {
                // 初回起動時だけ右下のメニューを目立たせる
                HashStripSplitButton.ShowDropDown();
            }
        }