diff --git a/SagiriUI/Form1.Designer.cs b/SagiriUI/Form1.Designer.cs
index ad38060..4fdcb1a 100644
--- a/SagiriUI/Form1.Designer.cs
+++ b/SagiriUI/Form1.Designer.cs
@@ -34,14 +34,13 @@ private void InitializeComponent()
this.pictureBoxAlbumArt = new System.Windows.Forms.PictureBox();
this.SeparatePanel = new System.Windows.Forms.Panel();
this.TitlePanel = new System.Windows.Forms.Panel();
+ this.MisskeyPostPanel = new System.Windows.Forms.Panel();
this.InfoPanel = new System.Windows.Forms.Panel();
this.AccountPanel = new System.Windows.Forms.Panel();
- this.NowPlayingPanel = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.ClosePanel = new System.Windows.Forms.Panel();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
- this.MisskeyPostPanel = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAlbumArt)).BeginInit();
this.TitlePanel.SuspendLayout();
this.SuspendLayout();
@@ -49,10 +48,10 @@ private void InitializeComponent()
// pictureBoxAlbumArt
//
this.pictureBoxAlbumArt.Cursor = System.Windows.Forms.Cursors.Hand;
- this.pictureBoxAlbumArt.Location = new System.Drawing.Point(0, 28);
- this.pictureBoxAlbumArt.Margin = new System.Windows.Forms.Padding(4);
+ this.pictureBoxAlbumArt.Location = new System.Drawing.Point(0, 37);
+ this.pictureBoxAlbumArt.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
this.pictureBoxAlbumArt.Name = "pictureBoxAlbumArt";
- this.pictureBoxAlbumArt.Size = new System.Drawing.Size(200, 200);
+ this.pictureBoxAlbumArt.Size = new System.Drawing.Size(229, 267);
this.pictureBoxAlbumArt.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBoxAlbumArt.TabIndex = 8;
this.pictureBoxAlbumArt.TabStop = false;
@@ -62,10 +61,10 @@ private void InitializeComponent()
this.SeparatePanel.BackColor = System.Drawing.Color.White;
this.SeparatePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.SeparatePanel.ForeColor = System.Drawing.Color.White;
- this.SeparatePanel.Location = new System.Drawing.Point(50, 7);
- this.SeparatePanel.Margin = new System.Windows.Forms.Padding(4);
+ this.SeparatePanel.Location = new System.Drawing.Point(57, 9);
+ this.SeparatePanel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
this.SeparatePanel.Name = "SeparatePanel";
- this.SeparatePanel.Size = new System.Drawing.Size(1, 16);
+ this.SeparatePanel.Size = new System.Drawing.Size(1, 21);
this.SeparatePanel.TabIndex = 1;
//
// TitlePanel
@@ -74,24 +73,37 @@ private void InitializeComponent()
this.TitlePanel.Controls.Add(this.MisskeyPostPanel);
this.TitlePanel.Controls.Add(this.InfoPanel);
this.TitlePanel.Controls.Add(this.AccountPanel);
- this.TitlePanel.Controls.Add(this.NowPlayingPanel);
this.TitlePanel.Controls.Add(this.label1);
this.TitlePanel.Controls.Add(this.ClosePanel);
this.TitlePanel.Controls.Add(this.SeparatePanel);
this.TitlePanel.Location = new System.Drawing.Point(0, 0);
+ this.TitlePanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.TitlePanel.Name = "TitlePanel";
- this.TitlePanel.Size = new System.Drawing.Size(200, 28);
+ this.TitlePanel.Size = new System.Drawing.Size(229, 37);
this.TitlePanel.TabIndex = 14;
this.TitlePanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TitlePanel_MouseDown);
this.TitlePanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TitlePanel_MouseMove);
//
+ // MisskeyPostPanel
+ //
+ this.MisskeyPostPanel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("MisskeyPostPanel.BackgroundImage")));
+ this.MisskeyPostPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.MisskeyPostPanel.Location = new System.Drawing.Point(94, 7);
+ this.MisskeyPostPanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.MisskeyPostPanel.Name = "MisskeyPostPanel";
+ this.MisskeyPostPanel.Size = new System.Drawing.Size(21, 24);
+ this.MisskeyPostPanel.TabIndex = 17;
+ this.toolTip1.SetToolTip(this.MisskeyPostPanel, "Post with Misskey.");
+ this.MisskeyPostPanel.Click += new System.EventHandler(this.MisskeyPostPanel_Click);
+ //
// InfoPanel
//
this.InfoPanel.BackgroundImage = global::SagiriUI.Properties.Resources.info;
this.InfoPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.InfoPanel.Location = new System.Drawing.Point(151, 5);
+ this.InfoPanel.Location = new System.Drawing.Point(173, 7);
+ this.InfoPanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.InfoPanel.Name = "InfoPanel";
- this.InfoPanel.Size = new System.Drawing.Size(18, 18);
+ this.InfoPanel.Size = new System.Drawing.Size(21, 24);
this.InfoPanel.TabIndex = 18;
this.toolTip1.SetToolTip(this.InfoPanel, "NowPlaying Info.");
this.InfoPanel.Click += new System.EventHandler(this.InfoPanel_Click);
@@ -100,31 +112,21 @@ private void InitializeComponent()
//
this.AccountPanel.BackgroundImage = global::SagiriUI.Properties.Resources.account;
this.AccountPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.AccountPanel.Location = new System.Drawing.Point(59, 5);
+ this.AccountPanel.Location = new System.Drawing.Point(67, 7);
+ this.AccountPanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.AccountPanel.Name = "AccountPanel";
- this.AccountPanel.Size = new System.Drawing.Size(18, 18);
+ this.AccountPanel.Size = new System.Drawing.Size(21, 24);
this.AccountPanel.TabIndex = 17;
this.toolTip1.SetToolTip(this.AccountPanel, "Account for Spotify.");
this.AccountPanel.Click += new System.EventHandler(this.AccountPanel_Click);
//
- // NowPlayingPanel
- //
- this.NowPlayingPanel.BackgroundImage = global::SagiriUI.Properties.Resources.send;
- this.NowPlayingPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.NowPlayingPanel.Location = new System.Drawing.Point(84, 5);
- this.NowPlayingPanel.Name = "NowPlayingPanel";
- this.NowPlayingPanel.Size = new System.Drawing.Size(18, 18);
- this.NowPlayingPanel.TabIndex = 16;
- this.toolTip1.SetToolTip(this.NowPlayingPanel, "Post with Twitter.");
- this.NowPlayingPanel.Click += new System.EventHandler(this.NowPlayingPanel_Click);
- //
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.White;
- this.label1.Location = new System.Drawing.Point(9, 6);
+ this.label1.Location = new System.Drawing.Point(10, 8);
this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(36, 15);
+ this.label1.Size = new System.Drawing.Size(47, 20);
this.label1.TabIndex = 15;
this.label1.Text = "Sagiri";
//
@@ -132,9 +134,10 @@ private void InitializeComponent()
//
this.ClosePanel.BackgroundImage = global::SagiriUI.Properties.Resources.close;
this.ClosePanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.ClosePanel.Location = new System.Drawing.Point(175, 4);
+ this.ClosePanel.Location = new System.Drawing.Point(200, 5);
+ this.ClosePanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ClosePanel.Name = "ClosePanel";
- this.ClosePanel.Size = new System.Drawing.Size(20, 20);
+ this.ClosePanel.Size = new System.Drawing.Size(23, 27);
this.ClosePanel.TabIndex = 15;
this.toolTip1.SetToolTip(this.ClosePanel, "Close App.");
this.ClosePanel.Click += new System.EventHandler(this.ClosePanel_Click);
@@ -144,27 +147,16 @@ private void InitializeComponent()
this.notifyIcon.Text = "notifyIcon";
this.notifyIcon.Visible = true;
//
- // MisskeyPostPanel
- //
- this.MisskeyPostPanel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("MisskeyPostPanel.BackgroundImage")));
- this.MisskeyPostPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.MisskeyPostPanel.Location = new System.Drawing.Point(108, 5);
- this.MisskeyPostPanel.Name = "MisskeyPostPanel";
- this.MisskeyPostPanel.Size = new System.Drawing.Size(18, 18);
- this.MisskeyPostPanel.TabIndex = 17;
- this.toolTip1.SetToolTip(this.MisskeyPostPanel, "Post with Misskey.");
- this.MisskeyPostPanel.Click += new System.EventHandler(this.MisskeyPostPanel_Click);
- //
// Form1
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(58)))), ((int)(((byte)(58)))), ((int)(((byte)(58)))));
- this.ClientSize = new System.Drawing.Size(200, 228);
+ this.ClientSize = new System.Drawing.Size(229, 304);
this.Controls.Add(this.TitlePanel);
this.Controls.Add(this.pictureBoxAlbumArt);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.Margin = new System.Windows.Forms.Padding(4);
+ this.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "Spotify NowPlaying";
@@ -185,8 +177,6 @@ private void InitializeComponent()
private System.Windows.Forms.Panel TitlePanel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel ClosePanel;
- private System.Windows.Forms.Panel NowPlayingPanel;
- private SagiriUI.Controls.BorderPanel BorderPanel;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.Panel InfoPanel;
private System.Windows.Forms.Panel AccountPanel;
diff --git a/SagiriUI/Form1.cs b/SagiriUI/Form1.cs
index c00d2d9..9798730 100644
--- a/SagiriUI/Form1.cs
+++ b/SagiriUI/Form1.cs
@@ -1,11 +1,9 @@
using System;
using System.Diagnostics;
using System.Drawing;
-using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading;
-using System.Threading.Tasks;
using System.Windows.Forms;
using Sagiri.Services.Misskey;
@@ -16,9 +14,7 @@
using Sagiri.Util.Common;
using Sagiri.Util.Configuration;
using SagiriUI.Properties;
-using SagiriSelenium.Interfaces;
-using Twist;
using SagiriUI.Controls;
using Microsoft.Toolkit.Uwp.Notifications;
using System.Collections.Generic;
@@ -31,13 +27,10 @@ public partial class Form1 : Form
private ISpotifyService _ISpotifyService { get; set; }
private IMisskeyService? _IMisskeyService { get; set; }
- private ISagiriSelenium _ISagiriSelenium { get; set; }
private CurrentTrackInfo _CurrentTrackInfo { get; set; }
private SpotifyCredentialConfig _SpotifyCredentialConfig { get; set; }
- private TwitterCredentialConfig _TwitterCredentialConfig { get; set; }
- private Twitter _Twist { get; set; }
private Logger _Logger { get; set; }
private Point _MousePoint { get; set; }
@@ -65,33 +58,11 @@ private async void Form1_Load(object sender, EventArgs e)
await _IMisskeyService.InitializeAsync();
_ISpotifyService = new SpotifyService();
- _ISagiriSelenium = new SagiriSelenium.SagiriSelenium();
_CurrentTrackInfo = new();
-
_SpotifyCredentialConfig = SpotifyCredentialConfig.Instance;
- _TwitterCredentialConfig = TwitterCredentialConfig.Instance;
_Logger = Logger.GetInstance;
- if (_TwitterCredentialConfig.IsExistCredentialFile())
- {
- var twConfig = await _TwitterCredentialConfig.LoadCredentialAsync();
- _Twist = new Twitter(
- twConfig.ConsumerKey,
- twConfig.ConsumerSecret,
- twConfig.AccessToken,
- twConfig.AccessTokenSecret,
- new HttpClient(new HttpClientHandler())
- );
- _Logger.WriteLog("[SagiriUI] - Finish read twitter credential info.", Logger.LogLevel.Debug);
- }
- else
- {
- var message = "[SagiriUI] - Twitter tokens file not found...\r\nCan't sent now-playing twitter.";
- MessageBox.Show(message);
- _Logger.WriteLog(message, Logger.LogLevel.Error);
- }
-
await _ISpotifyService.InitializeAsync();
if (_SpotifyCredentialConfig.IsExistCredentialFile())
{
@@ -118,7 +89,6 @@ private async void Form1_Load(object sender, EventArgs e)
private void Form1_Closing(object sender, EventArgs e)
{
_ISpotifyService.Dispose();
- _ISagiriSelenium.Dispose();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
@@ -142,8 +112,6 @@ private void _OnSpotifyCurrentTrackErrorDetected()
_Logger.WriteLog("Spotify CurrentTrackError...", Logger.LogLevel.Error);
_ISpotifyService.Dispose();
- _ISagiriSelenium.Dispose();
-
this.Invoke((MethodInvoker)(() => this.Close()));
}
@@ -158,54 +126,30 @@ private void _OnSpotifyCurrentlyPlayingChanged(CurrentTrackInfo trackInfo)
_CurrentTrackInfo = trackInfo;
this.Invoke((MethodInvoker)(() => pictureBoxAlbumArt.ImageLocation = trackInfo.ArtworkUrl));
- #region Saving AlbumArt
+ if (trackInfo.TrackTitle == _TrackTitleOld && trackInfo.Artist == _ArtistOld)
+ return;
- // Selenium 経由での画像投稿用に AlbumArt 保存
- _ = Task.Factory.StartNew(async () =>
- {
- if (trackInfo.TrackTitle == _TrackTitleOld && trackInfo.Artist == _ArtistOld)
- return;
- _TrackTitleOld = trackInfo.TrackTitle;
- _ArtistOld = trackInfo.Artist;
-
- using HttpClient httpClient = new(new HttpClientHandler());
- var byteStream = await httpClient.GetByteArrayAsync(trackInfo.ArtworkUrl);
- if (byteStream.Length == _ByteStreamLengthOld)
- return;
- _ByteStreamLengthOld = byteStream.Length;
-
- var saveName = "cover.jpg";
- using MemoryStream ms = new(byteStream);
- Bitmap bmp = new(ms);
- bmp.Save(saveName);
- });
+ _TrackTitleOld = trackInfo.TrackTitle;
+ _ArtistOld = trackInfo.Artist;
this._NotifyToastCurrentTrackInfo(trackInfo);
- #endregion Saving AlbumArt
-
#region Logging
- if (trackInfo.TrackTitle != _TrackTitleOld && trackInfo.Artist != _ArtistOld)
- {
- _Logger.WriteLog("Called OnSpotifyCurrentlyPlayingChanged", Logger.LogLevel.Debug);
- _Logger.WriteLog(
- $"OnSpotifyCurrentlyPlayingChanged -> " +
- $"🎵 {_CurrentTrackInfo.TrackTitle} - " +
- $"🎙 {_CurrentTrackInfo.Artist} - " +
- $"💿 {_CurrentTrackInfo.Album}",
- Logger.LogLevel.Info
- );
- }
+ _Logger.WriteLog("Called OnSpotifyCurrentlyPlayingChanged", Logger.LogLevel.Debug);
+ _Logger.WriteLog(
+ $"OnSpotifyCurrentlyPlayingChanged -> " +
+ $"🎵 {_CurrentTrackInfo.TrackTitle} - " +
+ $"🎙 {_CurrentTrackInfo.Artist} - " +
+ $"💿 {_CurrentTrackInfo.Album}",
+ Logger.LogLevel.Info
+ );
#endregion Logging
}
private void _NotifyToastCurrentTrackInfo(CurrentTrackInfo trackInfo)
{
- if (trackInfo.TrackTitle == _TrackTitleOld && trackInfo.Artist == _ArtistOld)
- return;
-
StringBuilder sb = new();
sb.Append($"title: {_CurrentTrackInfo.TrackTitle}\r\n");
sb.Append($"Artist: {_CurrentTrackInfo.Artist}\r\n");
@@ -221,80 +165,6 @@ private void _NotifyToastCurrentTrackInfo(CurrentTrackInfo trackInfo)
.Show();
}
- private async void NowPlayingPanel_Click(object sender, EventArgs e)
- {
- #region ★Dropped★ - Twitter API v2.0
-
-#if false
- // ★Twitter API v2.0の場合だと、1500post / month しかできないため、Selenium スクレイピング投稿に変更
- //var tw = new StringBuilder();
- //tw.Append($"🎵 {_CurrentTrackInfo.TrackTitle}\r\n");
- //tw.Append($"🎙 {_CurrentTrackInfo.Artist}\r\n");
- //tw.Append($"💿 {_CurrentTrackInfo.Album}\r\n");
- //tw.Append("#nowplaying #Sagiri");
-
- //using var httpClient = new HttpClient(new HttpClientHandler());
- //var byteStream = await httpClient.GetByteArrayAsync(_CurrentTrackInfo.ArtworkUrl);
- //using var artworkStream = new MemoryStream(byteStream);
- //await _Twist.UpdateWithMediaAsync(tw.ToString(), artworkStream);
-#endif
-
- #endregion Twitter API v2.0
-
- #region Selenium Side
-
- var tw = new StringBuilder();
- tw.Append($"{_CurrentTrackInfo.TrackTitle} - {_CurrentTrackInfo.Artist} ");
- tw.Append("#nowplaying #Sagiri");
-
- // $@"https://twitter.com/intent/tweet?text={tw.ToString()}" is Dropped
- var canPost = await _ISagiriSelenium.RunSeleniumAndPrePostTwitterAsync(@"https://twitter.com/", tw.ToString());
-
- if (!canPost)
- {
- MessageBox.Show("Post 前準備に失敗しました。", "投稿失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
- _Logger.WriteLog("[SagiriUI] - Post前準備に失敗しました。", Logger.LogLevel.Error);
- return;
- }
-
- await Task.Delay(500);
- SendKeys.SendWait($@"{Environment.CurrentDirectory}\cover.jpg");
-
- await Task.Delay(1000);
- SendKeys.SendWait("{Enter}");
-
- var isPostCompleted = await _ISagiriSelenium.PostTwitterAsync();
- if (!isPostCompleted)
- {
- MessageBox.Show("投稿失敗しました。", "投稿失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
- _Logger.WriteLog("[SagiriUI] - 投稿に失敗しました。", Logger.LogLevel.Error);
- return;
- }
-
- var sb = new StringBuilder();
- sb.Append("Twitter へ投稿完了しました。\r\n");
- sb.Append("----------------------------\r\n");
- sb.Append($"title: {_CurrentTrackInfo.TrackTitle}\r\n");
- sb.Append($"Artist: {_CurrentTrackInfo.Artist}\r\n");
- sb.Append($"Album: {_CurrentTrackInfo.Album}\r\n");
-
- new MessageBoxEx(sb.ToString(), "投稿完了!", 3000).Show();
-
- #endregion Selenium Side
-
- #region Logging
-
- _Logger.WriteLog(
- $"Posted on Twitter -> " +
- $"🎵 {_CurrentTrackInfo.TrackTitle} - " +
- $"🎙 {_CurrentTrackInfo.Artist} - " +
- $"💿 {_CurrentTrackInfo.Album}",
- Logger.LogLevel.Info
- );
-
- #endregion Logging
- }
-
private async void MisskeyPostPanel_Click(object sender, EventArgs e)
{
var note = new StringBuilder();
diff --git a/SagiriUI/Form1.resx b/SagiriUI/Form1.resx
index 758af3b..012117d 100644
--- a/SagiriUI/Form1.resx
+++ b/SagiriUI/Form1.resx
@@ -67,7 +67,7 @@
QdgdL+JIEasJPSUsldOZSq6qv++xKnFF0zMh8e2yWjEIEsCHmwlG8TNIP8NiB+nBS6/sKBHfl4+fZkVi
VbEa6+gsEydBBo+oq5I9Kj4melRmknWr/3/7asQGvHZ2lw8qn03zvQuc25DLmubXkWnmjqH8CS7ThfiV
Qxj6ED1b0DoPoH4Tzq8KWmQXLrag5VFTdCUvlcsqi8Xg7RRq56DpBqoX7J79nnPyAOEN+apr2NuHbrlf
- v/gDfZ1n8DyefxIAAAAJcEhZcwAACxIAAAsSAdLdfvwAAGetSURBVHhe7b0HeBznde4PEL2zi0WFFCkW
+ v/gDfZ1n8DyefxIAAAAJcEhZcwAACxEAAAsRAX9kX5EAAGetSURBVHhe7b0HeBznde4PEL2zi0WFFCkW
dVGFkqzeFduyEzvuli3JtuxYhRJ77wRJsKBQpLpIilRlk8TeewGL7LjEsZMb597cf5L7ONdOu67S/s+Z
mbN79uDMzuxgASwW532e3yObmPJ95zvf+84sQDDPZDKZTCaTyWQymUwmk8lkMplMJpPJZDKZTCaTyWQy
mUwmk8lkMplMJpPJZDKZTCaTyWQymUwmk8lkMplMJpPJZDKZTCaTyWQymUwmk8lkMplMJpPJZDKZTCaT
diff --git a/SagiriUI/SagiriUI.csproj b/SagiriUI/SagiriUI.csproj
index d1225d7..b26d0dd 100644
--- a/SagiriUI/SagiriUI.csproj
+++ b/SagiriUI/SagiriUI.csproj
@@ -12,13 +12,9 @@
-
-
-
-