Skip to content

Commit

Permalink
Changes for v2.2
Browse files Browse the repository at this point in the history
Fixed the hidden device dissapearance from settings - Thanks ExcuseMi!
Fixed a case where the device list was longer than expected and wasn't
resized to be longer
Added a new feature - Always Open Mode! Thanks for the suggestion xMez
and mintgrey :)
Usage: if you enable it in settings then it will allow dragging it by
items list and will remember it's position. If you want to reset it's
position then just disable and enable the mode again. Other behavior
quirks can be found by just using it :) Enjoy!
  • Loading branch information
sirWest committed Aug 13, 2017
1 parent 1ece957 commit 654fa22
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 28 deletions.
3 changes: 3 additions & 0 deletions Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ private static Settings newSettings()
[XmlElement] public bool QuickSwitchEnabled;
[XmlElement] public bool QuickSwitchShowOSD;
[XmlElement] public bool CloseAfterSelecting;
[XmlElement] public bool AlwaysVisible;
[XmlElement] public int FreePosLeft;
[XmlElement] public int FreePosTop;

private bool _useCustomOSD;

Expand Down
30 changes: 30 additions & 0 deletions Controls/CustomListView.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using AudioSwitch.Classes;

namespace AudioSwitch.Controls
{
internal sealed class CustomListView : ListView
{
internal event ScrollEventHandler Scroll;
Point dragOffset;

protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
var parent = FindForm();
if (parent.Name != "FormSwitcher" || !Program.settings.AlwaysVisible || e.Button != MouseButtons.Left)
return;

dragOffset = PointToScreen(e.Location);
var formLocation = parent.Location;
dragOffset.X -= formLocation.X;
dragOffset.Y -= formLocation.Y;
}

protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
var parent = FindForm();
if (parent.Name != "FormSwitcher" || !Program.settings.AlwaysVisible || e.Button != MouseButtons.Left)
return;

var newLocation = PointToScreen(e.Location);

newLocation.X -= dragOffset.X;
newLocation.Y -= dragOffset.Y;

parent.Location = newLocation;
}
public CustomListView()
{
DoubleBuffered = true;
Expand Down
58 changes: 36 additions & 22 deletions Forms/FormSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion Forms/FormSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ private void FormSettings_Load(object sender, EventArgs e)
checkQSShowOSD.Enabled = radioQuickSwitch.Checked;

checkQSShowOSD.Checked = Program.settings.QuickSwitchShowOSD;

checkAlwaysVisible.Checked = Program.settings.AlwaysVisible;

gridHotkeys.CellEndEdit += gridHotkeys_CellEndEdit;
}

Expand Down Expand Up @@ -137,6 +138,7 @@ private void FormSettings_FormClosing(object sender, FormClosingEventArgs e)
Program.settings.QuickSwitchShowOSD = checkQSShowOSD.Checked;
Program.settings.UseCustomOSD = checkCustomOSD.Checked;
Program.settings.CloseAfterSelecting = checkCloseSelect.Checked;
Program.settings.AlwaysVisible = checkAlwaysVisible.Checked;

Program.settings.Save();
}
Expand Down Expand Up @@ -241,5 +243,14 @@ private void playbackDevices_Load(object sender, EventArgs e)
playbackDevices.PostConstructor(EDataFlow.eRender);

}

private void checkAlwaysVisible_CheckedChanged(object sender, EventArgs e)
{
if (!checkAlwaysVisible.Checked)
{
Program.settings.FreePosLeft = 0;
Program.settings.FreePosTop = 0;
}
}
}
}
1 change: 1 addition & 0 deletions Forms/FormSwitcher.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 38 additions & 3 deletions Forms/FormSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,31 @@ public FormSwitcher()

ScrollVolume.VolumeScroll += ScrollTheVolume;
ScrollVolume.RegisterVolScroll(Program.settings.VolumeScroll.Enabled);

if (Program.settings.AlwaysVisible)
OpenAlwaysVisible();
}

private void OpenAlwaysVisible()
{
if (Program.settings.FreePosLeft == 0 || Program.settings.FreePosTop == 0)
{
var point = WindowPosition.GetWindowPosition(notifyIcon, Width, Height);
Left = point.X;
Top = point.Y;
}
else
{
Left = Program.settings.FreePosLeft;
Top = Program.settings.FreePosTop;
}
RenderType = Program.settings.DefaultDataFlow;
RefreshDevices(RenderType);
SetSizes();
VolBar.RegisterDevice(RenderType);
timer1.Enabled = true;
Show();
Activate();
}

private void DefaultChanged(string devID)
Expand Down Expand Up @@ -218,12 +243,14 @@ private static Icon getIcon(Bitmap source)
private void FormSwitcher_FormClosing(object sender, FormClosingEventArgs e)
{
GlobalHotkeys.UnregisterAll();
Program.settings.FreePosLeft = Left;
Program.settings.FreePosTop = Top;
Program.settings.Save();
}

private void FormSwitcher_Deactivate(object sender, EventArgs e)
{
if (Disposing)
if (Disposing || Program.settings.AlwaysVisible)
return;

Hide();
Expand Down Expand Up @@ -437,10 +464,13 @@ private void notifyIcon1_MouseUp(object sender, MouseEventArgs e)
private void SetSizes()
{
Height = listDevices.Items.Count * listDevices.TileSize.Height + pictureItemsBack.ClientSize.Height + (IsWin10 ? 2 : SystemInformation.FrameBorderSize.Width * 2);
pictureShadow.Top = pictureItemsBack.Top = ClientSize.Height - pictureItemsBack.ClientSize.Height;
listDevices.Height = pictureShadow.Top = pictureItemsBack.Top = ClientSize.Height - pictureItemsBack.ClientSize.Height;
VolBar.Top = pictureItemsBack.Top + pictureItemsBack.Height/2 - VolBar.Height/2;
ledLeft.Top = VolBar.Top - ledLeft.Height - 1;
ledRight.Top = VolBar.Top + VolBar.Height + 1;
if (Program.settings.AlwaysVisible)
return;

var point = WindowPosition.GetWindowPosition(notifyIcon, Width, Height);
Left = point.X;// (int)(point.X / DpiFactor);
Top = point.Y;// (int)(point.Y / DpiFactor);
Expand All @@ -452,7 +482,7 @@ private void timer1_Tick(object sender, EventArgs e)
ledLeft.SetValue(peaks[0]);
ledRight.SetValue(peaks[VolBar.Stereo ? 1 : 0]);

if (!listDevices.Focused)
if (!listDevices.Focused && !Program.settings.AlwaysVisible)
listDevices.Focus();
}

Expand Down Expand Up @@ -560,6 +590,11 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
ledLeft.OldStyle = Program.settings.ColorVU;
ledRight.OldStyle = Program.settings.ColorVU;
SetTrayIcons();

if (Program.settings.AlwaysVisible)
OpenAlwaysVisible();
else
FormSwitcher_Deactivate(sender, e);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.1.8")]
[assembly: AssemblyFileVersion("2.1.8")]
[assembly: AssemblyVersion("2.2.0")]
[assembly: AssemblyFileVersion("2.2.0")]

0 comments on commit 654fa22

Please sign in to comment.