Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Totopolis/monik.desktop
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.3
Choose a base ref
...
head repository: Totopolis/monik.desktop
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 3 commits
  • 8 files changed
  • 1 contributor

Commits on Apr 17, 2020

  1. Update readme

    Liklainy committed Apr 17, 2020
    Copy the full SHA
    ad2ee73 View commit details

Commits on Apr 21, 2020

  1. Save settings to roaming

    Liklainy committed Apr 21, 2020
    Copy the full SHA
    0e92488 View commit details
  2. Fix license packaging

    Liklainy committed Apr 21, 2020
    Copy the full SHA
    7a8edfb View commit details
10 changes: 10 additions & 0 deletions MonikDesktopSolution/MonikDesktop/Common/Config/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MonikDesktop.Common.Config
{
public class AppConfig
{
public string Accent { get; set; }
public bool IsDark { get; set; }
public string ServerUrl { get; set; }
public string AuthToken { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.IO;
using System.Text;
using Newtonsoft.Json;

namespace MonikDesktop.Common.Config
{
public class AppConfigStorage
{
private readonly FileInfo _fileInfo;

public AppConfigStorage()
{
_fileInfo = new FileInfo(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
@"MonikDesktop\app.config"));
_fileInfo.Directory?.Create();
}

public void Save(AppConfig value)
{
var data = JsonConvert.SerializeObject(value);
File.WriteAllText(_fileInfo.ToString(), data, Encoding.UTF8);
}

public AppConfig Load()
{
if (!_fileInfo.Exists)
{
return new AppConfig();
}

var data = File.ReadAllText(_fileInfo.ToString(), Encoding.UTF8);
return JsonConvert.DeserializeObject<AppConfig>(data);
}
}
}
74 changes: 0 additions & 74 deletions MonikDesktopSolution/MonikDesktop/Properties/Settings.Designer.cs

This file was deleted.

18 changes: 0 additions & 18 deletions MonikDesktopSolution/MonikDesktop/Properties/Settings.settings

This file was deleted.

62 changes: 37 additions & 25 deletions MonikDesktopSolution/MonikDesktop/ViewModels/StartupViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using DynamicData;
using MahApps.Metro;
using MonikDesktop.Common.Interfaces;
using MonikDesktop.Properties;
using MonikDesktop.Views;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
@@ -15,6 +14,7 @@
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows;
using MonikDesktop.Common.Config;
using Ui.Wpf.Common;
using Ui.Wpf.Common.ViewModels;

@@ -47,6 +47,9 @@ public StartupViewModel(IShell shell, ISourcesCacheProvider cacheProvider, IDock
_shell = shell;
_cacheProvider = cacheProvider;
_window = window;

var appConfigStorage = new AppConfigStorage();
var config = appConfigStorage.Load();

Title = "App settings";

@@ -58,26 +61,39 @@ public StartupViewModel(IShell shell, ISourcesCacheProvider cacheProvider, IDock

// Theme

Accent = Settings.Default.Accent;
IsDark = Settings.Default.IsDark;
UpdateTheme(false);
Accent = config.Accent ?? "Blue";
IsDark = config.IsDark;
UpdateTheme();

this.ObservableForProperty(x => x.Accent)
.Subscribe(_ => UpdateTheme());
.Subscribe(x =>
{
config.Accent = x.Value;
appConfigStorage.Save(config);
UpdateTheme();
});
this.ObservableForProperty(x => x.IsDark)
.Subscribe(_ => UpdateTheme());
.Subscribe(x =>
{
config.IsDark = x.Value;
appConfigStorage.Save(config);
UpdateTheme();
});

// Server Urls

var urls = Settings.Default.ServerUrl
var urls = config.ServerUrl?
.Split(';')
.Select(x => Uri.TryCreate(x, UriKind.Absolute, out var result) ? result : null as Uri)
.Where(x => x != null)
.ToArray();

ServerUrlsSource = new SourceList<Uri>();
ServerUrlsSource.AddRange(urls);
ServerUrl = urls.FirstOrDefault();
if (urls != null)
{
ServerUrlsSource.AddRange(urls);
ServerUrl = urls.First();
}

ServerUrlsSource
.Connect()
@@ -86,8 +102,8 @@ public StartupViewModel(IShell shell, ISourcesCacheProvider cacheProvider, IDock
.ToCollection()
.Subscribe(items =>
{
Settings.Default.ServerUrl = string.Join(";", items);
Settings.Default.Save();
config.ServerUrl = string.Join(";", items);
appConfigStorage.Save(config);
});

this.WhenAnyValue(x => x.ServerUrl)
@@ -96,14 +112,17 @@ public StartupViewModel(IShell shell, ISourcesCacheProvider cacheProvider, IDock

// Authorization Tokens

var tokens = Settings.Default.AuthToken
var tokens = config.AuthToken?
.Split(';')
.Where(x => !string.IsNullOrEmpty(x))
.ToArray();

AuthTokensSource = new SourceList<string>();
AuthTokensSource.AddRange(tokens);
AuthToken = tokens.FirstOrDefault();
if (tokens != null)
{
AuthTokensSource.AddRange(tokens);
AuthToken = tokens.First();
}

AuthTokensSource
.Connect()
@@ -112,8 +131,8 @@ public StartupViewModel(IShell shell, ISourcesCacheProvider cacheProvider, IDock
.ToCollection()
.Subscribe(items =>
{
Settings.Default.AuthToken = string.Join(";", items);
Settings.Default.Save();
config.AuthToken = string.Join(";", items);
appConfigStorage.Save(config);
});

this.WhenAnyValue(x => x.AuthToken)
@@ -158,7 +177,7 @@ public void UpdateSourcesCache()

public string UpdateServerUrl
{
get => ServerUrl.ToString();
get => ServerUrl?.ToString();
set
{
// will throw if Uri is incorrect
@@ -311,15 +330,8 @@ private void ManageGroups()
_shell.ShowTool<StartupView>(new ViewRequest("startup"));
}

private void UpdateTheme(bool needToSave = true)
private void UpdateTheme()
{
if (needToSave)
{
Settings.Default.Accent = Accent;
Settings.Default.IsDark = IsDark;
Settings.Default.Save();
}

ThemeManager.ChangeTheme(Application.Current,
IsDark ? ThemeManager.BaseColorDark : ThemeManager.BaseColorLight,
Accent);
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# monik.desktop
# monik.desktop

Install with Chocolatey
```powershell
choco source add -n=totopolis -s="https://www.myget.org/F/totopolis/"
choco install monikdesktop
monikdesktop
```
1 change: 0 additions & 1 deletion choco/MonikDesktop/monikdesktop.nuspec
Original file line number Diff line number Diff line change
@@ -21,6 +21,5 @@
<file src="..\..\MonikDesktopSolution\MonikDesktop\bin\Release\netcoreapp3.1\win-x64\publish\**\*.*" target="" />
<file src="MonikDesktop.exe.gui" />
<file src="tools\**" target="tools" />
<file src="..\..\LICENSE" target="tools\LICENSE.txt" />
</files>
</package>
21 changes: 21 additions & 0 deletions choco/MonikDesktop/tools/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.