Skip to content

Commit

Permalink
Merge pull request #127 from lacmus-foundation/dev
Browse files Browse the repository at this point in the history
0.5.0-preview2
  • Loading branch information
gosha20777 authored Aug 10, 2021
2 parents 3ebd067 + 4e9f964 commit 8cb75a9
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 78 deletions.
2 changes: 1 addition & 1 deletion mk-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dotnet publish --framework net5.0 --runtime="linux-x64" -c Release -o ./bin/app/
echo -n "building for win10"
dotnet publish --framework net5.0 --runtime="win10-x64" -c Release -o ./bin/app/win10
echo -n "building for osx"
dotnet publish --framework net5.9 --runtime="osx-x64" -c Release -o ./bin/app/osx
dotnet publish --framework net5.0 --runtime="osx-x64" -c Release -o ./bin/app/osx
cd ./bin/app/
zip -r -9 ./linux.zip ./linux/
zip -r -9 ./win10.zip ./win10/
Expand Down
10 changes: 1 addition & 9 deletions src/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="LacmusApp.App">
<Application.Styles>
<!--
<StyleInclude Source="avares://Material.Avalonia/Material.Avalonia.DeepPurple.xaml" />
<StyleInclude Source="avares://Material.Avalonia/Material.Avalonia.Templates.xaml" />
-->
<StyleInclude Source="avares://Citrus.Avalonia/Citrus.xaml"/>
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Default.xaml"/>
<!--
<StyleInclude Source="resm:Avalonia.Themes.Default.DefaultTheme.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"/>
-->
<StyleInclude Source="avares://Citrus.Avalonia/Citrus.xaml"/>
</Application.Styles>
<NativeMenu.Menu>
<NativeMenu>
Expand Down
39 changes: 18 additions & 21 deletions src/LacmusApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,25 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.9.12" />
<PackageReference Include="Avalonia.Angle.Natives" Version="2.0.0" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.9.12" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="2.3.2" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.12" />
<PackageReference Include="Avalonia.Native" Version="0.9.12" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.12" />
<PackageReference Include="Avalonia.Skia.Linux.Natives" Version="1.68.0.2" />
<PackageReference Include="Citrus.Avalonia" Version="1.2.6" />
<PackageReference Include="Avalonia" Version="0.10.6" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.6" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="3.6.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.6" />
<PackageReference Include="Avalonia.Native" Version="0.10.6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.6" />
<PackageReference Include="Citrus.Avalonia" Version="1.5.1" />
<PackageReference Include="Flurl" Version="3.0.2" />
<PackageReference Include="LacmusPlugin" Version="2.0.2" />
<PackageReference Include="Material.Avalonia" Version="0.9.0" />
<PackageReference Include="MessageBox.Avalonia" Version="0.9.6.1" />
<PackageReference Include="MetadataExtractor" Version="2.4.3" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="3.1.6" />
<PackageReference Include="NewtonSoft.Json" Version="12.0.3" />
<PackageReference Include="Octokit" Version="0.48.0" />
<PackageReference Include="ReactiveUI.Fody" Version="11.5.6" />
<PackageReference Include="ReactiveUI.Validation" Version="1.5.5" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.7.0" />
<PackageReference Include="MessageBox.Avalonia" Version="1.5.1" />
<PackageReference Include="MetadataExtractor" Version="2.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="5.0.8" />
<PackageReference Include="NewtonSoft.Json" Version="13.0.1" />
<PackageReference Include="Octokit" Version="0.50.0" />
<PackageReference Include="ReactiveUI.Fody" Version="14.2.1" />
<PackageReference Include="ReactiveUI.Validation" Version="2.1.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="5.0.1" />
</ItemGroup>
</Project>
8 changes: 5 additions & 3 deletions src/Models/Zoomer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ public class Zoomer
public static void Init(ZoomBorder zoomBorder)
{
_zoomBorder = zoomBorder;
_zoomBorder.PanButton = ButtonName.Left;
_zoomBorder.EnablePan = true;
}

public static void Zoom(double scale)
{
_zoomBorder?.ZoomTo(scale, 0, 0);
_zoomBorder?.ZoomTo(scale, 0, 0, false);
}

public static void MoveTo(double x, double y)
{
/* Thanks to @wieslawsoltes https://github.com/wieslawsoltes/PanAndZoom/issues/27 */
_zoomBorder?.StartPan(0,0);
_zoomBorder?.PanTo(x,y);
_zoomBorder?.Pan(0,0, false);
_zoomBorder?.PanDelta(x,y, false);
}

public static double GetZoomX()
Expand Down
2 changes: 1 addition & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.IO;
using Avalonia;
using Avalonia.Logging.Serilog;
using Avalonia.ReactiveUI;
using Serilog;

Expand Down Expand Up @@ -61,6 +60,7 @@ private static AppBuilder BuildAvaloniaApp()
return AppBuilder.Configure<App>()
.UsePlatformDetect()
.With(new Win32PlatformOptions {EnableMultitouch = true, AllowEglInitialization = true})
.With(new SkiaOptions{ MaxGpuResourceSizeBytes = 1024 * 1024 * 80})
.UseReactiveUI()
.LogToDebug();
}
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/FirstWizardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace LacmusApp.ViewModels
{
public class FirstWizardViewModel : ReactiveValidationObject<FirstWizardViewModel>, IRoutableViewModel
public class FirstWizardViewModel : ReactiveValidationObject, IRoutableViewModel
{
public IScreen HostScreen { get; }
public string UrlPathSegment { get; } = Guid.NewGuid().ToString().Substring(0, 5);
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/MetadataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace LacmusApp.ViewModels
{
public class MetadataViewModel : ReactiveValidationObject<MetadataViewModel>
public class MetadataViewModel : ReactiveValidationObject
{
private SourceList<MetaData> _metaDataList { get; set; } = new SourceList<MetaData>();
private ReadOnlyObservableCollection<MetaData> _metaDataCollection;
Expand Down
12 changes: 7 additions & 5 deletions src/ViewModels/ModelManagerWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace LacmusApp.ViewModels
{
public class ModelManagerWindowViewModel : ReactiveValidationObject<ModelManagerWindowViewModel>
public class ModelManagerWindowViewModel : ReactiveValidationObject
{
private bool isModelChanged = false;
private PluginManager _pluginManager;
Expand Down Expand Up @@ -81,22 +81,24 @@ public ModelManagerWindowViewModel(ModelManagerWindow window, LocalizationContex
{
_config = AppConfig.DeepCopy(_newConfig);
await _config.Save();
window.AppConfig = _config;
if (isModelChanged)
{
var msg = "To use new configuration of the ML Model you need to restart application.";
if (LocalizationContext.Language == Language.Russian)
msg = "Чтобы изменить ML модель необходим перезапуск программы.";
var msgbox = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
{
ButtonDefinitions = ButtonEnum.Ok,
ContentTitle = "Need to restart",
ContentMessage = "To use new configuration of the ML Model you need to restart application.",
ContentMessage = msg,
Icon = MessageBox.Avalonia.Enums.Icon.Info,
Style = Style.None,
ShowInCenter = true
});
var result = await msgbox.Show();
}

window.AppConfig = _config;
window.Close();
window.Close();
}, CanExecute());

CancelCommand = ReactiveCommand.Create(window.Close, CanExecute());
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/SaveAsWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace LacmusApp.ViewModels
{
public class SaveAsWindowViewModel : ReactiveValidationObject<SaveAsWindowViewModel>
public class SaveAsWindowViewModel : ReactiveValidationObject
{
private readonly SourceList<PhotoViewModel> _photos;
private readonly ApplicationStatusManager _applicationStatusManager;
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/SecondWizardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace LacmusApp.ViewModels
{
public class SecondWizardViewModel : ReactiveValidationObject<SecondWizardViewModel>, IRoutableViewModel
public class SecondWizardViewModel : ReactiveValidationObject, IRoutableViewModel
{
public IScreen HostScreen { get; }
public string UrlPathSegment { get; } = Guid.NewGuid().ToString().Substring(0, 5);
Expand Down
45 changes: 33 additions & 12 deletions src/ViewModels/SettingsWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using LacmusApp.Views;
using MessageBox.Avalonia;
using MessageBox.Avalonia.DTO;
using MessageBox.Avalonia.Enums;
using Serilog;
using OperatingSystem = LacmusPlugin.OperatingSystem;

Expand All @@ -18,23 +21,24 @@ namespace LacmusApp.ViewModels
public class SettingsWindowViewModel : ReactiveObject
{
LocalizationContext LocalizationContext {get; set;}
private ThemeManager _settingsThemeManager, _mainThemeManager;
private ThemeManager _mainThemeManager;
private readonly ApplicationStatusManager _applicationStatusManager;
private AppConfig _config, _newConfig;
private SettingsWindow _window;
private bool isThemeChanged = false;
private ThemeManager.Theme _currentTheme;

public SettingsWindowViewModel(SettingsWindow window, LocalizationContext context,
ref AppConfig config,
ApplicationStatusManager manager,
ThemeManager mainThemeManager,
ThemeManager settingsThemeManager)
ThemeManager mainThemeManager)
{
_window = window;
this.LocalizationContext = context;
_settingsThemeManager = settingsThemeManager;
_mainThemeManager = mainThemeManager;
_config = config;
_newConfig = AppConfig.DeepCopy(_config);
_currentTheme = _config.Theme;
_applicationStatusManager = manager;
InitView();

Expand Down Expand Up @@ -90,7 +94,7 @@ private void InitView()
break;
}

switch (_settingsThemeManager.CurrentTheme)
switch (_currentTheme)
{
case ThemeManager.Theme.Citrus:
ThemeIndex = 0;
Expand Down Expand Up @@ -125,16 +129,32 @@ private async void Apply()
default:
throw new Exception($"Invalid LanguageIndex: {LanguageIndex}");
}
_mainThemeManager.UseTheme(_settingsThemeManager.CurrentTheme);

//save app settings
_newConfig.Language = LocalizationContext.Language;
_newConfig.Theme = _mainThemeManager.CurrentTheme;
_newConfig.Theme = _currentTheme;
_newConfig.BorderColor = HexColor;

await _newConfig.Save();
_config = AppConfig.DeepCopy(_newConfig);
_window.AppConfig = _config;
if (isThemeChanged)
{
//TODO: refactor it
var msg = "To use new theme you need to restart application.";
if (LocalizationContext.Language == Language.Russian)
msg = "Чтобы изменить тему интерфейса необходим перезапуск программы.";
var msgbox = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
{
ButtonDefinitions = ButtonEnum.Ok,
ContentTitle = "Need to restart",
ContentMessage = msg,
Icon = MessageBox.Avalonia.Enums.Icon.Info,
Style = Style.None,
ShowInCenter = true
});
var result = await msgbox.Show();
}
_window.Close();
}
catch (Exception e)
Expand Down Expand Up @@ -194,23 +214,24 @@ private void SwitchSettingsTheme()
switch (ThemeIndex)
{
case 0:
_settingsThemeManager.UseTheme(ThemeManager.Theme.Citrus);
_currentTheme = ThemeManager.Theme.Citrus;
break;
case 1:
_settingsThemeManager.UseTheme(ThemeManager.Theme.Rust);
_currentTheme = ThemeManager.Theme.Rust;
break;
case 2:
_settingsThemeManager.UseTheme(ThemeManager.Theme.Sea);
_currentTheme = ThemeManager.Theme.Sea;
break;
case 3:
_settingsThemeManager.UseTheme(ThemeManager.Theme.Candy);
_currentTheme = ThemeManager.Theme.Candy;
break;
case 4:
_settingsThemeManager.UseTheme(ThemeManager.Theme.Magma);
_currentTheme = ThemeManager.Theme.Magma;
break;
default:
throw new Exception($"Invalid ThemeIndex: {LanguageIndex}");
}
isThemeChanged = true;
}
catch (Exception e)
{
Expand Down
34 changes: 13 additions & 21 deletions src/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,19 @@
<ItemsControl
HorizontalAlignment="Center"
VerticalAlignment="Center"
Items="{Binding PhotoViewModel.BoundBoxes}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas
Name="ShowedImage"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{Binding PhotoViewModel.Photo.ImageBrush}"
Height="{Binding CanvasHeight, Mode=TwoWay}"
Width="{Binding CanvasWidth, Mode=TwoWay}">
<Canvas.ContextMenu>
<ContextMenu>
<MenuItem Header="{Binding LocalizationContext.ShowGeoPosition}" Command="{Binding ShowGeoDataCommand}"/>
<!-- <MenuItem Header="Find nearest photo"/> -->
<Separator/>
<MenuItem Header="{Binding LocalizationContext.FavoritesStateString}" Command="{Binding AddToFavoritesCommand}"/>
</ContextMenu>
</Canvas.ContextMenu>
</Canvas>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
Items="{Binding PhotoViewModel.BoundBoxes}"
Background="{Binding PhotoViewModel.Photo.ImageBrush}"
Height="{Binding CanvasHeight, Mode=TwoWay}"
Width="{Binding CanvasWidth, Mode=TwoWay}"
>
<ItemsControl.ContextMenu>
<ContextMenu>
<MenuItem Header="{Binding LocalizationContext.ShowGeoPosition}" Command="{Binding ShowGeoDataCommand}"/>
<!-- <MenuItem Header="Find nearest photo"/> -->
<Separator/>
<MenuItem Header="{Binding LocalizationContext.FavoritesStateString}" Command="{Binding AddToFavoritesCommand}"/>
</ContextMenu>
</ItemsControl.ContextMenu>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type models:BoundBox}">
<Polygon
Expand Down
2 changes: 1 addition & 1 deletion src/Views/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public SettingsWindow(LocalizationContext context, ref AppConfig appConfig, Appl
AvaloniaXamlLoader.Load(this);
var settingsThemeManager = new ThemeManager(this);
settingsThemeManager.UseTheme(themeManager.CurrentTheme);
this.DataContext = new SettingsWindowViewModel(this, context, ref appConfig, manager, themeManager, settingsThemeManager);
this.DataContext = new SettingsWindowViewModel(this, context, ref appConfig, manager, themeManager);
}

public SettingsWindow() { }
Expand Down

0 comments on commit 8cb75a9

Please sign in to comment.