-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hurl Rewrite Project #112
Closed
+192
−0
Closed
Hurl Rewrite Project #112
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Application | ||
x:Class="Hurl.App.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:Hurl.App" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
DispatcherUnhandledException="Application_DispatcherUnhandledException" | ||
Startup="Application_Startup"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<!-- TODO: Light/Dark --> | ||
<ui:ThemesDictionary Theme="Dark" /> | ||
<ui:ControlsDictionary /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Text.Json; | ||
using System.Windows; | ||
using System.Windows.Threading; | ||
|
||
namespace Hurl.App; | ||
|
||
public partial class App : Application | ||
{ | ||
private void Application_Startup(object sender, StartupEventArgs e) | ||
{ | ||
MainWindow mainWindow = new(); | ||
mainWindow.Show(); | ||
} | ||
|
||
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) | ||
{ | ||
// TODO: reuse the code across the projects | ||
string ErrorMsgBuffer; | ||
string ErrorWndTitle; | ||
switch (e.Exception?.InnerException) | ||
{ | ||
case JsonException: | ||
ErrorMsgBuffer = "The UserSettings.json file is in invalid JSON format. \n"; | ||
ErrorWndTitle = "Invalid JSON"; | ||
break; | ||
default: | ||
ErrorMsgBuffer = "An unknown error has occurred. \n"; | ||
ErrorWndTitle = "Unknown Error"; | ||
break; | ||
|
||
} | ||
string errorMessage = string.Format("{0}\n{1}\n\n{2}", ErrorMsgBuffer, e.Exception.InnerException?.Message, e.Exception?.Message); | ||
MessageBox.Show(errorMessage, ErrorWndTitle, MessageBoxButton.OK, MessageBoxImage.Error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="WPF-UI" Version="3.0.3" /> | ||
<PackageReference Include="WPF-UI.Tray" Version="3.0.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<ui:FluentWindow | ||
x:Class="Hurl.App.MainWindow" | ||
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:local="clr-namespace:Hurl.App" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
Title="MainWindow" | ||
Width="800" | ||
Height="450" | ||
ExtendsContentIntoTitleBar="True" | ||
WindowBackdropType="Mica" | ||
WindowCornerPreference="Round" | ||
WindowStartupLocation="CenterScreen" | ||
mc:Ignorable="d"> | ||
<Grid> | ||
<ui:TitleBar Title="Hurl [BETA]" Grid.ColumnSpan="3" /> | ||
</Grid> | ||
</ui:FluentWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace Hurl.App; | ||
|
||
public partial class MainWindow | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Hurl.App.Utils; | ||
|
||
internal class SingleInstance | ||
{ | ||
// TAKEN from https://github.com/BartoszCichecki/LenovoLegionToolkit/blob/master/LenovoLegionToolkit.WPF/App.xaml.cs | ||
// TODO: Support sharing the Cmd Args between the instances | ||
private const string MUTEX_NAME = "hurl_app_mutex"; | ||
private const string EVENT_NAME = "hurl_app_mutex"; | ||
|
||
private Mutex? _singleInstanceMutex; | ||
private EventWaitHandle? _singleInstanceWaitHandle; | ||
|
||
private void EnsureSingleInstance() | ||
{ | ||
_singleInstanceMutex = new Mutex(true, MUTEX_NAME, out var isOwned); | ||
_singleInstanceWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, EVENT_NAME); | ||
|
||
if (!isOwned) | ||
{ | ||
_singleInstanceWaitHandle.Set(); | ||
Shutdown(); | ||
return; | ||
} | ||
|
||
new Thread(() => | ||
{ | ||
while (_singleInstanceWaitHandle.WaitOne()) | ||
{ | ||
Current.Dispatcher.BeginInvoke(async () => | ||
{ | ||
if (Current.MainWindow is { } window) | ||
{ | ||
window.BringToForeground(); | ||
} | ||
else | ||
{ | ||
await ShutdownAsync(); | ||
} | ||
}); | ||
} | ||
}) | ||
{ | ||
IsBackground = true | ||
}.Start(); | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Urgently recommend not to use the same Grid idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it makes everything way too complicated. You need to remember to put everything in the middle, and you will never have a scrollviewer that touches the sides. The same effect can be achieved with MaxWidth of the content.