Skip to content

Commit

Permalink
Adding Demo code, SDK executables and a README
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-krivdin committed Aug 17, 2023
1 parent bd1e746 commit 8e4749e
Show file tree
Hide file tree
Showing 146 changed files with 66,736 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# BlueParrott-Updater-SDK
# GNA Updater SDK Demo

GNA Updater SDK Demo (Demo) is a sample application showcasing the GNA Updater SDK (SDK) functionality.
It consists of Demo code located at "gna-updater-sdk-demo" folder and SDK files located at "gna-updater-sdk-..." folder.

## Build and Use

Build and usage instructions for Demo application as well as SDK documentation can be found at "gna-updater-sdk-demo\Documentation" folder.

## Credits

- [Newtonsoft.Json](https://www.newtonsoft.com/json) is used for JSON serialization/deserialization
- [NLog](https://github.com/NLog/NLog) is used for logging
- [GalaSoft MvvmLight](https://github.com/lbugnion/mvvmlight) is used for MVVM pattern implementation
- [CommonServiceLocator](https://github.com/unitycontainer/commonservicelocator) is used for IoC pattern implementation
29 changes: 29 additions & 0 deletions gna-updater-sdk-demo/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="GNAUpdaterSDK_Demo.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.6.0" newVersion="2.0.6.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<applicationSettings>
<GNAUpdaterSDK_Demo.Properties.Settings>
<setting name="SDKLoggingLevel" serializeAs="String">
<value>3</value>
</setting>
<setting name="DemoLoggingLevel" serializeAs="String">
<value>3</value>
</setting>
</GNAUpdaterSDK_Demo.Properties.Settings>
</applicationSettings>
</configuration>
30 changes: 30 additions & 0 deletions gna-updater-sdk-demo/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Application x:Class="GNAUpdaterSDK_Demo.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:GNAUpdaterSDK_Demo" StartupUri="Views/MainWindow.xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:view="clr-namespace:GNAUpdaterSDK_Demo.Views" xmlns:vm="clr-namespace:GNAUpdaterSDK_Demo.ViewModels" xmlns:helpers="clr-namespace:GNAUpdaterSDK_Demo.Helpers" xmlns:converters="clr-namespace:GNAUpdaterSDK_Demo.Converters" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Application.Resources>
<ResourceDictionary>
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
<DataTemplate DataType="{x:Type vm:DefaultDeviceInformationViewModel}">
<view:DefaultDeviceInformationView />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:ConnectedDevicesControlViewModel}">
<view:ConnectedDevicesControlView />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:InfoWindowViewModel}">
<view:InfoWindowView />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:OtherFunctionsWindowViewModel}">
<view:OtherFunctionsWindowView />
</DataTemplate>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converters:EmptyStringConverter x:Key="EmptyStringConverter" />
<converters:CountToVisibilityInverterConverter x:Key="CountToVisibilityInverterConverter" />
<converters:CommandResultsToStringConverter x:Key="CommandResultsToStringConverter" />
<converters:InvertableBooleanToVisibilityConverter x:Key="InvertableBooleanToVisibilityConverter" />
<converters:FullPathToShortConverter x:Key="FullPathToShortConverter" />
<helpers:ColorHelper x:Key="ColorHelper" />
<helpers:GeneralHelper x:Key="GeneralHelper" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
15 changes: 15 additions & 0 deletions gna-updater-sdk-demo/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Windows;

namespace GNAUpdaterSDK_Demo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
//TODO: Update version numbers before release
//Revision format is YYMMDD
internal static readonly Version DemoVersion = new Version(1, 1, 3, 230526);
}
}
30 changes: 30 additions & 0 deletions gna-updater-sdk-demo/Commands/CommandHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Windows.Input;

namespace GNAUpdaterSDK_Demo.Commands
{
public class CommandHandler : ICommand
{
private Action _action;
private bool _canExecute;
public CommandHandler(Action action, bool canExecute)
{
_action = action;
_canExecute = canExecute;
}

public bool CanExecute(object parameter)
{
return _canExecute;
}


#pragma warning disable CS0067
public event EventHandler CanExecuteChanged;

public void Execute(object parameter)
{
_action();
}
}
}
27 changes: 27 additions & 0 deletions gna-updater-sdk-demo/Converters/BooleanToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace GNAUpdaterSDK_Demo.Converters
{
public class BooleanToVisibilityConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var val = System.Convert.ToBoolean(value);
return val ? Visibility.Visible : Visibility.Hidden;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value?.Equals(Visibility.Visible) ?? false;
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
44 changes: 44 additions & 0 deletions gna-updater-sdk-demo/Converters/CommandResultsToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using GNAUpdaterSDK_Demo.Models;
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace GNAUpdaterSDK_Demo.Converters
{
public class CommandResultsToStringConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CommandResults val)
{
return getCommandResultsString(val);
}
else
{
return value.ToString();
}
}

public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}

public static string getCommandResultsString(CommandResults val)
{
if (val == CommandResults.NA)
{
return "N/A";
}

return val.ToString();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace GNAUpdaterSDK_Demo.Converters
{
public class CountToVisibilityInverterConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
if (value is int val)
{
return val > 0 ? Visibility.Collapsed : Visibility.Visible;
}
else
{
return Visibility.Collapsed;
}
}

public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
38 changes: 38 additions & 0 deletions gna-updater-sdk-demo/Converters/EmptyStringConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace GNAUpdaterSDK_Demo.Converters
{
public class EmptyStringConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
string result;

if (value is int)
{
result = value.ToString();
}
else
{
result = value as string;
}

return string.IsNullOrEmpty(result) ? parameter : result;
}

public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
35 changes: 35 additions & 0 deletions gna-updater-sdk-demo/Converters/FullPathToShortConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;
using System.Windows.Markup;

namespace GNAUpdaterSDK_Demo.Converters
{
public class FullPathToShortConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string val)
{
return Path.GetFileName(val);
}
else
{
return value.ToString();
}
}

public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace GNAUpdaterSDK_Demo.Converters
{
[ValueConversion(typeof(bool), typeof(Visibility))]
public class InvertableBooleanToVisibilityConverter : MarkupExtension, IValueConverter
{
public InvertableBooleanToVisibilityConverter()
{
TrueValue = Visibility.Collapsed;
FalseValue = Visibility.Visible;
}

public Visibility TrueValue { get; set; }
public Visibility FalseValue { get; set; }

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool val = System.Convert.ToBoolean(value);
return val ? TrueValue : FalseValue;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return TrueValue.Equals(value) ? true : false;
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 8e4749e

Please sign in to comment.