Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/RepoM.App/ActionMenuCore/RepositoryTagsFactoryV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ public RepositoryTagsFactoryV2(
_filename = fileSystem.Path.Combine(appDataPathProvider.AppDataPath, "TagsV2.yaml");
}

public Task<IEnumerable<string>> GetTagsAsync(Repository repository)
{
return _newStyleActionMenuFactory.GetTagsAsync(repository, _filename);
}
}
public Task<IEnumerable<string>> GetTagsAsync(Repository repository) => _newStyleActionMenuFactory.GetTagsAsync(repository,_filename);
}
123 changes: 32 additions & 91 deletions src/RepoM.App/App.xaml
Original file line number Diff line number Diff line change
@@ -1,109 +1,50 @@
<Application x:Class="RepoM.App.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:RepoM.App.Controls"
ShutdownMode="OnExplicitShutdown">
<Application
x:Class="RepoM.App.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:RepoM.App.Controls"
xmlns:local="clr-namespace:RepoM.App"
xmlns:syntax="http://schemas.lepo.co/wpfui/2022/xaml/syntax"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
ShutdownMode="OnExplicitShutdown"
>
<Application.Resources>

<!--
<!--
Note that this application does not have a StartupUri declared, so no Window is automatically loaded.
Also, the ShutdownMode was set to explicit, so we have to close the application programmatically
-->

<ResourceDictionary>
<ResourceDictionary>

<!--
Integrate MahApps to Material Design Toolkit
https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/wiki/MahApps.Metro-integration
-->
<ResourceDictionary.MergedDictionaries>

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/RepoM;component/Resources/Variables.xaml" />
<ResourceDictionary Source="pack://application:,,,/RepoM;component/Resources/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/RepoM;component/Resources/Typography.xaml" />
<ResourceDictionary Source="pack://application:,,,/RepoM;component/Resources/StaticColors.xaml" />
<ResourceDictionary Source="pack://application:,,,/RepoM;component/Resources/Accent.xaml" />
<ResourceDictionary Source="pack://application:,,,/RepoM;component/Resources/Palette.xaml" />

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<ResourceDictionary x:Name="Dark" Source="pack://application:,,,/RepoM;component/Resources/Theme/Dark.xaml" />
<ResourceDictionary x:Name="Light" Source="pack://application:,,,/RepoM;component/Resources/Theme/Light.xaml" />
<ResourceDictionary x:Name="HighContrastWhite" Source="pack://application:,,,/RepoM;component/Resources/Theme/HCWhite.xaml" />
<ResourceDictionary x:Name="HighContrastBlack" Source="pack://application:,,,/RepoM;component/Resources/Theme/HCBlack.xaml" />
<ResourceDictionary x:Name="HighContrastCustom1" Source="pack://application:,,,/RepoM;component/Resources/Theme/HC1.xaml" />
<ResourceDictionary x:Name="HighContrastCustom2" Source="pack://application:,,,/RepoM;component/Resources/Theme/HC2.xaml" />

<ui:ThemesDictionary Theme="Dark" />

<!-- MahApps -->
<ui:ControlsDictionary />

<!-- Material Design -->
<!--<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />-->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.LightBlue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.LightBlue.xaml" />
<!-- merge NotifyIcon and related stuff into the application -->
<ResourceDictionary Source="NotifyIconResources.xaml" />

<!-- Material Design: MahApps Compatibility -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Fonts.xaml" />
<!-- CRASHES?! <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Flyout.xaml" />-->
</ResourceDictionary.MergedDictionaries>

<!-- merge NotifyIcon and related stuff into the application -->
<ResourceDictionary Source="NotifyIconResources.xaml" />

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

<!-- MahApps Brushes -->

<!-- Light/Dark MaterialDesign themes to MahApps -->
<!-- WindowTitleColorBrush = MaterialDesignPaper -->
<!-- IdealForegroundColorBrush = MaterialDesignBody -->

<!-- Light -->
<!--
<SolidColorBrush x:Key="WindowTitleColorBrush" Color="#FFfafafa"/>
<SolidColorBrush x:Key="IdealForegroundColorBrush" Color="#DD000000"/>
-->

<!-- Dark -->
<SolidColorBrush x:Key="WindowTitleColorBrush"
Color="#FF303030" />
<SolidColorBrush x:Key="IdealForegroundColorBrush"
Color="#DDFFFFFF" />

<SolidColorBrush x:Key="HighlightBrush"
Color="{DynamicResource Primary700}" />
<SolidColorBrush x:Key="AccentColorBrush"
Color="{DynamicResource Primary500}" />
<!-- main accent -->
<SolidColorBrush x:Key="AccentColorBrush2"
Color="{DynamicResource Primary400}" />
<SolidColorBrush x:Key="AccentColorBrush3"
Color="{DynamicResource Primary300}" />
<SolidColorBrush x:Key="AccentColorBrush4"
Color="{DynamicResource Primary200}" />
<SolidColorBrush x:Key="AccentSelectedColorBrush"
Color="{DynamicResource Primary500Foreground}" />
<LinearGradientBrush x:Key="ProgressBrush"
EndPoint="0.001,0.5"
StartPoint="1.002,0.5">
<GradientStop Color="{DynamicResource Primary700}"
Offset="0" />
<GradientStop Color="{DynamicResource Primary300}"
Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="CheckmarkFill"
Color="{DynamicResource Primary500}" />
<SolidColorBrush x:Key="RightArrowFill"
Color="{DynamicResource Primary500}" />
<SolidColorBrush x:Key="IdealForegroundDisabledBrush"
Color="{DynamicResource Primary500}"
Opacity="0.4" />

<Style TargetType="{x:Type controls:ZTextBox}" BasedOn="{StaticResource {x:Type TextBox}}" />

<Style TargetType="{x:Type controls:AcrylicContextMenu}" BasedOn="{StaticResource {x:Type ContextMenu}}" >
<Setter Property="Background" Value="#50000000" />
<Setter Property="FontSize" Value="13.5" />

</Style>


<Style TargetType="{x:Type controls:AcrylicMenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}" >
<Setter Property="Background" Value="Transparent"/>
</Style>

</ResourceDictionary>

</Application.Resources>
</Application.Resources>

</Application>
66 changes: 49 additions & 17 deletions src/RepoM.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ namespace RepoM.App;
using System.Threading;
using System.Windows;
using Hardcodet.Wpf.TaskbarNotification;
using RepoM.Api.Git;
using RepoM.Api.IO;
using RepoM.App.i18n;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using RepoM.Api;
using RepoM.Api.Git;
using RepoM.Api.IO;
using RepoM.Api.Plugins;
using RepoM.App.i18n;
using RepoM.App.Plugins;
using RepoM.App.Services;
using RepoM.App.Services.HotKey;
using Serilog;
using Serilog.Core;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using RepoM.App.Services;
using Application = System.Windows.Application;
using Container = SimpleInjector.Container;
using RepoM.App.Services.HotKey;
using RepoM.Api;
using ILogger = Microsoft.Extensions.Logging.ILogger;

/// <summary>
/// Interaction logic for App.xaml
Expand All @@ -35,6 +36,29 @@ public partial class App : Application
private HotKeyService? _hotKeyService;
private WindowSizeService? _windowSizeService;

//private static UiApplication? _uiApplication;

private static App? _app;

private Window? _mainWindow;
public Window? MainWindowInstance
{
get => _app?.MainWindow ?? _mainWindow;
set
{
if (_app != null)
{
_app.MainWindow = value;
}

_mainWindow = value;
}
}


/// <summary>
/// Main program start point
/// </summary>
[STAThread]
public static void Main()
{
Expand All @@ -44,11 +68,15 @@ public static void Main()
}

Thread.CurrentThread.Name ??= "UI";
var app = new App();
app.InitializeComponent();
app.Run();
_app = new App();
_app.InitializeComponent();
_app.Run();
}

/// <summary>
/// OnStartup event
/// </summary>
/// <param name="e"></param>
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Expand Down Expand Up @@ -85,7 +113,7 @@ protected override async void OnStartup(StartupEventArgs e)

EnsureStartup ensureStartup = Bootstrapper.Container.GetInstance<EnsureStartup>();
await ensureStartup.EnsureFilesAsync().ConfigureAwait(true);

UseRepositoryMonitor(Bootstrapper.Container);

_moduleService = Bootstrapper.Container.GetInstance<ModuleService>();
Expand All @@ -104,18 +132,22 @@ protected override async void OnStartup(StartupEventArgs e)
logger.LogError(exception, "Could not start all modules.");
}
}


/// <summary>
/// OnExit Event
/// </summary>
/// <param name="e"></param>
protected override void OnExit(ExitEventArgs e)
{
_windowSizeService?.Unregister();

_moduleService?.StopAsync().GetAwaiter().GetResult();

_hotKeyService?.Unregister();

// #pragma warning disable CA1416 // Validate platform compatibility
// #pragma warning disable CA1416 // Validate platform compatibility
_notifyIcon?.Dispose();
// #pragma warning restore CA1416 // Validate platform compatibility
// #pragma warning restore CA1416 // Validate platform compatibility

ReleaseAndDisposeMutex();

Expand Down Expand Up @@ -199,5 +231,5 @@ private static void ReleaseAndDisposeMutex()
}
}

public static string? AvailableUpdate { get; private set; } = null;
}
public static string? AvailableUpdate { get; private set; }
}
12 changes: 5 additions & 7 deletions src/RepoM.App/Controls/AcrylicContextMenu.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
namespace RepoM.App.Controls;

using System.Windows;
using System.Windows.Controls;
using RepoM.App.Services;

public class AcrylicContextMenu : ContextMenu
{
protected override void OnOpened(RoutedEventArgs e)
{
base.OnOpened(e);
//protected override void OnOpened(RoutedEventArgs e)
//{
// base.OnOpened(e);

AcrylicHelper.EnableBlur(this);
}
// AcrylicHelper.EnableBlur(this);
//}
}
96 changes: 45 additions & 51 deletions src/RepoM.App/Controls/AcrylicMenuItem.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
namespace RepoM.App.Controls;

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using RepoM.App.Services;

public class AcrylicMenuItem : MenuItem
public class AcrylicMenuItem : Wpf.Ui.Controls.MenuItem
{
private static readonly Brush _solidColorBrush = new SolidColorBrush(Color.FromArgb(80, 0, 0, 0));

protected override void OnSubmenuOpened(RoutedEventArgs e)
{
base.OnSubmenuOpened(e);

Dispatcher.BeginInvoke((Action)BlurSubMenu);
}

private void BlurSubMenu()
{
DependencyObject firstSubItem = ItemContainerGenerator.ContainerFromIndex(0);

if (firstSubItem == null)
{
return;
}

if (VisualTreeHelper.GetParent(firstSubItem) is not Visual container)
{
return;
}

DependencyObject parent = container;
var borderIndex = 0;

while (parent != null)
{
if (parent is Border b)
{
// only put color on the first border (transparent colors will add up otherwise)
b.Background = borderIndex == 0
? _solidColorBrush
: Brushes.Transparent;

borderIndex++;
}

parent = VisualTreeHelper.GetParent(parent);
}

AcrylicHelper.EnableBlur(container);
}
}
//private static readonly Brush _solidColorBrush = new SolidColorBrush(Color.FromArgb(80, 0, 0, 0));

//protected override void OnSubmenuOpened(RoutedEventArgs e)
//{
// base.OnSubmenuOpened(e);

// Dispatcher.BeginInvoke((Action)BlurSubMenu);
//}

//private void BlurSubMenu()
//{
// //DependencyObject firstSubItem = ItemContainerGenerator.ContainerFromIndex(0);

// //if (firstSubItem == null)
// //{
// // return;
// //}

// //if (VisualTreeHelper.GetParent(firstSubItem) is not Visual container)
// //{
// // return;
// //}

// //DependencyObject parent = container;
// //var borderIndex = 0;

// //while (parent != null)
// //{
// // if (parent is Border b)
// // {
// // // only put color on the first border (transparent colors will add up otherwise)
// // //b.Background = borderIndex == 0
// // // ? _solidColorBrush
// // // : Brushes.Transparent;

// // borderIndex++;
// // }

// // parent = VisualTreeHelper.GetParent(parent);
// //}

// //AcrylicHelper.EnableBlur(container);
//}
}
Loading