Skip to content

Commit

Permalink
Cleaned up new settings style and features.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcadeRenegade committed Feb 6, 2016
1 parent 0bd17fb commit ef17a39
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 60 deletions.
22 changes: 0 additions & 22 deletions SidebarDiagnostics/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -368,28 +368,6 @@
<Setter Property="Margin" Value="10" />
</Style>

<Style x:Key="MonitorParamBool" TargetType="{x:Type CheckBox}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,5" />
</Style>

<Style x:Key="MonitorParamInt" TargetType="{x:Type StackPanel}">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="Margin" Value="0,5" />
<Style.Resources>
<Style TargetType="{x:Type Label}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,10,0" />
<Setter Property="Padding" Value="0" />
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="40" />
<Setter Property="MaxLines" Value="1" />
</Style>
</Style.Resources>
</Style>

<Style x:Key="HotkeyToggle" TargetType="{x:Type ToggleButton}">
<Setter Property="Content" Value="Bind" />
<Setter Property="Height" Value="22" />
Expand Down
46 changes: 40 additions & 6 deletions SidebarDiagnostics/AppBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,48 @@
<DataTrigger Binding="{Binding ShowDetails, Mode=OneWay}" Value="True">
<Setter Property="Content">
<Setter.Value>
<StackPanel Orientation="Vertical">
<StackPanel Style="{StaticResource VerticalPanel}">
<TextBlock Text="{Binding Path=Label, Mode=OneWay}" Style="{StaticResource SensorText}" />
<ProgressBar Value="{Binding Path=Value, Mode=OneWay}" Margin="0,4" Width="{Binding Source={x:Static prop:Settings.Default}, Path=FontSetting.BarWidthWide, Mode=OneWay}" Style="{StaticResource DriveProgress}" />
<TextBlock Text="{Binding Path=Load, Mode=OneWay}" Style="{StaticResource SensorText}" />
<TextBlock Text="{Binding Path=UsedGB, Mode=OneWay}" Style="{StaticResource DataText}" />
<TextBlock Text="{Binding Path=FreeGB, Mode=OneWay}" Style="{StaticResource DataText}" />
<TextBlock Text="{Binding Path=ReadRate, Mode=OneWay}" Style="{StaticResource DataText}" />
<TextBlock Text="{Binding Path=WriteRate, Mode=OneWay}" Style="{StaticResource DataText}" />

<ContentControl>
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DriveSpace, Mode=OneWay}" Value="True">
<Setter Property="Content">
<Setter.Value>
<StackPanel Style="{StaticResource VerticalPanel}">
<TextBlock Text="{Binding Path=Load, Mode=OneWay}" Style="{StaticResource SensorText}" />
<TextBlock Text="{Binding Path=UsedGB, Mode=OneWay}" Style="{StaticResource DataText}" />
<TextBlock Text="{Binding Path=FreeGB, Mode=OneWay}" Style="{StaticResource DataText}" />
</StackPanel>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>

<ContentControl>
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DriveIO, Mode=OneWay}" Value="True">
<Setter Property="Content">
<Setter.Value>
<StackPanel Style="{StaticResource VerticalPanel}">
<TextBlock Text="{Binding Path=ReadRate, Mode=OneWay}" Style="{StaticResource DataText}" />
<TextBlock Text="{Binding Path=WriteRate, Mode=OneWay}" Style="{StaticResource DataText}" />
</StackPanel>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</StackPanel>
</Setter.Value>
</Setter>
Expand Down
2 changes: 2 additions & 0 deletions SidebarDiagnostics/AppBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public void Reload()
return;
}

Ready = false;

App._reloading = true;

Close();
Expand Down
78 changes: 62 additions & 16 deletions SidebarDiagnostics/Monitoring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,12 @@ public class DriveMonitor : iMonitor
public DriveMonitor(string[] disabledHardware, ConfigParam[] parameters)
{
bool _showDetails = parameters.GetValue<bool>(ParamKey.DriveDetails);
bool _driveSpace = parameters.GetValue<bool>(ParamKey.DriveSpace);
bool _driveIO = parameters.GetValue<bool>(ParamKey.DriveIO);
bool _roundAll = parameters.GetValue<bool>(ParamKey.RoundAll);
int _usedSpaceAlert = parameters.GetValue<int>(ParamKey.UsedSpaceAlert);

Drives = GetHardware().Where(h => !disabledHardware.Contains(h.ID)).Select(d => new DriveInfo(d.ID, d.Name, _showDetails, _roundAll, _usedSpaceAlert)).ToArray();
Drives = GetHardware().Where(h => !disabledHardware.Contains(h.ID)).Select(d => new DriveInfo(d.ID, d.Name, _showDetails, _driveSpace, _driveIO, _roundAll, _usedSpaceAlert)).ToArray();
}

public void Dispose()
Expand Down Expand Up @@ -901,18 +903,20 @@ public class DriveInfo : IDisposable, INotifyPropertyChanged
private const string BYTESREADPERSECOND = "Disk Read Bytes/sec";
private const string BYTESWRITEPERSECOND = "Disk Write Bytes/sec";

public DriveInfo(string instance, string name, bool showDetails = false, bool roundAll = false, double usedSpaceAlert = 0)
public DriveInfo(string instance, string name, bool showDetails = false, bool driveSpace = true, bool driveIO = true, bool roundAll = false, double usedSpaceAlert = 0)
{
Instance = instance;
Label = name;
ShowDetails = showDetails;
DriveSpace = driveSpace;
DriveIO = driveIO;
RoundAll = roundAll;
UsedSpaceAlert = usedSpaceAlert;

_counterFreeMB = new PerformanceCounter(DriveMonitor.CATEGORYNAME, FREEMB, name);
_counterFreePercent = new PerformanceCounter(DriveMonitor.CATEGORYNAME, PERCENTFREE, name);

if (showDetails)
if (showDetails && driveIO)
{
_counterReadRate = new PerformanceCounter(DriveMonitor.CATEGORYNAME, BYTESREADPERSECOND, name);
_counterWriteRate = new PerformanceCounter(DriveMonitor.CATEGORYNAME, BYTESWRITEPERSECOND, name);
Expand Down Expand Up @@ -984,23 +988,29 @@ public void Update()

if (ShowDetails)
{
Load = string.Format("Load: {0:#,##0.##}%", _usedPercent.Round(RoundAll));
UsedGB = string.Format("Used: {0:#,##0.##} GB", _usedGB.Round(RoundAll));
FreeGB = string.Format("Free: {0:#,##0.##} GB", _freeGB.Round(RoundAll));
if (DriveSpace)
{
Load = string.Format("Load: {0:#,##0.##}%", _usedPercent.Round(RoundAll));
UsedGB = string.Format("Used: {0:#,##0.##} GB", _usedGB.Round(RoundAll));
FreeGB = string.Format("Free: {0:#,##0.##} GB", _freeGB.Round(RoundAll));
}

double _readRate = _counterReadRate.NextValue() / 1024d;
if (DriveIO)
{
double _readRate = _counterReadRate.NextValue() / 1024d;

string _readFormat;
Data.MinifyKiloBytesPerSecond(ref _readRate, out _readFormat);
string _readFormat;
Data.MinifyKiloBytesPerSecond(ref _readRate, out _readFormat);

ReadRate = string.Format("Read: {0:#,##0.##} {1}", _readRate.Round(RoundAll), _readFormat);
ReadRate = string.Format("Read: {0:#,##0.##} {1}", _readRate.Round(RoundAll), _readFormat);

double _writeRate = _counterWriteRate.NextValue() / 1024d;
double _writeRate = _counterWriteRate.NextValue() / 1024d;

string _writeFormat;
Data.MinifyKiloBytesPerSecond(ref _writeRate, out _writeFormat);
string _writeFormat;
Data.MinifyKiloBytesPerSecond(ref _writeRate, out _writeFormat);

WriteRate = string.Format("Write: {0:#,##0.##} {1}", _writeRate.Round(RoundAll), _writeFormat);
WriteRate = string.Format("Write: {0:#,##0.##} {1}", _writeRate.Round(RoundAll), _writeFormat);
}
}

if (UsedSpaceAlert > 0 && UsedSpaceAlert <= _usedPercent)
Expand Down Expand Up @@ -1146,6 +1156,10 @@ public bool IsAlert

public bool ShowDetails { get; private set; }

public bool DriveSpace { get; private set; }

public bool DriveIO { get; private set; }

public bool RoundAll { get; private set; }

public double UsedSpaceAlert { get; private set; }
Expand Down Expand Up @@ -1615,9 +1629,11 @@ public static MonitorConfig[] Default
Enabled = true,
Order = 4,
Hardware = new HardwareConfig[0],
Params = new ConfigParam[3]
Params = new ConfigParam[5]
{
ConfigParam.Defaults.DriveDetails,
ConfigParam.Defaults.ShowDriveSpace,
ConfigParam.Defaults.ShowDriveIO,
ConfigParam.Defaults.RoundAll,
ConfigParam.Defaults.UsedSpaceAlert
}
Expand Down Expand Up @@ -1714,6 +1730,12 @@ public string Name
case ParamKey.RoundAll:
return "Round All Decimals";

case ParamKey.DriveSpace:
return "Show Drive Space";

case ParamKey.DriveIO:
return "Show Drive IO";

default:
return "Unknown";
}
Expand Down Expand Up @@ -1759,6 +1781,12 @@ public string Tooltip
case ParamKey.RoundAll:
return "Round all decimal values to the nearest integer.";

case ParamKey.DriveSpace:
return "Shows load percent, used space, and free space if drive details is enabled.";

case ParamKey.DriveIO:
return "Shows drive read and write speeds if drive details is enabled.";

default:
return "Unknown";
}
Expand Down Expand Up @@ -1862,6 +1890,22 @@ public static ConfigParam RoundAll
return new ConfigParam() { Key = ParamKey.RoundAll, Value = false };
}
}

public static ConfigParam ShowDriveSpace
{
get
{
return new ConfigParam() { Key = ParamKey.DriveSpace, Value = true };
}
}

public static ConfigParam ShowDriveIO
{
get
{
return new ConfigParam() { Key = ParamKey.DriveIO, Value = true };
}
}
}
}

Expand All @@ -1878,7 +1922,9 @@ public enum ParamKey : byte
BandwidthInAlert,
BandwidthOutAlert,
UseBytes,
RoundAll
RoundAll,
DriveSpace,
DriveIO
}

public enum DataType : byte
Expand Down
4 changes: 2 additions & 2 deletions SidebarDiagnostics/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.2.0")]
[assembly: AssemblyFileVersion("2.4.2.0")]
[assembly: AssemblyVersion("2.4.3.0")]
[assembly: AssemblyFileVersion("2.4.3.0")]
Loading

0 comments on commit ef17a39

Please sign in to comment.