mirror of
https://github.com/ckaczor/WorkIndicator.git
synced 2026-01-13 17:23:18 -05:00
Add setting for default status
This commit is contained in:
@@ -27,12 +27,20 @@ namespace WorkIndicator
|
||||
_stoplightIndicator = new StoplightIndicator();
|
||||
_stoplightIndicator.SetLight(StoplightIndicator.Light.Yellow, StoplightIndicator.LightState.On);
|
||||
|
||||
Properties.Settings.Default.PropertyChanged += HandleSettingChange;
|
||||
|
||||
AudioWatcher.MicrophoneInUseChanged += AudioWatcher_MicrophoneInUseChanged;
|
||||
AudioWatcher.Start();
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
private static void HandleSettingChange(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(Properties.Settings.Default.DefaultStatus))
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
private static void DevicesChanged()
|
||||
{
|
||||
_stoplightIndicator?.Dispose();
|
||||
@@ -77,20 +85,21 @@ namespace WorkIndicator
|
||||
var yellow = StoplightIndicator.LightState.Off;
|
||||
var green = StoplightIndicator.LightState.Off;
|
||||
|
||||
if (_status == Status.Auto)
|
||||
var status = _status;
|
||||
|
||||
if (status == Status.Auto)
|
||||
{
|
||||
if (AudioWatcher.MicrophoneInUse())
|
||||
{
|
||||
red = StoplightIndicator.LightState.On;
|
||||
status = Status.OnPhone;
|
||||
}
|
||||
else
|
||||
{
|
||||
yellow = StoplightIndicator.LightState.On;
|
||||
status = (Status) Enum.Parse(typeof(Status), Properties.Settings.Default.DefaultStatus);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_status)
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case Status.Free:
|
||||
green = StoplightIndicator.LightState.On;
|
||||
@@ -107,7 +116,6 @@ namespace WorkIndicator
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
_stoplightIndicator.SetLights(red, yellow, green);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,14 @@
|
||||
xmlns:properties="clr-namespace:WorkIndicator.Properties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
d:DesignWidth="300"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
@@ -18,5 +24,19 @@
|
||||
VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Center"
|
||||
Grid.ColumnSpan="2" />
|
||||
<Label Content="{x:Static properties:Resources.DefaultStatus}"
|
||||
Name="ApplicationNameLabel"
|
||||
VerticalAlignment="Center"
|
||||
Padding="0,0,6,0"
|
||||
Grid.Row="1"
|
||||
Margin="0,20,0,0" />
|
||||
<ComboBox Name="DefaultStatus"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="0,20,0,0"
|
||||
ItemsSource="{Binding Path=DefaultStatusList}"
|
||||
DisplayMemberPath="Text"
|
||||
SelectedValuePath="Value">
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</windows:CategoryPanel>
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
using Common.Wpf.Extensions;
|
||||
using System;
|
||||
using Common.Wpf.Extensions;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
|
||||
namespace WorkIndicator.Options
|
||||
{
|
||||
public partial class GeneralOptionsPanel
|
||||
{
|
||||
public class StatusItem
|
||||
{
|
||||
public Status Value { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public StatusItem(Status value, string text)
|
||||
{
|
||||
Value = value;
|
||||
Text = text;
|
||||
}
|
||||
}
|
||||
|
||||
public GeneralOptionsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -17,6 +31,8 @@ namespace WorkIndicator.Options
|
||||
var settings = Properties.Settings.Default;
|
||||
|
||||
StartWithWindows.IsChecked = settings.StartWithWindows;
|
||||
|
||||
DefaultStatus.SelectedValue = Enum.Parse(typeof(Status), settings.DefaultStatus);
|
||||
}
|
||||
|
||||
public override bool ValidatePanel()
|
||||
@@ -32,8 +48,18 @@ namespace WorkIndicator.Options
|
||||
settings.StartWithWindows = StartWithWindows.IsChecked.Value;
|
||||
|
||||
Application.Current.SetStartWithWindows(settings.StartWithWindows);
|
||||
|
||||
settings.DefaultStatus = DefaultStatus.SelectedValue.ToString();
|
||||
}
|
||||
|
||||
public override string CategoryName => Properties.Resources.OptionCategory_General;
|
||||
|
||||
public ObservableCollection<StatusItem> DefaultStatusList => new ObservableCollection<StatusItem>
|
||||
{
|
||||
new StatusItem(Status.Free, Properties.Resources.Free),
|
||||
new StatusItem(Status.Working, Properties.Resources.Working),
|
||||
new StatusItem(Status.OnPhone, Properties.Resources.OnPhone),
|
||||
new StatusItem(Status.Talking, Properties.Resources.Talking)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
9
Properties/Resources.Designer.cs
generated
9
Properties/Resources.Designer.cs
generated
@@ -169,6 +169,15 @@ namespace WorkIndicator.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Default status:.
|
||||
/// </summary>
|
||||
public static string DefaultStatus {
|
||||
get {
|
||||
return ResourceManager.GetString("DefaultStatus", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Delete.
|
||||
/// </summary>
|
||||
|
||||
@@ -244,4 +244,7 @@
|
||||
<data name="CheckUpdate" xml:space="preserve">
|
||||
<value>_Check for Update</value>
|
||||
</data>
|
||||
<data name="DefaultStatus" xml:space="preserve">
|
||||
<value>_Default status:</value>
|
||||
</data>
|
||||
</root>
|
||||
14
Properties/Settings.Designer.cs
generated
14
Properties/Settings.Designer.cs
generated
@@ -12,7 +12,7 @@ namespace WorkIndicator.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -64,5 +64,17 @@ namespace WorkIndicator.Properties {
|
||||
this["WindowPatterns"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Free")]
|
||||
public string DefaultStatus {
|
||||
get {
|
||||
return ((string)(this["DefaultStatus"]));
|
||||
}
|
||||
set {
|
||||
this["DefaultStatus"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,8 @@
|
||||
<Setting Name="WindowPatterns" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="DefaultStatus" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Free</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -16,6 +16,9 @@
|
||||
<setting name="WindowPatterns" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="DefaultStatus" serializeAs="String">
|
||||
<value>Free</value>
|
||||
</setting>
|
||||
</WorkIndicator.Properties.Settings>
|
||||
</userSettings>
|
||||
<applicationSettings>
|
||||
|
||||
Reference in New Issue
Block a user