Skip to content

Commit

Permalink
Lynn hakim (#41)
Browse files Browse the repository at this point in the history
* added AudioOutputForm.cs and enabled windows targetting

* removed the drop down and testing if my audio is on the same form

* fixed the drop down

* added audio cycling

* removed the drop down and testing if my audio is on the same form

* fixed the drop down

* fix merge conflicts

* integrated audio outputs in the main form

* integrated audio outputs in the main form

* integrated audio outputs in the main form

* removed audioOutputDesigner

* fixing merge conflicts

* added refresh feature to update audio output list

* removed comments, fixed ui

* panel sizing

* removing bin files

* removed bin and obj

* removed .vs

* one more obj

* removed displayProfileManager bin and obj

---------

Co-authored-by: shawiminhas <shawiminhas@hotmail.com>
  • Loading branch information
lynnhakim and shawiminhas authored Sep 28, 2024
1 parent e858700 commit 6a3fc04
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 36 deletions.
69 changes: 69 additions & 0 deletions DAIRemote/AudioOutputForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using NAudio.CoreAudioApi;

namespace DAIRemote
{
public partial class AudioOutputForm : System.Windows.Forms.Form
{
private ComboBox audioDeviceComboBox;

public AudioOutputForm()

Check warning on line 13 in DAIRemote/AudioOutputForm.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'audioDeviceComboBox' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
InitializeComponent();
LoadAudioDevices();
}

private void InitializeComponent()
{
audioDeviceComboBox = new ComboBox();
SuspendLayout();

audioDeviceComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
audioDeviceComboBox.FormattingEnabled = true;
audioDeviceComboBox.Location = new Point(12, 100);
audioDeviceComboBox.Name = "audioDeviceComboBox";
audioDeviceComboBox.Size = new Size(260, 33);
audioDeviceComboBox.TabIndex = 0;
audioDeviceComboBox.DropDown += audioDeviceComboBox_DropDown;
audioDeviceComboBox.SelectedIndexChanged += audioDeviceComboBox_SelectedIndexChanged;

ClientSize = new Size(284, 100);
Controls.Add(audioDeviceComboBox);
Name = "AudioOutputForm";
Text = "Audio Output Switcher";
Load += AudioOutputForm_Load;
ResumeLayout(false);
}

private void LoadAudioDevices()
{
var devices = GetAudioDevices();
audioDeviceComboBox.DataSource = devices;
}

public List<string> GetAudioDevices()
{
var enumerator = new MMDeviceEnumerator();
var devices = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
return devices.Select(d => d.FriendlyName).ToList();
}

private void audioDeviceComboBox_DropDown(object sender, EventArgs e)
{
LoadAudioDevices();
}

private void audioDeviceComboBox_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void AudioOutputForm_Load(object sender, EventArgs e)
{

}
}
}
120 changes: 120 additions & 0 deletions DAIRemote/AudioOutputForm.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
6 changes: 6 additions & 0 deletions DAIRemote/DAIRemote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>


<ItemGroup>
<ProjectReference Include="..\DisplayProfileManager\DisplayProfileManager.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NAudio" Version="2.2.1" />
</ItemGroup>

</Project>
15 changes: 9 additions & 6 deletions DAIRemote/DAIRemote.csproj.user
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>
<ItemGroup>
<Compile Update="AudioOutputForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>
39 changes: 34 additions & 5 deletions DAIRemote/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,64 @@

namespace DAIRemote
{
public partial class Form1 : Form
public partial class Form1 : System.Windows.Forms.Form
{
private TrayIconManager trayIconManager;
private Panel audioFormPanel;

public Form1()

Check warning on line 12 in DAIRemote/Form1.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'audioFormPanel' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
InitializeComponent();
InitializeCustomComponents();
trayIconManager = new TrayIconManager(this);
this.Load += Form1_Load;

Check warning on line 17 in DAIRemote/Form1.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'sender' of 'void Form1.Form1_Load(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).
this.FormClosing += Form1_FormClosing;

Check warning on line 18 in DAIRemote/Form1.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'sender' of 'void Form1.Form1_FormClosing(object sender, FormClosingEventArgs e)' doesn't match the target delegate 'FormClosingEventHandler' (possibly because of nullability attributes).
}

private void Form1_Load(object sender, EventArgs e)
{
this.Hide();
this.Hide();
}

private void BtnShowAudioOutputs_Click(object sender, EventArgs e)
{
audioFormPanel.Controls.Clear();

AudioOutputForm audioForm = new AudioOutputForm
{
TopLevel = false,
FormBorderStyle = FormBorderStyle.None,
Dock = DockStyle.Fill
};

audioFormPanel.Controls.Add(audioForm);
audioForm.Show();
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = false;
e.Cancel = false;
trayIconManager.HideIcon();
}
}
string fileName = "displayConfig";

private void InitializeCustomComponents()
{
this.audioFormPanel = new Panel
{
Location = new System.Drawing.Point(10, 60),
Size = new System.Drawing.Size(760, 370),
};

this.Controls.Add(this.audioFormPanel);
}

private void BtnSaveDisplayConfig_Click(object sender, EventArgs e)
{
string fileName = "displayConfig";
DisplayConfig.SaveDisplaySettings(fileName + ".json");
}
}
}
}
48 changes: 25 additions & 23 deletions DAIRemote/Form1.Designer.cs → DAIRemote/Form1.designer.cs

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

4 changes: 2 additions & 2 deletions DAIRemote/Form1.resx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
Expand Down Expand Up @@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
Expand Down
Loading

0 comments on commit 6a3fc04

Please sign in to comment.