Skip to content

Commit

Permalink
Update Gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
pomianowski committed Sep 11, 2023
1 parent e46dad5 commit 40ff2a6
Show file tree
Hide file tree
Showing 206 changed files with 2,619 additions and 3,468 deletions.
6 changes: 1 addition & 5 deletions docs/codesnippet/Rtf/Hyperlink/RtfDocumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ from attr in doc.Descendants().Attributes()
#endregion

#region FixLink
private static void FixLink(
XAttribute link,
RelativePath filePath,
HashSet<string> linkToFiles
)
private static void FixLink(XAttribute link, RelativePath filePath, HashSet<string> linkToFiles)
{
string linkFile;
string anchor = null;
Expand Down
4 changes: 1 addition & 3 deletions docs/codesnippet/Rtf/RtfBuildStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public class RtfBuildStep : IDocumentBuildStep
public void Build(FileModel model, IHostService host)
{
string content = (string)((Dictionary<string, object>)model.Content)["conceptual"];
content = _taskFactory
.StartNew(() => RtfToHtmlConverter.ConvertRtfToHtml(content))
.Result;
content = _taskFactory.StartNew(() => RtfToHtmlConverter.ConvertRtfToHtml(content)).Result;
((Dictionary<string, object>)model.Content)["conceptual"] = content;
}
#endregion
Expand Down
6 changes: 1 addition & 5 deletions docs/codesnippet/Rtf/RtfDocumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ public FileModel Load(FileAndType file, ImmutableDictionary<string, object> meta
#region Save
public SaveResult Save(FileModel model)
{
return new SaveResult
{
DocumentType = "Conceptual",
FileWithoutExtension = Path.ChangeExtension(model.File, null),
};
return new SaveResult { DocumentType = "Conceptual", FileWithoutExtension = Path.ChangeExtension(model.File, null), };
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion docs/templates/wpfui/src/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function renderNavbar(): Promise<NavItem[]> {
<form class="icons">
${window.docfx.iconLinks?.map(i => html`<a href="${i.href}" title="${i.title}" class="btn border-0"><i class="bi bi-${i.icon}"></i></a>`)}
${themePicker(renderCore)}
<a class="btn btn-border-0 btn-sponsor mr-05" rel="noopener noreferrer" href="https://github.com/sponsors/lepoco">Sponsor</a>
<a class="btn btn-border-0 btn-colorful mr-05" rel="noopener noreferrer" href="https://github.com/sponsors/lepoco">Sponsor</a>
</form>`

render(html`${menu} ${icons}`, navbar)
Expand Down
5 changes: 1 addition & 4 deletions src/Wpf.Ui.Demo.Mvvm/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ private async void OnExit(object sender, ExitEventArgs e)
/// <summary>
/// Occurs when an exception is thrown by an application but not handled.
/// </summary>
private void OnDispatcherUnhandledException(
object sender,
DispatcherUnhandledExceptionEventArgs e
)
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// For more info see https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?view=windowsdesktop-6.0
}
Expand Down
4 changes: 1 addition & 3 deletions src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ private async Task HandleActivationAsync()

if (!Application.Current.Windows.OfType<MainWindow>().Any())
{
_navigationWindow = (
_serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow
)!;
_navigationWindow = (_serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow)!;
_navigationWindow!.ShowWindow();

_navigationWindow.Navigate(typeof(Views.Pages.DashboardPage));
Expand Down
7 changes: 1 addition & 6 deletions src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ private void InitializeViewModel()
new DataColor
{
Color = new SolidColorBrush(
Color.FromArgb(
(byte)200,
(byte)random.Next(0, 250),
(byte)random.Next(0, 250),
(byte)random.Next(0, 250)
)
Color.FromArgb((byte)200, (byte)random.Next(0, 250), (byte)random.Next(0, 250), (byte)random.Next(0, 250))
)
}
);
Expand Down
16 changes: 4 additions & 12 deletions src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public partial class SettingsViewModel : ObservableObject, INavigationAware
private string _appVersion = String.Empty;

[ObservableProperty]
private Wpf.Ui.Appearance.ApplicationTheme _currentApplicationTheme = Wpf.Ui
.Appearance
.ApplicationTheme
.Unknown;
private Wpf.Ui.Appearance.ApplicationTheme _currentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Unknown;

public void OnNavigatedTo()
{
Expand All @@ -38,8 +35,7 @@ private void InitializeViewModel()

private string GetAssemblyVersion()
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString()
?? String.Empty;
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? String.Empty;
}

[RelayCommand]
Expand All @@ -51,9 +47,7 @@ private void OnChangeTheme(string parameter)
if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Light)
break;

Wpf.Ui.Appearance.ApplicationThemeManager.Apply(
Wpf.Ui.Appearance.ApplicationTheme.Light
);
Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Light);
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Light;

break;
Expand All @@ -62,9 +56,7 @@ private void OnChangeTheme(string parameter)
if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Dark)
break;

Wpf.Ui.Appearance.ApplicationThemeManager.Apply(
Wpf.Ui.Appearance.ApplicationTheme.Dark
);
Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Dark);
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Dark;

break;
Expand Down
9 changes: 2 additions & 7 deletions src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ public partial class MainWindow : INavigationWindow
{
public ViewModels.MainWindowViewModel ViewModel { get; }

public MainWindow(
ViewModels.MainWindowViewModel viewModel,
IPageService pageService,
INavigationService navigationService
)
public MainWindow(ViewModels.MainWindowViewModel viewModel, IPageService pageService, INavigationService navigationService)
{
ViewModel = viewModel;
DataContext = this;
Expand All @@ -37,8 +33,7 @@ INavigationService navigationService

public bool Navigate(Type pageType) => RootNavigation.Navigate(pageType);

public void SetPageService(IPageService pageService) =>
RootNavigation.SetPageService(pageService);
public void SetPageService(IPageService pageService) => RootNavigation.SetPageService(pageService);

public void ShowWindow() => Show();

Expand Down
10 changes: 2 additions & 8 deletions src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@ public DashboardPage()
DataContext = this;
InitializeComponent();

CounterTextBlock.SetCurrentValue(
System.Windows.Controls.TextBlock.TextProperty,
_counter.ToString()
);
CounterTextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.TextProperty, _counter.ToString());
}

private void OnBaseButtonClick(object sender, RoutedEventArgs e)
{
CounterTextBlock.SetCurrentValue(
System.Windows.Controls.TextBlock.TextProperty,
(++_counter).ToString()
);
CounterTextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.TextProperty, (++_counter).ToString());
}
}
7 changes: 1 addition & 6 deletions src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ private void InitializeData()
new DataColor
{
Color = new SolidColorBrush(
Color.FromArgb(
(byte)200,
(byte)random.Next(0, 250),
(byte)random.Next(0, 250),
(byte)random.Next(0, 250)
)
Color.FromArgb((byte)200, (byte)random.Next(0, 250), (byte)random.Next(0, 250), (byte)random.Next(0, 250))
)
}
);
Expand Down
3 changes: 1 addition & 2 deletions src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ private void OnDarkThemeRadioButtonChecked(object sender, RoutedEventArgs e)

private string GetAssemblyVersion()
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString()
?? String.Empty;
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? String.Empty;
}
}
18 changes: 4 additions & 14 deletions src/Wpf.Ui.FontMapper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
Console.WriteLine("Fluent System Icons Mapper");
System.Diagnostics.Debug.WriteLine("INFO | Fluent System Icons Mapper", "Wpf.Ui.FontMapper");

var workingDirectory = Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().Location
);
var workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

if (workingDirectory is null)
{
Expand Down Expand Up @@ -76,9 +74,7 @@ async Task FetchFontContents(FontSource source, string version)
await httpClient.GetFromJsonAsync<Dictionary<string, long>>(source.SourcePath)
?? throw new Exception("Unable to obtain JSON data");

sourceJsonContent = sourceJsonContent
.OrderBy(x => x.Value)
.ToDictionary(k => FormatIconName(k.Key), v => v.Value);
sourceJsonContent = sourceJsonContent.OrderBy(x => x.Value).ToDictionary(k => FormatIconName(k.Key), v => v.Value);

source.SetContents(sourceJsonContent);
source.UpdateVersion(version);
Expand All @@ -91,9 +87,7 @@ await httpClient.GetFromJsonAsync<Dictionary<string, long>>(source.SourcePath)

ICollection<string> regularKeys = regularIcons.Contents.Keys;
ICollection<string> filledKeys = filledIcons.Contents.Keys;
IEnumerable<string> keysToRemove = regularKeys
.Except(filledKeys)
.Concat(filledKeys.Except(regularKeys));
IEnumerable<string> keysToRemove = regularKeys.Except(filledKeys).Concat(filledKeys.Except(regularKeys));

foreach (var key in keysToRemove)
{
Expand Down Expand Up @@ -150,11 +144,7 @@ async Task WriteToFile(FontSource singleFont, string fileRootDirectory)
_ = enumMapStringBuilder.AppendLine($" {singleIcon.Key} = 0x{singleIcon.Value:X},");
}

_ = enumMapStringBuilder
.AppendLine("}")
.AppendLine(String.Empty)
.AppendLine("#pragma warning restore CS1591")
.Append("\r\n");
_ = enumMapStringBuilder.AppendLine("}").AppendLine(String.Empty).AppendLine("#pragma warning restore CS1591").Append("\r\n");

var fileInfo = new FileInfo(destinationPath);

Expand Down
15 changes: 3 additions & 12 deletions src/Wpf.Ui.Gallery/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,8 @@ public partial class App
services.AddSingleton<SettingsViewModel>();

// All other pages and view models
services.AddTransientFromNamespace(
"Wpf.Ui.Gallery.Views",
GalleryAssembly.Asssembly
);
services.AddTransientFromNamespace(
"Wpf.Ui.Gallery.ViewModels",
GalleryAssembly.Asssembly
);
services.AddTransientFromNamespace("Wpf.Ui.Gallery.Views", GalleryAssembly.Asssembly);
services.AddTransientFromNamespace("Wpf.Ui.Gallery.ViewModels", GalleryAssembly.Asssembly);
}
)
.Build();
Expand Down Expand Up @@ -92,10 +86,7 @@ private void OnExit(object sender, ExitEventArgs e)
/// <summary>
/// Occurs when an exception is thrown by an application but not handled.
/// </summary>
private void OnDispatcherUnhandledException(
object sender,
DispatcherUnhandledExceptionEventArgs e
)
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// For more info see https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?view=windowsdesktop-6.0
}
Expand Down
13 changes: 3 additions & 10 deletions src/Wpf.Ui.Gallery/Controllers/MonacoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,9 @@ await _webView.ExecuteScriptAsync(

public async Task SetLanguageAsync(MonacoLanguage monacoLanguage)
{
var languageId =
monacoLanguage == MonacoLanguage.ObjectiveC
? "objective-c"
: monacoLanguage.ToString().ToLower();
var languageId = monacoLanguage == MonacoLanguage.ObjectiveC ? "objective-c" : monacoLanguage.ToString().ToLower();

await _webView.ExecuteScriptAsync(
"monaco.editor.setModelLanguage(" + EditorObject + $".getModel(), \"{languageId}\");"
);
await _webView.ExecuteScriptAsync("monaco.editor.setModelLanguage(" + EditorObject + $".getModel(), \"{languageId}\");");
}

public async Task SetContentAsync(string contents)
Expand All @@ -76,8 +71,6 @@ public void DispatchScript(string script)
if (_webView == null)
return;

Application.Current.Dispatcher.InvokeAsync(
async () => await _webView!.ExecuteScriptAsync(script)
);
Application.Current.Dispatcher.InvokeAsync(async () => await _webView!.ExecuteScriptAsync(script));
}
}
22 changes: 7 additions & 15 deletions src/Wpf.Ui.Gallery/Controls/ControlExample.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public class ControlExample : Control
nameof(XamlCodeSource),
typeof(Uri),
typeof(ControlExample),
new PropertyMetadata(
null,
static (o, args) => ((ControlExample)o).OnXamlCodeSourceChanged((Uri)args.NewValue)
)
new PropertyMetadata(null, static (o, args) => ((ControlExample)o).OnXamlCodeSourceChanged((Uri)args.NewValue))
);

public static readonly DependencyProperty CsharpCodeProperty = DependencyProperty.Register(
Expand All @@ -48,17 +45,12 @@ public class ControlExample : Control
new PropertyMetadata(null)
);

public static readonly DependencyProperty CsharpCodeSourceProperty =
DependencyProperty.Register(
nameof(CsharpCodeSource),
typeof(Uri),
typeof(ControlExample),
new PropertyMetadata(
null,
static (o, args) =>
((ControlExample)o).OnCsharpCodeSourceChanged((Uri)args.NewValue)
)
);
public static readonly DependencyProperty CsharpCodeSourceProperty = DependencyProperty.Register(
nameof(CsharpCodeSource),
typeof(Uri),
typeof(ControlExample),
new PropertyMetadata(null, static (o, args) => ((ControlExample)o).OnCsharpCodeSourceChanged((Uri)args.NewValue))
);

public string? HeaderText
{
Expand Down
18 changes: 7 additions & 11 deletions src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ public class GalleryNavigationPresenter : System.Windows.Controls.Control
/// <summary>
/// Property for <see cref="TemplateButtonCommand"/>.
/// </summary>
public static readonly DependencyProperty TemplateButtonCommandProperty =
DependencyProperty.Register(
nameof(TemplateButtonCommand),
typeof(Wpf.Ui.Input.IRelayCommand),
typeof(GalleryNavigationPresenter),
new PropertyMetadata(null)
);
public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register(
nameof(TemplateButtonCommand),
typeof(Wpf.Ui.Input.IRelayCommand),
typeof(GalleryNavigationPresenter),
new PropertyMetadata(null)
);

public object? ItemsSource
{
Expand All @@ -46,10 +45,7 @@ public object? ItemsSource
/// </summary>
public GalleryNavigationPresenter()
{
SetValue(
TemplateButtonCommandProperty,
new Input.RelayCommand<Type>(o => OnTemplateButtonClick(o))
);
SetValue(TemplateButtonCommandProperty, new Input.RelayCommand<Type>(o => OnTemplateButtonClick(o)));
}

private void OnTemplateButtonClick(Type? pageType)
Expand Down
Loading

0 comments on commit 40ff2a6

Please sign in to comment.