Compare commits
18
Commits
a29fcfe9a6
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a55ef1f27e | ||
|
|
46fce20771 | ||
|
|
d28f421ea3 | ||
|
|
5aeefebc47 | ||
|
|
ca956f207b | ||
|
|
ad212e7416 | ||
|
|
8c63b93d09 | ||
|
|
6ba4854bd8 | ||
|
|
2be5b86b17 | ||
|
|
a75a2d8926 | ||
|
|
f97621c37b | ||
|
|
d76d148c67 | ||
|
|
3c1a931f26 | ||
|
|
7a246bb61b | ||
|
|
3c6f648e4e | ||
|
|
f372f99d95 | ||
|
|
84d2435b83 | ||
|
|
e64c6878c1 |
@@ -0,0 +1,36 @@
|
|||||||
|
name: Deploy to Gitea Releases
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-to-gitea-releases:
|
||||||
|
runs-on: ubuntu-latest-x86-64
|
||||||
|
|
||||||
|
container:
|
||||||
|
image: ghcr.io/catthehacker/ubuntu:dotnet-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get next version
|
||||||
|
uses: reecetech/version-increment@2024.4.3
|
||||||
|
id: version
|
||||||
|
with:
|
||||||
|
scheme: calver
|
||||||
|
|
||||||
|
- name: Publish Application
|
||||||
|
run: dotnet publish WorkIndicator.csproj -r win-x86 -c Release -o publish
|
||||||
|
|
||||||
|
- name: Create Velopack Release
|
||||||
|
run: |
|
||||||
|
export PATH="$PATH:/root/.dotnet/tools"
|
||||||
|
dotnet tool install -g vpk
|
||||||
|
vpk [win] download gitea --channel win-x86 --repoUrl https://gitea.kaczorzoo.net/ckaczor/WorkIndicator
|
||||||
|
vpk [win] pack --channel win-x86 -u WorkIndicator -v ${{ steps.version.outputs.version }} -p publish --packTitle "Work Indicator" --shortcuts StartMenuRoot --framework net10.0-x86-desktop
|
||||||
|
vpk [win] upload gitea --channel win-x86 --repoUrl https://gitea.kaczorzoo.net/ckaczor/WorkIndicator --publish --releaseName "${{ steps.version.outputs.version }}" --token ${{ secrets.VPK_TOKEN }}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
name: Deploy to GitHub Releases
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy-to-github-releases:
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Get next version
|
|
||||||
uses: reecetech/version-increment@2024.4.3
|
|
||||||
id: version
|
|
||||||
with:
|
|
||||||
scheme: calver
|
|
||||||
|
|
||||||
- name: Install .NET
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: 10.0.x
|
|
||||||
|
|
||||||
- name: Publish Application
|
|
||||||
run: dotnet publish WorkIndicator.csproj -c Release -o publish
|
|
||||||
|
|
||||||
- name: Create Velopack Release
|
|
||||||
run: |
|
|
||||||
dotnet tool install -g vpk
|
|
||||||
vpk download github --repoUrl https://github.com/ckaczor/WorkIndicator
|
|
||||||
vpk pack -u WorkIndicator -v ${{ steps.version.outputs.version }} -p publish --packTitle "Work Indicator" --shortcuts StartMenuRoot --framework net10.0-x64-desktop
|
|
||||||
vpk upload github --repoUrl https://github.com/ckaczor/WorkIndicator --publish --releaseName "${{ steps.version.outputs.version }}" --tag v${{ steps.version.outputs.version }} --token ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using NAudio.CoreAudioApi;
|
||||||
|
using NAudio.CoreAudioApi.Interfaces;
|
||||||
|
using Serilog;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace WorkIndicator.Audio;
|
||||||
|
|
||||||
|
internal class AudioDevice
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public delegate void AudioSessionsChangedDelegate();
|
||||||
|
|
||||||
|
public event AudioSessionsChangedDelegate AudioSessionsChanged;
|
||||||
|
|
||||||
|
public bool IsMuted { get; private set; }
|
||||||
|
|
||||||
|
public string FriendlyName { get; }
|
||||||
|
|
||||||
|
public Dictionary<string, AudioSession> Sessions { get; } = new();
|
||||||
|
|
||||||
|
public AudioDevice(MMDevice device)
|
||||||
|
{
|
||||||
|
_logger = Log.ForContext<AudioDevice>();
|
||||||
|
|
||||||
|
FriendlyName = device.DeviceFriendlyName;
|
||||||
|
IsMuted = device.AudioEndpointVolume.Mute;
|
||||||
|
|
||||||
|
_logger.Information("AudioDevice: {name} {muted}", FriendlyName, IsMuted);
|
||||||
|
|
||||||
|
device.AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification;
|
||||||
|
device.AudioSessionManager.OnSessionCreated += AudioSessionManager_OnSessionCreated;
|
||||||
|
|
||||||
|
device.AudioSessionManager.RefreshSessions();
|
||||||
|
var sessions = device.AudioSessionManager.Sessions;
|
||||||
|
|
||||||
|
for (var i = 0; i < sessions.Count; i++)
|
||||||
|
{
|
||||||
|
SetupSession(sessions[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
|
||||||
|
{
|
||||||
|
_logger.Information("AudioEndpointVolume_OnVolumeNotification: {name} {muted}", FriendlyName, data.Muted);
|
||||||
|
|
||||||
|
IsMuted = data.Muted;
|
||||||
|
|
||||||
|
AudioSessionsChanged?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AudioSessionManager_OnSessionCreated(object sender, IAudioSessionControl newSession)
|
||||||
|
{
|
||||||
|
var session = new AudioSessionControl(newSession);
|
||||||
|
|
||||||
|
_logger.Information("OnSessionCreated: {name}", session.GetSessionIdentifier);
|
||||||
|
|
||||||
|
SetupSession(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupSession(AudioSessionControl session)
|
||||||
|
{
|
||||||
|
_logger.Information("SetupSession: {name}", session.GetSessionIdentifier);
|
||||||
|
|
||||||
|
var audioSession = new AudioSession(session, FriendlyName);
|
||||||
|
|
||||||
|
Sessions[session.GetSessionIdentifier] = audioSession;
|
||||||
|
|
||||||
|
audioSession.AudioSessionChanged += AudioSession_AudioSessionChanged;
|
||||||
|
|
||||||
|
AudioSessionsChanged?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AudioSession_AudioSessionChanged(string id, AudioSessionState state)
|
||||||
|
{
|
||||||
|
_logger.Information("AudioSessionChanged: {id} {state}", id, state);
|
||||||
|
|
||||||
|
AudioSessionsChanged?.Invoke();
|
||||||
|
|
||||||
|
if (state == AudioSessionState.AudioSessionStateExpired)
|
||||||
|
{
|
||||||
|
Sessions.Remove(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ActiveSessionCount => Sessions.Values.Count(s => s.State == AudioSessionState.AudioSessionStateActive);
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
using NAudio.CoreAudioApi;
|
||||||
|
using NAudio.CoreAudioApi.Interfaces;
|
||||||
|
using Serilog;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace WorkIndicator.Audio;
|
||||||
|
|
||||||
|
internal class AudioSession : IAudioSessionEventsHandler
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly AudioSessionControl _audioSessionControl;
|
||||||
|
|
||||||
|
public string Id { get; }
|
||||||
|
public string FriendlyName { get; }
|
||||||
|
|
||||||
|
public delegate void AudioSessionChangedDelegate(string id, AudioSessionState state);
|
||||||
|
|
||||||
|
public event AudioSessionChangedDelegate AudioSessionChanged;
|
||||||
|
|
||||||
|
public AudioSession(AudioSessionControl audioSessionControl, string friendlyName)
|
||||||
|
{
|
||||||
|
_logger = Log.ForContext<AudioSession>();
|
||||||
|
|
||||||
|
_audioSessionControl = audioSessionControl;
|
||||||
|
|
||||||
|
Id = audioSessionControl.GetSessionIdentifier;
|
||||||
|
FriendlyName = friendlyName;
|
||||||
|
|
||||||
|
audioSessionControl.RegisterEventClient(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AudioSessionState State => _audioSessionControl.State;
|
||||||
|
|
||||||
|
void IAudioSessionEventsHandler.OnVolumeChanged(float volume, bool isMuted)
|
||||||
|
{
|
||||||
|
_logger.Information("OnVolumeChanged: {name} {volume} {isMuted}", FriendlyName, volume, isMuted);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAudioSessionEventsHandler.OnDisplayNameChanged(string displayName)
|
||||||
|
{
|
||||||
|
_logger.Information("OnDisplayNameChanged: {name}", displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAudioSessionEventsHandler.OnIconPathChanged(string iconPath)
|
||||||
|
{
|
||||||
|
_logger.Information("OnIconPathChanged: {path}", iconPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAudioSessionEventsHandler.OnChannelVolumeChanged(uint channelCount, IntPtr newVolumes, uint channelIndex)
|
||||||
|
{
|
||||||
|
_logger.Information("OnChannelVolumeChanged: {channelCount} {newVolumes} {channelIndex}", channelCount, newVolumes, channelIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAudioSessionEventsHandler.OnGroupingParamChanged(ref Guid groupingId)
|
||||||
|
{
|
||||||
|
_logger.Information("OnGroupingParamChanged: {groupingId}", groupingId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAudioSessionEventsHandler.OnStateChanged(AudioSessionState state)
|
||||||
|
{
|
||||||
|
_logger.Information("OnStateChanged: {state}", state);
|
||||||
|
|
||||||
|
AudioSessionChanged?.Invoke(Id, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAudioSessionEventsHandler.OnSessionDisconnected(AudioSessionDisconnectReason disconnectReason)
|
||||||
|
{
|
||||||
|
_logger.Information("OnSessionDisconnected: {disconnectReason}", disconnectReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
using NAudio.CoreAudioApi;
|
||||||
|
using NAudio.CoreAudioApi.Interfaces;
|
||||||
|
using Serilog;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace WorkIndicator.Audio;
|
||||||
|
|
||||||
|
internal enum MicrophoneStatus
|
||||||
|
{
|
||||||
|
NotUsed,
|
||||||
|
UsedMuted,
|
||||||
|
UsedNotMuted
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class AudioWatcher : IMMNotificationClient
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger = Log.ForContext<AudioWatcher>();
|
||||||
|
private readonly MMDeviceEnumerator _deviceEnumerator = new();
|
||||||
|
private readonly Dictionary<string, AudioDevice> _inputDevices = new();
|
||||||
|
|
||||||
|
public delegate void MicrophoneStatusChangedDelegate(MicrophoneStatus microphoneStatus);
|
||||||
|
|
||||||
|
public event MicrophoneStatusChangedDelegate MicrophoneStatusChanged;
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
_logger.Information("Start");
|
||||||
|
|
||||||
|
_deviceEnumerator.RegisterEndpointNotificationCallback(this);
|
||||||
|
|
||||||
|
_logger.Information("Getting capture devices");
|
||||||
|
|
||||||
|
var captureDevices = _deviceEnumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active);
|
||||||
|
|
||||||
|
foreach (var captureDevice in captureDevices)
|
||||||
|
{
|
||||||
|
_logger.Information("Capture device: {name}", captureDevice.DeviceFriendlyName);
|
||||||
|
|
||||||
|
HandleAddedDevice(captureDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogState()
|
||||||
|
{
|
||||||
|
_logger.Information("---");
|
||||||
|
|
||||||
|
foreach (var inputDevicePair in _inputDevices)
|
||||||
|
{
|
||||||
|
_logger.Information("Device: {name} {muted}", inputDevicePair.Value.FriendlyName, inputDevicePair.Value.IsMuted);
|
||||||
|
|
||||||
|
foreach (var sessionPair in inputDevicePair.Value.Sessions)
|
||||||
|
{
|
||||||
|
var session = sessionPair.Value;
|
||||||
|
|
||||||
|
_logger.Information("Session: {id} {friendlyName} {state}", session.Id, session.FriendlyName, session.State);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Information("---");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleAddedDevice(MMDevice captureDevice)
|
||||||
|
{
|
||||||
|
_logger.Information("Device added: {name}", captureDevice.DeviceFriendlyName);
|
||||||
|
|
||||||
|
var audioDevice = new AudioDevice(captureDevice);
|
||||||
|
audioDevice.AudioSessionsChanged += AudioDevice_AudioSessionsChanged;
|
||||||
|
|
||||||
|
_inputDevices[captureDevice.ID] = audioDevice;
|
||||||
|
|
||||||
|
MicrophoneStatusChanged?.Invoke(GetMicrophoneStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AudioDevice_AudioSessionsChanged()
|
||||||
|
{
|
||||||
|
MicrophoneStatusChanged?.Invoke(GetMicrophoneStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleRemovedDevice(string deviceId)
|
||||||
|
{
|
||||||
|
_logger.Information("Device removed: {id}", deviceId);
|
||||||
|
|
||||||
|
_inputDevices.Remove(deviceId);
|
||||||
|
|
||||||
|
MicrophoneStatusChanged?.Invoke(GetMicrophoneStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
_logger.Information("Stop");
|
||||||
|
|
||||||
|
_deviceEnumerator.UnregisterEndpointNotificationCallback(this);
|
||||||
|
_deviceEnumerator.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MicrophoneStatus GetMicrophoneStatus()
|
||||||
|
{
|
||||||
|
foreach (var inputDevice in _inputDevices.Values)
|
||||||
|
{
|
||||||
|
if (inputDevice.ActiveSessionCount > 0)
|
||||||
|
return inputDevice.IsMuted ? MicrophoneStatus.UsedMuted : MicrophoneStatus.UsedNotMuted;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MicrophoneStatus.NotUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMMNotificationClient.OnDeviceStateChanged(string deviceId, DeviceState newState)
|
||||||
|
{
|
||||||
|
_logger.Information("OnDeviceStateChanged: {deviceId} {newState}", deviceId, newState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMMNotificationClient.OnDeviceAdded(string deviceId)
|
||||||
|
{
|
||||||
|
_logger.Information("OnDeviceAdded: {deviceId}", deviceId);
|
||||||
|
|
||||||
|
var device = _deviceEnumerator.GetDevice(deviceId);
|
||||||
|
|
||||||
|
if (device.DataFlow is DataFlow.Capture or DataFlow.All)
|
||||||
|
{
|
||||||
|
HandleAddedDevice(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMMNotificationClient.OnDeviceRemoved(string deviceId)
|
||||||
|
{
|
||||||
|
_logger.Information("OnDeviceRemoved: {deviceId}", deviceId);
|
||||||
|
|
||||||
|
HandleRemovedDevice(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMMNotificationClient.OnDefaultDeviceChanged(DataFlow flow, Role role, string defaultDeviceId)
|
||||||
|
{
|
||||||
|
_logger.Information("OnDefaultDeviceChanged: {defaultDeviceId} {flow} {role}", defaultDeviceId, flow, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMMNotificationClient.OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key)
|
||||||
|
{
|
||||||
|
_logger.Debug("OnPropertyValueChanged: {deviceId} {propertyId}", pwstrDeviceId, key.propertyId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
namespace WorkIndicator;
|
|
||||||
|
|
||||||
internal static class AudioWatcher
|
|
||||||
{
|
|
||||||
public delegate void MicrophoneInUseChangedDelegate(bool microphoneInUse);
|
|
||||||
|
|
||||||
public static event MicrophoneInUseChangedDelegate MicrophoneInUseChanged;
|
|
||||||
|
|
||||||
public static void Start()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Stop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool MicrophoneInUse()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace WorkIndicator.Delcom
|
namespace WorkIndicator.Delcom
|
||||||
{
|
{
|
||||||
public class StoplightIndicator : IDisposable
|
public class StoplightIndicator : IDisposable
|
||||||
{
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public enum Light
|
public enum Light
|
||||||
{
|
{
|
||||||
Green,
|
Green,
|
||||||
@@ -25,6 +28,8 @@ namespace WorkIndicator.Delcom
|
|||||||
|
|
||||||
public StoplightIndicator()
|
public StoplightIndicator()
|
||||||
{
|
{
|
||||||
|
_logger = Log.ForContext<StoplightIndicator>();
|
||||||
|
|
||||||
Device = new Delcom();
|
Device = new Delcom();
|
||||||
Device.Open();
|
Device.Open();
|
||||||
|
|
||||||
@@ -74,7 +79,7 @@ namespace WorkIndicator.Delcom
|
|||||||
_yellow = yellow;
|
_yellow = yellow;
|
||||||
_green = green;
|
_green = green;
|
||||||
|
|
||||||
Debug.WriteLine($"Red: {_red}, Yellow: {_yellow}, Green: {_green}");
|
_logger.Information("Red: {red}, Yellow: {yellow}, Green: {green}", _red, _yellow, _green);
|
||||||
|
|
||||||
port1 = port1.SetBitValue((int) Light.Green, green == LightState.Off);
|
port1 = port1.SetBitValue((int) Light.Green, green == LightState.Off);
|
||||||
port1 = port1.SetBitValue((int) Light.Yellow, yellow == LightState.Off);
|
port1 = port1.SetBitValue((int) Light.Yellow, yellow == LightState.Off);
|
||||||
|
|||||||
+13
-4
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using WorkIndicator.Audio;
|
||||||
using WorkIndicator.Delcom;
|
using WorkIndicator.Delcom;
|
||||||
|
|
||||||
namespace WorkIndicator
|
namespace WorkIndicator
|
||||||
@@ -14,6 +15,7 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
public static class LightController
|
public static class LightController
|
||||||
{
|
{
|
||||||
|
private static readonly AudioWatcher AudioWatcher = new();
|
||||||
private static StoplightIndicator _stoplightIndicator;
|
private static StoplightIndicator _stoplightIndicator;
|
||||||
private static UsbService _usbService;
|
private static UsbService _usbService;
|
||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
@@ -29,7 +31,7 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
Properties.Settings.Default.PropertyChanged += HandleSettingChange;
|
Properties.Settings.Default.PropertyChanged += HandleSettingChange;
|
||||||
|
|
||||||
AudioWatcher.MicrophoneInUseChanged += AudioWatcher_MicrophoneInUseChanged;
|
AudioWatcher.MicrophoneStatusChanged += AudioWatcher_MicrophoneStatusChanged;
|
||||||
AudioWatcher.Start();
|
AudioWatcher.Start();
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
@@ -49,7 +51,7 @@ namespace WorkIndicator
|
|||||||
UpdateLights();
|
UpdateLights();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AudioWatcher_MicrophoneInUseChanged(bool microphoneInUse)
|
private static void AudioWatcher_MicrophoneStatusChanged(MicrophoneStatus microphoneStatus)
|
||||||
{
|
{
|
||||||
UpdateLights();
|
UpdateLights();
|
||||||
}
|
}
|
||||||
@@ -89,9 +91,11 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
if (status == Status.Auto)
|
if (status == Status.Auto)
|
||||||
{
|
{
|
||||||
if (AudioWatcher.MicrophoneInUse())
|
var microphoneStatus = AudioWatcher.GetMicrophoneStatus();
|
||||||
|
|
||||||
|
if (microphoneStatus != MicrophoneStatus.NotUsed)
|
||||||
{
|
{
|
||||||
status = Status.OnPhone;
|
status = microphoneStatus == MicrophoneStatus.UsedMuted ? Status.OnPhone : Status.Talking;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -119,5 +123,10 @@ namespace WorkIndicator
|
|||||||
|
|
||||||
_stoplightIndicator.SetLights(red, yellow, green);
|
_stoplightIndicator.SetLights(red, yellow, green);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LogAudioState()
|
||||||
|
{
|
||||||
|
AudioWatcher.LogState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using H.NotifyIcon;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using WorkIndicator.Audio;
|
||||||
using WorkIndicator.Properties;
|
using WorkIndicator.Properties;
|
||||||
using WorkIndicator.SettingsWindow;
|
using WorkIndicator.SettingsWindow;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ internal static class NotificationIcon
|
|||||||
{
|
{
|
||||||
// Create the notification icon
|
// Create the notification icon
|
||||||
_notificationIcon = new TaskbarIcon { Icon = Resources.ApplicationIcon };
|
_notificationIcon = new TaskbarIcon { Icon = Resources.ApplicationIcon };
|
||||||
|
_notificationIcon.TrayMouseDoubleClick += _notificationIcon_TrayMouseDoubleClick;
|
||||||
|
|
||||||
// Set up the menu
|
// Set up the menu
|
||||||
var contextMenu = new ContextMenu();
|
var contextMenu = new ContextMenu();
|
||||||
@@ -53,6 +55,11 @@ internal static class NotificationIcon
|
|||||||
_notificationIcon.ForceCreate(false);
|
_notificationIcon.ForceCreate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void _notificationIcon_TrayMouseDoubleClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
LightController.LogAudioState();
|
||||||
|
}
|
||||||
|
|
||||||
private static void ShowSettings(object sender, RoutedEventArgs e)
|
private static void ShowSettings(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var categoryPanels = new List<CategoryPanelBase>
|
var categoryPanels = new List<CategoryPanelBase>
|
||||||
|
|||||||
+5
-1
@@ -10,8 +10,12 @@ internal static class Program
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Log.Logger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger();
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.WriteTo.File("log.txt")
|
||||||
|
.WriteTo.Debug(outputTemplate: "{Timestamp:u} [{Level}] ({SourceContext}) {Message}{NewLine}{Exception}")
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
|
Log.Logger.Information("");
|
||||||
Log.Logger.Information("Start");
|
Log.Logger.Information("Start");
|
||||||
|
|
||||||
var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger);
|
var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger);
|
||||||
|
|||||||
Generated
+1
-1
@@ -188,7 +188,7 @@ namespace WorkIndicator.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Settings.
|
/// Looks up a localized string similar to Settings....
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string NotificationIconContextMenuSettings {
|
public static string NotificationIconContextMenuSettings {
|
||||||
get {
|
get {
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ Would you like to download and install it now?</value>
|
|||||||
<value>Talking</value>
|
<value>Talking</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="NotificationIconContextMenuSettings" xml:space="preserve">
|
<data name="NotificationIconContextMenuSettings" xml:space="preserve">
|
||||||
<value>Settings</value>
|
<value>Settings...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StatusFree" xml:space="preserve">
|
<data name="StatusFree" xml:space="preserve">
|
||||||
<value>Free</value>
|
<value>Free</value>
|
||||||
|
|||||||
@@ -1 +1,11 @@
|
|||||||
# WorkIndicator
|
# WorkIndicator
|
||||||
|
|
||||||
|
Controls a [Delcom Green/Yellow/Red Indicator](https://www.delcomproducts.com/productdetails.asp?PartNumber=907241) to show work status (free, working, on phone, talking) either manually or by automatically detecting a window title.
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
* **Chris Kaczor** - *Initial work* - https://github.com/ckaczor - https://chriskaczor.com
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ internal static class UpdateCheck
|
|||||||
{
|
{
|
||||||
private static UpdateManager _updateManager;
|
private static UpdateManager _updateManager;
|
||||||
|
|
||||||
public static UpdateManager UpdateManager => _updateManager ??= new UpdateManager(new GithubSource("https://github.com/ckaczor/WorkIndicator", null, false));
|
public static UpdateManager UpdateManager => _updateManager ??= new UpdateManager(new GiteaSource("https://gitea.kaczorzoo.net/ckaczor/WorkIndicator", null, false));
|
||||||
|
|
||||||
public static string LocalVersion => (UpdateManager.CurrentVersion ?? new SemanticVersion(0, 0, 0)).ToString();
|
public static string LocalVersion => (UpdateManager.CurrentVersion ?? new SemanticVersion(0, 0, 0)).ToString();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
<StartupObject>WorkIndicator.Program</StartupObject>
|
<StartupObject>WorkIndicator.Program</StartupObject>
|
||||||
<ApplicationIcon>Resources\Application.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\Application.ico</ApplicationIcon>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<Platforms>AnyCPU;x86</Platforms>
|
<Platforms>x86</Platforms>
|
||||||
|
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
@@ -22,9 +23,11 @@
|
|||||||
<PackageReference Include="ChrisKaczor.Wpf.Validation" Version="1.0.4" />
|
<PackageReference Include="ChrisKaczor.Wpf.Validation" Version="1.0.4" />
|
||||||
<PackageReference Include="ChrisKaczor.Wpf.Windows.CategoryWindow" Version="1.0.2" />
|
<PackageReference Include="ChrisKaczor.Wpf.Windows.CategoryWindow" Version="1.0.2" />
|
||||||
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
||||||
|
<PackageReference Include="NAudio.Wasapi" Version="2.3.0" />
|
||||||
<PackageReference Include="Serilog" Version="4.0.2" />
|
<PackageReference Include="Serilog" Version="4.0.2" />
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
<PackageReference Include="Velopack" Version="0.0.626" />
|
<PackageReference Include="Velopack" Version="0.0.626" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -47,7 +50,7 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include=".github\workflows\main.yml" />
|
<None Include=".gitea\workflows\main.yml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
|||||||
+1
-3
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 18
|
# Visual Studio Version 18
|
||||||
VisualStudioVersion = 18.9.12023.133 insiders
|
VisualStudioVersion = 18.9.12023.133
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkIndicator", "WorkIndicator.csproj", "{B4A9FB98-C873-487F-AC4B-9B4356491DE3}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkIndicator", "WorkIndicator.csproj", "{B4A9FB98-C873-487F-AC4B-9B4356491DE3}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -14,11 +14,9 @@ Global
|
|||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Debug|x86.ActiveCfg = Debug|x86
|
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Debug|x86.Build.0 = Debug|x86
|
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Debug|x86.Build.0 = Debug|x86
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Release|x86.ActiveCfg = Release|x86
|
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Release|x86.ActiveCfg = Release|x86
|
||||||
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Release|x86.Build.0 = Release|x86
|
{B4A9FB98-C873-487F-AC4B-9B4356491DE3}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|||||||
Reference in New Issue
Block a user