private bool _DoFavRetweetFlags = false;
private bool osResumed = false;
- private Dictionary<string, IMultimediaShareService> pictureService;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
private string _postBrowserStatusText = "";
public long? inReplyToId = null;
public string inReplyToName = null;
public string imageService = ""; //画像投稿サービス名
- public string imagePath = "";
+ public string[] imagePath = null;
public PostingStatus()
{
}
SettingDialog.UseAtIdSupplement = _cfgCommon.UseAtIdSupplement;
SettingDialog.UseHashSupplement = _cfgCommon.UseHashSupplement;
SettingDialog.PreviewEnable = _cfgCommon.PreviewEnable;
+ SettingDialog.StatusAreaAtBottom = _cfgCommon.StatusAreaAtBottom;
AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@");
SettingDialog.IsMonospace = _cfgCommon.IsMonospace;
AllrepliesToolStripMenuItem.Checked = tw.AllAtReply;
//画像投稿サービス
- this.CreatePictureServices();
- SetImageServiceCombo();
- ImageSelectionPanel.Enabled = false;
-
- SelectImageServiceComboItem(_cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
+ ImageSelector.Initialize(tw, SettingDialog.TwitterConfiguration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
//ウィンドウ設定
this.ClientSize = _cfgLocal.FormSize;
// NameLabel のフォントを OTBaseForm.GlobalFont に変更
this.NameLabel.Font = this.ReplaceToGlobalFont(this.NameLabel.Font);
+ // 必要であれば、発言一覧と発言詳細部・入力欄の上下を入れ替える
+ SplitContainer1.IsPanelInverted = !SettingDialog.StatusAreaAtBottom;
+
//全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定)
if (SettingDialog.UnreadManage == false)
{
{
if (StatusText.Text.Trim().Length == 0)
{
- if (!ImageSelectionPanel.Enabled)
+ if (!ImageSelector.Enabled)
{
DoRefresh();
return;
args.status.inReplyToId = _reply_to_id;
args.status.inReplyToName = _reply_to_name;
- if (ImageSelectionPanel.Visible)
+ if (ImageSelector.Visible)
{
//画像投稿
- if (!TryGetSelectedMedia(out args.status.imageService, out args.status.imagePath))
+ if (!ImageSelector.TryGetSelectedMedia(out args.status.imageService, out args.status.imagePath))
return;
}
case MyCommon.WORKERTYPE.PostMessage:
bw.ReportProgress(200);
- if (string.IsNullOrEmpty(args.status.imagePath))
+ if (args.status.imagePath == null || args.status.imagePath.Length == 0 || string.IsNullOrEmpty(args.status.imagePath[0]))
{
ret = tw.PostStatus(args.status.status, args.status.inReplyToId);
}
else
{
- ret = this.pictureService[args.status.imageService].Upload(ref args.status.imagePath,
- ref args.status.status,
- args.status.inReplyToId);
+ var service = ImageSelector.GetService(args.status.imageService);
+ try
+ {
+ service.PostStatusAsync(args.status.status, args.status.inReplyToId, args.status.imagePath)
+ .Wait();
+ }
+ catch (AggregateException ex)
+ {
+ ret = ex.InnerException.Message;
+ }
}
bw.ReportProgress(300);
rslt.status = args.status;
//_waitFollower = false
if (SettingDialog.TwitterConfiguration.PhotoSizeLimit != 0)
{
- pictureService["Twitter"].Configuration("MaxUploadFilesize", SettingDialog.TwitterConfiguration.PhotoSizeLimit);
+ foreach (var service in this.ImageSelector.GetServices())
+ {
+ service.UpdateTwitterConfiguration(this.SettingDialog.TwitterConfiguration);
+ }
}
this.PurgeListViewItemCache();
if (_curList != null) _curList.Refresh();
}
}
+ private async Task RefreshMuteUserIdsAsync()
+ {
+ this.StatusLabel.Text = Properties.Resources.UpdateMuteUserIds_Start;
+
+ try
+ {
+ await tw.RefreshMuteUserIdsAsync();
+ }
+ catch (WebApiException ex)
+ {
+ this.StatusLabel.Text = string.Format(Properties.Resources.UpdateMuteUserIds_Error, ex.Message);
+ return;
+ }
+
+ this.StatusLabel.Text = Properties.Resources.UpdateMuteUserIds_Finish;
+ }
+
private void RemovePostFromFavTab(Int64[] ids)
{
string favTabName = _statuses.GetTabByType(MyCommon.TabUsageType.Favorites).TabName;
SettingDialog.ProxyPort,
SettingDialog.ProxyUser,
SettingDialog.ProxyPassword);
- this.CreatePictureServices();
+
+ ImageSelector.Reset(tw, SettingDialog.TwitterConfiguration);
try
{
// タブの表示位置の決定
SetTabAlignment();
+ SplitContainer1.IsPanelInverted = !SettingDialog.StatusAreaAtBottom;
+
var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance;
imgazyobizinet.Enabled = this.SettingDialog.EnableImgAzyobuziNet;
imgazyobizinet.DisabledInDM = this.SettingDialog.ImgAzyobuziNetDisabledInDM;
if (uid != tw.Username) this.doGetFollowersMenu();
- SetImageServiceCombo();
if (SettingDialog.IsNotifyUseGrowl) gh.RegisterGrowl();
try
{
/// </summary>
private void SetTabAlignment()
{
- ListTab.Alignment = (SettingDialog.ViewTabBottom ? TabAlignment.Bottom : TabAlignment.Top);
+ var newAlignment = SettingDialog.ViewTabBottom ? TabAlignment.Bottom : TabAlignment.Top;
+ if (ListTab.Alignment == newAlignment) return;
+
+ //現在の選択状態を退避
+ Dictionary<string, long[]> selId = new Dictionary<string, long[]>();
+ Dictionary<string, long[]> focusedId = new Dictionary<string, long[]>();
+ SaveSelectedStatus(selId, focusedId);
+
+ ListTab.Alignment = newAlignment;
+
+ //選択状態を復帰
+ foreach (TabPage tab in ListTab.TabPages)
+ {
+ DetailsListView lst = (DetailsListView)tab.Tag;
+ using (ControlTransaction.Update(lst))
+ {
+ this.SelectListItem(lst,
+ _statuses.IndexOf(tab.Text, selId[tab.Text]),
+ _statuses.IndexOf(tab.Text, focusedId[tab.Text]));
+ }
+ }
}
private void ApplyListViewIconSize(MyCommon.IconSizes iconSz)
// pLen += m.Result("${url}").Length - SettingDialog.TwitterConfiguration.ShortUrlLength;
//}
}
- if (ImageSelectionPanel.Visible && ImageSelectedPicture.Tag != null && !string.IsNullOrEmpty(this.ImageService))
+ if (ImageSelector.Visible && !string.IsNullOrEmpty(ImageSelector.ServiceName))
{
pLen -= SettingDialog.TwitterConfiguration.CharactersReservedPerMedia;
}
{
if (e.State == 0) return;
e.DrawDefault = false;
+
+ SolidBrush brs2 = null;
if (!e.Item.Selected) //e.ItemStateでうまく判定できない???
{
- SolidBrush brs2 = null;
-
if (e.Item.BackColor == _clSelf)
brs2 = _brsBackColorMine;
else if (e.Item.BackColor == _clAtSelf)
brs2 = _brsBackColorAtTo;
else
brs2 = _brsBackColorNone;
-
- e.Graphics.FillRectangle(brs2, e.Bounds);
}
else
{
//選択中の行
if (((Control)sender).Focused)
- e.Graphics.FillRectangle(_brsHighLight, e.Bounds);
+ brs2 = _brsHighLight;
else
- e.Graphics.FillRectangle(_brsDeactiveSelection, e.Bounds);
+ brs2 = _brsDeactiveSelection;
}
- if ((e.State & ListViewItemStates.Focused) == ListViewItemStates.Focused) e.DrawFocusRectangle();
+ e.Graphics.FillRectangle(brs2, e.Bounds);
+ e.DrawFocusRectangle();
this.DrawListViewItemIcon(e);
}
//アイコン以外の列
RectangleF rct = e.Bounds;
rct.Width = e.Header.Width;
+ int fontHeight = e.Item.Font.Height;
if (_iconCol)
{
- rct.Y += e.Item.Font.Height;
- rct.Height -= e.Item.Font.Height;
+ rct.Y += fontHeight;
+ rct.Height -= fontHeight;
}
int heightDiff;
- int drawLineCount = Math.Max(1, Math.DivRem((int)rct.Height, e.Item.Font.Height, out heightDiff));
+ int drawLineCount = Math.Max(1, Math.DivRem((int)rct.Height, fontHeight, out heightDiff));
- //if (heightDiff > e.Item.Font.Height * 0.7)
+ //if (heightDiff > fontHeight * 0.7)
//{
- // rct.Height += e.Item.Font.Height;
+ // rct.Height += fontHeight;
// drawLineCount += 1;
//}
if (!_iconCol && drawLineCount <= 1)
{
//rct.Inflate(0, heightDiff / -2);
- //rct.Height += e.Item.Font.Height / 2;
+ //rct.Height += fontHeight / 2;
}
- else if (heightDiff < e.Item.Font.Height * 0.7)
+ else if (heightDiff < fontHeight * 0.7)
{
//最終行が70%以上欠けていたら、最終行は表示しない
- //rct.Height = (float)((e.Item.Font.Height * drawLineCount) + (e.Item.Font.Height / 2));
- rct.Height = (e.Item.Font.Height * drawLineCount) - 1;
+ //rct.Height = (float)((fontHeight * drawLineCount) + (fontHeight / 2));
+ rct.Height = (fontHeight * drawLineCount) - 1;
}
else
{
//if (!_iconCol && drawLineCount > 1)
//{
- // rct.Y += e.Item.Font.Height * 0.2;
- // if (heightDiff >= e.Item.Font.Height * 0.8) rct.Height -= e.Item.Font.Height * 0.2;
+ // rct.Y += fontHeight * 0.2;
+ // if (heightDiff >= fontHeight * 0.8) rct.Height -= fontHeight * 0.2;
//}
if (rct.Width > 0)
if (_iconCol)
{
- RectangleF rctB = e.Bounds;
+ Rectangle rctB = e.Bounds;
rctB.Width = e.Header.Width;
- rctB.Height = e.Item.Font.Height;
+ rctB.Height = fontHeight;
using (Font fnt = new Font(e.Item.Font, FontStyle.Bold))
{
TextRenderer.DrawText(e.Graphics,
e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]",
fnt,
- Rectangle.Round(rctB),
+ rctB,
color,
TextFormatFlags.SingleLine |
TextFormatFlags.EndEllipsis |
private void DrawListViewItemIcon(DrawListViewItemEventArgs e)
{
+ if (_iconSz == 0) return;
+
ImageListViewItem item = (ImageListViewItem)e.Item;
//e.Bounds.Leftが常に0を指すから自前で計算
Rectangle itemRect = item.Bounds;
- itemRect.Width = e.Item.ListView.Columns[0].Width;
+ var col0 = e.Item.ListView.Columns[0];
+ itemRect.Width = col0.Width;
- foreach (ColumnHeader clm in e.Item.ListView.Columns)
+ if (col0.DisplayIndex > 0)
{
- if (clm.DisplayIndex < e.Item.ListView.Columns[0].DisplayIndex)
- itemRect.X += clm.Width;
+ foreach (ColumnHeader clm in e.Item.ListView.Columns)
+ {
+ if (clm.DisplayIndex < col0.DisplayIndex)
+ itemRect.X += clm.Width;
+ }
}
// ディスプレイの DPI 設定を考慮したアイコンサイズ
var realStateSize = new SizeF(16 * this.currentScaleFactor.Width, 16 * this.currentScaleFactor.Height).ToSize();
Rectangle iconRect;
- Rectangle stateRect;
- if (item.Image != null)
+ var img = item.Image;
+ if (img != null)
{
iconRect = Rectangle.Intersect(new Rectangle(e.Item.GetBounds(ItemBoundsPortion.Icon).Location, realIconSize), itemRect);
iconRect.Offset(0, Math.Max(0, (itemRect.Height - realIconSize.Height) / 2));
- stateRect = Rectangle.Intersect(new Rectangle(new Point(iconRect.X + realIconSize.Width + 2, iconRect.Y), realStateSize), itemRect);
+
+ if (iconRect.Width > 0)
+ {
+ e.Graphics.FillRectangle(Brushes.White, iconRect);
+ e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
+ try
+ {
+ e.Graphics.DrawImage(img.Image, iconRect);
+ }
+ catch (ArgumentException)
+ {
+ item.RefreshImageAsync();
+ }
+ }
}
else
{
iconRect = Rectangle.Intersect(new Rectangle(e.Item.GetBounds(ItemBoundsPortion.Icon).Location, new Size(1, 1)), itemRect);
//iconRect.Offset(0, Math.Max(0, (itemRect.Height - realIconSize.Height) / 2));
- stateRect = Rectangle.Intersect(new Rectangle(new Point(iconRect.X + realIconSize.Width + 2, iconRect.Y), realStateSize), itemRect);
- }
-
- var img = item.Image;
- if (img != null && iconRect.Width > 0)
- {
- e.Graphics.FillRectangle(Brushes.White, iconRect);
- e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
- try
- {
- e.Graphics.DrawImage(img.Image, iconRect);
- }
- catch (ArgumentException)
- {
- item.RefreshImageAsync();
- }
}
if (item.StateImageIndex > -1)
{
+ Rectangle stateRect = Rectangle.Intersect(new Rectangle(new Point(iconRect.X + realIconSize.Width + 2, iconRect.Y), realStateSize), itemRect);
if (stateRect.Width > 0)
{
//e.Graphics.FillRectangle(Brushes.White, stateRect);
int idx = -1;
DetailsListView lst = null;
- if (ImageSelectionPanel.Enabled)
+ if (ImageSelector.Enabled)
return;
//現在タブから最終タブまで探索
if (this.thumbnailTokenSource != null)
{
var oldTokenSource = this.thumbnailTokenSource;
- oldTokenSource.Cancel();
+
+ // TODO: キャンセルを行うとUIスレッドが阻害される問題を調査
+ //oldTokenSource.Cancel();
+
this.thumbnailTask.ContinueWith(_ => oldTokenSource.Dispose());
}
_cfgCommon.UseAtIdSupplement = SettingDialog.UseAtIdSupplement;
_cfgCommon.UseHashSupplement = SettingDialog.UseHashSupplement;
_cfgCommon.PreviewEnable = SettingDialog.PreviewEnable;
+ _cfgCommon.StatusAreaAtBottom = SettingDialog.StatusAreaAtBottom;
_cfgCommon.Language = SettingDialog.Language;
_cfgCommon.SortOrder = (int)_statuses.SortOrder;
_cfgCommon.AllAtReply = tw.AllAtReply;
_cfgCommon.OpenUserTimeline = SettingDialog.OpenUserTimeline;
_cfgCommon.ListCountApi = SettingDialog.ListCountApi;
- _cfgCommon.UseImageService = ImageServiceCombo.SelectedIndex;
- _cfgCommon.UseImageServiceName = this.ImageService;
+ _cfgCommon.UseImageService = ImageSelector.ServiceIndex;
+ _cfgCommon.UseImageServiceName = ImageSelector.ServiceName;
_cfgCommon.ListDoubleClickAction = SettingDialog.ListDoubleClickAction;
_cfgCommon.UserAppointUrl = SettingDialog.UserAppointUrl;
_cfgCommon.HideDuplicatedRetweets = SettingDialog.HideDuplicatedRetweets;
}
catch (WebApiException ex)
{
- var message = ex.InnerException.Message;
+ var message = ex.Message;
MessageBox.Show(this, string.Format(Properties.Resources.OpenURL_LoadFailed, message),
Properties.Resources.OpenURL_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
{
if (this._curPost == null) return;
- var imageUrl = this._curPost.ImageUrl;
- try
+ await this.UserPicture.SetImageFromTask(async () =>
{
- var image = await this.IconCache.DownloadImageAsync(imageUrl, force: true);
+ var imageUrl = this._curPost.ImageUrl;
- this.ClearUserPicture();
- this.UserPicture.Image = image.Clone();
- }
- catch (Exception)
- {
- this.UserPicture.ShowErrorImage();
- try
- {
- throw;
- }
- catch (HttpRequestException) { }
- catch (InvalidImageException) { }
- catch (TaskCanceledException) { }
- }
+ var image = await this.IconCache.DownloadImageAsync(imageUrl, force: true)
+ .ConfigureAwait(false);
+
+ return await image.CloneAsync()
+ .ConfigureAwait(false);
+ });
}
private void SaveOriginalSizeIconPictureToolStripMenuItem_Click(object sender, EventArgs e)
if (this.IsNetworkAvailable())
{
+ this.RefreshMuteUserIdsAsync();
GetTimeline(MyCommon.WORKERTYPE.BlockIds, 0, 0, "");
GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, "");
if (SettingDialog.StartupFollowers)
Match m = Regex.Match(this._postBrowserStatusText, @"^https?://twitter.com/search\?q=%23(?<hash>.+)$");
if (m.Success)
{
- HashMgr.SetPermanentHash("#" + m.Result("${hash}"));
+ HashMgr.SetPermanentHash("#" + Uri.UnescapeDataString(m.Result("${hash}")));
HashStripSplitButton.Text = HashMgr.UseHash;
HashToggleMenuItem.Checked = true;
HashToggleToolStripMenuItem.Checked = true;
}
}
- private void doShowUserStatus(TwitterUser user)
+ private async void doShowUserStatus(TwitterUser user)
{
- using (var userinfo = new UserInfoDialog())
+ using (var userDialog = new UserInfoDialog(this, this.tw))
{
- userinfo.Owner = this;
- userinfo.DisplayUser = user;
- userinfo.ShowDialog(this);
+ var showUserTask = userDialog.ShowUserAsync(user);
+ userDialog.ShowDialog(this);
+
this.Activate();
this.BringToFront();
+
+ // ユーザー情報の表示が完了するまで userDialog を破棄しない
+ await showUserTask;
}
}
this._apiGauge.BorderSides = ToolStripStatusLabelBorderSides.Right;
this.StatusStrip1.Items.Insert(2, this._apiGauge);
- this.ImageSelectedPicture.InitialImage = Properties.Resources.InitialImage;
+ this.ImageSelector.Visible = false;
+ this.ImageSelector.Enabled = false;
+ this.ImageSelector.FilePickDialog = OpenFileDialog1;
this.ReplaceAppName();
}
}
#region "画像投稿"
- private void CreatePictureServices()
- {
- if (this.pictureService != null) this.pictureService.Clear();
- this.pictureService = null;
- this.pictureService = new Dictionary<string, IMultimediaShareService> {
- {"TwitPic", new TwitPic(tw)},
- {"img.ly", new imgly(tw)},
- {"yfrog", new yfrog(tw)},
- {"Twitter", new TwitterPhoto(tw)},
- {"ついっぷるフォト", new TwipplePhoto(tw)},
- {"Imgur", new Imgur(tw)},
- };
- }
-
private void ImageSelectMenuItem_Click(object sender, EventArgs e)
{
- if (ImageSelectionPanel.Visible)
- {
- CloseImageSelectionPanel();
- }
+ if (ImageSelector.Visible)
+ ImageSelector.EndSelection();
else
- {
- OpenImageSelectionPanel();
- ImageFromSelectedFile(true);
- ImagefilePathText.Focus();
- }
- }
-
- private void OpenImageSelectionPanel()
- {
- ImageSelectionPanel.Visible = true;
- ImageSelectionPanel.Enabled = true;
- TimelinePanel.Visible = false;
- TimelinePanel.Enabled = false;
- }
-
- private void CloseImageSelectionPanel()
- {
- ImagefilePathText.CausesValidation = false;
- TimelinePanel.Visible = true;
- TimelinePanel.Enabled = true;
- ImageSelectionPanel.Visible = false;
- ImageSelectionPanel.Enabled = false;
- ((DetailsListView)ListTab.SelectedTab.Tag).Focus();
- ClearImageSelectedPicture();
- ImagefilePathText.CausesValidation = true;
+ ImageSelector.BeginSelection();
}
private void SelectMedia_DragEnter(DragEventArgs e)
{
- string filename = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
- FileInfo fl = new FileInfo(filename);
- string ext = fl.Extension;
-
- if (!string.IsNullOrEmpty(this.ImageService) &&
- this.pictureService[this.ImageService].CheckValidFilesize(ext, fl.Length))
+ if (ImageSelector.HasUploadableService(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]))
{
e.Effect = DragDropEffects.Copy;
return;
}
- foreach (string svc in ImageServiceCombo.Items)
- {
- if (!string.IsNullOrEmpty(svc) &&
- this.pictureService[svc].CheckValidFilesize(ext, fl.Length))
- {
- //ImageServiceCombo.SelectedItem = svc;
- e.Effect = DragDropEffects.Copy;
- return;
- }
- }
e.Effect = DragDropEffects.None;
}
{
this.Activate();
this.BringToFront();
- OpenImageSelectionPanel();
- ImagefilePathText.Text = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
- ImageFromSelectedFile(false);
+ ImageSelector.BeginSelection(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]);
StatusText.Focus();
}
- private void FilePickButton_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(this.ImageService)) return;
- OpenFileDialog1.Filter = this.pictureService[this.ImageService].GetFileOpenDialogFilter();
- OpenFileDialog1.Title = Properties.Resources.PickPictureDialog1;
- OpenFileDialog1.FileName = "";
-
- try
- {
- this.AllowDrop = false;
- if (OpenFileDialog1.ShowDialog() == DialogResult.Cancel) return;
- }
- finally
- {
- this.AllowDrop = true;
- }
-
- ImagefilePathText.Text = OpenFileDialog1.FileName;
- ImageFromSelectedFile(false);
- }
-
- private void ImagefilePathText_Validating(object sender, CancelEventArgs e)
- {
- if (ImageCancelButton.Focused)
- {
- ImagefilePathText.CausesValidation = false;
- return;
- }
-
- ImageFromSelectedFile(false);
- }
-
- private void ImageFromSelectedFile(bool suppressMsgBox)
+ private void ImageSelector_BeginSelecting(object sender, EventArgs e)
{
- this.ClearImageSelectedPicture();
-
- try
- {
- ImagefilePathText.Text = ImagefilePathText.Text.Trim();
- if (string.IsNullOrEmpty(ImagefilePathText.Text) || string.IsNullOrEmpty(this.ImageService))
- {
- ImagefilePathText.Text = "";
- return;
- }
-
- FileInfo fl = new FileInfo(ImagefilePathText.Text);
- string ext = fl.Extension;
- var imageService = this.pictureService[this.ImageService];
-
- if (!imageService.CheckValidExtension(ext))
- {
- //画像以外の形式
- ImagefilePathText.Text = "";
- if (!suppressMsgBox)
- {
- MessageBox.Show(
- string.Format(Properties.Resources.PostPictureWarn3, this.ImageService, MakeAvailableServiceText(ext, fl.Length), ext),
- Properties.Resources.PostPictureWarn4,
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning);
- }
- return;
- }
-
- if (!imageService.CheckValidFilesize(ext, fl.Length))
- {
- // ファイルサイズが大きすぎる
- ImagefilePathText.Text = "";
- if (!suppressMsgBox)
- {
- MessageBox.Show(
- string.Format(Properties.Resources.PostPictureWarn5, this.ImageService, MakeAvailableServiceText(ext, fl.Length)),
- Properties.Resources.PostPictureWarn4,
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning);
- }
- return;
- }
-
- switch (imageService.GetFileType(ext))
- {
- case MyCommon.UploadFileType.Picture:
- using (var fs = File.OpenRead(ImagefilePathText.Text))
- {
- ImageSelectedPicture.Image = MemoryImage.CopyFromStream(fs);
- }
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Picture;
- break;
- case MyCommon.UploadFileType.MultiMedia:
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.MultiMedia;
- break;
- default:
- ImagefilePathText.Text = "";
- break;
- }
- }
- catch (FileNotFoundException)
- {
- ImagefilePathText.Text = "";
- if (!suppressMsgBox) MessageBox.Show("File not found.");
- }
- catch (Exception)
- {
- ImagefilePathText.Text = "";
- if (!suppressMsgBox) MessageBox.Show("The type of this file is not image.");
- }
- }
-
- private string MakeAvailableServiceText(string ext, long fileSize)
- {
- StringBuilder sb = new StringBuilder();
-
- foreach (string svc in ImageServiceCombo.Items)
- {
- if (!string.IsNullOrEmpty(svc) &&
- this.pictureService[svc].CheckValidFilesize(ext, fileSize))
- {
- if (sb.Length > 0) sb.Append(", ");
- sb.Append(svc);
- }
- }
- if (sb.Length == 0)
- return Properties.Resources.PostPictureWarn6;
-
- return sb.ToString();
- }
-
- private void ClearImageSelectedPicture()
- {
- var oldImage = this.ImageSelectedPicture.Image;
- if (oldImage != null)
- {
- this.ImageSelectedPicture.Image = null;
- oldImage.Dispose();
- }
-
- this.ImageSelectedPicture.Tag = null;
- this.ImageSelectedPicture.ShowInitialImage();
- }
-
- private void ImageCancelButton_Click(object sender, EventArgs e)
- {
- CloseImageSelectionPanel();
- }
-
- private void ImageSelection_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Escape)
- {
- CloseImageSelectionPanel();
- }
- }
-
- private void ImageSelection_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (Convert.ToInt32(e.KeyChar) == 0x1B)
- {
- ImagefilePathText.CausesValidation = false;
- e.Handled = true;
- }
- }
-
- private void ImageSelection_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
- {
- if (e.KeyCode == Keys.Escape)
- {
- ImagefilePathText.CausesValidation = false;
- }
- }
-
- private bool TryGetSelectedMedia(out string imageService, out string imagePath)
- {
- if (ImageSelectedPicture.Tag != null &&
- ImageServiceCombo.SelectedIndex > -1 &&
- !string.IsNullOrEmpty(ImagefilePathText.Text))
- {
- if (MessageBox.Show(string.Format(Properties.Resources.PostPictureConfirm1, this.ImageService),
- Properties.Resources.PostPictureConfirm2,
- MessageBoxButtons.OKCancel,
- MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button1)
- == DialogResult.OK)
- {
- imageService = ImageServiceCombo.Text;
- imagePath = ImagefilePathText.Text;
- CloseImageSelectionPanel();
- ImagefilePathText.Text = "";
- return true;
- }
- }
- else
- {
- MessageBox.Show(Properties.Resources.PostPictureWarn1, Properties.Resources.PostPictureWarn2);
- }
-
- CloseImageSelectionPanel();
- imageService = null;
- imagePath = null;
- return false;
+ TimelinePanel.Visible = false;
+ TimelinePanel.Enabled = false;
}
- private void SetImageServiceCombo()
+ private void ImageSelector_EndSelecting(object sender, EventArgs e)
{
- string svc = "";
- if (ImageServiceCombo.SelectedIndex > -1) svc = ImageServiceCombo.SelectedItem.ToString();
- ImageServiceCombo.Items.Clear();
-
- // Add service names to combobox
- foreach (var key in pictureService.Keys)
- {
- ImageServiceCombo.Items.Add(key);
- }
-
- SelectImageServiceComboItem(svc);
+ TimelinePanel.Visible = true;
+ TimelinePanel.Enabled = true;
+ ((DetailsListView)ListTab.SelectedTab.Tag).Focus();
}
- private void SelectImageServiceComboItem(string svc, int? index = null)
+ private void ImageSelector_FilePickDialogOpening(object sender, EventArgs e)
{
- int idx;
- if (string.IsNullOrEmpty(svc))
- {
- idx = index ?? 0;
- }
- else
- {
- idx = ImageServiceCombo.Items.IndexOf(svc);
- if (idx == -1) idx = index ?? 0;
- }
-
- try
- {
- ImageServiceCombo.SelectedIndex = idx;
- }
- catch (ArgumentOutOfRangeException)
- {
- ImageServiceCombo.SelectedIndex = 0;
- }
+ this.AllowDrop = false;
}
- private string ImageService
+ private void ImageSelector_FilePickDialogClosed(object sender, EventArgs e)
{
- get { return ImageServiceCombo.SelectedItem.ToString(); }
+ this.AllowDrop = true;
}
- private void ImageServiceCombo_SelectedIndexChanged(object sender, EventArgs e)
+ private void ImageSelector_SelectedServiceChanged(object sender, EventArgs e)
{
- if (ImageSelectedPicture.Tag != null && !string.IsNullOrEmpty(this.ImageService))
+ if (ImageSelector.Visible)
{
- try
- {
- FileInfo fi = new FileInfo(ImagefilePathText.Text.Trim());
- string ext = fi.Extension;
- var imageService = this.pictureService[this.ImageService];
- if (!imageService.CheckValidFilesize(ext, fi.Length))
- {
- ClearImageSelectedPicture();
- ImagefilePathText.Text = "";
- }
- }
- catch (Exception)
- {
- ClearImageSelectedPicture();
- ImagefilePathText.Text = "";
- }
_modifySettingCommon = true;
SaveConfigsAll(true);
- if (this.ImageService == "Twitter")
- {
+
+ if (ImageSelector.ServiceName.Equals("Twitter"))
this.StatusText_TextChanged(null, null);
- }
}
}
- private void ImageSelectionPanel_VisibleChanged(object sender, EventArgs e)
+ private void ImageSelector_VisibleChanged(object sender, EventArgs e)
{
this.StatusText_TextChanged(null, null);
}