Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
petrspelos committed Aug 24, 2020
1 parent 3497e47 commit 7758df6
Show file tree
Hide file tree
Showing 88 changed files with 2,516 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/Miunie"]
path = src/Miunie
url = [email protected]:control-net/Miunie.git
1 change: 1 addition & 0 deletions src/Miunie
Submodule Miunie added at 9e3e57
18 changes: 18 additions & 0 deletions src/Miunie.WindowsApp/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Application
x:Class="Miunie.WindowsApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Miunie.WindowsApp"
xmlns:cv="using:Miunie.WindowsApp.Converters"
xmlns:vm="using:Miunie.WindowsApp.ViewModels">
<Application.Resources>
<ResourceDictionary>
<cv:IntToVisabilityConverter x:Key="IntToVisabilityConverter"/>
<cv:TokenMaskConverter x:Key="TokenMaskConverter" />
<vm:ViewModelLocator xmlns:vm="using:Miunie.WindowsApp.ViewModels" x:Key="Locator"/>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
141 changes: 141 additions & 0 deletions src/Miunie.WindowsApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// This file is part of Miunie.
//
// Miunie is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Miunie is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Miunie. If not, see <https://www.gnu.org/licenses/>.

using GalaSoft.MvvmLight.Threading;
using Miunie.WindowsApp.Views;
using System;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.Foundation;
using Windows.UI.Popups;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace Miunie.WindowsApp
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public sealed partial class App : Application
{
/// <summary>
/// Initializes a new instance of the <see cref="App"/> class.
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
InitializeComponent();
Suspending += OnSuspending;
UnhandledException += App_UnhandledException;
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// Set preferred application window min size
ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(500, 400));

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (!(Window.Current.Content is Frame rootFrame))
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();

rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// TODO: Load state from previously suspended application
}

// Place the frame in the current Window
Window.Current.Content = rootFrame;
}

if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
_ = rootFrame.Navigate(typeof(StartPage), e.Arguments);
}

// Ensure the current window is active
Window.Current.Activate();
}

DispatcherHelper.Initialize();
}

private async void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
e.Handled = true;
System.Diagnostics.Debug.WriteLine(e.Exception);

var confirmRestart = new ContentDialog
{
Title = "Unexpected Error",
Content = "An unexpected error occurred, would you like to restart Miunie, or ignore this problem?",
PrimaryButtonText = "Yes, restart Miunie",
CloseButtonText = "Ignore and continue"
};

var confirmResult = await confirmRestart.ShowAsync();

if (confirmResult != ContentDialogResult.Primary) { return; }

var restartResult = await CoreApplication.RequestRestartAsync($"Restart on Error: {e.Message}");

var failureAlert = new MessageDialog("Restart Failed", restartResult.ToString());
_ = await failureAlert.ShowAsync();
}

/// <summary>
/// Invoked when Navigation to a certain page fails.
/// </summary>
/// <param name="sender">The Frame which failed navigation.</param>
/// <param name="e">Details about the navigation failure.</param>
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();

// TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Miunie.WindowsApp/Assets/bg-pattern-black.png
Binary file added src/Miunie.WindowsApp/Assets/bg-pattern-white.png
21 changes: 21 additions & 0 deletions src/Miunie.WindowsApp/Controls/NoContentControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<UserControl
x:Class="Miunie.WindowsApp.Controls.NoContentControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="{x:Bind Icon}" FontSize="124" Margin="25"/>
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="{x:Bind Title}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}"
Text="{x:Bind Description}"
TextAlignment="Center"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Margin="50 15" />
</StackPanel>
</UserControl>
33 changes: 33 additions & 0 deletions src/Miunie.WindowsApp/Controls/NoContentControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file is part of Miunie.
//
// Miunie is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Miunie is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Miunie. If not, see <https://www.gnu.org/licenses/>.

using Windows.UI.Xaml.Controls;

namespace Miunie.WindowsApp.Controls
{
public sealed partial class NoContentControl : UserControl
{
public NoContentControl()
{
InitializeComponent();
}

public string Icon { get; set; }

public string Title { get; set; }

public string Description { get; set; }
}
}
39 changes: 39 additions & 0 deletions src/Miunie.WindowsApp/Converters/IntToVisabilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is part of Miunie.
//
// Miunie is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Miunie is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Miunie. If not, see <https://www.gnu.org/licenses/>.

using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace Miunie.WindowsApp.Converters
{
public class IntToVisabilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is int count)
{
value = count > 0 ? Visibility.Visible : Visibility.Collapsed;
}

return value;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
44 changes: 44 additions & 0 deletions src/Miunie.WindowsApp/Converters/TokenMaskConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This file is part of Miunie.
//
// Miunie is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Miunie is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Miunie. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Linq;
using Windows.UI.Xaml.Data;

namespace Miunie.WindowsApp.Converters
{
public class TokenMaskConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is string token)
{
if (token == "[NOT CONFIGURED]")
{
return value;
}

value = $"{string.Join(string.Empty, token.Take(5))} ****************************** {string.Join(string.Empty, token.TakeLast(5))}";
}

return value;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
31 changes: 31 additions & 0 deletions src/Miunie.WindowsApp/Infrastructure/UwpFileSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This file is part of Miunie.
//
// Miunie is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Miunie is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Miunie. If not, see <https://www.gnu.org/licenses/>.

using Miunie.Core.Infrastructure;
using Windows.Storage;

namespace Miunie.WindowsApp.Infrastructure
{
public class UwpFileSystem : IFileSystem
{
public UwpFileSystem()
{
var storageFolder = ApplicationData.Current.LocalFolder;
DataStoragePath = storageFolder.Path;
}

public string DataStoragePath { get; }
}
}
52 changes: 52 additions & 0 deletions src/Miunie.WindowsApp/InversionOfControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// This file is part of Miunie.
//
// Miunie is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Miunie is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Miunie. If not, see <https://www.gnu.org/licenses/>.

using Microsoft.Extensions.DependencyInjection;
using Miunie.Core.Infrastructure;
using Miunie.Core.Logging;
using Miunie.Infrastructure.Logging;
using Miunie.Infrastructure.OS;
using Miunie.InversionOfControl;
using Miunie.WindowsApp.Infrastructure;

namespace Miunie.WindowsApp
{
public static class InversionOfControl
{
private static ServiceProvider _provider;

public static ServiceProvider Provider => GetOrInitProvider();

private static ServiceProvider GetOrInitProvider()
{
if (_provider is null)
{
InitializeProvider();
}

return _provider;
}

private static void InitializeProvider()
=> _provider = new ServiceCollection()
.AddSingleton<InMemoryLogger>()
.AddSingleton<ILogReader>(s => s.GetRequiredService<InMemoryLogger>())
.AddSingleton<ILogWriter>(s => s.GetRequiredService<InMemoryLogger>())
.AddTransient<IDateTime, SystemDateTime>()
.AddSingleton<IFileSystem, UwpFileSystem>()
.AddMiunieTypes()
.BuildServiceProvider();
}
}
Loading

0 comments on commit 7758df6

Please sign in to comment.