Skip to content

Added EventTriggerBehavior #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Secret Value found!
on:
push:
public:
jobs:
scan:
name: gitleaks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install the gitleaks
run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz
shell: pwsh
- name: Extract the tar file
run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz
- name: Generate the report
id: gitleaks
run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json
shell: bash
continue-on-error: true
- name: Setup NuGet.exe
if: steps.gitleaks.outcome != 'success'
uses: nuget/setup-nuget@v1
with:
nuget-version: latest
- name: Install the dotnet
if: steps.gitleaks.outcome != 'success'
uses: actions/setup-dotnet@v3
with:
dotnet-version: '3.1.x'
- name: Install the report tool packages
if: steps.gitleaks.outcome != 'success'
run: |
nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/"
dir $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1
dotnet $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1/Email.dll "citeam@syncfusion.com" "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE"
exit 1
41 changes: 7 additions & 34 deletions MultiselectComboBox/MultiselectComboBox/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:editors="using:Syncfusion.UI.Xaml.Editors"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Interactions="using:Microsoft.Xaml.Interactions.Core"
mc:Ignorable="d">
<Grid>
<Grid.DataContext>
Expand All @@ -18,10 +20,14 @@
SelectionMode="Multiple"
MultiSelectionDisplayMode="Token"
PlaceholderText="Try anne"
InputSubmitted="OnInputSubmitted"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="500">
<Interactions:EventTriggerBehavior EventName="Loaded">
<!--<Interactions:EventTriggerBehavior EventName="InputSubmitted">-->
<Interactions:InvokeCommandAction Command="{Binding InputSubmitted}"/>
<!--<Interactions:CallMethodAction MethodName="OnInputSubmitted" TargetObject="{Binding}"/>-->
</Interactions:EventTriggerBehavior>
<editors:SfComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding EmailID}"/>
Expand All @@ -39,37 +45,4 @@
</editors:SfComboBox.TokenItemTemplate>
</editors:SfComboBox>
</Grid>
<!--<Grid>
<Grid.DataContext>
<local:ViewModel/>
</Grid.DataContext>
<editors:SfComboBox ItemsSource="{Binding Persons}"
IsEditable="True"
IsFilteringEnabled="True"
IsTextSearchEnabled="True"
FilterBehavior="{Binding}"
SearchBehavior="{Binding}"
SelectionMode="Multiple"
MultiSelectionDisplayMode="Token"
PlaceholderText="Try anne"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="500">
<editors:SfComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding EmailID}"/>
</DataTemplate>
</editors:SfComboBox.ItemTemplate>
<editors:SfComboBox.TokenItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Inlines>
<Run Text="{Binding FirstName}" />
<Run Text="{Binding LastName}" />
</TextBlock.Inlines>
</TextBlock>
</DataTemplate>
</editors:SfComboBox.TokenItemTemplate>
</editors:SfComboBox>
</Grid>-->
</Window>
39 changes: 0 additions & 39 deletions MultiselectComboBox/MultiselectComboBox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Syncfusion.UI.Xaml.Editors;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -30,43 +29,5 @@ public MainWindow()
{
this.InitializeComponent();
}

private async void OnInputSubmitted(object sender, ComboBoxInputSubmittedEventArgs e)
{
var emailString = e.Text;
bool isEmail = Regex.IsMatch(emailString, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

// If given input is a valid email format
if (isEmail)
{
// Create new person for selection
Person newPerson = new Person();
newPerson.EmailID = emailString;
int atIndex = emailString.LastIndexOf('@');
int dotIndex = emailString.IndexOf('.');
string name = emailString.Substring(0, atIndex);
if (name.Contains('.'))
{
newPerson.FirstName = name.Substring(0, dotIndex);
newPerson.LastName = name.Substring(dotIndex + 1);
}
else
{
newPerson.FirstName = name;
}
e.Item = newPerson;
}

// If email is id invalid, show error dialog.
else
{
var dialog = new ContentDialog();
dialog.CloseButtonText = "Close";
dialog.Content = "Invalid email id!";
dialog.Title = "Error";
dialog.XamlRoot = this.Content.XamlRoot;
await dialog.ShowAsync();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.196" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.8" />
<PackageReference Include="Syncfusion.Editors.WinUI" Version="19.4.0.41" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
Expand All @@ -33,6 +34,6 @@
Tools extension to be activated for this project even if the Windows App SDK Nuget
package has not yet been restored -->
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnablePreviewMsixTooling)'=='true'">
<ProjectCapability Include="Msix"/>
<ProjectCapability Include="Msix" />
</ItemGroup>
</Project>
56 changes: 54 additions & 2 deletions MultiselectComboBox/MultiselectComboBox/ViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Syncfusion.UI.Xaml.Core;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Syncfusion.UI.Xaml.Core;
using Syncfusion.UI.Xaml.Editors;
using System;
using System.Collections;
Expand All @@ -7,7 +9,9 @@
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Input;

namespace MultiselectComboBox
{
Expand All @@ -26,6 +30,14 @@ public ViewModel()
Persons.Add(createNewPerson("Nancy", "Davolio", "nancy.davolio@mail.com"));
Persons.Add(createNewPerson("Robert", "King", "robert.king@mail.com"));
Persons.Add(createNewPerson("Steven", "Buchanan", "steven.buchanan@mail.com"));

InputSubmitted = new DelegateCommand(OnInputSubmitted, CanExe);

}

private bool CanExe(object obj)
{
return true;
}

private ObservableCollection<Person> persons;
Expand All @@ -43,6 +55,8 @@ public ObservableCollection<Person> Persons
}
}

public ICommand InputSubmitted { get; set; }

private Person createNewPerson(string firstName, string lastName, string eMail)
{
return new Person
Expand All @@ -69,7 +83,6 @@ public List<int> GetMatchingIndexes(SfComboBox source, ComboBoxFilterInfo filter
return indices;
}


public List<int> GetMatchingIndexes2(SfComboBox source, ComboBoxFilterInfo filterInfo)
{
var items = Persons;
Expand All @@ -95,5 +108,44 @@ public List<int> GetMatchingIndexes2(SfComboBox source, ComboBoxFilterInfo filte

return indices;
}

public void OnInputSubmitted(object e)
{
var args = e as ComboBoxInputSubmittedEventArgs;
var emailString = args.Text;
bool isEmail = Regex.IsMatch(emailString, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

// If given input is a valid email format
if (isEmail)
{
// Create new person for selection
Person newPerson = new Person();
newPerson.EmailID = emailString;
int atIndex = emailString.LastIndexOf('@');
int dotIndex = emailString.IndexOf('.');
string name = emailString.Substring(0, atIndex);
if (name.Contains('.'))
{
newPerson.FirstName = name.Substring(0, dotIndex);
newPerson.LastName = name.Substring(dotIndex + 1);
}
else
{
newPerson.FirstName = name;
}
args.Item = newPerson;
}

// If email is id invalid, show error dialog.
else
{
var dialog = new ContentDialog();
dialog.CloseButtonText = "Close";
dialog.Content = "Invalid email id!";
dialog.Title = "Error";
// dialog.XamlRoot = this.Content.XamlRoot;
// await dialog.ShowAsync();
}
}
}
}