Skip to content

Commit

Permalink
Merge pull request jwallet#287 from jwallet/fixture
Browse files Browse the repository at this point in the history
code cleanup and fixed form being closed twice
  • Loading branch information
jwallet authored Dec 27, 2020
2 parents 386e2ad + 13a3b2c commit 605036e
Show file tree
Hide file tree
Showing 51 changed files with 188 additions and 285 deletions.
13 changes: 5 additions & 8 deletions EspionSpotify/AudioSessions/AudioMMDevicesManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using Microsoft.Win32.SafeHandles;
using NAudio.CoreAudioApi;
using NAudio.CoreAudioApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.AudioSessions
{
Expand All @@ -19,8 +15,9 @@ public class AudioMMDevicesManager : NAudio.CoreAudioApi.Interfaces.IMMNotificat
public MMDeviceEnumerator AudioMMDevices { get; private set; }
public string AudioEndPointDeviceID { get; private set; }
public string DefaultAudioEndPointDeviceID { get; private set; }

public MMDevice AudioEndPointDevice {

public MMDevice AudioEndPointDevice
{
get
{
return AudioMMDevices.GetDevice(AudioEndPointDeviceNames.ContainsKey(AudioEndPointDeviceID)
Expand Down Expand Up @@ -111,7 +108,7 @@ public void OnPropertyValueChanged(string deviceId, PropertyKey propertyKey) { }
public void Dispose()
{
Dispose(true);

GC.SuppressFinalize(this);
}

Expand Down
9 changes: 5 additions & 4 deletions EspionSpotify/AudioSessions/MainAudioSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ public class MainAudioSession : IMainAudioSession, IDisposable

public MMDeviceEnumerator AudioMMDevices { get; private set; }
public AudioMMDevicesManager AudioMMDevicesManager { get; private set; }
public int AudioDeviceVolume { get => (int)(AudioMMDevicesManager.AudioEndPointDevice.AudioEndpointVolume.MasterVolumeLevelScalar * 100); }
public int AudioDeviceVolume { get => (int)(AudioMMDevicesManager.AudioEndPointDevice.AudioEndpointVolume.MasterVolumeLevelScalar * 100); }
public bool IsAudioEndPointDeviceIndexAvailable { get => AudioMMDevicesManager.AudioEndPointDeviceNames.ContainsKey(AudioMMDevicesManager.AudioEndPointDeviceID); }

public ICollection<AudioSessionControl> SpotifyAudioSessionControls { get; private set; } = new List<AudioSessionControl>();
public void ClearSpotifyAudioSessionControls() => SpotifyAudioSessionControls = new List<AudioSessionControl>();

private SessionCollection GetSessionsAudioEndPointDevice => AudioMMDevicesManager.GetAudioEndPointDeviceSessions;

internal MainAudioSession(string audioEndPointDevice):
this(audioEndPointDevice, processManager: new ProcessManager()) { }
internal MainAudioSession(string audioEndPointDevice) :
this(audioEndPointDevice, processManager: new ProcessManager())
{ }

public MainAudioSession(string audioEndPointDeviceID, IProcessManager processManager)
{
Expand Down Expand Up @@ -206,7 +207,7 @@ private async Task<bool> IsSpotifyPlayingOutsideDefaultAudioEndPoint(bool runnin
public void Dispose()
{
Dispose(true);

GC.SuppressFinalize(this);
}

Expand Down
8 changes: 1 addition & 7 deletions EspionSpotify/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify
namespace EspionSpotify
{
public static class Constants
{
Expand Down
2 changes: 1 addition & 1 deletion EspionSpotify/Controls/MetroComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace EspionSpotify.Controls
{
public class MetroComboBox: MetroFramework.Controls.MetroComboBox
public class MetroComboBox : MetroFramework.Controls.MetroComboBox
{
protected override void OnMouseWheel(MouseEventArgs e)
{
Expand Down
6 changes: 5 additions & 1 deletion EspionSpotify/Controls/MetroCredentialsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public FrmSpotifyAPICredentials(Analytics analytics)
txtSecretId.Text = Settings.Default.SpotifyAPISecretId?.Trim();

Text = FrmEspionSpotify.Instance.Rm.GetString(I18nKeys.TitleSpotifyAPICredentials);

lblClientId.Text = FrmEspionSpotify.Instance.Rm.GetString(I18nKeys.LblClientId);
lblSecretId.Text = FrmEspionSpotify.Instance.Rm.GetString(I18nKeys.LblSecretId);

Expand Down Expand Up @@ -103,7 +103,9 @@ private void InitializeComponent()
this.txtClientId.MaxLength = 32;
this.txtClientId.Name = "txtClientId";
this.txtClientId.PasswordChar = '\0';
#pragma warning disable CS0618 // Type or member is obsolete
this.txtClientId.PromptText = "PASTE_KEY_ID_HERE";
#pragma warning restore CS0618 // Type or member is obsolete
this.txtClientId.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.txtClientId.SelectedText = "";
this.txtClientId.SelectionLength = 0;
Expand Down Expand Up @@ -144,7 +146,9 @@ private void InitializeComponent()
this.txtSecretId.MaxLength = 32;
this.txtSecretId.Name = "txtSecretId";
this.txtSecretId.PasswordChar = '\0';
#pragma warning disable CS0618 // Type or member is obsolete
this.txtSecretId.PromptText = "PASTE_KEY_ID_HERE";
#pragma warning restore CS0618 // Type or member is obsolete
this.txtSecretId.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.txtSecretId.SelectedText = "";
this.txtSecretId.SelectionLength = 0;
Expand Down
2 changes: 1 addition & 1 deletion EspionSpotify/Controls/MetroTrackBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EspionSpotify.Controls
{
public class MetroTrackBar: MetroFramework.Controls.MetroTrackBar
public class MetroTrackBar : MetroFramework.Controls.MetroTrackBar
{
protected override void OnMouseWheel(MouseEventArgs e)
{
Expand Down
8 changes: 2 additions & 6 deletions EspionSpotify/Drivers/AudioVirtualCableDriver.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using NAudio.CoreAudioApi;
using System;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Drivers
{
Expand All @@ -21,7 +17,7 @@ public static bool ExistsInAudioEndPointDevices(IDictionary<string, string> audi
{
return audioEndPointDeviceNames.Any(x => x.Value.Contains(DriverName));
}

public static bool SetupDriver()
{
try
Expand Down
8 changes: 1 addition & 7 deletions EspionSpotify/Enums/RecordRecordingsStatus.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Enums
namespace EspionSpotify.Enums
{
public enum RecordRecordingsStatus
{
Expand Down
8 changes: 1 addition & 7 deletions EspionSpotify/Enums/TitleSeparatorType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Enums
namespace EspionSpotify.Enums
{
public enum TitleSeparatorType
{
Expand Down
8 changes: 1 addition & 7 deletions EspionSpotify/Enums/WaveFormatMP3Restriction.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Enums
namespace EspionSpotify.Enums
{
public enum WaveFormatMP3Restriction
{
Expand Down
10 changes: 2 additions & 8 deletions EspionSpotify/Extensions/ClassPropertyExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Extensions
namespace EspionSpotify.Extensions
{
public static class ClassPropertyExtensions
{
Expand All @@ -21,7 +15,7 @@ public static void CopyAllTo<TSource, TTarget>(this TSource source, TTarget targ
{
if (!childProperty.CanWrite || !parentProperty.CanRead) break;
if (parentProperty.Name == childProperty.Name && parentProperty.PropertyType == childProperty.PropertyType)
{
{
childProperty.SetValue(target, parentProperty.GetValue(source));
break;
}
Expand Down
7 changes: 1 addition & 6 deletions EspionSpotify/Extensions/ColorExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace EspionSpotify.Extensions
{
Expand Down
5 changes: 0 additions & 5 deletions EspionSpotify/Extensions/ControlExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EspionSpotify.Extensions
Expand Down
2 changes: 0 additions & 2 deletions EspionSpotify/Extensions/LinqExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Extensions
{
Expand Down
5 changes: 0 additions & 5 deletions EspionSpotify/Extensions/ResourceManagerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using EspionSpotify.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Extensions
{
Expand Down
5 changes: 0 additions & 5 deletions EspionSpotify/Extensions/SettingExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using EspionSpotify.Enums;
using EspionSpotify.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Extensions
{
Expand Down
4 changes: 0 additions & 4 deletions EspionSpotify/Extensions/WaveFormatExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using EspionSpotify.Enums;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EspionSpotify.Extensions
{
Expand Down
8 changes: 4 additions & 4 deletions EspionSpotify/GitHub.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using EspionSpotify.Extensions;
using EspionSpotify.Models;
using EspionSpotify.Models.GitHub;
using EspionSpotify.Properties;
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using EspionSpotify.Models;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EspionSpotify
{
Expand All @@ -38,7 +38,7 @@ public static async Task GetVersion()

try
{
using (var response = (HttpWebResponse) await request.GetResponseAsync())
using (var response = (HttpWebResponse)await request.GetResponseAsync())
{
if (response.StatusCode != HttpStatusCode.OK) return;

Expand Down
2 changes: 1 addition & 1 deletion EspionSpotify/IFrmEspionSpotify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace EspionSpotify
{
public interface IFrmEspionSpotify
public interface IFrmEspionSpotify
{
ResourceManager Rm { get; }
void UpdateIconSpotify(bool isSpotifyPlaying, bool isRecording = false);
Expand Down
6 changes: 2 additions & 4 deletions EspionSpotify/IWatcher.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using EspionSpotify.Models;
using EspionSpotify.Spotify;
using System.Threading.Tasks;
using EspionSpotify.Spotify;

namespace EspionSpotify
{
Expand All @@ -9,7 +7,7 @@ public interface IWatcher
int CountSeconds { get; set; }
ISpotifyHandler Spotify { get; set; }

bool RecorderUpAndRunning { get; }
bool RecorderUpAndRunning { get; }
bool IsTypeAllowed { get; }
bool IsOldSong { get; }

Expand Down
1 change: 0 additions & 1 deletion EspionSpotify/MediaTags/ILastFMAPI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EspionSpotify.Models;
using System.Threading.Tasks;

namespace EspionSpotify.MediaTags
{
Expand Down
1 change: 0 additions & 1 deletion EspionSpotify/MediaTags/ISpotifyAPI.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using EspionSpotify.Models;
using SpotifyAPI.Web.Models;
using System.Threading.Tasks;

namespace EspionSpotify.MediaTags
{
Expand Down
3 changes: 1 addition & 2 deletions EspionSpotify/MediaTags/LastFMAPI.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using EspionSpotify.Models;
using PCLWebUtility;
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using PCLWebUtility;
using EspionSpotify.Spotify;

namespace EspionSpotify.MediaTags
{
Expand Down
Loading

0 comments on commit 605036e

Please sign in to comment.