Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lightlike committed Oct 17, 2019
2 parents 72d470c + ba07aec commit c9b76d9
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 87 deletions.
6 changes: 5 additions & 1 deletion Drachenhorn.Core/Lang/LanguageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Resources;
using Drachenhorn.Xml;
using Easy.Logger.Interfaces;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;

namespace Drachenhorn.Core.Lang
Expand All @@ -13,7 +14,7 @@ public class LanguageManager : BindableBase, INotifyLanguageChanged
{
#region Properties

private readonly ResourceManager _resourceManager =
private readonly ResourceManager _resourceManager =
new ResourceManager("Drachenhorn.Core.Lang.lang", typeof(LanguageManager).Assembly);

private CultureInfo _currentCulture = CultureInfo.CurrentUICulture;
Expand Down Expand Up @@ -47,6 +48,9 @@ public CultureInfo CurrentCulture
/// <returns>Translated Text.</returns>
public string GetLanguageText(string identifier)
{
if (ViewModelBase.IsInDesignModeStatic)
return identifier;

try
{
return _resourceManager.GetString(identifier, CurrentCulture)?.Replace("\\n", "\n");
Expand Down
3 changes: 1 addition & 2 deletions Drachenhorn.Core/Settings/ISettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public interface ISettings : INotifyPropertyChanged

CultureInfo CurrentCulture { get; set; }
string Version { get; }
string GitCommit { get; }
string GitCommitLink { get; }
string NewVersion { get; }

VisualThemeType VisualTheme { get; set; }
string AccentColor { get; set; }
Expand Down
17 changes: 13 additions & 4 deletions Drachenhorn.Desktop/Converter/NullVisibilityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ public class NullVisibilityConverter : IValueConverter
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return Visibility.Collapsed;
else
return Visibility.Visible;
var onNull = Visibility.Collapsed;
var notNull = Visibility.Visible;

if (parameter != null && parameter.ToString() == "Invert")
{
onNull = Visibility.Visible;
notNull = Visibility.Collapsed;
}

if (value == null || string.IsNullOrEmpty(value.ToString()))
return onNull;

return notNull;
}

/// <inheritdoc />
Expand Down
3 changes: 0 additions & 3 deletions Drachenhorn.Desktop/Drachenhorn.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,6 @@
<Resource Include="..\img\White\Common\Yes.png">
<Link>Images\White\Common\Yes.png</Link>
</Resource>
<Content Include="commit">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Resource Include="Images\Common\Drachenhorn.ico" />
<Content Include="log4net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
2 changes: 1 addition & 1 deletion Drachenhorn.Desktop/UI/Lang/TranslateExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public TranslateExtension(string name) : base("[%" + name + "]")
try
{
if (ViewModelBase.IsInDesignModeStatic)
Source = new LanguageManager {CurrentCulture = CultureInfo.CurrentCulture};
Source = new LanguageManager();
else
Source = SimpleIoc.Default.GetInstance<LanguageManager>();
}
Expand Down
74 changes: 34 additions & 40 deletions Drachenhorn.Desktop/UserControls/Common/SettingsViewControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,51 +92,45 @@
<mah:MetroTabItem Header="{lang:Translate UI.Properties.About}"
CloseButtonEnabled="False">
<StackPanel>
<Border Margin="5" BorderThickness="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{lang:Translate About.Version}"
Grid.Row="0" Grid.Column="0" Margin="5" />
<TextBlock Text="{Binding Settings.Version}"
Grid.Row="0" Grid.Column="1" Margin="5" />

<TextBlock Text="{lang:Translate About.GitCommit}" Grid.Row="1" Grid.Column="0"
Margin="5" />
<TextBlock Margin="5" Grid.Row="1" Grid.Column="1">
<Hyperlink NavigateUri="{Binding Settings.GitCommitLink}"
RequestNavigate="Hyperlink_RequestNavigate">
<Run Text="{Binding Settings.GitCommit, FallbackValue=commit, Mode=OneWay}" />
</Hyperlink>
</TextBlock>
<Border Margin="5" BorderThickness="2" BorderBrush="{DynamicResource ControlBorderBrush}">
<StackPanel>

<DockPanel Margin="10">
<mah:ProgressRing Name="UpdateRing" IsActive="False" Height="55" Width="55"
Foreground="{DynamicResource AccentColorBrush}" DockPanel.Dock="Right"/>

<TextBlock Margin="5 3 5 0" DockPanel.Dock="Bottom" FontSize="12">
<Hyperlink NavigateUri="https://github.com/lightlike"
RequestNavigate="Hyperlink_RequestNavigate">
<Run Text="lightlike (DanielN)" />
</Hyperlink>
</TextBlock>

<StackPanel Orientation="Horizontal">
<TextBlock Text="Drachenhorn" FontSize="30" Margin="0 0 10 0" FontFamily="{StaticResource Morpheus}"/>
<TextBlock Text="v" FontSize="20" FontFamily="{StaticResource Morpheus}" VerticalAlignment="Bottom"/>
<TextBlock Text="{Binding Settings.Version}" FontSize="20" FontFamily="{StaticResource Morpheus}" VerticalAlignment="Bottom"/>
</StackPanel>
</DockPanel>

<WrapPanel Margin="20 5 10 0" Visibility="{Binding Settings.NewVersion, Converter={StaticResource NullVisibilityConverter}}">
<TextBlock Text="{lang:Translate Updater.UpdateAvailable}" FontSize="18"/>
<TextBlock Text="{Binding Settings.NewVersion}" FontSize="18"/>
</WrapPanel>

<WrapPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5">
<Button Content="{lang:Translate Updater.CheckForUpdate}" HorizontalAlignment="Left"
Click="UpdateButton_OnClick" />
<Button Content="{lang:Translate Updater.CheckForUpdate}"
Click="CheckUpdateButton_OnClick" HorizontalAlignment="Right"
Visibility="{Binding Settings.NewVersion, Converter={StaticResource NullVisibilityConverter}, ConverterParameter=Invert}"/>

<mah:ProgressRing Name="UpdateRing" IsActive="False" Height="28" Width="28" />
<WrapPanel HorizontalAlignment="Right" Margin="10 5 10 0"
Visibility="{Binding Settings.NewVersion, Converter={StaticResource NullVisibilityConverter}}">
<Button Content="{lang:Translate Updater.DoUpdate}"/>
<Button Content="{lang:Translate Updater.Changelog}"/>
</WrapPanel>

<TextBlock Text="{lang:Translate About.Publisher}" Grid.Row="3" Grid.Column="0"
Margin="5" />
<TextBlock Margin="5" Grid.Row="3" Grid.Column="1">
<Hyperlink NavigateUri="https://github.com/lightlike"
RequestNavigate="Hyperlink_RequestNavigate">
<Run Text="lightlike (DanielN)" />
</Hyperlink>
</TextBlock>
</Grid>
</StackPanel>
</Border>

<Border Margin="5" BorderThickness="2">
<Border Margin="5" BorderThickness="2" BorderBrush="{DynamicResource ControlBorderBrush}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEv
}
}

private void UpdateButton_OnClick(object sender, RoutedEventArgs e)
private void CheckUpdateButton_OnClick(object sender, RoutedEventArgs e)
{
UpdateRing.IsActive = true;

Expand Down
32 changes: 1 addition & 31 deletions Drachenhorn.Desktop/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ public class Settings : BindableBase, ISettings

public Settings()
{
var path = Path.Combine(Environment.CurrentDirectory, "commit");
if (File.Exists(path))
GitCommit = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "commit")).Replace("\r", "")
.Replace("\n", "");
else
GitCommit = "No Commit found";

PropertyChanged += (sender, args) => { Save(); };
LastOpenFiles.CollectionChanged += (sender, args) => { Save(); };
}
Expand All @@ -43,8 +36,6 @@ public Settings()

[XmlIgnore] private SheetTemplate _currentTemplate;

[XmlIgnore] private string _gitCommit;

[XmlIgnore] private bool _isNew = true;

[XmlIgnore] private VisualThemeType _visualTheme;
Expand Down Expand Up @@ -121,28 +112,7 @@ public CultureInfo CurrentCulture
public string Version => SquirrelManager.CurrentVersion;

[XmlIgnore]
public string GitCommit
{
get => _gitCommit;
private set
{
if (_gitCommit == value)
return;
_gitCommit = value;
OnPropertyChanged();
}
}

[XmlIgnore]
public string GitCommitLink
{
get
{
if (GitCommit.Contains(" "))
return null;
return @"https://github.com/lightlike/Drachenhorn/commit/" + GitCommit;
}
}
public string NewVersion => SquirrelManager.NewVersion;

[XmlElement("VisualTheme")]
public VisualThemeType VisualTheme
Expand Down
8 changes: 5 additions & 3 deletions Drachenhorn.Desktop/UserSettings/SquirrelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ private set
_newVersion = value;
}
}


private static string _currentVersion;

public static string CurrentVersion
Expand All @@ -43,18 +45,18 @@ public static string CurrentVersion
{
try
{
using (var mgr = new UpdateManager(null))
using (var mgr = new UpdateManager("C:"))
{
_currentVersion = mgr.CurrentlyInstalledVersion().ToString();
}
}
catch (Exception e)
{
_currentVersion = "X.X.X";

SimpleIoc.Default.GetInstance<ILogService>().GetLogger<Settings>()
.Debug("Unable to load Squirrel Version.", e);
}

_currentVersion = "Application not installed.";
}

return _currentVersion;
Expand Down
1 change: 0 additions & 1 deletion Drachenhorn.Desktop/commit

This file was deleted.

0 comments on commit c9b76d9

Please sign in to comment.