diff --git a/.clabot b/.clabot deleted file mode 100644 index fcd8e86bb..000000000 --- a/.clabot +++ /dev/null @@ -1,11 +0,0 @@ -{ - "contributors": [ - "dependabot[bot]", - "pomianowski", - "IvanDmitriev1", - "chucker", - "niels9001", - "syntax-tm", - "jdrames" - ] -} diff --git a/.csharpierrc b/.csharpierrc new file mode 100644 index 000000000..cf0ebaf20 --- /dev/null +++ b/.csharpierrc @@ -0,0 +1,10 @@ +{ + "printWidth": 130, + "useTabs": false, + "tabWidth": 4, + "preprocessorSymbolSets": [ + "", + "DEBUG", + "DEBUG,CODE_STYLE" + ] +} diff --git a/.github/policies/cla.yml b/.github/policies/cla.yml new file mode 100644 index 000000000..dd1a976b9 --- /dev/null +++ b/.github/policies/cla.yml @@ -0,0 +1,25 @@ +name: Contributor License Agreement Policy +description: CLA policy file + +resource: repository + +configuration: + cla: + content: https://raw.githubusercontent.com/lepoco/.github/main/CLA/lepoco.yml + minimalChangeRequired: + files: 1 + codeLines: 1 + bypassUsers: + - azclibot + - azure-pipelines[bot] + - azure-pipelines-bot + - azure-powershell-bot + - azuresdkciprbot + - dependabot[bot] + - dependabot-preview[bot] + - dotnet-bot + - dotnet-corert-bot + - dotnet-docker-bot + - dotnet-maestro[bot] + - dotnet-maestro-bot + - dotnet-winget-bot diff --git a/.github/policies/platformcontext.yml b/.github/policies/platformcontext.yml new file mode 100644 index 000000000..65870e8b2 --- /dev/null +++ b/.github/policies/platformcontext.yml @@ -0,0 +1,10 @@ +name: platform_context +description: The context for GitOps platform, this will drive GitOps specific policies +owner: +resource: repository +where: +configuration: + platformContext: + active: true +onFailure: +onSuccess: diff --git a/.github/workflows/wpf-ui-cd-docs.yaml b/.github/workflows/wpf-ui-cd-docs.yaml index 17f18ce99..94541ed45 100644 --- a/.github/workflows/wpf-ui-cd-docs.yaml +++ b/.github/workflows/wpf-ui-cd-docs.yaml @@ -26,7 +26,7 @@ jobs: runs-on: windows-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Pages uses: actions/configure-pages@v3 - name: Use Node.js 18.x diff --git a/.github/workflows/wpf-ui-cd-extension.yaml b/.github/workflows/wpf-ui-cd-extension.yaml index c400a5698..4850004c4 100644 --- a/.github/workflows/wpf-ui-cd-extension.yaml +++ b/.github/workflows/wpf-ui-cd-extension.yaml @@ -10,7 +10,7 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: microsoft/setup-msbuild@v1.3 with: msbuild-architecture: x64 diff --git a/.github/workflows/wpf-ui-cd-nuget.yaml b/.github/workflows/wpf-ui-cd-nuget.yaml index 51e13cdbc..65427fbe8 100644 --- a/.github/workflows/wpf-ui-cd-nuget.yaml +++ b/.github/workflows/wpf-ui-cd-nuget.yaml @@ -10,7 +10,7 @@ jobs: deploy: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: microsoft/setup-msbuild@v1.3 with: msbuild-architecture: x64 diff --git a/.github/workflows/wpf-ui-pr-validator.yaml b/.github/workflows/wpf-ui-pr-validator.yaml index ed21ffcf8..b8f337907 100644 --- a/.github/workflows/wpf-ui-pr-validator.yaml +++ b/.github/workflows/wpf-ui-pr-validator.yaml @@ -12,7 +12,7 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: microsoft/setup-msbuild@v1.3 with: msbuild-architecture: x64 diff --git a/Directory.Build.props b/Directory.Build.props index a4a9234bc..f585e6dc9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 3.0.0-preview.6 + 3.0.0-preview.7 11.0 true diff --git a/Directory.Packages.props b/Directory.Packages.props index b5a282e71..af80ca323 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,14 +11,14 @@ - + - + - + - \ No newline at end of file + diff --git a/Settings.XamlStyler b/Settings.XamlStyler index 3b3a21984..7e44ef314 100644 --- a/Settings.XamlStyler +++ b/Settings.XamlStyler @@ -7,7 +7,7 @@ "SeparateByGroups": false, "AttributeIndentation": 0, "AttributeIndentationStyle": 1, - "RemoveDesignTimeReferences": false, + "RemoveDesignTimeReferences": false, "IgnoreDesignTimeReferencePrefix": false, "EnableAttributeReordering": true, "AttributeOrderingRuleGroups": [ @@ -38,5 +38,7 @@ "ThicknessSeparator": 2, "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin", "FormatOnSave": true, - "CommentPadding": 2 + "CommentPadding": 2, + "IndentSize": 4, + "IndentWithTabs": false } \ No newline at end of file diff --git a/docs/codesnippet/Rtf/Hyperlink/RtfDocumentProcessor.cs b/docs/codesnippet/Rtf/Hyperlink/RtfDocumentProcessor.cs index b11ab0b4e..6062721b1 100644 --- a/docs/codesnippet/Rtf/Hyperlink/RtfDocumentProcessor.cs +++ b/docs/codesnippet/Rtf/Hyperlink/RtfDocumentProcessor.cs @@ -87,11 +87,7 @@ from attr in doc.Descendants().Attributes() #endregion #region FixLink - private static void FixLink( - XAttribute link, - RelativePath filePath, - HashSet linkToFiles - ) + private static void FixLink(XAttribute link, RelativePath filePath, HashSet linkToFiles) { string linkFile; string anchor = null; diff --git a/docs/codesnippet/Rtf/RtfBuildStep.cs b/docs/codesnippet/Rtf/RtfBuildStep.cs index 47f81467e..09974f580 100644 --- a/docs/codesnippet/Rtf/RtfBuildStep.cs +++ b/docs/codesnippet/Rtf/RtfBuildStep.cs @@ -22,9 +22,7 @@ public class RtfBuildStep : IDocumentBuildStep public void Build(FileModel model, IHostService host) { string content = (string)((Dictionary)model.Content)["conceptual"]; - content = _taskFactory - .StartNew(() => RtfToHtmlConverter.ConvertRtfToHtml(content)) - .Result; + content = _taskFactory.StartNew(() => RtfToHtmlConverter.ConvertRtfToHtml(content)).Result; ((Dictionary)model.Content)["conceptual"] = content; } #endregion diff --git a/docs/codesnippet/Rtf/RtfDocumentProcessor.cs b/docs/codesnippet/Rtf/RtfDocumentProcessor.cs index 3c1f54028..107aaa67a 100644 --- a/docs/codesnippet/Rtf/RtfDocumentProcessor.cs +++ b/docs/codesnippet/Rtf/RtfDocumentProcessor.cs @@ -59,11 +59,7 @@ public FileModel Load(FileAndType file, ImmutableDictionary 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 diff --git a/docs/templates/wpfui/src/nav.ts b/docs/templates/wpfui/src/nav.ts index 3fe73020f..40e55068f 100644 --- a/docs/templates/wpfui/src/nav.ts +++ b/docs/templates/wpfui/src/nav.ts @@ -56,7 +56,7 @@ export async function renderNavbar(): Promise {
${window.docfx.iconLinks?.map(i => html``)} ${themePicker(renderCore)} - Sponsor + Sponsor
` render(html`${menu} ${icons}`, navbar) diff --git a/docs/templates/wpfui/src/wpfui.scss b/docs/templates/wpfui/src/wpfui.scss index c9246a002..b46aef970 100644 --- a/docs/templates/wpfui/src/wpfui.scss +++ b/docs/templates/wpfui/src/wpfui.scss @@ -38,6 +38,13 @@ h5 { rgb(19, 104, 145) 50%, rgb(32, 135, 135) 75% ); + transition: background-position 0.5s ease-in-out; + background-size: 200% 200%; + background-position: 0% 0%; + + &:hover { + background-position: 100% 100%; + } } .btn-colorful { @@ -48,16 +55,14 @@ h5 { rgb(19, 104, 145) 50%, rgb(32, 135, 135) 75% ); -} + transition: background-position 0.5s ease-in-out; + background-size: 200% 200%; + background-position: 0% 0%; + color: white; -.btn-sponsor { - background-color: rgb(15, 163, 180); - background-image: linear-gradient( - 140deg, - rgb(0, 128, 154), - rgb(19, 104, 145) 50%, - rgb(32, 135, 135) 75% - ); + &:hover { + background-position: 100% 100%; + } } img { diff --git a/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs b/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs index 51ccb2d2d..b74b1aab6 100644 --- a/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs +++ b/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs @@ -95,10 +95,7 @@ private async void OnExit(object sender, ExitEventArgs e) /// /// Occurs when an exception is thrown by an application but not handled. /// - 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 } diff --git a/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs b/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs index c627bab09..3ab781637 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs @@ -48,9 +48,7 @@ private async Task HandleActivationAsync() if (!Application.Current.Windows.OfType().Any()) { - _navigationWindow = ( - _serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow - )!; + _navigationWindow = (_serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow)!; _navigationWindow!.ShowWindow(); _navigationWindow.Navigate(typeof(Views.Pages.DashboardPage)); diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs index c69801289..5883dcbb2 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs @@ -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)) ) } ); diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs index d9a82738a..a19721e9a 100644 --- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs +++ b/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs @@ -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() { @@ -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] @@ -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; @@ -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; diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs b/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs index 12a5c4072..0adca1281 100644 --- a/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs +++ b/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs @@ -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; @@ -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(); diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs b/src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs index 503a03859..9771f5bdd 100644 --- a/src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs +++ b/src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs @@ -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()); } } diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs b/src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs index 577720b35..d6883741d 100644 --- a/src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs +++ b/src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs @@ -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)) ) } ); diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs b/src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs index e48c18e52..9c732caea 100644 --- a/src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs +++ b/src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs @@ -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; } } diff --git a/src/Wpf.Ui.FontMapper/Program.cs b/src/Wpf.Ui.FontMapper/Program.cs index 45b62df60..e6e424f7f 100644 --- a/src/Wpf.Ui.FontMapper/Program.cs +++ b/src/Wpf.Ui.FontMapper/Program.cs @@ -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) { @@ -76,9 +74,7 @@ async Task FetchFontContents(FontSource source, string version) await httpClient.GetFromJsonAsync>(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); @@ -91,9 +87,7 @@ await httpClient.GetFromJsonAsync>(source.SourcePath) ICollection regularKeys = regularIcons.Contents.Keys; ICollection filledKeys = filledIcons.Contents.Keys; -IEnumerable keysToRemove = regularKeys - .Except(filledKeys) - .Concat(filledKeys.Except(regularKeys)); +IEnumerable keysToRemove = regularKeys.Except(filledKeys).Concat(filledKeys.Except(regularKeys)); foreach (var key in keysToRemove) { @@ -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); diff --git a/src/Wpf.Ui.Gallery/App.xaml.cs b/src/Wpf.Ui.Gallery/App.xaml.cs index 6e2c95309..673385918 100644 --- a/src/Wpf.Ui.Gallery/App.xaml.cs +++ b/src/Wpf.Ui.Gallery/App.xaml.cs @@ -27,10 +27,9 @@ public partial class App c.SetBasePath(AppContext.BaseDirectory); }) .ConfigureServices( - (context, services) => + (_, services) => { // App Host - services.AddHostedService(); // Main window container with navigation @@ -50,14 +49,8 @@ public partial class App services.AddSingleton(); // 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(); @@ -93,10 +86,7 @@ private void OnExit(object sender, ExitEventArgs e) /// /// Occurs when an exception is thrown by an application but not handled. /// - 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 } diff --git a/src/Wpf.Ui.Gallery/AssemblyInfo.cs b/src/Wpf.Ui.Gallery/AssemblyInfo.cs index a48496f49..89adb40fb 100644 --- a/src/Wpf.Ui.Gallery/AssemblyInfo.cs +++ b/src/Wpf.Ui.Gallery/AssemblyInfo.cs @@ -3,11 +3,4 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -[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) -)] +[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] diff --git a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs index 0c35254d3..391af63ae 100644 --- a/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs +++ b/src/Wpf.Ui.Gallery/Controllers/MonacoController.cs @@ -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) @@ -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)); } } diff --git a/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml b/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml index 1d42050f2..4635a3247 100644 --- a/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml +++ b/src/Wpf.Ui.Gallery/Controls/ControlExample.xaml @@ -32,7 +32,7 @@ + Text="C#" /> ((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( @@ -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 { diff --git a/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs b/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs index 105c4d0e5..28c1b652a 100644 --- a/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/GalleryNavigationPresenter.xaml.cs @@ -20,13 +20,12 @@ public class GalleryNavigationPresenter : System.Windows.Controls.Control /// /// Property for . /// - 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 { @@ -46,10 +45,7 @@ public object? ItemsSource /// public GalleryNavigationPresenter() { - SetValue( - TemplateButtonCommandProperty, - new Input.RelayCommand(o => OnTemplateButtonClick(o)) - ); + SetValue(TemplateButtonCommandProperty, new Input.RelayCommand(o => OnTemplateButtonClick(o))); } private void OnTemplateButtonClick(Type? pageType) diff --git a/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs b/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs index 9abf65f17..6efc421e7 100644 --- a/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/PageControlDocumentation.xaml.cs @@ -17,21 +17,18 @@ public class PageControlDocumentation : Control new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender) ); - public static readonly DependencyProperty DocumentationTypeProperty = - DependencyProperty.RegisterAttached( - "DocumentationType", - typeof(Type), - typeof(FrameworkElement), - new FrameworkPropertyMetadata(null) - ); + public static readonly DependencyProperty DocumentationTypeProperty = DependencyProperty.RegisterAttached( + "DocumentationType", + typeof(Type), + typeof(FrameworkElement), + new FrameworkPropertyMetadata(null) + ); public static bool GetShow(FrameworkElement target) => (bool)target.GetValue(ShowProperty); - public static void SetShow(FrameworkElement target, bool show) => - target.SetValue(ShowProperty, show); + public static void SetShow(FrameworkElement target, bool show) => target.SetValue(ShowProperty, show); - public static Type? GetDocumentationType(FrameworkElement target) => - (Type?)target.GetValue(DocumentationTypeProperty); + public static Type? GetDocumentationType(FrameworkElement target) => (Type?)target.GetValue(DocumentationTypeProperty); public static void SetDocumentationType(FrameworkElement target, Type type) => target.SetValue(DocumentationTypeProperty, type); @@ -43,21 +40,19 @@ public static void SetDocumentationType(FrameworkElement target, Type type) => new FrameworkPropertyMetadata(null) ); - public static readonly DependencyProperty IsDocumentationLinkVisibleProperty = - DependencyProperty.Register( - nameof(IsDocumentationLinkVisible), - typeof(Visibility), - typeof(PageControlDocumentation), - new FrameworkPropertyMetadata(Visibility.Collapsed) - ); + public static readonly DependencyProperty IsDocumentationLinkVisibleProperty = DependencyProperty.Register( + nameof(IsDocumentationLinkVisible), + typeof(Visibility), + typeof(PageControlDocumentation), + new FrameworkPropertyMetadata(Visibility.Collapsed) + ); - public static readonly DependencyProperty TemplateButtonCommandProperty = - DependencyProperty.Register( - nameof(TemplateButtonCommand), - typeof(ICommand), - typeof(PageControlDocumentation), - new PropertyMetadata(null) - ); + public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register( + nameof(TemplateButtonCommand), + typeof(ICommand), + typeof(PageControlDocumentation), + new PropertyMetadata(null) + ); public INavigationView? NavigationView { @@ -78,10 +73,7 @@ public PageControlDocumentation() Loaded += static (sender, _) => ((PageControlDocumentation)sender).OnLoaded(); Unloaded += static (sender, _) => ((PageControlDocumentation)sender).OnUnloaded(); - SetValue( - TemplateButtonCommandProperty, - new CommunityToolkit.Mvvm.Input.RelayCommand(OnClick) - ); + SetValue(TemplateButtonCommandProperty, new CommunityToolkit.Mvvm.Input.RelayCommand(OnClick)); } private FrameworkElement? _page; @@ -135,8 +127,7 @@ private void OnClick(string? param) string navigationUrl = param switch { - "doc" when GetDocumentationType(_page) is { } documentationType - => CreateUrlForDocumentation(documentationType), + "doc" when GetDocumentationType(_page) is { } documentationType => CreateUrlForDocumentation(documentationType), "xaml" => CreateUrlForGithub(_page.GetType(), ".xaml"), "c#" => CreateUrlForGithub(_page.GetType(), ".xaml.cs"), _ => String.Empty @@ -164,9 +155,7 @@ private static string CreateUrlForGithub(Type pageType, ReadOnlySpan fileE const string baseUrl = "https://github.com/lepoco/wpfui/tree/main/src/Wpf.Ui.Gallery/"; const string baseNamespace = "Wpf.Ui.Gallery"; - var pageFullNameWithoutBaseNamespace = pageType.FullName - .AsSpan() - .Slice(baseNamespace.Length + 1); + var pageFullNameWithoutBaseNamespace = pageType.FullName.AsSpan().Slice(baseNamespace.Length + 1); Span pageUrl = stackalloc char[pageFullNameWithoutBaseNamespace.Length]; pageFullNameWithoutBaseNamespace.CopyTo(pageUrl); diff --git a/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs b/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs index 8f53efc43..364c6b866 100644 --- a/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs +++ b/src/Wpf.Ui.Gallery/Controls/TypographyControl.xaml.cs @@ -18,19 +18,15 @@ public class TypographyControl : Control new PropertyMetadata(string.Empty) ); - public static readonly DependencyProperty ExampleFontTypographyProperty = - DependencyProperty.Register( - nameof(ExampleFontTypography), - typeof(FontTypography), - typeof(TypographyControl), - new PropertyMetadata( - FontTypography.Body, - static (o, args) => - ((TypographyControl)o).OnExampleFontTypographyChanged( - (FontTypography)args.NewValue - ) - ) - ); + public static readonly DependencyProperty ExampleFontTypographyProperty = DependencyProperty.Register( + nameof(ExampleFontTypography), + typeof(FontTypography), + typeof(TypographyControl), + new PropertyMetadata( + FontTypography.Body, + static (o, args) => ((TypographyControl)o).OnExampleFontTypographyChanged((FontTypography)args.NewValue) + ) + ); public static readonly DependencyProperty VariableFontProperty = DependencyProperty.Register( nameof(VariableFont), @@ -46,13 +42,12 @@ public class TypographyControl : Control new PropertyMetadata(string.Empty) ); - public static readonly DependencyProperty FontTypographyStyleProperty = - DependencyProperty.Register( - nameof(FontTypographyStyle), - typeof(string), - typeof(TypographyControl), - new PropertyMetadata(FontTypography.Body.ToString()) - ); + public static readonly DependencyProperty FontTypographyStyleProperty = DependencyProperty.Register( + nameof(FontTypographyStyle), + typeof(string), + typeof(TypographyControl), + new PropertyMetadata(FontTypography.Body.ToString()) + ); public string Example { diff --git a/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs b/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs index b1e0579bf..f17a7ea75 100644 --- a/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs +++ b/src/Wpf.Ui.Gallery/ControlsLookup/ControlPages.cs @@ -11,14 +11,9 @@ static class ControlPages public static IEnumerable All() { - foreach ( - var type in GalleryAssembly.Asssembly - .GetTypes() - .Where(t => t.IsDefined(typeof(GalleryPageAttribute))) - ) + foreach (var type in GalleryAssembly.Asssembly.GetTypes().Where(t => t.IsDefined(typeof(GalleryPageAttribute)))) { - var galleryPageAttribute = type.GetCustomAttributes() - .FirstOrDefault(); + var galleryPageAttribute = type.GetCustomAttributes().FirstOrDefault(); if (galleryPageAttribute is not null) { diff --git a/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs b/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs index b1e88011f..ebaa22dbb 100644 --- a/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs +++ b/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs @@ -17,14 +17,7 @@ params Assembly[] assemblies { IEnumerable types = assembly .GetTypes() - .Where( - x => - x.IsClass - && x.Namespace!.StartsWith( - namespaceName, - StringComparison.InvariantCultureIgnoreCase - ) - ); + .Where(x => x.IsClass && x.Namespace!.StartsWith(namespaceName, StringComparison.InvariantCultureIgnoreCase)); foreach (Type? type in types) { diff --git a/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs b/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs index 4c9748d89..26b38689f 100644 --- a/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs +++ b/src/Wpf.Ui.Gallery/Helpers/NameToPageTypeConverter.cs @@ -17,8 +17,6 @@ internal class NameToPageTypeConverter { pageName = pageName.Trim().ToLower() + "page"; - return PageTypes.FirstOrDefault( - singlePageType => singlePageType.Name.ToLower() == pageName - ); + return PageTypes.FirstOrDefault(singlePageType => singlePageType.Name.ToLower() == pageName); } } diff --git a/src/Wpf.Ui.Gallery/Helpers/NullToVisibilityConverter.cs b/src/Wpf.Ui.Gallery/Helpers/NullToVisibilityConverter.cs index 607695d0d..4809b87ec 100644 --- a/src/Wpf.Ui.Gallery/Helpers/NullToVisibilityConverter.cs +++ b/src/Wpf.Ui.Gallery/Helpers/NullToVisibilityConverter.cs @@ -12,12 +12,7 @@ public object Convert(object? value, Type targetType, object? parameter, Culture return value is null ? Visibility.Collapsed : Visibility.Visible; } - public object ConvertBack( - object? value, - Type targetType, - object? parameter, - CultureInfo culture - ) + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { throw new NotImplementedException(); } diff --git a/src/Wpf.Ui.Gallery/Services/ApplicationHostService.cs b/src/Wpf.Ui.Gallery/Services/ApplicationHostService.cs index 59c47a45d..ff8007b58 100644 --- a/src/Wpf.Ui.Gallery/Services/ApplicationHostService.cs +++ b/src/Wpf.Ui.Gallery/Services/ApplicationHostService.cs @@ -4,6 +4,7 @@ // All Rights Reserved. using Wpf.Ui.Gallery.Services.Contracts; +using Wpf.Ui.Gallery.Views.Pages; using Wpf.Ui.Gallery.Views.Windows; namespace Wpf.Ui.Gallery.Services; @@ -25,33 +26,44 @@ public ApplicationHostService(IServiceProvider serviceProvider) /// Triggered when the application host is ready to start the service. /// /// Indicates that the start process has been aborted. - public async Task StartAsync(CancellationToken cancellationToken) + public Task StartAsync(CancellationToken cancellationToken) { - await HandleActivationAsync(); + return HandleActivationAsync(); } /// /// Triggered when the application host is performing a graceful shutdown. /// /// Indicates that the shutdown process should no longer be graceful. - public async Task StopAsync(CancellationToken cancellationToken) + public Task StopAsync(CancellationToken cancellationToken) { - await Task.CompletedTask; + return Task.CompletedTask; } /// /// Creates main window during activation. /// - private async Task HandleActivationAsync() + private Task HandleActivationAsync() { - await Task.CompletedTask; + if (Application.Current.Windows.OfType().Any()) + { + return Task.CompletedTask; + } + + IWindow mainWindow = _serviceProvider.GetRequiredService(); + mainWindow.Loaded += OnMainWindowLoaded; + mainWindow?.Show(); - if (!Application.Current.Windows.OfType().Any()) + return Task.CompletedTask; + } + + private void OnMainWindowLoaded(object sender, RoutedEventArgs e) + { + if (sender is not MainWindow mainWindow) { - var mainWindow = _serviceProvider.GetService(typeof(IWindow)) as IWindow; - mainWindow?.Show(); + return; } - await Task.CompletedTask; + _ = mainWindow.NavigationView.Navigate(typeof(DashboardPage)); } } diff --git a/src/Wpf.Ui.Gallery/Services/Contracts/IWindow.cs b/src/Wpf.Ui.Gallery/Services/Contracts/IWindow.cs index 89f17eef1..9aeb4927e 100644 --- a/src/Wpf.Ui.Gallery/Services/Contracts/IWindow.cs +++ b/src/Wpf.Ui.Gallery/Services/Contracts/IWindow.cs @@ -7,5 +7,7 @@ namespace Wpf.Ui.Gallery.Services.Contracts; public interface IWindow { + event RoutedEventHandler Loaded; + void Show(); } diff --git a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs index 05d6d439b..8ce948284 100644 --- a/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs +++ b/src/Wpf.Ui.Gallery/Services/WindowsProviderService.cs @@ -17,9 +17,7 @@ public WindowsProviderService(IServiceProvider serviceProvider) public void Show() where T : class { if (!typeof(Window).IsAssignableFrom(typeof(T))) - throw new InvalidOperationException( - $"The window class should be derived from {typeof(Window)}." - ); + throw new InvalidOperationException($"The window class should be derived from {typeof(Window)}."); var windowInstance = _serviceProvider.GetService() as Window; diff --git a/src/Wpf.Ui.Gallery/Usings.cs b/src/Wpf.Ui.Gallery/Usings.cs index e67921be7..6fef748bb 100644 --- a/src/Wpf.Ui.Gallery/Usings.cs +++ b/src/Wpf.Ui.Gallery/Usings.cs @@ -24,4 +24,4 @@ global using System.Windows.Input; global using System.Windows.Markup; global using System.Windows.Media; -global using System.Windows.Threading; \ No newline at end of file +global using System.Windows.Threading; diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs index 1241c8dc3..47eff6a4f 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs @@ -28,9 +28,7 @@ private void OnSelectAllChecked(object sender) return; if (checkBox.IsChecked == null) - checkBox.IsChecked = !( - OptionOneCheckBoxChecked && OptionTwoCheckBoxChecked && OptionThreeCheckBoxChecked - ); + checkBox.IsChecked = !(OptionOneCheckBoxChecked && OptionTwoCheckBoxChecked && OptionThreeCheckBoxChecked); if (checkBox.IsChecked == true) { @@ -51,9 +49,7 @@ private void OnSingleChecked(string option) { if (OptionOneCheckBoxChecked && OptionTwoCheckBoxChecked && OptionThreeCheckBoxChecked) SelectAllCheckBoxChecked = true; - else if ( - !OptionOneCheckBoxChecked && !OptionTwoCheckBoxChecked && !OptionThreeCheckBoxChecked - ) + else if (!OptionOneCheckBoxChecked && !OptionTwoCheckBoxChecked && !OptionThreeCheckBoxChecked) SelectAllCheckBoxChecked = false; else SelectAllCheckBoxChecked = null; diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkButtonViewModel.cs similarity index 88% rename from src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkViewModel.cs rename to src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkButtonViewModel.cs index 323568d3f..4152768a5 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkButtonViewModel.cs @@ -7,7 +7,7 @@ namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput; -public partial class HyperlinkViewModel : ObservableObject +public partial class HyperlinkButtonViewModel : ObservableObject { [ObservableProperty] private bool _isHyperlinkEnabled = true; @@ -16,7 +16,9 @@ public partial class HyperlinkViewModel : ObservableObject private void OnHyperlinkCheckboxChecked(object sender) { if (sender is not CheckBox checkbox) + { return; + } IsHyperlinkEnabled = !(checkbox?.IsChecked ?? false); } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs index 70a4e4156..68e777894 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs @@ -33,10 +33,7 @@ private ObservableCollection GenerateProducts() { ProductId = i, ProductCode = i, - ProductName = - adjectives[random.Next(0, adjectives.Length)] - + " " - + names[random.Next(0, names.Length)], + ProductName = adjectives[random.Next(0, adjectives.Length)] + " " + names[random.Next(0, names.Length)], UnitPrice = Math.Round(random.NextDouble() * 20.0, 3), UnitsInStock = random.Next(0, 100), IsVirtual = random.Next(0, 2) == 1 diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarDatePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarDatePickerViewModel.cs new file mode 100644 index 000000000..2a70e5f3d --- /dev/null +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarDatePickerViewModel.cs @@ -0,0 +1,8 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +namespace Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime; + +public partial class CalendarDatePickerViewModel : ObservableObject { } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/TimePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/TimePickerViewModel.cs new file mode 100644 index 000000000..0cd7c902d --- /dev/null +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/TimePickerViewModel.cs @@ -0,0 +1,8 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +namespace Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime; + +public partial class TimePickerViewModel : ObservableObject { } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs index 796604395..b5044fc45 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs @@ -125,8 +125,7 @@ private void UpdateSymbolData() SelectedSymbolName = selectedSymbol.Name; SelectedSymbolUnicodePoint = selectedSymbol.Code; SelectedSymbolTextGlyph = $"&#x{selectedSymbol.Code};"; - SelectedSymbolXaml = - $""; + SelectedSymbolXaml = $""; } private void UpdateSearchResults(string searchedText) @@ -142,9 +141,7 @@ private void UpdateSearchResults(string searchedText) var formattedText = searchedText.ToLower().Trim(); - FilteredIconsCollection = IconsCollection - .Where(icon => icon.Name.ToLower().Contains(formattedText)) - .ToArray(); + FilteredIconsCollection = IconsCollection.Where(icon => icon.Name.ToLower().Contains(formattedText)).ToArray(); return true; }); diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs index 7e22bb65a..22c9e7dc4 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs @@ -45,9 +45,7 @@ private async Task OnShowDialog(object content) [RelayCommand] private async Task OnShowSignInContentDialog() { - var termsOfUseContentDialog = new TermsOfUseContentDialog( - _contentDialogService.GetContentPresenter() - ); + var termsOfUseContentDialog = new TermsOfUseContentDialog(_contentDialogService.GetContentPresenter()); await termsOfUseContentDialog.ShowAsync(); } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs index 94124aa47..3d7cca1e3 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs @@ -5,4 +5,52 @@ namespace Wpf.Ui.Gallery.ViewModels.Pages.OpSystem; -public partial class ClipboardViewModel : ObservableObject { } +public partial class ClipboardViewModel : ObservableObject +{ + [ObservableProperty] + private string _textToCopy = "This text will be copied to the clipboard."; + + [ObservableProperty] + private string _clipboardContent = "Click the button!"; + + [ObservableProperty] + private Visibility _textCopiedVisibility = Visibility.Collapsed; + + [RelayCommand] + private async Task OnCopyTextToClipboard() + { + try + { + Clipboard.Clear(); + Clipboard.SetText(TextToCopy); + } + catch (Exception e) + { + Debug.WriteLine(e); + } + + if (TextCopiedVisibility == Visibility.Visible) + { + return; + } + + TextCopiedVisibility = Visibility.Visible; + + await Task.Delay(5000); + + TextCopiedVisibility = Visibility.Collapsed; + } + + [RelayCommand] + private void OnParseTextFromClipboard() + { + try + { + ClipboardContent = Clipboard.GetText(); + } + catch (Exception e) + { + Debug.WriteLine(e); + } + } +} diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs index 2c6cdb8a4..fa46aa6b2 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs @@ -3,6 +3,204 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using Microsoft.Win32; + namespace Wpf.Ui.Gallery.ViewModels.Pages.OpSystem; -public partial class FilePickerViewModel : ObservableObject { } +public partial class FilePickerViewModel : ObservableObject +{ + [ObservableProperty] + private Visibility _openedFilePathVisibility = Visibility.Collapsed; + + [ObservableProperty] + private string _openedFilePath = String.Empty; + + [ObservableProperty] + private Visibility _openedPicturePathVisibility = Visibility.Collapsed; + + [ObservableProperty] + private string _openedPicturePath = String.Empty; + + [ObservableProperty] + private Visibility _openedMultiplePathVisibility = Visibility.Collapsed; + + [ObservableProperty] + private string _openedMultiplePath = String.Empty; + + [ObservableProperty] + private Visibility _openedFolderPathVisibility = Visibility.Collapsed; + + [ObservableProperty] + private string _openedFolderPath = String.Empty; + + [ObservableProperty] + private string _fileToSaveName = String.Empty; + + [ObservableProperty] + private string _fileToSaveContents = String.Empty; + + [ObservableProperty] + private Visibility _savedFileNoticeVisibility = Visibility.Collapsed; + + [ObservableProperty] + private string _savedFileNotice = String.Empty; + + [RelayCommand] + public void OnOpenFile() + { + OpenedFilePathVisibility = Visibility.Collapsed; + + OpenFileDialog openFileDialog = + new() + { + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), + Filter = "All files (*.*)|*.*" + }; + + if (openFileDialog.ShowDialog() != true) + { + return; + } + + if (!File.Exists(openFileDialog.FileName)) + { + return; + } + + OpenedFilePath = openFileDialog.FileName; + OpenedFilePathVisibility = Visibility.Visible; + } + + [RelayCommand] + public void OnOpenPicture() + { + OpenedPicturePathVisibility = Visibility.Collapsed; + + OpenFileDialog openFileDialog = + new() + { + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), + Filter = "Image files (*.bmp;*.jpg;*.jpeg;*.png)|*.bmp;*.jpg;*.jpeg;*.png|All files (*.*)|*.*" + }; + + if (openFileDialog.ShowDialog() != true) + { + return; + } + + if (!File.Exists(openFileDialog.FileName)) + { + return; + } + + OpenedPicturePath = openFileDialog.FileName; + OpenedPicturePathVisibility = Visibility.Visible; + } + + [RelayCommand] + public void OnOpenMultiple() + { + OpenedMultiplePathVisibility = Visibility.Collapsed; + + OpenFileDialog openFileDialog = + new() + { + Multiselect = true, + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), + Filter = "All files (*.*)|*.*" + }; + + if (openFileDialog.ShowDialog() != true) + { + return; + } + + if (openFileDialog.FileNames.Length == 0) + { + return; + } + + var fileNames = openFileDialog.FileNames; + + OpenedMultiplePath = String.Join("\n", fileNames); + OpenedMultiplePathVisibility = Visibility.Visible; + } + + [RelayCommand] + public void OnOpenFolder() + { +#if NET8_0_OR_GREATER + OpenedFolderPathVisibility = Visibility.Collapsed; + + OpenFolderDialog openFolderDialog = + new() + { + Multiselect = true, + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + }; + + if (openFolderDialog.ShowDialog() != true) + { + return; + } + + if (openFolderDialog.FolderNames.Length == 0) + { + return; + } + + OpenedFolderPath = String.Join("\n", openFolderDialog.FolderNames); + OpenedFolderPathVisibility = Visibility.Visible; +#else + OpenedFolderPath = "OpenFolderDialog requires .NET 8 or newer"; + OpenedFolderPathVisibility = Visibility.Visible; +#endif + } + + [RelayCommand] + public async Task OnSaveFile(CancellationToken cancellation) + { + SavedFileNoticeVisibility = Visibility.Collapsed; + + SaveFileDialog saveFileDialog = + new() + { + Filter = "Text Files (*.txt)|*.txt", + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + }; + + if (!String.IsNullOrEmpty(FileToSaveName)) + { + var invalidChars = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); + + saveFileDialog.FileName = String + .Join("_", FileToSaveName.Split(invalidChars.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) + .Trim(); + } + + if (saveFileDialog.ShowDialog() != true) + { + return; + } + + if (File.Exists(saveFileDialog.FileName)) + { + // Protect the user from accidental writes + return; + } + + try + { + await File.WriteAllTextAsync(saveFileDialog.FileName, FileToSaveContents, cancellation); + } + catch (Exception e) + { + Debug.WriteLine(e); + + return; + } + + SavedFileNoticeVisibility = Visibility.Visible; + SavedFileNotice = $"File {saveFileDialog.FileName} was saved."; + } +} diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs index 8a1cee583..c352f14e5 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs @@ -16,10 +16,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() { @@ -50,8 +47,7 @@ private void OnThemeChanged(ApplicationTheme currentApplicationTheme, Color syst private string GetAssemblyVersion() { - return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() - ?? String.Empty; + return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? String.Empty; } [RelayCommand] @@ -65,9 +61,7 @@ private void OnChangeTheme(string parameter) 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; @@ -78,9 +72,7 @@ private void OnChangeTheme(string parameter) 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; diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs index 51991c57c..4f0576a22 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs @@ -18,7 +18,10 @@ public partial class WindowsViewModel : ObservableObject private IEnumerable _windowCards = new WindowCard[] { new("Monaco", "Visual Studio Code in your WPF app.", SymbolRegular.CodeBlock24, "monaco"), - new("Editor", "Text editor with tabbed background.", SymbolRegular.ScanText24, "editor") + new("Editor", "Text editor with tabbed background.", SymbolRegular.ScanText24, "editor"), +#if DEBUG + new("Sandbox", "Sandbox for controls testing.", SymbolRegular.ScanText24, "sandbox"), +#endif }; public WindowsViewModel(WindowsProviderService windowsProviderService) @@ -30,7 +33,9 @@ public WindowsViewModel(WindowsProviderService windowsProviderService) public void OnOpenWindow(string value) { if (String.IsNullOrEmpty(value)) + { return; + } switch (value) { @@ -41,6 +46,10 @@ public void OnOpenWindow(string value) case "editor": _windowsProviderService.Show(); break; + + case "sandbox": + _windowsProviderService.Show(); + break; } } } diff --git a/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs index 96e6836ce..f11a57a21 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs @@ -3,6 +3,8 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Windows.Controls; +using System.Windows.Controls.Primitives; using Wpf.Ui.Controls; using Wpf.Ui.Gallery.Views.Pages; using Wpf.Ui.Gallery.Views.Pages.BasicInput; @@ -35,77 +37,30 @@ public partial class MainWindowViewModel : ObservableObject Icon = new SymbolIcon { Symbol = SymbolRegular.DesignIdeas24 }, MenuItems = new object[] { - new NavigationViewItem( - "Typography", - SymbolRegular.TextFont24, - typeof(TypographyPage) - ), + new NavigationViewItem("Typography", SymbolRegular.TextFont24, typeof(TypographyPage)), new NavigationViewItem("Icons", SymbolRegular.Diversity24, typeof(IconsPage)), new NavigationViewItem("Colors", SymbolRegular.Color24, typeof(ColorsPage)) } }, new NavigationViewItem("All samples", SymbolRegular.List24, typeof(AllControlsPage)), new NavigationViewItemSeparator(), - new NavigationViewItem + new NavigationViewItem("Basic Input", SymbolRegular.CheckboxChecked24, typeof(BasicInputPage)) { - Content = "Basic input", - Icon = new SymbolIcon { Symbol = SymbolRegular.CheckboxChecked24 }, - TargetPageType = typeof(BasicInputPage), MenuItems = new object[] { - new NavigationViewItem { Content = "Anchor", TargetPageType = typeof(AnchorPage) }, - new NavigationViewItem { Content = "Button", TargetPageType = typeof(ButtonPage) }, - new NavigationViewItem - { - Content = "DropDownButton", - TargetPageType = typeof(DropDownButtonPage) - }, - new NavigationViewItem - { - Content = "Hyperlink", - TargetPageType = typeof(HyperlinkPage) - }, - new NavigationViewItem - { - Content = "ToggleButton", - TargetPageType = typeof(ToggleButtonPage) - }, - new NavigationViewItem - { - Content = "ToggleSwitch", - TargetPageType = typeof(ToggleSwitchPage) - }, - new NavigationViewItem - { - Content = "CheckBox", - TargetPageType = typeof(CheckBoxPage) - }, - new NavigationViewItem - { - Content = "ComboBox", - TargetPageType = typeof(ComboBoxPage) - }, - new NavigationViewItem - { - Content = "RadioButton", - TargetPageType = typeof(RadioButtonPage) - }, - new NavigationViewItem - { - Content = "RatingControl", - TargetPageType = typeof(RatingPage) - }, - new NavigationViewItem - { - Content = "ThumbRate", - TargetPageType = typeof(ThumbRatePage) - }, - new NavigationViewItem - { - Content = "SplitButton", - TargetPageType = typeof(SplitButtonPage) - }, - new NavigationViewItem { Content = "Slider", TargetPageType = typeof(SliderPage) }, + new NavigationViewItem(nameof(Anchor), typeof(AnchorPage)), + new NavigationViewItem(nameof(Wpf.Ui.Controls.Button), typeof(ButtonPage)), + new NavigationViewItem(nameof(DropDownButton), typeof(DropDownButtonPage)), + new NavigationViewItem(nameof(HyperlinkButton), typeof(HyperlinkButtonPage)), + new NavigationViewItem(nameof(ToggleButton), typeof(ToggleButtonPage)), + new NavigationViewItem(nameof(ToggleSwitch), typeof(ToggleSwitchPage)), + new NavigationViewItem(nameof(CheckBox), typeof(CheckBoxPage)), + new NavigationViewItem(nameof(ComboBox), typeof(ComboBoxPage)), + new NavigationViewItem(nameof(RadioButton), typeof(RadioButtonPage)), + new NavigationViewItem(nameof(RatingControl), typeof(RatingPage)), + new NavigationViewItem(nameof(ThumbRate), typeof(ThumbRatePage)), + new NavigationViewItem(nameof(SplitButton), typeof(SplitButtonPage)), + new NavigationViewItem(nameof(Slider), typeof(SliderPage)), } }, new NavigationViewItem @@ -115,93 +70,39 @@ public partial class MainWindowViewModel : ObservableObject TargetPageType = typeof(CollectionsPage), MenuItems = new object[] { - new NavigationViewItem - { - Content = "DataGrid", - TargetPageType = typeof(DataGridPage) - }, - new NavigationViewItem - { - Content = "ListBox", - TargetPageType = typeof(ListBoxPage) - }, - new NavigationViewItem - { - Content = "ListView", - TargetPageType = typeof(ListViewPage) - }, - new NavigationViewItem - { - Content = "TreeView", - TargetPageType = typeof(TreeViewPage) - }, + new NavigationViewItem(nameof(System.Windows.Controls.DataGrid), typeof(DataGridPage)), + new NavigationViewItem(nameof(ListBox), typeof(ListBoxPage)), + new NavigationViewItem(nameof(ListView), typeof(ListViewPage)), + new NavigationViewItem(nameof(TreeView), typeof(TreeViewPage)), #if DEBUG - new NavigationViewItem - { - Content = "TreeList", - TargetPageType = typeof(TreeListPage) - }, + new NavigationViewItem("TreeList", typeof(TreeListPage)), #endif } }, - new NavigationViewItem + new NavigationViewItem("Date & time", SymbolRegular.CalendarClock24, typeof(DateAndTimePage)) { - Content = "Date & time", - Icon = new SymbolIcon { Symbol = SymbolRegular.CalendarClock24 }, - TargetPageType = typeof(DateAndTimePage), MenuItems = new object[] { - new NavigationViewItem - { - Content = "Calendar", - TargetPageType = typeof(CalendarPage) - }, - new NavigationViewItem - { - Content = "DatePicker", - TargetPageType = typeof(DatePickerPage) - }, + new NavigationViewItem(nameof(CalendarDatePicker), typeof(CalendarDatePickerPage)), + new NavigationViewItem(nameof(System.Windows.Controls.Calendar), typeof(CalendarPage)), + new NavigationViewItem(nameof(DatePicker), typeof(DatePickerPage)), + new NavigationViewItem(nameof(TimePicker), typeof(TimePickerPage)) } }, - new NavigationViewItem + new NavigationViewItem("Dialogs & flyouts", SymbolRegular.Chat24, typeof(DialogsAndFlyoutsPage)) { - Content = "Dialogs & flyouts", - Icon = new SymbolIcon { Symbol = SymbolRegular.Chat24 }, - TargetPageType = typeof(DialogsAndFlyoutsPage), MenuItems = new object[] { - new NavigationViewItem - { - Content = "Snackbar", - TargetPageType = typeof(SnackbarPage) - }, - new NavigationViewItem - { - Content = "ContentDialog", - TargetPageType = typeof(ContentDialogPage) - }, - new NavigationViewItem { Content = "Flyout", TargetPageType = typeof(FlyoutPage) }, - new NavigationViewItem - { - Content = "MessageBox", - TargetPageType = typeof(MessageBoxPage) - }, + new NavigationViewItem(nameof(Snackbar), typeof(SnackbarPage)), + new NavigationViewItem(nameof(ContentDialog), typeof(ContentDialogPage)), + new NavigationViewItem(nameof(Flyout), typeof(FlyoutPage)), + new NavigationViewItem(nameof(Wpf.Ui.Controls.MessageBox), typeof(MessageBoxPage)), } }, #if DEBUG - new NavigationViewItem + new NavigationViewItem("Layout", SymbolRegular.News24, typeof(LayoutPage)) { - Content = "Layout", - Icon = new SymbolIcon { Symbol = SymbolRegular.News24 }, - TargetPageType = typeof(LayoutPage), - MenuItems = new object[] - { - new NavigationViewItem - { - Content = "Expander", - TargetPageType = typeof(ExpanderPage) - }, - } + MenuItems = new object[] { new NavigationViewItem("Expander", typeof(ExpanderPage)) } }, #endif new NavigationViewItem @@ -211,136 +112,52 @@ public partial class MainWindowViewModel : ObservableObject TargetPageType = typeof(MediaPage), MenuItems = new object[] { - new NavigationViewItem { Content = "Image", TargetPageType = typeof(ImagePage) }, - new NavigationViewItem { Content = "Canvas", TargetPageType = typeof(CanvasPage) }, - new NavigationViewItem - { - Content = "WebView", - TargetPageType = typeof(WebViewPage) - }, - new NavigationViewItem - { - Content = "WebBrowser", - TargetPageType = typeof(WebBrowserPage) - }, + new NavigationViewItem("Image", typeof(ImagePage)), + new NavigationViewItem("Canvas", typeof(CanvasPage)), + new NavigationViewItem("WebView", typeof(WebViewPage)), + new NavigationViewItem("WebBrowser", typeof(WebBrowserPage)) } }, - new NavigationViewItem + new NavigationViewItem("Navigation", SymbolRegular.Navigation24, typeof(NavigationPage)) { - Content = "Navigation", - Icon = new SymbolIcon { Symbol = SymbolRegular.Navigation24 }, - TargetPageType = typeof(NavigationPage), MenuItems = new object[] { - new NavigationViewItem - { - Content = "BreadcrumbBar", - TargetPageType = typeof(BreadcrumbBarPage) - }, - new NavigationViewItem - { - Content = "NavigationView", - TargetPageType = typeof(NavigationViewPage) - }, - new NavigationViewItem { Content = "Menu", TargetPageType = typeof(MenuPage) }, - new NavigationViewItem - { - Content = "Multilevel navigation", - TargetPageType = typeof(MultilevelNavigationPage) - }, - new NavigationViewItem - { - Content = "TabControl", - TargetPageType = typeof(TabControlPage) - }, + new NavigationViewItem("BreadcrumbBar", typeof(BreadcrumbBarPage)), + new NavigationViewItem("NavigationView", typeof(NavigationViewPage)), + new NavigationViewItem("Menu", typeof(MenuPage)), + new NavigationViewItem("Multilevel navigation", typeof(MultilevelNavigationPage)), + new NavigationViewItem("TabControl", typeof(TabControlPage)) } }, - new NavigationViewItem + new NavigationViewItem("Status & info", SymbolRegular.ChatBubblesQuestion24, typeof(StatusAndInfoPage)) { - Content = "Status & info", - Icon = new SymbolIcon { Symbol = SymbolRegular.ChatBubblesQuestion24 }, - TargetPageType = typeof(StatusAndInfoPage), MenuItems = new object[] { - new NavigationViewItem - { - Content = "InfoBar", - TargetPageType = typeof(InfoBarPage) - }, - new NavigationViewItem - { - Content = "ProgressBar", - TargetPageType = typeof(ProgressBarPage) - }, - new NavigationViewItem - { - Content = "ProgressRing", - TargetPageType = typeof(ProgressRingPage) - }, - new NavigationViewItem - { - Content = "ToolTip", - TargetPageType = typeof(ToolTipPage) - }, + new NavigationViewItem("InfoBar", typeof(InfoBarPage)), + new NavigationViewItem("ProgressBar", typeof(ProgressBarPage)), + new NavigationViewItem("ProgressRing", typeof(ProgressRingPage)), + new NavigationViewItem("ToolTip", typeof(ToolTipPage)) } }, - new NavigationViewItem + new NavigationViewItem("Text", SymbolRegular.DrawText24, typeof(TextPage)) { - Content = "Text", - Icon = new SymbolIcon { Symbol = SymbolRegular.DrawText24 }, - TargetPageType = typeof(TextPage), MenuItems = new object[] { - new NavigationViewItem - { - Content = "AutoSuggestBox", - TargetPageType = typeof(AutoSuggestBoxPage) - }, - new NavigationViewItem - { - Content = "NumberBox", - TargetPageType = typeof(NumberBoxPage) - }, - new NavigationViewItem - { - Content = "PasswordBox", - TargetPageType = typeof(PasswordBoxPage) - }, - new NavigationViewItem - { - Content = "RichTextBox", - TargetPageType = typeof(RichTextBoxPage) - }, - new NavigationViewItem { Content = "Label", TargetPageType = typeof(LabelPage) }, - new NavigationViewItem - { - Content = "TextBlock", - TargetPageType = typeof(TextBlockPage) - }, - new NavigationViewItem - { - Content = "TextBox", - TargetPageType = typeof(TextBoxPage) - }, + new NavigationViewItem(nameof(AutoSuggestBox), typeof(AutoSuggestBoxPage)), + new NavigationViewItem(nameof(NumberBox), typeof(NumberBoxPage)), + new NavigationViewItem(nameof(Wpf.Ui.Controls.PasswordBox), typeof(PasswordBoxPage)), + new NavigationViewItem(nameof(Wpf.Ui.Controls.RichTextBox), typeof(RichTextBoxPage)), + new NavigationViewItem(nameof(Label), typeof(LabelPage)), + new NavigationViewItem(nameof(Wpf.Ui.Controls.TextBlock), typeof(TextBlockPage)), + new NavigationViewItem(nameof(Wpf.Ui.Controls.TextBox), typeof(TextBoxPage)), } }, - new NavigationViewItem + new NavigationViewItem("System", SymbolRegular.Desktop24, typeof(OpSystemPage)) { - Content = "System", - Icon = new SymbolIcon { Symbol = SymbolRegular.Desktop24 }, - TargetPageType = typeof(OpSystemPage), MenuItems = new object[] { - new NavigationViewItem - { - Content = "Clipboard", - TargetPageType = typeof(ClipboardPage) - }, - new NavigationViewItem - { - Content = "FilePicker", - TargetPageType = typeof(FilePickerPage) - }, + new NavigationViewItem("Clipboard", typeof(ClipboardPage)), + new NavigationViewItem("FilePicker", typeof(FilePickerPage)), } }, new NavigationViewItem("Windows", SymbolRegular.WindowApps24, typeof(WindowsPage)) @@ -349,16 +166,11 @@ public partial class MainWindowViewModel : ObservableObject [ObservableProperty] private ICollection _footerMenuItems = new ObservableCollection() { - new NavigationViewItem - { - Content = "Settings", - Icon = new SymbolIcon { Symbol = SymbolRegular.Settings24 }, - TargetPageType = typeof(SettingsPage) - } + new NavigationViewItem("Settings", SymbolRegular.Settings24, typeof(SettingsPage)) }; [ObservableProperty] - private ObservableCollection _trayMenuItems = + private ObservableCollection _trayMenuItems = new() { new Wpf.Ui.Controls.MenuItem { Header = "Home", Tag = "tray_home" }, diff --git a/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs index b9c803f54..d25e3b648 100644 --- a/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs +++ b/src/Wpf.Ui.Gallery/ViewModels/Windows/MonacoWindowViewModel.cs @@ -20,10 +20,7 @@ public void SetWebView(WebView2 webView) webView.UseLayoutRounding = true; webView.DefaultBackgroundColor = System.Drawing.Color.Transparent; webView.Source = new Uri( - System.IO.Path.Combine( - System.AppDomain.CurrentDomain.BaseDirectory, - @"Assets\Monaco\index.html" - ) + System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"Assets\Monaco\index.html") ); _monacoController = new MonacoController(webView); diff --git a/src/Wpf.Ui.Gallery/ViewModels/Windows/SandboxWindowViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Windows/SandboxWindowViewModel.cs new file mode 100644 index 000000000..57011bb4a --- /dev/null +++ b/src/Wpf.Ui.Gallery/ViewModels/Windows/SandboxWindowViewModel.cs @@ -0,0 +1,12 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +namespace Wpf.Ui.Gallery.ViewModels.Windows; + +public partial class SandboxWindowViewModel : ObservableObject +{ + [ObservableProperty] + public string? _autoSuggestBoxText; +} diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/AnchorPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/AnchorPage.xaml index 3feac6a74..b8fc460f8 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/AnchorPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/AnchorPage.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/CheckBoxPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/CheckBoxPage.xaml index fe82b0b0d..f88433b8e 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/CheckBoxPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/CheckBoxPage.xaml @@ -1,4 +1,4 @@ - - + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml index 1c6c889ac..10a4add10 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml @@ -18,7 +18,7 @@ Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d"> - + - + - + - + - + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkButtonPage.xaml similarity index 79% rename from src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkPage.xaml rename to src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkButtonPage.xaml index 278135858..e5f8e900a 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkButtonPage.xaml @@ -1,5 +1,5 @@ - + + XamlCode="<ui:HyperlinkButton NavigateUri="https://" />"> - @@ -46,24 +46,24 @@ - + - + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkButtonPage.xaml.cs similarity index 65% rename from src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkPage.xaml.cs rename to src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkButtonPage.xaml.cs index 1f040d2b8..b292ec685 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/HyperlinkButtonPage.xaml.cs @@ -1,4 +1,4 @@ -// This Source Code Form is subject to the terms of the MIT License. +// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. @@ -10,11 +10,11 @@ namespace Wpf.Ui.Gallery.Views.Pages.BasicInput; [GalleryPage("Opens a link.", SymbolRegular.Link24)] -public partial class HyperlinkPage : INavigableView +public partial class HyperlinkButtonPage : INavigableView { - public HyperlinkViewModel ViewModel { get; } + public HyperlinkButtonViewModel ViewModel { get; } - public HyperlinkPage(HyperlinkViewModel viewModel) + public HyperlinkButtonPage(HyperlinkButtonViewModel viewModel) { ViewModel = viewModel; DataContext = this; diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/RadioButtonPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/RadioButtonPage.xaml index 83a35b029..36caf2865 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/RadioButtonPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/RadioButtonPage.xaml @@ -1,4 +1,4 @@ - - + - + - + - + - + - + @@ -74,7 +74,7 @@ Background="Green" CornerRadius="4,0,0,4" /> - + - + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/SplitButtonPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/SplitButtonPage.xaml.cs index 706b6a9e9..7f2f20c7a 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/SplitButtonPage.xaml.cs +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/SplitButtonPage.xaml.cs @@ -9,10 +9,7 @@ namespace Wpf.Ui.Gallery.Views.Pages.BasicInput; -[GalleryPage( - "Button with two parts that can be invoked separately.", - SymbolRegular.ControlButton24 -)] +[GalleryPage("Button with two parts that can be invoked separately.", SymbolRegular.ControlButton24)] public partial class SplitButtonPage : INavigableView { public SplitButtonViewModel ViewModel { get; } diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ThumbRatePage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ThumbRatePage.xaml index 93407f17d..8fb395864 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ThumbRatePage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ThumbRatePage.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleButtonPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleButtonPage.xaml index ba5ebe061..1e41a6490 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleButtonPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleButtonPage.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml index 498eb620f..25d54c574 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Collections/DataGridPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/Collections/DataGridPage.xaml index cc8fd42e9..376fa40f5 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Collections/DataGridPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/Collections/DataGridPage.xaml @@ -1,4 +1,4 @@ -https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGrid.cs - + - + <ListBox>\n diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Collections/ListViewPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/Collections/ListViewPage.xaml index 146fc2932..345d4b568 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Collections/ListViewPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/Collections/ListViewPage.xaml @@ -1,4 +1,4 @@ - - + <ListView ItemsSource="{Binding ViewModel.MyCollection}"><>\n diff --git a/src/Wpf.Ui.Gallery/Views/Pages/Collections/TreeViewPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/Collections/TreeViewPage.xaml index 9502fc78a..744975603 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/Collections/TreeViewPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/Collections/TreeViewPage.xaml @@ -1,4 +1,4 @@ - - - - <TreeView AllowDrop="True">\n - \t<TreeViewItem Header="Work Documents" IsExpanded="True">\n - \t\t<TreeViewItem Header="Feature Schedule"/>\n - \t</TreeViewItem>\n - </TreeView> - - - - - - - - - - - - + + + + <TreeView AllowDrop="True">\n + \t<TreeViewItem Header="Work Documents" IsExpanded="True">\n + \t\t<TreeViewItem Header="Feature Schedule"/>\n + \t</TreeViewItem>\n + </TreeView> + + + + + - - - + + + + + + + + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DashboardPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/DashboardPage.xaml index 099460f34..0dbc9eb16 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DashboardPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/DashboardPage.xaml @@ -206,31 +206,31 @@ FontSize="18" FontWeight="DemiBold" Text="Learn more" /> - - - - - + + + + + + + + + + + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/CalendarDatePickerPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/CalendarDatePickerPage.xaml.cs new file mode 100644 index 000000000..3a3112355 --- /dev/null +++ b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/CalendarDatePickerPage.xaml.cs @@ -0,0 +1,24 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +using Wpf.Ui.Controls; +using Wpf.Ui.Gallery.ControlsLookup; +using Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime; + +namespace Wpf.Ui.Gallery.Views.Pages.DateAndTime; + +[GalleryPage("Button opening Calendar.", SymbolRegular.CalendarRtl24)] +public partial class CalendarDatePickerPage : INavigableView +{ + public CalendarDatePickerViewModel ViewModel { get; init; } + + public CalendarDatePickerPage(CalendarDatePickerViewModel viewModel) + { + ViewModel = viewModel; + DataContext = this; + + InitializeComponent(); + } +} diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/CalendarPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/CalendarPage.xaml index d02bb67a8..d820dc013 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/CalendarPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/CalendarPage.xaml @@ -18,10 +18,12 @@ Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d"> - - - <Calendar/> - - - + + + + <Calendar/> + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DateAndTimePage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DateAndTimePage.xaml index b40c20ff7..21c44bea2 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DateAndTimePage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DateAndTimePage.xaml @@ -18,8 +18,10 @@ Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d"> - + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DatePickerPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DatePickerPage.xaml index 29ac0b810..a1012be28 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DatePickerPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/DatePickerPage.xaml @@ -18,10 +18,12 @@ Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d"> - - - <DatePicker/> - - - + + + + <DatePicker/> + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/TimePickerPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/TimePickerPage.xaml new file mode 100644 index 000000000..6d071f379 --- /dev/null +++ b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/TimePickerPage.xaml @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/TimePickerPage.xaml.cs b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/TimePickerPage.xaml.cs new file mode 100644 index 000000000..fed10c058 --- /dev/null +++ b/src/Wpf.Ui.Gallery/Views/Pages/DateAndTime/TimePickerPage.xaml.cs @@ -0,0 +1,24 @@ +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. +// Copyright (C) Leszek Pomianowski and WPF UI Contributors. +// All Rights Reserved. + +using Wpf.Ui.Controls; +using Wpf.Ui.Gallery.ControlsLookup; +using Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime; + +namespace Wpf.Ui.Gallery.Views.Pages.DateAndTime; + +[GalleryPage("allows a user to pick a time value.", SymbolRegular.Clock24)] +public partial class TimePickerPage : INavigableView +{ + public TimePickerViewModel ViewModel { get; init; } + + public TimePickerPage(TimePickerViewModel viewModel) + { + ViewModel = viewModel; + DataContext = this; + + InitializeComponent(); + } +} diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DesignGuidance/IconsPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/DesignGuidance/IconsPage.xaml index a7a6716b7..37b9b9cc0 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DesignGuidance/IconsPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/DesignGuidance/IconsPage.xaml @@ -33,7 +33,7 @@ Grid.Row="0" Text="WPF UI uses Fluent System Icons. Although this font was also created by Microsoft, it does not contain all the icons for Windows 11. If you need the missing icons, add Segoe Fluent Icons to your application." TextWrapping="WrapWithOverflow" /> - - diff --git a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml index 40bd9ade8..8f6567b8c 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/DialogsAndFlyouts/FlyoutPage.xaml @@ -19,33 +19,35 @@ Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d"> - - - - - - - - - -