diff --git a/Tools/Get-LatestAddedSamples.ps1 b/Tools/Get-LatestAddedSamples.ps1 new file mode 100644 index 000000000..74bcafdb3 --- /dev/null +++ b/Tools/Get-LatestAddedSamples.ps1 @@ -0,0 +1,54 @@ +# Define the folder containing the WinUIGallery relative to the script location +$ControlPages = Join-Path -Path $PSScriptRoot -ChildPath "..\WinUIGallery\ControlPages" + +# Path to the ControlPages folder from repository root +$ControlPagesInRepo = "WinUIGallery/ControlPages" + +# Retrieve the list of files in the folder with their details +$filesWithDetails = git ls-tree -r HEAD --name-only $ControlPages | ForEach-Object { + $file = $_ # Current file path from the git tree + + # Check if the file is directly under the $currentFolder and not in subdirectories + if ($file -match "^$ControlPagesInRepo/[^/]+$") { + # Get the date of the first commit where the file was added (diff-filter A means "added") + $firstAddCommit = git log --diff-filter=A --reverse --format="%ai" -- $file | Select-Object -First 1 + + # If the file has an add commit (i.e., it's not a new file) + if ($firstAddCommit) { + # Create a custom object with file name and its first added commit date + [PSCustomObject]@{ + File = $file.Substring($ControlPagesInRepo.Length + 1) # Remove the folder path to get the file name + FirstAddCommitDate = $firstAddCommit # Date of the first commit where the file was added + } + } + } +} + +# Sort the files by their first add commit date in descending order (most recent first) +$sortedFiles = $filesWithDetails | Sort-Object FirstAddCommitDate -Descending + +# Create a hashtable to cache processed file base names to avoid duplicates +$cachedBaseNames = @{ } + +# Initialize the output string for the latest added samples +$LatestAddeddSamples = "Latest Added Samples:`n" + +# Process the sorted files +$sortedFiles | ForEach-Object { + # Remove file extensions and standardize the file name + $fileName = $_.File -replace '\.xaml\.cs$', '' -replace '\.xaml$', '' + $fileName = $fileName -replace 'Page$', '' + $date = $_.FirstAddCommitDate + + # Add the file to the output if it hasn't been cached yet (to avoid duplicates) + if (-not $cachedBaseNames.Contains($fileName)) { + $cachedBaseNames[$fileName] = $true # Mark the file name as cached + $LatestAddeddSamples += $fileName + " (" + $date + ")`n" # Append the file name to the output list + } +} + +# Output the list of the latest added samples +Write-Output $LatestAddeddSamples + +# Wait for the user to press Enter before closing the PowerShell window +Read-Host -Prompt "Press Enter to exit" diff --git a/Tools/Get-LatestUpdatedSamples.ps1 b/Tools/Get-LatestUpdatedSamples.ps1 new file mode 100644 index 000000000..3daf893d1 --- /dev/null +++ b/Tools/Get-LatestUpdatedSamples.ps1 @@ -0,0 +1,56 @@ +# Define the folder containing the WinUIGallery relative to the script location +$ControlPages = Join-Path -Path $PSScriptRoot -ChildPath "..\WinUIGallery\ControlPages" + +# Path to the ControlPages folder from repository root +$ControlPagesInRepo = "WinUIGallery/ControlPages" + +# Retrieve the list of files in the folder with their details +$filesWithDetails = git ls-tree -r HEAD --name-only $ControlPages | ForEach-Object { + $file = $_ # Current file path from the git tree + + # Check if the file is directly under the $currentFolder and not in subdirectories + if ($file -match "^$ControlPagesInRepo/[^/]+$") { + # Get the last commit date for the file + $lastCommitDate = git log -1 --format="%ai" -- $file + + # Get the commit status for the file (checks if it was modified in the last commit) + $commitStatus = git log -1 --name-status -- $file | Select-String -Pattern "^M" | ForEach-Object { $_.Line.Split()[0] } + + # If the file was modified ("M"), create a custom object with file details + if ($commitStatus -eq "M") { + [PSCustomObject]@{ + File = $file.Substring($ControlPagesInRepo.Length + 1) # Trim the folder path to get the file name + LastCommitDate = $lastCommitDate # Last commit date for the file + } + } + } +} + +# Sort the files by the last commit date in descending order +$sortedFiles = $filesWithDetails | Sort-Object LastCommitDate -Descending + +# Create a hashtable to cache processed file base names to avoid duplicates +$cachedBaseNames = @{ } + +# Initialize the output string for the latest updated samples +$LatestUpdatedSamples = "Latest Updated Samples:`n" + +# Process the sorted files +$sortedFiles | ForEach-Object { + # Remove file extensions and standardize the file name + $fileName = $_.File -replace '\.xaml\.cs$', '' -replace '\.xaml$', '' + $fileName = $fileName -replace 'Page$', '' + $date = $_.LastCommitDate + + # Add the file to the output if it hasn't been cached yet + if (-not $cachedBaseNames.Contains($fileName)) { + $cachedBaseNames[$fileName] = $true # Mark the file name as cached + $LatestUpdatedSamples += $fileName + " (" + $date + ")`n" # Append the file name to the output + } +} + +# Output the list of latest updated samples +Write-Output $LatestUpdatedSamples + +# Wait for the user to press Enter before closing the PowerShell window +Read-Host -Prompt "Press Enter to exit" diff --git a/Tools/readme.md b/Tools/readme.md new file mode 100644 index 000000000..d85bb44f5 --- /dev/null +++ b/Tools/readme.md @@ -0,0 +1,37 @@ +# Tools Folder + +The Tools folder contains a set of tools and utilities that are repeatedly used by developers to assist in managing and developing the WinUI Gallery. These tools streamline various development tasks, providing functionality to track, manage, and organize files within the repository. + +> **Note**: Before running any PowerShell script, you must set the execution policy to allow locally created scripts to run. Use the following command to set the policy: +> +> ```powershell +> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser +> ``` +> This ensures that PowerShell scripts downloaded from the internet are not run unless they are signed by a trusted publisher, while locally created scripts are allowed to run. + + +## Running scripts + +#### 1st Way: From File Explorer +- Step 1: Navigate to the `Tools` folder. +- Step 2: Right-click the `Get-LatestAddedSamples.ps1` script and select **Run with PowerShell**. +- Step 3: The script will output a list of newly added files along with their first commit dates. + +#### 2nd Way: From Visual Studio +- Step 1: Open `WinUIGallery` project in Visual Studio. +- Step 2: Navigate to the **Tools** menu and select **Open PowerShell Window**. +- Step 3: In the PowerShell window, type the following command: + ```powershell + ..\Tools\Get-LatestAddedSamples.ps1 + ``` +- Step 4: The script will output the list of added files. + +## Scripts + +### Get-LatestAddedSamples tool + +The goal of the `Get-LatestAddedSamples.ps1` script is to assist developers in identifying newly added files in the `ControlPages` directory, along with the date of their first commit. This helps in tracking the progress of new additions to the project and identifying which samples should be included on the home page, ensuring that the most recent content is always showcased. + +### Get-LatestUpdatedSamples tool + +The goal of the `Get-LatestUpdatedSamples.ps1` script is to help developers quickly identify files in the `ControlPages` directory that have been updated, along with their last commit dates. This information is useful for tracking changes made to the project, ensuring that developers can monitor updates to existing samples, and identifying which updated samples might need to be showcased on the home page. \ No newline at end of file diff --git a/WinUIGallery/DataModel/ControlInfoData.json b/WinUIGallery/DataModel/ControlInfoData.json index d28fc748d..13455c9ca 100644 --- a/WinUIGallery/DataModel/ControlInfoData.json +++ b/WinUIGallery/DataModel/ControlInfoData.json @@ -208,6 +208,7 @@ "Subtitle": "An object which is used to define the look and feel of a given command.", "ImagePath": "ms-appx:///Assets/ControlImages/AppBarSeparator.png", "Description": "An object which is used to define the look and feel of a given command, which can be reused across your app, and which is understood natively by the standard XAML controls.", + "IsUpdated": true, "Docs": [ { "Title": "Guidelines", @@ -499,6 +500,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/MenuFlyout.png", "Description": "A MenuFlyout displays lightweight UI that is light dismissed by clicking or tapping off of it. Use it to let the user choose from a contextual list of simple commands or options.", "Content": "
Look at the MenuFlyoutPage.xaml file in Visual Studio to see the full code.
", + "IsUpdated": true, "SourcePath": "/CommonStyles/MenuFlyout_themeresources.xaml", "Docs": [ { @@ -552,7 +554,6 @@ "Subtitle": "Touch gesture for quick menu actions on items.", "ImagePath": "ms-appx:///Assets/ControlImages/SwipeControl.png", "Description": "Touch gesture for quick menu actions on items.", - "IsUpdated": true, "Docs": [ { "Title": "SwipeControl - API", @@ -821,6 +822,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/TreeView.png", "Description": "The TreeView control is a hierarchical list pattern with expanding and collapsing nodes that contain nested items. ", "Content": "PullToRefresh can be used for a collection of items of any type. To populate the view, add items to the Items collection, or set the ItemsSource property to a data source.
Set an ItemTemplate to define the look of individual items.
Look at the ListViewPage.xaml file in Visual Studio to see the full code for this page.
", + "IsUpdated": true, "SourcePath": "/TreeView", "Docs": [ { @@ -1004,7 +1006,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Button.png", "Description": "The Button control provides a Click event to respond to user input from a touch, mouse, keyboard, stylus, or other input device. You can put different kinds of content in a button, such as text or an image, or you can restyle a button to give it a new look.", "Content": "The main purpose of a Button is to make something happen when a user clicks it. There are two ways you can make something happen:
Buttons often have only simple string content, but you can use any object as content. You can also change the style and template to give them any look you want.
Look at the ButtonPage.xaml file in Visual Studio to see the custom button style and template definitions used on this page.
", - "IsUpdated": true, "SourcePath": "/CommonStyles/Button_themeresources.xaml", "Docs": [ { @@ -1183,7 +1184,6 @@ "Subtitle": "A two-part button that displays a flyout when its secondary part is clicked.", "ImagePath": "ms-appx:///Assets/ControlImages/SplitButton.png", "Description": "The splitbutton is a dropdown button, but with an addition execution hit target.", - "IsUpdated": true, "SourcePath": "/SplitButton", "Docs": [ { @@ -1259,7 +1259,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/CheckBox.png", "Description": "CheckBox controls let the user select a combination of binary options. In contrast, RadioButton controls allow the user to select from mutually exclusive options. The indeterminate state is used to indicate that an option is set for some, but not all, child options. Don't allow users to set an indeterminate state directly to indicate a third option.", "Content": "Check and uncheck these controls to see how they look in each state. The label for each CheckBox is defined by its Content property.
Use a three-state CheckBox to show that none, some, or all of an items sub-options are checked. You have to add some code to do this. Take a look at the methods in the SelectAllMethods region of CheckBoxPage.xaml.cs to see how we did it.
", - "IsUpdated": true, "SourcePath": "/CommonStyles/CheckBox_themeresources.xaml", "Docs": [ { @@ -1428,7 +1427,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Slider.png", "Description": "Use a Slider when you want your users to be able to set defined, contiguous values (such as volume or brightness) or a range of discrete values (such as screen resolution settings).", "Content": "Look at the SliderPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "SourcePath": "/CommonStyles/Slider_themeresources.xaml", "Docs": [ { @@ -1502,6 +1500,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/InfoBadge.png", "Description": "Badging is a non-intrusive and intuitive way to display notifications or bring focus to an area within an app - whether that be for notifications, indicating new content, or showing an alert.", "Content": "Look at the InfoBadgePage.xaml file in Visual Studio to see the full code for this page.
", + "IsNew": true, "SourcePath": "/InfoBadge", "Docs": [ { @@ -1533,7 +1532,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/InfoBar.png", "Description": "Use an InfoBar control when a user should be informed of, acknowledge, or take action on a changed application state. By default the notification will remain in the content area until closed by the user but will not necessarily break user flow.", "Content": "Look at the InfoBarPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "SourcePath": "/InfoBar", "Docs": [ { @@ -1668,7 +1666,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/ContentDialog.png", "Description": "Use a ContentDialog to show relavant information or to provide a modal dialog experience that can show any XAML content.", "Content": "Look at the ContentDialog.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "SourcePath": "/CommonStyles/ContentDialog_themeresources.xaml", "Docs": [ { @@ -1759,6 +1756,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/TeachingTip.png", "Description": "The XAML TeachingTip Control provides a way for your app to guide and inform users in your application with a non-invasive and content rich notification. TeachingTip can be used for bringing focus to a new or important feature, teaching users how to perform a task, or enhancing the user workflow by providing contextually relevant information to their task at hand.", "Content": "Look at the TeachingTip.xaml file in Visual Studio to see the full code for this page.
", + "IsUpdated": true, "SourcePath": "/TeachingTip", "Docs": [ { @@ -1860,6 +1858,7 @@ "Description": "A ScrollView lets a user scroll, pan, and zoom to see content that's larger than the viewable area. The ItemsView has a ScrollView built into its control template to provide automatic scrolling.", "Content": "Look at the ScrollViewPage.xaml file in Visual Studio to see the full code for this page.
", "IsNew": true, + "IsUpdated": true, "SourcePath": "/ScrollView", "Docs": [ { @@ -1898,7 +1897,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/ScrollViewer.png", "Description": "A ScrollViewer lets a user scroll, pan, and zoom to see content that's larger than the viewable area. Many content controls, like ListView, have ScrollViewers built into their control templates to provide automatic scrolling.", "Content": "Look at the ScrollViewerPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "SourcePath": "/CommonStyles/ScrollViewer_themeresources.xaml", "Docs": [ { @@ -2309,6 +2307,7 @@ "Subtitle": "A container control that scales its content to a specified size.", "ImagePath": "ms-appx:///Assets/ControlImages/Viewbox.png", "Description": "Use a Viewbox control scale content up or down to a specified size.", + "IsNew": true, "Content": "Look at the ViewboxPage.xaml file in Visual Studio to see the full code for this page.
", "Docs": [ { @@ -2347,7 +2346,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/BreadcrumbBar.png", "Description": "The BreadcrumbBar control provides a common horizontal layout to display the trail of navigation taken to the current location. Resize to see the nodes crumble, starting at the root.", "Content": "Look at the BreadcrumbBarPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "SourcePath": "/Breadcrumb", "Docs": [ { @@ -2474,6 +2472,7 @@ "Subtitle": "A control that displays a collection of tabs that can be used to display several documents.", "ImagePath": "ms-appx:///Assets/ControlImages/TabView.png", "Description": "TabView provides the user with a collection of tabs that can be used to display several documents.", + "IsUpdated": true, "SourcePath": "/TabView", "Docs": [ { @@ -2548,6 +2547,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/CaptureElement.png", "Description": "You can use a MediaPlayerElement control to show a camera preview with a MediaCapture object.", "IsNew": true, + "IsUpdated": true, "Docs": [ { "Title": "MediaCapture - API", @@ -2760,7 +2760,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/AnimatedIcon.png", "Description": "An element that displays and controls an icon that animates when the user interacts with the control.", "Content": "Look at the AnimatedIconPage.xaml and AnimatedIconPage.xaml.cs files in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "SourcePath": "/AnimatedIcon", "Docs": [ { @@ -2787,6 +2786,7 @@ "Subtitle": "How to use a Resource Dictionary to enable compact sizing.", "ImagePath": "ms-appx:///Assets/ControlImages/CompactSizing.png", "Description": "Enables the creation of compact, smaller apps by adding a style resource at the app, page or control level.", + "IsUpdated": true, "Docs": [ { "Title": "Spacing", @@ -3002,6 +3002,7 @@ "Description": "Use NumberBox to allow users to enter algebraic equations and numeric input in your app.", "Content": "Look at the NumberBox.xaml file in Visual Studio to see the full code for this page.
", "SourcePath": "/NumberBox", + "IsUpdated": true, "Docs": [ { "Title": "NumberBox - API", @@ -3067,7 +3068,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/RichEditBox.png", "Description": "You can use a RichEditBox control to enter and edit rich text documents that contain formatted text, hyperlinks, and images. By default, the RichEditBox supports spell checking. You can make a RichEditBox read-only by setting its IsReadOnly property to true.", "Content": "On this page, you can type into the RichTextBox control and save it as a RichTextFormat (.rtf) document, or load an existing .rtf document. You can format the text as Bold or Underlined, and change the text color.
Look at the RichEditBoxPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "SourcePath": "/CommonStyles/RichEditBox_themeresources.xaml", "Docs": [ { @@ -3100,7 +3100,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/RichTextBlock.png", "Description": "RichTextBlock provides more advanced formatting features than the TextBlock control. You can apply character and paragraph formatting to the text in the RichTextBlock. For example, you can apply Bold, Italic, and Underline to any portion of the text in the control. You can use linked text containers (a RichTextBlock linked to RichTextBlockOverflow elements) to create advanced page layouts.", "Content": "Change the width of the app to see how the RichTextBlock overflows into additional columns as the app gets narrower.
Look at the RichTextBlockPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, "Docs": [ { "Title": "RichTextBlock - API", @@ -3459,7 +3458,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Clipboard.png", "Description": "Copy and paste to and from the system Clipboard.", "Content": "Look at the ClipboardPage.xaml file in Visual Studio to see the full code for this page.
", - "IsNew": true, "Docs": [ { "Title": "Clipboard - API", @@ -3478,7 +3476,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/FilePicker.png", "Description": "Shows how to access files and folders by letting the user choose them through the file pickers and how to save a file so that the user can specify the name, file type, and location of a file to save.", "Content": "Look at the FilePickerPage.xaml file in Visual Studio to see the full code for this page.
", - "IsNew": true, + "IsUpdated": true, "Docs": [ { "Title": "FilePicker - API", @@ -3497,6 +3495,7 @@ "Description": "Provides an edit box where you can type in some markup and load it to see how it looks and behaves.", "Content": "Look at the ScratchPadPage.xaml file in Visual Studio to see the full code for this page.
", "IsNew": true, + "isUpdated": true, "Docs": [ { "Title": "XamlReader - API",