Skip to content

Commit

Permalink
Updated the main page layout to fit the Windows 11 guideline. (#38)
Browse files Browse the repository at this point in the history
* Improved the layout of DevToys

* layout v2

* cleaning

* removed back button

* refactoring
  • Loading branch information
veler authored Oct 22, 2021
1 parent 9af9e4a commit 86598e3
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
Expand Down Expand Up @@ -649,7 +650,13 @@ protected override void OnApplyTemplate()
_view.DOMContentLoaded += WebView_DOMContentLoaded;
_view.NavigationCompleted += WebView_NavigationCompleted;
_view.NewWindowRequested += WebView_NewWindowRequested;
_view.Source = new System.Uri("ms-appx-web:///DevToys.MonacoEditor/CodeEditorControl/CodeEditorCore.html");
Task.Delay(250).ContinueWith(async _ =>
{
await _view.Dispatcher.RunIdleAsync((IdleDispatchedHandlerArgs e) =>
{
_view.Source = new System.Uri("ms-appx-web:///DevToys.MonacoEditor/CodeEditorControl/CodeEditorCore.html");
});
});
}

base.OnApplyTemplate();
Expand Down
44 changes: 20 additions & 24 deletions src/dev/impl/DevToys/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,14 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e)
// On Windows 10 version 1607 or later, this code signals that this app wants to participate in prelaunch
CoreApplication.EnablePrelaunch(true);

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(MainPage),
new NavigationParameter(
mefComposer.ExportProvider.GetExport<IMefProvider>(),
query: e.Arguments),
new SuppressNavigationTransitionInfo());
}
await NavigateToMainPageAsync(rootFrame, e.Arguments);

// Ensure the current window is active
Window.Current.Activate();
}
else
{
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(MainPage),
new NavigationParameter(
mefComposer.ExportProvider.GetExport<IMefProvider>(),
query: e.Arguments),
new SuppressNavigationTransitionInfo());
}
await NavigateToMainPageAsync(rootFrame, e.Arguments);
}

// Setup the title bar.
Expand Down Expand Up @@ -239,6 +217,24 @@ private async Task<Frame> EnsureWindowIsInitializedAsync()
return rootFrame;
}

private async Task NavigateToMainPageAsync(Frame rootFrame, string arguments)
{
if (rootFrame.Content == null)
{
var mefComposer = await _mefComposer;

// 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(MainPage),
new NavigationParameter(
mefComposer.ExportProvider.GetExport<IMefProvider>(),
query: arguments),
new SuppressNavigationTransitionInfo());
}
}

private async Task ValidateDefaultTextEditorFontAsync()
{
await TaskScheduler.Default;
Expand Down
1 change: 0 additions & 1 deletion src/dev/impl/DevToys/DevToys.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@
<Compile Include="UI\Controls\HighlightSpan.cs" />
<Compile Include="UI\Controls\ICustomTextBox.cs" />
<Compile Include="UI\Converters\BooleanToGridLengthConverter.cs" />
<Compile Include="UI\Converters\BooleanToScrollBarVisibilityConverter.cs" />
<Compile Include="UI\Converters\BooleanToScrollModeConverter.cs" />
<Compile Include="UI\Converters\BooleanToTextWrappingConverter.cs" />
<Compile Include="UI\Converters\BooleanToVisibilityConverter.cs" />
Expand Down
7 changes: 6 additions & 1 deletion src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace DevToys.UI.Controls
{
public sealed partial class CodeEditor : UserControl
public sealed partial class CodeEditor : UserControl, IDisposable
{
public static readonly DependencyProperty SettingsProviderProperty
= DependencyProperty.Register(
Expand Down Expand Up @@ -170,6 +170,11 @@ public CodeEditor()
UpdateUI();
}

public void Dispose()
{
CodeEditorCore.Dispose();
}

private void CodeEditorCore_InternalException(MonacoEditor.CodeEditorControl.CodeEditorCore sender, Exception args)
{
ErrorMessage = $"{args.Message}\r\n{args.InnerException?.Message}";
Expand Down

This file was deleted.

8 changes: 5 additions & 3 deletions src/dev/impl/DevToys/UI/Converters/EnumToBooleanConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ namespace DevToys.UI.Converters
/// </summary>
public sealed class EnumToBooleanConverter : IValueConverter
{
public bool IsInverted { get; set; }

public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is null || parameter is null || !(value is Enum))
{
return false;
return IsInverted;
}

var currentState = value.ToString();
Expand All @@ -26,11 +28,11 @@ public object Convert(object value, Type targetType, object parameter, string la
{
if (string.Equals(currentState, stateStringsSplitted[i].Trim(), StringComparison.Ordinal))
{
return true;
return !IsInverted;
}
}

return false;
return IsInverted;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
Expand Down
20 changes: 4 additions & 16 deletions src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ internal string? HeaderText
{
get
{
if (IsInCompactOverlayMode)
{
return null;
}

return SelectedMenuItem?.ToolProvider.DisplayName;
}
}
Expand Down Expand Up @@ -147,7 +142,7 @@ private set
/// <summary>
/// Gets or sets in what mode the navigation view is displayed.
/// </summary>
public NavigationViewDisplayMode NavigationViewDisplayMode // Important to keep this property Public to bind it to ChangePropertyAction in the XAML.
internal NavigationViewDisplayMode NavigationViewDisplayMode
{
get => _navigationViewDisplayMode;
set
Expand All @@ -161,7 +156,7 @@ public NavigationViewDisplayMode NavigationViewDisplayMode // Important to keep
/// <summary>
/// Gets or sets whether the pane is opened.
/// </summary>
public bool IsNavigationViewPaneOpened // Important to keep this property Public to bind it to ChangePropertyAction in the XAML.
internal bool IsNavigationViewPaneOpened
{
get => _isNavigationViewPaneOpened;
set
Expand All @@ -179,16 +174,9 @@ public NavigationViewDisplayMode ActualNavigationViewDisplayMode
{
get
{
if (NavigationViewDisplayMode == NavigationViewDisplayMode.Expanded)
if (IsNavigationViewPaneOpened)
{
if (IsNavigationViewPaneOpened)
{
return NavigationViewDisplayMode.Expanded;
}
else
{
return NavigationViewDisplayMode.Compact;
}
return NavigationViewDisplayMode.Expanded;
}
else
{
Expand Down
Loading

0 comments on commit 86598e3

Please sign in to comment.