2021-05-04 21:15:25 -07:00
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
# include "pch.h"
# include "AddProfile.h"
# include "AddProfile.g.cpp"
# include "AddProfilePageNavigationState.g.cpp"
# include "EnumEntry.h"
using namespace winrt : : Windows : : Foundation ;
using namespace winrt : : Windows : : System ;
using namespace winrt : : Windows : : UI : : Core ;
2022-02-02 12:45:05 -08:00
using namespace winrt : : Windows : : UI : : Xaml ;
2021-05-04 21:15:25 -07:00
using namespace winrt : : Windows : : UI : : Xaml : : Navigation ;
using namespace winrt : : Microsoft : : Terminal : : Settings : : Model ;
namespace winrt : : Microsoft : : Terminal : : Settings : : Editor : : implementation
{
AddProfile : : AddProfile ( )
{
InitializeComponent ( ) ;
2022-02-02 12:45:05 -08:00
Automation : : AutomationProperties : : SetName ( AddNewButton ( ) , RS_ ( L " AddProfile_AddNewTextBlock/Text " ) ) ;
Automation : : AutomationProperties : : SetName ( DuplicateButton ( ) , RS_ ( L " AddProfile_DuplicateTextBlock/Text " ) ) ;
2021-05-04 21:15:25 -07:00
}
void AddProfile : : OnNavigatedTo ( const NavigationEventArgs & e )
{
2026-02-10 12:31:19 -08:00
const auto args = e . Parameter ( ) . as < Editor : : NavigateToPageArgs > ( ) ;
_State = args . ViewModel ( ) . as < Editor : : AddProfilePageNavigationState > ( ) ;
2026-02-20 15:04:45 -08:00
BringIntoViewWhenLoaded ( args . ElementToFocus ( ) ) ;
2025-08-21 17:06:20 -07:00
TraceLoggingWrite (
g_hTerminalSettingsEditorProvider ,
" NavigatedToPage " ,
TraceLoggingDescription ( " Event emitted when the user navigates to a page in the settings UI " ) ,
TraceLoggingValue ( " addProfile " , " PageId " , " The identifier of the page that was navigated to " ) ,
TraceLoggingKeyword ( MICROSOFT_KEYWORD_MEASURES ) ,
TelemetryPrivacyDataTag ( PDT_ProductAndServiceUsage ) ) ;
2021-05-04 21:15:25 -07:00
}
void AddProfile : : AddNewClick ( const IInspectable & /*sender*/ ,
const Windows : : UI : : Xaml : : RoutedEventArgs & /*eventArgs*/ )
{
2025-08-21 17:06:20 -07:00
TraceLoggingWrite (
g_hTerminalSettingsEditorProvider ,
" AddNewProfile " ,
TraceLoggingDescription ( " Event emitted when the user adds a new profile " ) ,
TraceLoggingValue ( " EmptyProfile " , " Type " , " The type of the creation method (i.e. empty profile, duplicate) " ) ,
TraceLoggingKeyword ( MICROSOFT_KEYWORD_MEASURES ) ,
TelemetryPrivacyDataTag ( PDT_ProductAndServiceUsage ) ) ;
2021-05-04 21:15:25 -07:00
_State . RequestAddNew ( ) ;
}
void AddProfile : : DuplicateClick ( const IInspectable & /*sender*/ ,
const Windows : : UI : : Xaml : : RoutedEventArgs & /*eventArgs*/ )
{
if ( const auto selected = Profiles ( ) . SelectedItem ( ) )
{
2025-08-21 17:06:20 -07:00
const auto selectedProfile = selected . as < Model : : Profile > ( ) ;
TraceLoggingWrite (
g_hTerminalSettingsEditorProvider ,
" AddNewProfile " ,
TraceLoggingDescription ( " Event emitted when the user adds a new profile " ) ,
TraceLoggingValue ( " Duplicate " , " Type " , " The type of the creation method (i.e. empty profile, duplicate) " ) ,
TraceLoggingValue ( ! selectedProfile . Source ( ) . empty ( ) , " SourceProfileHasSource " , " True, if the source profile has a source (i.e. dynamic profile generator namespace, fragment). Otherwise, False, indicating it's based on a custom profile. " ) ,
TraceLoggingKeyword ( MICROSOFT_KEYWORD_MEASURES ) ,
TelemetryPrivacyDataTag ( PDT_ProductAndServiceUsage ) ) ;
_State . RequestDuplicate ( selectedProfile . Guid ( ) ) ;
2021-05-04 21:15:25 -07:00
}
}
2022-01-06 19:29:45 +01:00
void AddProfile : : ProfilesSelectionChanged ( const IInspectable & /*sender*/ ,
const Windows : : UI : : Xaml : : RoutedEventArgs & /*eventArgs*/ )
{
if ( ! _IsProfileSelected )
{
IsProfileSelected ( true ) ;
}
}
2021-05-04 21:15:25 -07:00
}