Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated nuget packages and made it compile under VS2017. Fixed issue … #120

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions OpenHAB.Windows/Controls/ChartWidget.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Microsoft.Practices.ServiceLocation;
using GalaSoft.MvvmLight.Ioc;
using OpenHAB.Core.Common;
using OpenHAB.Core.Contracts.Services;
using Windows.UI.Xaml;
Expand All @@ -9,7 +9,7 @@
namespace OpenHAB.Windows.Controls
{
/// <summary>
/// Widget control that represents an OpenHAB slider
/// Widget control that represents an OpenHAB chart
/// </summary>
public sealed partial class ChartWidget : WidgetBase
{
Expand Down Expand Up @@ -38,7 +38,7 @@ public ChartWidget()
{
InitializeComponent();
Loaded += OnLoaded;
_settingsService = ServiceLocator.Current.GetInstance<ISettingsService>();
_settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
}

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
Expand Down
1 change: 0 additions & 1 deletion OpenHAB.Windows/Controls/ColorMap.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Numerics;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using OpenHAB.Core.Common;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Input;
Expand Down
9 changes: 3 additions & 6 deletions OpenHAB.Windows/Controls/RadialSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,10 @@ private static void OnValueChanged(DependencyObject d)
}

var middleOfScale = Radius - percentageRing.ScaleWidth / 2;
var valueText = percentageRing.GetTemplateChild(ValueTextPartName) as TextBlock;
percentageRing.ValueAngle = percentageRing.ValueToAngle(percentageRing.Value);

// Trail
var trail = percentageRing.GetTemplateChild(TrailPartName) as Path;
if (trail != null)
if (percentageRing.GetTemplateChild(TrailPartName) is Path trail)
{
if (percentageRing.ValueAngle > percentageRing.NormalizedMinAngle)
{
Expand Down Expand Up @@ -368,7 +366,7 @@ private static void OnValueChanged(DependencyObject d)
}

// Value Text
if (valueText != null)
if (percentageRing.GetTemplateChild(ValueTextPartName) is TextBlock valueText)
{
valueText.Text = percentageRing.Value.ToString(percentageRing.ValueStringFormat);
}
Expand Down Expand Up @@ -406,8 +404,7 @@ private static void OnScaleChanged(DependencyObject d)

percentageRing.UpdateNormalizedAngles();

var scale = percentageRing.GetTemplateChild(ScalePartName) as Path;
if (scale != null)
if (percentageRing.GetTemplateChild(ScalePartName) is Path scale)
{
if (percentageRing.NormalizedMaxAngle - percentageRing.NormalizedMinAngle == 360)
{
Expand Down
8 changes: 7 additions & 1 deletion OpenHAB.Windows/Converters/BoolToBackgroundColorConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@

namespace OpenHAB.Windows.Converters
{
/// <summary>
/// Background converter
/// </summary>
public class BoolToBackgroundColorConverter : IValueConverter
{

/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, string language)
{
//throw new NotImplementedException();
// throw new NotImplementedException();
return null;
}

/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
Expand Down
4 changes: 2 additions & 2 deletions OpenHAB.Windows/Converters/IconToBitmapConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Microsoft.Practices.ServiceLocation;
using GalaSoft.MvvmLight.Ioc;
using OpenHAB.Core.Common;
using OpenHAB.Core.Contracts.Services;
using OpenHAB.Core.Model;
Expand All @@ -16,7 +16,7 @@ public class IconToBitmapConverter : IValueConverter
/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, string language)
{
var settingsService = ServiceLocator.Current.GetInstance<ISettingsService>();
var settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
var settings = settingsService.Load();
var serverUrl = settings.IsRunningInDemoMode.Value ? Constants.Api.DemoModeUrl : settings.OpenHABUrl;

Expand Down
4 changes: 2 additions & 2 deletions OpenHAB.Windows/Converters/IconToPathConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Microsoft.Practices.ServiceLocation;
using GalaSoft.MvvmLight.Ioc;
using OpenHAB.Core.Common;
using OpenHAB.Core.Contracts.Services;
using OpenHAB.Core.Model;
Expand All @@ -15,7 +15,7 @@ public class IconToPathConverter : IValueConverter
/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, string language)
{
var settingsService = ServiceLocator.Current.GetInstance<ISettingsService>();
var settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
var settings = settingsService.Load();
var serverUrl = settings.IsRunningInDemoMode.Value ? Constants.Api.DemoModeUrl : settings.OpenHABUrl;

Expand Down
11 changes: 7 additions & 4 deletions OpenHAB.Windows/OpenHAB.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<SDKReference Include="Microsoft.VCLibs, Version=14.0">
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
</SDKReference>
<SDKReference Include="WindowsDesktop, Version=10.0.16299.0">
<Name>Windows Desktop Extensions for the UWP</Name>
</SDKReference>
Expand All @@ -336,16 +339,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.0.1</Version>
<Version>6.0.7</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>2.0.0</Version>
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="MvvmLightLibs">
<Version>5.3.0</Version>
<PackageReference Include="MvvmLightLibsStd10">
<Version>5.4.1</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.0.2</Version>
Expand Down
5 changes: 3 additions & 2 deletions Openhab.Core/Common/OpenHABHttpClient.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Net;
using System.Net.Http;
using Microsoft.Practices.ServiceLocation;
using GalaSoft.MvvmLight.Ioc;
using OpenHAB.Core.Contracts.Services;


namespace OpenHAB.Core.Common
{
/// <summary>
Expand Down Expand Up @@ -70,7 +71,7 @@ private static HttpClient InitClient(bool disposable = false)

private static NetworkCredential GetCredentials()
{
var settings = ServiceLocator.Current.GetInstance<ISettingsService>().Load();
var settings = SimpleIoc.Default.GetInstance<ISettingsService>().Load();
string username = settings.Username;
string password = settings.Password;

Expand Down
17 changes: 6 additions & 11 deletions Openhab.Core/Openhab.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,24 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.0.1</Version>
<Version>6.0.7</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp">
<Version>2.0.0</Version>
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Connectivity">
<Version>2.0.0</Version>
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="MvvmLightLibs">
<Version>5.3.0</Version>
<PackageReference Include="MvvmLightLibsStd10">
<Version>5.4.1</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>10.0.3</Version>
<Version>11.0.1</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.0.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="WindowsRuntime.HttpClientFilters">
<HintPath>C:\Users\nvmwy41\.nuget\packages\winrthttpclienthandler\1.0.0\lib\portable-win81+wpa81\WindowsRuntime.HttpClientFilters.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion Openhab.Core/SDK/OpenHAB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ private async Task<bool> SetValidUrl(Settings settings)

if (NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
{
if (settings.OpenHABRemoteUrl.Trim() == string.Empty) {
if (settings.OpenHABRemoteUrl.Trim() == string.Empty)
{
throw new OpenHABException("No remote url configured");
}

Expand Down
5 changes: 5 additions & 0 deletions Openhab.Core/Services/WidgetNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public static void Navigate(OpenHABWidget target)
/// <returns>The previous visted widget</returns>
public static OpenHABWidget GoBack()
{
if (WidgetBackStack.Count == 0)
{
return null;
}

WidgetBackStack.Pop();
_currentWidget = WidgetBackStack.Count == 0 ? null : WidgetBackStack.Peek();

Expand Down
8 changes: 4 additions & 4 deletions Openhab.Core/ViewModel/ViewModelLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using GalaSoft.MvvmLight.Ioc;
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Views;
using Microsoft.Practices.ServiceLocation;
using OpenHAB.Core.Contracts.Services;
using OpenHAB.Core.SDK;
using OpenHAB.Core.Services;
Expand All @@ -19,7 +18,7 @@ public class ViewModelLocator : IDisposable
/// </summary>
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
//ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default );

RegisterServices();
RegisterViewModels();
Expand All @@ -42,12 +41,13 @@ private void RegisterViewModels()
/// <summary>
/// Gets the MainViewModel for binding a View's DataContext
/// </summary>
public MainViewModel Main => ServiceLocator.Current.GetInstance<MainViewModel>();
//public MainViewModel Main => ServiceLocator.Current.GetInstance<MainViewModel>();
public MainViewModel Main => SimpleIoc.Default.GetInstance<MainViewModel>();

/// <summary>
/// Gets the SettingsViewModel for binding a View's DataContext
/// </summary>
public SettingsViewModel Settings => ServiceLocator.Current.GetInstance<SettingsViewModel>();
public SettingsViewModel Settings => SimpleIoc.Default.GetInstance<SettingsViewModel>();

/// <inheritdoc />
public void Dispose()
Expand Down