Skip to content

Commit

Permalink
Added json data file
Browse files Browse the repository at this point in the history
  • Loading branch information
Inestic committed Apr 2, 2021
1 parent b58a615 commit b3097b3
Show file tree
Hide file tree
Showing 37 changed files with 541 additions and 602 deletions.
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
8 changes: 4 additions & 4 deletions SophiApp/SophiApp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Themes/Light.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Commons/Tags.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Commons/Constants.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Controls/ScrollViewer.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Themes/Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/Commons/Tags.xaml" />
<ResourceDictionary Source="pack://application:,,,/Commons/Constants.xaml" />
<ResourceDictionary Source="pack://application:,,,/Controls/ScrollViewer.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
8 changes: 2 additions & 6 deletions SophiApp/SophiApp/Commons/Fabric.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using SophiApp.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SophiApp.Commons
{
class Fabric
internal class Fabric
{
internal static IUIElementModel CreateElementModel(JsonDTO json, UILanguage language)
{
Expand All @@ -17,4 +13,4 @@ internal static IUIElementModel CreateElementModel(JsonDTO json, UILanguage lang
return element;
}
}
}
}
53 changes: 24 additions & 29 deletions SophiApp/SophiApp/Commons/JsonDTO.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace SophiApp.Commons
{
[DataContract]
public class LocalizedHeaders
public class JsonDTO
{
[DataMember(Name = "RU")]
public string RU { get; set; }
[DataMember(Name = "Id")]
public int Id { get; set; }

[DataMember(Name = "EN")]
public string EN { get; set; }
[DataMember(Name = "LocalizedDescriptions")]
public LocalizedDescriptions LocalizedDescriptions { get; set; }

[DataMember(Name = "LocalizedHeaders")]
public LocalizedHeaders LocalizedHeaders { get; set; }

[DataMember(Name = "Tag")]
public string Tag { get; set; }

[DataMember(Name = "Type")]
public string Type { get; set; }
}

[DataContract]
public class LocalizedDescriptions
{
[DataMember(Name = "RU")]
public string RU { get; set; }

[DataMember(Name = "EN")]
public string EN { get; set; }

[DataMember(Name = "RU")]
public string RU { get; set; }
}

[DataContract]
public class JsonDTO
public class LocalizedHeaders
{
[DataMember(Name = "Id")]
public int Id { get; set; }

[DataMember(Name = "LocalizedHeaders")]
public LocalizedHeaders LocalizedHeaders { get; set; }

[DataMember(Name = "LocalizedDescriptions")]
public LocalizedDescriptions LocalizedDescriptions { get; set; }

[DataMember(Name = "Type")]
public string Type { get; set; }
[DataMember(Name = "EN")]
public string EN { get; set; }

[DataMember(Name = "Tag")]
public string Tag { get; set; }
[DataMember(Name = "RU")]
public string RU { get; set; }
}
}
}
33 changes: 15 additions & 18 deletions SophiApp/SophiApp/Commons/Localizator.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace SophiApp.Commons
{
class Localizator
internal class Localizator
{
private static UILanguage GetName(string localizationName) => Enum.GetNames(typeof(UILanguage)).Contains(localizationName) ? (UILanguage)Enum.Parse(typeof(UILanguage), localizationName) : UILanguage.EN;

private static Uri GetUris(UILanguage localization)
{
var languagesUris = new Dictionary<UILanguage, Uri>()
{
{ UILanguage.EN, new Uri("pack://application:,,,/Localizations/EN.xaml", UriKind.Absolute) },
{ UILanguage.RU, new Uri("pack://application:,,,/Localizations/RU.xaml", UriKind.Absolute) }
};

return languagesUris[localization];
}

internal static Dictionary<UILanguage, string> GetLocalizedDescriptions(JsonDTO json)
{
return new Dictionary<UILanguage, string>
Expand All @@ -36,19 +47,5 @@ internal static UILanguage Initializing()
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = uri });
return localization;
}

private static Uri GetUris(UILanguage localization)
{
var languagesUris = new Dictionary<UILanguage, Uri>()
{
{ UILanguage.EN, new Uri("pack://application:,,,/Localizations/EN.xaml", UriKind.Absolute) },
{ UILanguage.RU, new Uri("pack://application:,,,/Localizations/RU.xaml", UriKind.Absolute) }
};

return languagesUris[localization];
}

private static UILanguage GetName(string localizationName) => Enum.GetNames(typeof(UILanguage)).Contains(localizationName) ? (UILanguage)Enum.Parse(typeof(UILanguage), localizationName) : UILanguage.EN;

}
}
}
8 changes: 3 additions & 5 deletions SophiApp/SophiApp/Commons/Parser.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace SophiApp.Commons
{
class Parser
internal class Parser
{
internal static IEnumerable<JsonDTO> ParseJson(byte[] jsonData)
{
Expand All @@ -30,4 +28,4 @@ internal static IEnumerable<JsonDTO> ParseJson(byte[] jsonData)
});
}
}
}
}
5 changes: 0 additions & 5 deletions SophiApp/SophiApp/Commons/RelayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public void Execute(object parameter)
execute(parameter);
}

public void Execute(int parameter)
{
execute(parameter);
}

public void RaiseCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
Expand Down
12 changes: 3 additions & 9 deletions SophiApp/SophiApp/Commons/UILanguage.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SophiApp.Commons
namespace SophiApp.Commons
{
enum UILanguage
internal enum UILanguage
{
EN,
RU
}
}
}
58 changes: 29 additions & 29 deletions SophiApp/SophiApp/Controls/Button.xaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
<UserControl x:Class="SophiApp.Controls.Button"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SophiApp.Controls"
mc:Ignorable="d">

<UserControl.Resources>
<Style TargetType="{x:Type Grid}">
<Setter Property="Width" Value="{Binding Path=Width, RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Height" Value="{Binding Path=Height, RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Width" Value="{Binding Path=Width, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter Property="Height" Value="{Binding Path=Height, RelativeSource={RelativeSource TemplatedParent}}" />
</Style>
<Style TargetType="{x:Type Border}">
<Setter Property="Width" Value="{Binding Path=Width, RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Height" Value="32"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="2"/>
<Setter Property="Width" Value="{Binding Path=Width, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter Property="Height" Value="32" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="2" />
</Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Text" Value="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Text" Value="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}}" />
</Style>
<Style TargetType="{x:Type local:Button}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
<Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
<Setter Property="Width" Value="146"/>
<Setter Property="Height" Value="52"/>
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
<Setter Property="TextOptions.TextFormattingMode" Value="Display" />
<Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
<Setter Property="Width" Value="146" />
<Setter Property="Height" Value="52" />
</Style>
</UserControl.Resources>
<UserControl.Template>
<ControlTemplate>
<Grid>
<Border x:Name="BorderButton" MouseLeftButtonDown="Button_MouseLeftButtonDown">
<TextBlock/>
<TextBlock />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter TargetName="BorderButton" Property="Background" Value="{DynamicResource Brush.Window.Background}"/>
<Setter TargetName="BorderButton" Property="BorderBrush" Value="{DynamicResource Brush.Window.Element.Border.Light1}"/>
<Setter TargetName="BorderButton" Property="Background" Value="{DynamicResource Brush.Window.Background}" />
<Setter TargetName="BorderButton" Property="BorderBrush" Value="{DynamicResource Brush.Window.Element.Border.Light1}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="BorderButton" Property="Background" Value="{DynamicResource Brush.Window.Acсent.Light1}"/>
<Setter TargetName="BorderButton" Property="Background" Value="{DynamicResource Brush.Window.Acсent.Light1}" />
</Trigger>
<EventTrigger SourceName="BorderButton" RoutedEvent="MouseLeftButtonDown">
<BeginStoryboard>
Expand All @@ -58,14 +58,14 @@
From="0, 0, 0, 0"
To="0, 10, 0, 0"
SpeedRatio="3"
AutoReverse="True"/>
AutoReverse="True" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=BorderButton}" Value="True">
<Setter TargetName="BorderButton" Property="Background" Value="{DynamicResource Brush.Window.Element.Hover}"/>
<Setter TargetName="BorderButton" Property="Background" Value="{DynamicResource Brush.Window.Element.Hover}" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</UserControl.Template>
</UserControl>
</UserControl>
Loading

0 comments on commit b3097b3

Please sign in to comment.