Skip to content

Commit

Permalink
Removed FormatBytes as we know uses the BindingConverter from Wokhan.UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
wokhan committed Oct 29, 2020
1 parent ede29ff commit 4645061
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 55 deletions.
4 changes: 1 addition & 3 deletions Common.Tests/Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Wokhan.Core" Version="0.9.2-alpha" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
Expand All @@ -55,9 +56,6 @@
<Reference Include="Interop.NetFwTypeLib">
<HintPath>..\Interop\Interop.NetFwTypeLib.dll</HintPath>
</Reference>
<Reference Include="Wokhan.Core">
<HintPath>..\TempSharedLib\Wokhan.Core.dll</HintPath>
</Reference>
</ItemGroup>
<!-- <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -->
Expand Down
8 changes: 2 additions & 6 deletions Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="Wokhan.Core" Version="0.9.2-alpha" />
<PackageReference Include="Wokhan.UI" Version="0.9.2-alpha" />
</ItemGroup>
<ItemGroup>
<Reference Include="Interop.NetFwTypeLib">
<HintPath>..\Interop\Interop.NetFwTypeLib.dll</HintPath>
</Reference>
<Reference Include="Wokhan.Core">
<HintPath>..\TempSharedLib\Wokhan.Core.dll</HintPath>
</Reference>
<Reference Include="Wokhan.UI">
<HintPath>..\TempSharedLib\Wokhan.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Shield.ico">
Expand Down
22 changes: 0 additions & 22 deletions Common/Core/Resources/ResourcesLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,5 @@ public static string GetMSResourceString(string src)
return src ?? String.Empty;

}

public static string FormatBytes(double size, string? suffix = null)
{
if (size >= 1024.0 * 1024.0 * 1024.0 * 1024.0)
{
return string.Format("{0:##.##}TiB{1}", size / (1024.0 * 1024.0 * 1024.0 * 1024.0), suffix);
}
else if (size >= 1024.0 * 1024.0 * 1024.0)
{
return string.Format("{0:##.##}GiB{1}", size / (1024.0 * 1024.0 * 1024.0), suffix);
}
else if (size >= 1024.0 * 1024.0)
{
return string.Format("{0:##.##}MiB{1}", size / (1024.0 * 1024.0), suffix);
}
else if (size >= 1024.0)
{
return string.Format("{0:##.##}KiB{1}", size / 1024.0, suffix);
}

return string.Format("{0:#0.##}B{1}", size, suffix);
}
}
}
26 changes: 22 additions & 4 deletions Console/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,47 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:BindingConverters="clr-namespace:Wokhan.UI.BindingConverters;assembly=Wokhan.UI"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:ext="clr-namespace:Wokhan.UI.Xaml.Extensibility;assembly=Wokhan.UI"
xmlns:ext="clr-namespace:Wokhan.UI.Xaml.Extensibility;assembly=Wokhan.UI"
StartupUri="UI/Windows/MainWindow.xaml" Startup="Application_Startup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Wokhan.WindowsFirewallNotifier.Common;component/UI/Theme.xaml" />
<ResourceDictionary Source="Resources/Images.xaml" />
<ResourceDictionary Source="pack://application:,,,/LiveCharts.Wpf;component/Themes/Colors/material.xaml" />
</ResourceDictionary.MergedDictionaries>
<BindingConverters:BooleanNegateConverter x:Key="booleanNegator" />
<BindingConverters:UnitFormatConverter x:Key="unitFormatter" />
<BindingConverters:ValueToVisibilityConverter x:Key="valueToVisibility" />
<BindingConverters:ValueToVisibilityNegateConverter x:Key="valueToVisibilityNegate" />
<system:Double x:Key="ConsoleSizeHeight">600</system:Double>
<system:Double x:Key="ConsoleSizeWidth">900</system:Double>
<SolidColorBrush x:Key="AccentColorBrush" Color="Coral" />
<!--<Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="Background" Value="White" />
</Style>-->
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="WhiteSmoke" />
<Setter Property="BorderThickness" Value="0,0,1,1" />
<Setter Property="BorderBrush" Value="LightGray" />
<Setter Property="Padding" Value="5" />
</Style>
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
<Setter Property="MinHeight" Value="30" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="LightBlue" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="Label" x:Key="SectionHeader">
<Setter Property="FontSize" Value="18" />
</Style>
Expand Down
20 changes: 11 additions & 9 deletions Console/Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,30 @@

<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
<Compile Remove="UI\Pages\Monitor.xaml.cs" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Backgrounds\Blue-Abstract.jpg" />
</ItemGroup>

<ItemGroup>
<Page Remove="UI\Pages\Monitor.xaml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="LiveCharts.Geared" Version="1.2.9" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="log4net" Version="2.0.8.0" />
<PackageReference Include="MaxMind.Db" Version="2.6.1" />
<PackageReference Include="MaxMind.GeoIP2" Version="3.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PackageReference Include="MaxMind.GeoIP2" Version="3.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Maps.MapControl.WPF" Version="1.0.0.3" />
<PackageReference Include="Wokhan.Core" Version="0.9.2-alpha" />
<PackageReference Include="Wokhan.UI" Version="0.9.2-alpha" />
</ItemGroup>
<ItemGroup>
<Content Include="IPDatabase\GeoLite2-City.mmdb">
Expand Down Expand Up @@ -97,13 +106,6 @@
<Reference Include="Interop.NetFwTypeLib">
<HintPath>..\Interop\Interop.NetFwTypeLib.dll</HintPath>
</Reference>
<Reference Include="Wokhan.Core">
<HintPath>..\TempSharedLib\Wokhan.Core.dll</HintPath>
</Reference>
<Reference Include="Wokhan.UI">
<HintPath>..\TempSharedLib\Wokhan.UI.dll</HintPath>
<Private></Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Resource Include="version.xml" />
Expand Down
10 changes: 2 additions & 8 deletions Console/Helpers/ViewModels/ExposedInterfaceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.ComponentModel;
using System.Linq;
using System.Net.NetworkInformation;
using Wokhan.WindowsFirewallNotifier.Common.Core.Resources;

namespace Wokhan.WindowsFirewallNotifier.Console.Helpers.ViewModels
{
Expand All @@ -18,10 +17,7 @@ public void NotifyPropertyChanged(string propertyName)
public string MAC => String.Join(":", Information.GetPhysicalAddress().GetAddressBytes().Select(b => b.ToString("X2")));

public NetworkInterface Information { get; private set; }
public string FormattedBytesSent => ResourcesLoader.FormatBytes(Statistics.BytesSent);
public string FormattedBytesReceived => ResourcesLoader.FormatBytes(Statistics.BytesReceived);



public IPInterfaceStatistics Statistics => Information.GetIPStatistics();

public IPInterfaceProperties Properties => Information.GetIPProperties();
Expand All @@ -33,7 +29,7 @@ public ExposedInterfaceView(NetworkInterface inter)

internal ExposedInterfaceView()
{

}

internal void UpdateInner(NetworkInterface inter)
Expand All @@ -43,8 +39,6 @@ internal void UpdateInner(NetworkInterface inter)
NotifyPropertyChanged(nameof(Statistics));
NotifyPropertyChanged(nameof(Properties));
NotifyPropertyChanged(nameof(MAC));
NotifyPropertyChanged(nameof(FormattedBytesSent));
NotifyPropertyChanged(nameof(FormattedBytesReceived));
}
}
}
4 changes: 1 addition & 3 deletions Notifier/Notifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="Wokhan.UI" Version="0.9.2-alpha" />
</ItemGroup>

<ItemGroup>
Expand All @@ -70,9 +71,6 @@
<Reference Include="Interop.NetFwTypeLib">
<HintPath>..\Interop\Interop.NetFwTypeLib.dll</HintPath>
</Reference>
<Reference Include="Wokhan.UI">
<HintPath>..\TempSharedLib\Wokhan.UI.dll</HintPath>
</Reference>
</ItemGroup>

<!--<PropertyGroup>
Expand Down

0 comments on commit 4645061

Please sign in to comment.