Пример #1
0
        public void ShowSuplDialog(TextBox owner, AtIdSupplement dialog, int offset = 0, string startswith = "")
        {
            dialog.StartsWith = startswith;
            if (dialog.Visible)
            {
                dialog.Focus();
            }
            else
            {
                dialog.ShowDialog();
            }

            TopMost = _configs.AlwaysTop;
            int    selStart  = owner.SelectionStart;
            string frontHalf = string.Empty;
            string lastHalf  = string.Empty;

            if (dialog.DialogResult == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(dialog.InputText))
                {
                    if (selStart > 0)
                    {
                        frontHalf = owner.Text.Substring(0, selStart - offset);
                    }

                    if (selStart < owner.Text.Length)
                    {
                        lastHalf = owner.Text.Substring(selStart);
                    }

                    owner.Text           = frontHalf + dialog.InputText + lastHalf;
                    owner.SelectionStart = selStart + dialog.InputText.Length;
                }
            }
            else
            {
                if (selStart > 0)
                {
                    frontHalf = owner.Text.Substring(0, selStart);
                }

                if (selStart < owner.Text.Length)
                {
                    lastHalf = owner.Text.Substring(selStart);
                }

                owner.Text = frontHalf + lastHalf;
                if (selStart > 0)
                {
                    owner.SelectionStart = selStart;
                }
            }

            owner.Focus();
        }
Пример #2
0
        private bool _isAdd; // 編集モード

        #endregion Fields

        #region Constructors

        public HashtagManage(AtIdSupplement hashSuplForm, string[] history, string permanentHash, bool isPermanent, bool isHead, bool isNotAddToAtReply)
        {
            // この呼び出しは、Windows フォーム デザイナで必要です。
            InitializeComponent();

            // InitializeComponent() 呼び出しの後で初期化を追加します。
            _hashSupl = hashSuplForm;
            foreach (var t in history)
            {
                HistoryHashList.Items.Add(t);
            }
            UseHash = permanentHash;
            IsPermanent = isPermanent;
            IsHead = isHead;
            IsNotAddToAtReply = isNotAddToAtReply;
        }
Пример #3
0
        private bool _isAdd;                       // 編集モード

        public HashtagManage(AtIdSupplement hashSuplForm, string[] history, string permanentHash, bool isPermanent, bool isHead, bool isNotAddToAtReply)
        {
            // この呼び出しは、Windows フォーム デザイナで必要です。
            InitializeComponent();

            // InitializeComponent() 呼び出しの後で初期化を追加します。
            _hashSupl = hashSuplForm;
            foreach (var t in history)
            {
                HistoryHashList.Items.Add(t);
            }
            UseHash           = permanentHash;
            IsPermanent       = isPermanent;
            IsHead            = isHead;
            IsNotAddToAtReply = isNotAddToAtReply;
        }
Пример #4
0
        private void TweenMain_LoadExtracted()
        {
            _ignoreConfigSave = true;
            Visible = false;
            VerUpMenuItem.Image = _shield.Icon;
            _spaceKeyCanceler = new SpaceKeyCanceler(PostButton);
            _spaceKeyCanceler.SpaceCancel += SpaceKeyCanceler_SpaceCancel;

            Regex.CacheSize = 100;

            InitializeTraceFrag();

            _statuses = TabInformations.Instance; // 発言保持クラス

            // アイコン設定
            LoadIcons();                        // アイコン読み込み
            Icon = _mainIcon;               // メインフォーム(TweenMain)
            NotifyIcon1.Icon = _iconAt;     // タスクトレイ
            TabImage.Images.Add(_tabIcon);  // タブ見出し

            _settingDialog.Owner = this;
            _searchDialog.Owner = this;
            _fltDialog.Owner = this;
            _tabDialog.Owner = this;
            _urlDialog.Owner = this;

            _postHistory.Add(new PostingStatus());
            _postHistoryIndex = 0;

            ClearReplyToInfo();

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

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

            // フォント&文字色&背景色保持
            _fntUnread = _cfgLocal.FontUnread;
            _clrUnread = _cfgLocal.ColorUnread;
            _fntReaded = _cfgLocal.FontRead;
            _clrRead = _cfgLocal.ColorRead;
            _clrFav = _cfgLocal.ColorFav;
            _clrOwl = _cfgLocal.ColorOwl;
            _clrRetweet = _cfgLocal.ColorRetweet;
            _fntDetail = _cfgLocal.FontDetail;
            _clrDetail = _cfgLocal.ColorDetail;
            _clrDetailLink = _cfgLocal.ColorDetailLink;
            _clrDetailBackcolor = _cfgLocal.ColorDetailBackcolor;
            _clrSelf = _cfgLocal.ColorSelf;
            _clrAtSelf = _cfgLocal.ColorAtSelf;
            _clrTarget = _cfgLocal.ColorTarget;
            _clrAtTarget = _cfgLocal.ColorAtTarget;
            _clrAtFromTarget = _cfgLocal.ColorAtFromTarget;
            _clrAtTo = _cfgLocal.ColorAtTo;
            _clrListBackcolor = _cfgLocal.ColorListBackcolor;
            InputBackColor = _cfgLocal.ColorInputBackcolor;
            _clrInputForecolor = _cfgLocal.ColorInputFont;
            _fntInputFont = _cfgLocal.FontInputFont;

            InitUserBrushes();

            // StringFormatオブジェクトへの事前設定
            _tabStringFormat.Alignment = StringAlignment.Center;
            _tabStringFormat.LineAlignment = StringAlignment.Center;

            // 設定画面への反映
            HttpTwitter.SetTwitterUrl(_cfgCommon.TwitterUrl);
            _configs.TwitterApiUrl = _cfgCommon.TwitterUrl;
            _configs.TwitterSearchApiUrl = _cfgCommon.TwitterSearchUrl;

            // 認証関連
            if (string.IsNullOrEmpty(_cfgCommon.Token))
            {
                _cfgCommon.UserName = string.Empty;
            }

            _tw.Initialize(_cfgCommon.Token, _cfgCommon.TokenSecret, _cfgCommon.UserName, _cfgCommon.UserId);

            _configs.UserAccounts = _cfgCommon.UserAccounts;
            _configs.TimelinePeriodInt = _cfgCommon.TimelinePeriod;
            _configs.ReplyPeriodInt = _cfgCommon.ReplyPeriod;
            _configs.DMPeriodInt = _cfgCommon.DMPeriod;
            _configs.PubSearchPeriodInt = _cfgCommon.PubSearchPeriod;
            _configs.UserTimelinePeriodInt = _cfgCommon.UserTimelinePeriod;
            _configs.ListsPeriodInt = _cfgCommon.ListsPeriod;

            // 不正値チェック
            if (!MyCommon.NoLimit)
            {
                if (_configs.TimelinePeriodInt < 15 && _configs.TimelinePeriodInt > 0)
                {
                    _configs.TimelinePeriodInt = 15;
                }

                if (_configs.ReplyPeriodInt < 15 && _configs.ReplyPeriodInt > 0)
                {
                    _configs.ReplyPeriodInt = 15;
                }

                if (_configs.DMPeriodInt < 15 && _configs.DMPeriodInt > 0)
                {
                    _configs.DMPeriodInt = 15;
                }

                if (_configs.PubSearchPeriodInt < 30 && _configs.PubSearchPeriodInt > 0)
                {
                    _configs.PubSearchPeriodInt = 30;
                }

                if (_configs.UserTimelinePeriodInt < 15 && _configs.UserTimelinePeriodInt > 0)
                {
                    _configs.UserTimelinePeriodInt = 15;
                }

                if (_configs.ListsPeriodInt < 15 && _configs.ListsPeriodInt > 0)
                {
                    _configs.ListsPeriodInt = 15;
                }
            }

            // 起動時読み込み分を既読にするか。Trueなら既読として処理
            _configs.Readed = _cfgCommon.Read;

            // 新着取得時のリストスクロールをするか。Trueならスクロールしない
            ListLockMenuItem.Checked = _cfgCommon.ListLock;
            LockListFileMenuItem.Checked = _cfgCommon.ListLock;
            _configs.IconSz = _cfgCommon.IconSize;

            // 文末ステータス
            _configs.Status = _cfgLocal.StatusText;

            // 未読管理。Trueなら未読管理する
            _configs.UnreadManage = _cfgCommon.UnreadManage;

            // サウンド再生(タブ別設定より優先)
            _configs.PlaySound = _cfgCommon.PlaySound;
            PlaySoundMenuItem.Checked = _configs.PlaySound;
            PlaySoundFileMenuItem.Checked = _configs.PlaySound;

            // 片思い表示。Trueなら片思い表示する
            _configs.OneWayLove = _cfgCommon.OneWayLove;

            // フォント&文字色&背景色
            _configs.FontUnread = _fntUnread;
            _configs.ColorUnread = _clrUnread;
            _configs.FontReaded = _fntReaded;
            _configs.ColorReaded = _clrRead;
            _configs.ColorFav = _clrFav;
            _configs.ColorOWL = _clrOwl;
            _configs.ColorRetweet = _clrRetweet;
            _configs.FontDetail = _fntDetail;
            _configs.ColorDetail = _clrDetail;
            _configs.ColorDetailLink = _clrDetailLink;
            _configs.ColorDetailBackcolor = _clrDetailBackcolor;
            _configs.ColorSelf = _clrSelf;
            _configs.ColorAtSelf = _clrAtSelf;
            _configs.ColorTarget = _clrTarget;
            _configs.ColorAtTarget = _clrAtTarget;
            _configs.ColorAtFromTarget = _clrAtFromTarget;
            _configs.ColorAtTo = _clrAtTo;
            _configs.ColorListBackcolor = _clrListBackcolor;
            _configs.ColorInputBackcolor = InputBackColor;
            _configs.ColorInputFont = _clrInputForecolor;
            _configs.FontInputFont = _fntInputFont;
            _configs.NameBalloon = _cfgCommon.NameBalloon;
            _configs.PostCtrlEnter = _cfgCommon.PostCtrlEnter;
            _configs.PostShiftEnter = _cfgCommon.PostShiftEnter;
            _configs.CountApi = _cfgCommon.CountApi;
            _configs.CountApiReply = _cfgCommon.CountApiReply;
            if (_configs.CountApi < 20 || _configs.CountApi > 200)
            {
                _configs.CountApi = 60;
            }

            if (_configs.CountApiReply < 20 || _configs.CountApiReply > 200)
            {
                _configs.CountApiReply = 40;
            }

            _configs.BrowserPath = _cfgLocal.BrowserPath;
            _configs.PostAndGet = _cfgCommon.PostAndGet;
            _configs.UseRecommendStatus = _cfgLocal.UseRecommendStatus;
            _configs.DispUsername = _cfgCommon.DispUsername;
            _configs.CloseToExit = _cfgCommon.CloseToExit;
            _configs.MinimizeToTray = _cfgCommon.MinimizeToTray;
            _configs.DispLatestPost = _cfgCommon.DispLatestPost;
            _configs.SortOrderLock = _cfgCommon.SortOrderLock;
            _configs.TinyUrlResolve = _cfgCommon.TinyUrlResolve;
            _configs.ShortUrlForceResolve = _cfgCommon.ShortUrlForceResolve;
            _configs.SelectedProxyType = _cfgLocal.ProxyType;
            _configs.ProxyAddress = _cfgLocal.ProxyAddress;
            _configs.ProxyPort = _cfgLocal.ProxyPort;
            _configs.ProxyUser = _cfgLocal.ProxyUser;
            _configs.ProxyPassword = _cfgLocal.ProxyPassword;
            _configs.PeriodAdjust = _cfgCommon.PeriodAdjust;
            _configs.StartupVersion = _cfgCommon.StartupVersion;
            _configs.StartupFollowers = _cfgCommon.StartupFollowers;
            _configs.RestrictFavCheck = _cfgCommon.RestrictFavCheck;
            _configs.AlwaysTop = _cfgCommon.AlwaysTop;
            _configs.UrlConvertAuto = false;
            _configs.OutputzEnabled = _cfgCommon.Outputz;
            _configs.OutputzKey = _cfgCommon.OutputzKey;
            _configs.OutputzUrlmode = _cfgCommon.OutputzUrlMode;
            _configs.UseUnreadStyle = _cfgCommon.UseUnreadStyle;
            _configs.DefaultTimeOut = _cfgCommon.DefaultTimeOut;
            _configs.RetweetNoConfirm = _cfgCommon.RetweetNoConfirm;
            _configs.PlaySound = _cfgCommon.PlaySound;
            _configs.DateTimeFormat = _cfgCommon.DateTimeFormat;
            _configs.LimitBalloon = _cfgCommon.LimitBalloon;
            _configs.EventNotifyEnabled = _cfgCommon.EventNotifyEnabled;
            _configs.EventNotifyFlag = _cfgCommon.EventNotifyFlag;
            _configs.IsMyEventNotifyFlag = _cfgCommon.IsMyEventNotifyFlag;
            _configs.ForceEventNotify = _cfgCommon.ForceEventNotify;
            _configs.FavEventUnread = _cfgCommon.FavEventUnread;
            _configs.TranslateLanguage = _cfgCommon.TranslateLanguage;
            _configs.EventSoundFile = _cfgCommon.EventSoundFile;

            // 廃止サービスが選択されていた場合bit.lyへ読み替え
            if (_cfgCommon.AutoShortUrlFirst < 0)
            {
                _cfgCommon.AutoShortUrlFirst = UrlConverter.Bitly;
            }

            _configs.AutoShortUrlFirst = _cfgCommon.AutoShortUrlFirst;
            _configs.TabIconDisp = _cfgCommon.TabIconDisp;
            _configs.ReplyIconState = _cfgCommon.ReplyIconState;
            _configs.ReadOwnPost = _cfgCommon.ReadOwnPost;
            _configs.GetFav = _cfgCommon.GetFav;
            _configs.ReadOldPosts = _cfgCommon.ReadOldPosts;
            _configs.UseSsl = _cfgCommon.UseSsl;
            _configs.BitlyUser = _cfgCommon.BilyUser;
            _configs.BitlyPwd = _cfgCommon.BitlyPwd;
            _configs.ShowGrid = _cfgCommon.ShowGrid;
            _configs.Language = _cfgCommon.Language;
            _configs.UseAtIdSupplement = _cfgCommon.UseAtIdSupplement;
            _configs.UseHashSupplement = _cfgCommon.UseHashSupplement;
            _configs.PreviewEnable = _cfgCommon.PreviewEnable;
            AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@");

            _configs.IsMonospace = _cfgCommon.IsMonospace;
            _detailHtmlFormatFooter = GetDetailHtmlFormatFooter(_configs.IsMonospace);
            _detailHtmlFormatHeader = GetDetailHtmlFormatHeader(_configs.IsMonospace);

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

            _configs.RecommendStatusText = " [HH2v" + Regex.Replace(MyCommon.FileVersion.Replace(".", string.Empty), "^0*", string.Empty) + "]";

            // 書式指定文字列エラーチェック
            try
            {
                if (DateTime.Now.ToString(_configs.DateTimeFormat).Length == 0)
                {
                    // このブロックは絶対に実行されないはず
                    // 変換が成功した場合にLengthが0にならない
                    _configs.DateTimeFormat = "yyyy/MM/dd H:mm:ss";
                }
            }
            catch (FormatException)
            {
                // FormatExceptionが発生したら初期値を設定 (=yyyy/MM/dd H:mm:ssとみなされる)
                _configs.DateTimeFormat = "yyyy/MM/dd H:mm:ss";
            }

            _configs.Nicoms = _cfgCommon.Nicoms;
            _configs.HotkeyEnabled = _cfgCommon.HotkeyEnabled;
            _configs.HotkeyMod = _cfgCommon.HotkeyModifier;
            _configs.HotkeyKey = _cfgCommon.HotkeyKey;
            _configs.HotkeyValue = _cfgCommon.HotkeyValue;
            _configs.BlinkNewMentions = _cfgCommon.BlinkNewMentions;
            _configs.UseAdditionalCount = _cfgCommon.UseAdditionalCount;
            _configs.MoreCountApi = _cfgCommon.MoreCountApi;
            _configs.FirstCountApi = _cfgCommon.FirstCountApi;
            _configs.SearchCountApi = _cfgCommon.SearchCountApi;
            _configs.FavoritesCountApi = _cfgCommon.FavoritesCountApi;
            _configs.UserTimelineCountApi = _cfgCommon.UserTimelineCountApi;
            _configs.ListCountApi = _cfgCommon.ListCountApi;
            _configs.UserstreamStartup = _cfgCommon.UserstreamStartup;
            _configs.UserstreamPeriodInt = _cfgCommon.UserstreamPeriod;
            _configs.OpenUserTimeline = _cfgCommon.OpenUserTimeline;
            _configs.ListDoubleClickAction = _cfgCommon.ListDoubleClickAction;
            _configs.UserAppointUrl = _cfgCommon.UserAppointUrl;
            _configs.HideDuplicatedRetweets = _cfgCommon.HideDuplicatedRetweets;
            _configs.IsPreviewFoursquare = _cfgCommon.IsPreviewFoursquare;
            _configs.FoursquarePreviewHeight = _cfgCommon.FoursquarePreviewHeight;
            _configs.FoursquarePreviewWidth = _cfgCommon.FoursquarePreviewWidth;
            _configs.FoursquarePreviewZoom = _cfgCommon.FoursquarePreviewZoom;
            _configs.IsListStatusesIncludeRts = _cfgCommon.IsListsIncludeRts;
            _configs.TabMouseLock = _cfgCommon.TabMouseLock;
            _configs.IsRemoveSameEvent = _cfgCommon.IsRemoveSameEvent;
            _configs.IsNotifyUseGrowl = _cfgCommon.IsUseNotifyGrowl;

            // ハッシュタグ関連
            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;
            }

            _isInitializing = true;

            // アイコンリスト作成
            try
            {
                _iconDict = new ImageDictionary(5);
            }
            catch (Exception)
            {
                MessageBox.Show("Please install [.NET Framework 4 (Full)].");
                Application.Exit();
                return;
            }

            _iconDict.PauseGetImage = false;

            bool saveRequired = false;

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

                // 設定せずにキャンセルされた場合はプログラム終了
                if (_settingDialog.ShowDialog(this) == DialogResult.Cancel)
                {
                    // 強制終了
                    Application.Exit();
                    return;
                }

                // 設定されたが、依然ユーザー名とパスワードが未設定ならプログラム終了
                if (string.IsNullOrEmpty(_tw.Username))
                {
                    // 強制終了
                    Application.Exit();
                    return;
                }

                // フォント&文字色&背景色保持
                _fntUnread = _configs.FontUnread;
                _clrUnread = _configs.ColorUnread;
                _fntReaded = _configs.FontReaded;
                _clrRead = _configs.ColorReaded;
                _clrFav = _configs.ColorFav;
                _clrOwl = _configs.ColorOWL;
                _clrRetweet = _configs.ColorRetweet;
                _fntDetail = _configs.FontDetail;
                _clrDetail = _configs.ColorDetail;
                _clrDetailLink = _configs.ColorDetailLink;
                _clrDetailBackcolor = _configs.ColorDetailBackcolor;
                _clrSelf = _configs.ColorSelf;
                _clrAtSelf = _configs.ColorAtSelf;
                _clrTarget = _configs.ColorTarget;
                _clrAtTarget = _configs.ColorAtTarget;
                _clrAtFromTarget = _configs.ColorAtFromTarget;
                _clrAtTo = _configs.ColorAtTo;
                _clrListBackcolor = _configs.ColorListBackcolor;
                InputBackColor = _configs.ColorInputBackcolor;
                _clrInputForecolor = _configs.ColorInputFont;
                _fntInputFont = _configs.FontInputFont;
                DisposeUserBrushes();
                InitUserBrushes();
                _detailHtmlFormatFooter = GetDetailHtmlFormatFooter(_configs.IsMonospace);
                _detailHtmlFormatHeader = GetDetailHtmlFormatHeader(_configs.IsMonospace);
            }

            if (_configs.HotkeyEnabled)
            {
                // グローバルホットキーの登録
                var modKey = HookGlobalHotkey.ModKeys.None;
                if ((_configs.HotkeyMod & Keys.Alt) == Keys.Alt)
                {
                    modKey = modKey | HookGlobalHotkey.ModKeys.Alt;
                }

                if ((_configs.HotkeyMod & Keys.Control) == Keys.Control)
                {
                    modKey = modKey | HookGlobalHotkey.ModKeys.Ctrl;
                }

                if ((_configs.HotkeyMod & Keys.Shift) == Keys.Shift)
                {
                    modKey = modKey | HookGlobalHotkey.ModKeys.Shift;
                }

                if ((_configs.HotkeyMod & Keys.LWin) == Keys.LWin)
                {
                    modKey = modKey | HookGlobalHotkey.ModKeys.Win;
                }

                _hookGlobalHotkey.RegisterOriginalHotkey(_configs.HotkeyKey, _configs.HotkeyValue, modKey);
            }

            // Twitter用通信クラス初期化
            HttpConnection.InitializeConnection(_configs.DefaultTimeOut, _configs.SelectedProxyType, _configs.ProxyAddress, _configs.ProxyPort, _configs.ProxyUser, _configs.ProxyPassword);

            _tw.SetRestrictFavCheck(_configs.RestrictFavCheck);
            _tw.ReadOwnPost = _configs.ReadOwnPost;
            ShortUrl.IsResolve = _configs.TinyUrlResolve;
            ShortUrl.IsForceResolve = _configs.ShortUrlForceResolve;
            ShortUrl.SetBitlyId(_configs.BitlyUser);
            ShortUrl.SetBitlyKey(_configs.BitlyPwd);
            HttpTwitter.SetTwitterUrl(_cfgCommon.TwitterUrl);
            _tw.TrackWord = _cfgCommon.TrackWord;
            TrackToolStripMenuItem.Checked = !string.IsNullOrEmpty(_tw.TrackWord);
            _tw.AllAtReply = _cfgCommon.AllAtReply;
            AllrepliesToolStripMenuItem.Checked = _tw.AllAtReply;

            Outputz.Key = _configs.OutputzKey;
            Outputz.Enabled = _configs.OutputzEnabled;
            switch (_configs.OutputzUrlmode)
            {
                case OutputzUrlmode.twittercom:
                    Outputz.OutUrl = "http://twitter.com/";
                    break;

                case OutputzUrlmode.twittercomWithUsername:
                    Outputz.OutUrl = "http://twitter.com/" + _tw.Username;
                    break;
            }

            // 画像投稿サービス
            CreatePictureServices();
            SetImageServiceCombo();
            ImageSelectionPanel.Enabled = false;
            ImageServiceCombo.SelectedIndex = _cfgCommon.UseImageService;

            // ウィンドウ設定
            ClientSize = _cfgLocal.FormSize;
            _mySize = _cfgLocal.FormSize;          // サイズ保持(最小化・最大化されたまま終了した場合の対応用)
            _myLoc = _cfgLocal.FormLocation;       // タイトルバー領域
            if (WindowState != FormWindowState.Minimized)
            {
                DesktopLocation = _cfgLocal.FormLocation;
                var tbarRect = new Rectangle(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)
                    {
                        DesktopLocation = new Point(0, 0);
                        _myLoc = DesktopLocation;
                    }
                }
            }

            TopMost = _configs.AlwaysTop;
            _mySpDis = _cfgLocal.SplitterDistance;
            _mySpDis2 = _cfgLocal.StatusTextHeight;
            _mySpDis3 = _cfgLocal.PreviewDistance;
            if (_mySpDis3 == -1)
            {
                _mySpDis3 = _mySize.Width - 150;
                if (_mySpDis3 < 1)
                {
                    _mySpDis3 = 50;
                }

                _cfgLocal.PreviewDistance = _mySpDis3;
            }

            _myAdSpDis = _cfgLocal.AdSplitterDistance;
            MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline;
            PlaySoundMenuItem.Checked = _configs.PlaySound;
            PlaySoundFileMenuItem.Checked = _configs.PlaySound;

            // 入力欄
            StatusText.Font = _fntInputFont;
            StatusText.ForeColor = _clrInputForecolor;

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

            if (_configs.IsNotifyUseGrowl)
            {
                _growlHelper.RegisterGrowl();
            }

            // タイマー設定
            _timerTimeline.AutoReset = true;
            _timerTimeline.SynchronizingObject = this;

            // Recent取得間隔
            _timerTimeline.Interval = 1000;
            _timerTimeline.Enabled = true;

            // 更新中アイコンアニメーション間隔
            TimerRefreshIcon.Interval = 200;
            TimerRefreshIcon.Enabled = true;

            // 状態表示部の初期化(画面右下)
            StatusLabel.Text = string.Empty;
            StatusLabel.AutoToolTip = false;
            StatusLabel.ToolTipText = string.Empty;

            // 文字カウンタ初期化
            lblLen.Text = GetRestStatusCount(true, false).ToString();

            _statuses.SortOrder = (SortOrder)_cfgCommon.SortOrder;
            IdComparerClass.ComparerMode mode = default(IdComparerClass.ComparerMode);
            switch (_cfgCommon.SortColumn)
            {
                case 0:
                case 5:
                case 6:

                    // 0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク
                    // ソートしない Idソートに読み替え
                    mode = IdComparerClass.ComparerMode.Id;
                    break;

                case 1:

                    // ニックネーム
                    mode = IdComparerClass.ComparerMode.Nickname;
                    break;

                case 2:

                    // 本文
                    mode = IdComparerClass.ComparerMode.Data;
                    break;

                case 3:

                    // 時刻=発言Id
                    mode = IdComparerClass.ComparerMode.Id;
                    break;

                case 4:

                    // 名前
                    mode = IdComparerClass.ComparerMode.Name;
                    break;

                case 7:

                    // Source
                    mode = IdComparerClass.ComparerMode.Source;
                    break;
            }

            _statuses.SortMode = mode;

            switch (_configs.IconSz)
            {
                case IconSizes.IconNone:
                    _iconSz = 0;
                    break;

                case IconSizes.Icon16:
                    _iconSz = 16;
                    break;

                case IconSizes.Icon24:
                    _iconSz = 26;
                    break;

                case IconSizes.Icon48:
                    _iconSz = 48;
                    break;

                case IconSizes.Icon48_2:
                    _iconSz = 48;
                    _iconCol = true;
                    break;
            }

            if (_iconSz == 0)
            {
                _tw.SetGetIcon(false);
            }
            else
            {
                _tw.SetGetIcon(true);
                _tw.SetIconSize(_iconSz);
            }

            _tw.SetTinyUrlResolve(_configs.TinyUrlResolve);
            ShortUrl.IsForceResolve = _configs.ShortUrlForceResolve;

            _tw.DetailIcon = _iconDict;
            StatusLabel.Text = R.Form1_LoadText1;  // 画面右下の状態表示を変更
            StatusLabelUrl.Text = string.Empty;  // 画面左下のリンク先URL表示部を初期化
            NameLabel.Text = string.Empty;       // 発言詳細部名前ラベル初期化
            DateTimeLabel.Text = string.Empty;   // 発言詳細部日時ラベル初期化
            SourceLinkLabel.Text = string.Empty; // Source部分初期化

            // <<<<<<<<タブ関連>>>>>>>
            // デフォルトタブの存在チェック、ない場合には追加
            if (_statuses.GetTabByType(TabUsageType.Home) == null)
            {
                if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.RECENT))
                {
                    _statuses.AddTab(MyCommon.DEFAULTTAB.RECENT, TabUsageType.Home, null);
                }
                else
                {
                    _statuses.Tabs[MyCommon.DEFAULTTAB.RECENT].TabType = TabUsageType.Home;
                }
            }

            if (_statuses.GetTabByType(TabUsageType.Mentions) == null)
            {
                if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.REPLY))
                {
                    _statuses.AddTab(MyCommon.DEFAULTTAB.REPLY, TabUsageType.Mentions, null);
                }
                else
                {
                    _statuses.Tabs[MyCommon.DEFAULTTAB.REPLY].TabType = TabUsageType.Mentions;
                }
            }

            if (_statuses.GetTabByType(TabUsageType.DirectMessage) == null)
            {
                if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.DM))
                {
                    _statuses.AddTab(MyCommon.DEFAULTTAB.DM, TabUsageType.DirectMessage, null);
                }
                else
                {
                    _statuses.Tabs[MyCommon.DEFAULTTAB.DM].TabType = TabUsageType.DirectMessage;
                }
            }

            if (_statuses.GetTabByType(TabUsageType.Favorites) == null)
            {
                if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.FAV))
                {
                    _statuses.AddTab(MyCommon.DEFAULTTAB.FAV, TabUsageType.Favorites, null);
                }
                else
                {
                    _statuses.Tabs[MyCommon.DEFAULTTAB.FAV].TabType = TabUsageType.Favorites;
                }
            }

            foreach (string tn in _statuses.Tabs.Keys)
            {
                if (_statuses.Tabs[tn].TabType == TabUsageType.Undefined)
                {
                    _statuses.Tabs[tn].TabType = TabUsageType.UserDefined;
                }

                if (!AddNewTab(tn, true, _statuses.Tabs[tn].TabType, _statuses.Tabs[tn].ListInfo))
                {
                    throw new Exception(R.TweenMain_LoadText1);
                }
            }

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

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

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

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

            SplitContainer4.Panel2Collapsed = true;
            _ignoreConfigSave = false;
            ResizeMainForm();
            if (saveRequired)
            {
                SaveConfigsAll(false);
            }

            if (_tw.UserId == 0)
            {
                _tw.VerifyCredentials();
                foreach (var ua in _cfgCommon.UserAccounts)
                {
                    if (ua.Username.ToLower() == _tw.Username.ToLower())
                    {
                        ua.UserId = _tw.UserId;
                        break;
                    }
                }
            }

            foreach (var ua in _configs.UserAccounts)
            {
                if (ua.UserId == 0 && ua.Username.ToLower() == _tw.Username.ToLower())
                {
                    ua.UserId = _tw.UserId;
                    break;
                }
            }
        }
Пример #5
0
        public void ShowSuplDialog(TextBox owner, AtIdSupplement dialog, int offset = 0, string startswith = "")
        {
            dialog.StartsWith = startswith;
            if (dialog.Visible)
            {
                dialog.Focus();
            }
            else
            {
                dialog.ShowDialog();
            }

            TopMost = _configs.AlwaysTop;
            int selStart = owner.SelectionStart;
            string frontHalf = string.Empty;
            string lastHalf = string.Empty;
            if (dialog.DialogResult == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(dialog.InputText))
                {
                    if (selStart > 0)
                    {
                        frontHalf = owner.Text.Substring(0, selStart - offset);
                    }

                    if (selStart < owner.Text.Length)
                    {
                        lastHalf = owner.Text.Substring(selStart);
                    }

                    owner.Text = frontHalf + dialog.InputText + lastHalf;
                    owner.SelectionStart = selStart + dialog.InputText.Length;
                }
            }
            else
            {
                if (selStart > 0)
                {
                    frontHalf = owner.Text.Substring(0, selStart);
                }

                if (selStart < owner.Text.Length)
                {
                    lastHalf = owner.Text.Substring(selStart);
                }

                owner.Text = frontHalf + lastHalf;
                if (selStart > 0)
                {
                    owner.SelectionStart = selStart;
                }
            }

            owner.Focus();
        }