321 lines · 21.5 KB · Text
RawDownload
<UserControl x:Class="GSF.TimeSeries.UI.UserControls.SecurityUserControl"             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"              xmlns:sys="clr-namespace:System;assembly=mscorlib"             mc:Ignorable="d" d:DesignHeight="650" d:DesignWidth="850"             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             xmlns:uc="clr-namespace:GSF.TimeSeries.UI.UserControls"             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"             Background="Transparent">     <UserControl.Resources>        <ResourceDictionary>            <ResourceDictionary.MergedDictionaries>                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/StyleResource.xaml" />            </ResourceDictionary.MergedDictionaries>        </ResourceDictionary>    </UserControl.Resources>     <StackPanel Orientation="Vertical">                <StackPanel.Resources>            <Style TargetType="TextBox">                <Setter Property="HorizontalAlignment" Value="Left" />                <Setter Property="VerticalAlignment" Value="Center" />                <Setter Property="Width" Value="{StaticResource ItemSize}" />                <Setter Property="Margin" Value="2" />                <Setter Property="Validation.ErrorTemplate">                    <Setter.Value>                        <ControlTemplate>                            <Grid>                                <Polygon Points="0,0 10,0 0,10 0,0" HorizontalAlignment="Right" Fill="Red" FlowDirection="RightToLeft" />                                <Border BorderBrush="Red" BorderThickness="1">                                    <AdornedElementPlaceholder Name="ControlWithError" />                                </Border>                            </Grid>                        </ControlTemplate>                    </Setter.Value>                </Setter>                <Style.Triggers>                    <Trigger Property="Validation.HasError" Value="true">                        <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />                    </Trigger>                </Style.Triggers>            </Style>                        <Style TargetType="PasswordBox">                <Setter Property="HorizontalAlignment" Value="Left" />                <Setter Property="VerticalAlignment" Value="Center" />                <Setter Property="Width" Value="{StaticResource ItemSize}" />                <Setter Property="Margin" Value="2" />            </Style>             <Style TargetType="TextBlock">                <Setter Property="Margin" Value="2" />                <Setter Property="TextAlignment" Value="Right" />                <Setter Property="HorizontalAlignment" Value="Left" />                                                <Setter Property="VerticalAlignment" Value="Center" />            </Style>                        <Style TargetType="CheckBox">                <Setter Property="Margin" Value="2"/>                <Setter Property="VerticalAlignment" Value="Center"/>                <Setter Property="HorizontalAlignment" Value="Left"/>                            </Style>                        <Style TargetType="ListBox">                <Setter Property="Width" Value="160" />                <Setter Property="SelectionMode" Value="Multiple"/>                <Setter Property="Height" Value="130" />            </Style>                        <Style TargetType="Grid">                <Setter Property="Margin" Value="5,0,5,0"/>            </Style>                    </StackPanel.Resources>                <GroupBox x:Name="GroupBoxManageUsers">            <HeaderedContentControl.Header>                <TextBlock Text="Manage User Accounts" FontWeight="Bold"/>            </HeaderedContentControl.Header>                        <StackPanel Orientation="Vertical">                <ComboBox ItemsSource="{tsfBinding:Column Path=ItemsSource}" SelectedItem="{tsfBinding:Column Path=CurrentItem}" Width="250">                    <ComboBox.ItemTemplate>                        <DataTemplate>                            <TextBlock Text="{tsfBinding:Column Path=Name}" TextAlignment="Left" />                        </DataTemplate>                    </ComboBox.ItemTemplate>                </ComboBox>                 <Grid x:Name="GridManageUsers" DataContext="{Binding Path=CurrentItem, Mode=TwoWay}">                     <Grid.BindingGroup >                        <BindingGroup Name="input"/>                    </Grid.BindingGroup>                     <Grid.ColumnDefinitions>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                    </Grid.ColumnDefinitions>                    <Grid.RowDefinitions>                        <RowDefinition Height="Auto"/>                        <RowDefinition Height="Auto"/>                        <RowDefinition Height="Auto"/>                        <RowDefinition Height="Auto"/>                                            </Grid.RowDefinitions>                                        <TextBlock Grid.Row="0" Grid.Column="0" Text="Authentication" />                    <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">                        <RadioButton x:Name="RadioButtonWindows" Content="Windows" IsChecked="{Binding Path=UseADAuthentication}" GroupName="Authentication" Margin="0,0,2,0" />                        <RadioButton x:Name="RadioButtonDatabase" Content="Database" IsChecked="{Binding Path=UseADAuthentication, Converter={StaticResource NotConverter}}" GroupName="Authentication" />                    </StackPanel>                                        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0">                        <TextBlock Text="Username" Style="{StaticResource RequiredLabel}"/>                        <TextBlock Style="{StaticResource RequiredMarker}" />                    </StackPanel>                    <TextBox Grid.Row="1" Grid.Column="1" Text="{tsfBinding:Column Path=Name}" MaxLength="50"/>                    <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="0">                        <TextBlock Text="Password" Style="{StaticResource RequiredLabel}"/>                        <TextBlock Style="{StaticResource RequiredMarker}" />                    </StackPanel>                    <PasswordBox x:Name="TextBoxPassword" Grid.Row="2" Grid.Column="1" IsEnabled="{Binding ElementName=RadioButtonDatabase, Path=IsChecked}" />                    <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="2">                        <TextBlock Text="First Name" Style="{StaticResource RequiredLabel}"/>                        <TextBlock Style="{StaticResource RequiredMarker}" />                    </StackPanel>                    <TextBox Grid.Row="0" Grid.Column="3" Text="{tsfBinding:Column Path=FirstName}" IsEnabled="{Binding ElementName=RadioButtonDatabase, Path=IsChecked}" MaxLength="50"/>                    <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2">                        <TextBlock Text="Last Name" Style="{StaticResource RequiredLabel}"/>                        <TextBlock Style="{StaticResource RequiredMarker}" />                    </StackPanel>                    <TextBox Grid.Row="1" Grid.Column="3" Text="{tsfBinding:Column Path=LastName}" IsEnabled="{Binding ElementName=RadioButtonDatabase, Path=IsChecked}" MaxLength="50" />                    <TextBlock Grid.Row="2" Grid.Column="2" Text="Password Expiry" />                    <DatePicker Grid.Row="2" Grid.Column="3" SelectedDate="{tsfBinding:Column Path=ChangePasswordOn}" IsEnabled="{Binding ElementName=RadioButtonDatabase, Path=IsChecked}"/>                     <TextBlock Grid.Row="0" Grid.Column="4" Text="Phone"/>                    <TextBox Grid.Row="0" Grid.Column="5" Text="{tsfBinding:Column Path=Phone}" IsEnabled="{Binding ElementName=RadioButtonDatabase, Path=IsChecked}" MaxLength="50"/>                    <TextBlock Grid.Row="1" Grid.Column="4" Text="Email"/>                    <TextBox Grid.Row="1" Grid.Column="5" Text="{tsfBinding:Column Path=Email}" IsEnabled="{Binding ElementName=RadioButtonDatabase, Path=IsChecked}" MaxLength="256" />                    <CheckBox Content="Locked Out" Grid.Row="2" Grid.Column="5" IsChecked="{tsfBinding:Column Path=LockedOut}" />                                                        </Grid>                                <uc:DetailViewFooterUserControl DeleteCommand="{Binding DeleteCommand}" ClearCommand="{Binding ClearCommand}" SaveCommand="{Binding SaveCommand}"                    SaveEnabled="{tsfBinding:DataOperation GroupBoxManageUsers, Path=(Validation.HasError)}" />                        </StackPanel>                    </GroupBox>         <GroupBox x:Name="GroupBoxManageGroups">            <HeaderedContentControl.Header>                <TextBlock Text="Manage User Groups" FontWeight="Bold"/>            </HeaderedContentControl.Header>                        <StackPanel Orientation="Vertical">                 <ComboBox ItemsSource="{tsfBinding:Column Path=ItemsSource}" SelectedItem="{tsfBinding:Column Path=CurrentItem}" Width="250">                    <ComboBox.ItemTemplate>                        <DataTemplate>                            <TextBlock Text="{tsfBinding:Column Path=Name}" TextAlignment="Left" />                        </DataTemplate>                    </ComboBox.ItemTemplate>                </ComboBox>                 <Grid x:Name="GridManageGroups" DataContext="{Binding Path=CurrentItem, Mode=TwoWay}" HorizontalAlignment="Left">                     <Grid.BindingGroup >                        <BindingGroup Name="input"/>                    </Grid.BindingGroup>                     <Grid.ColumnDefinitions>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                    </Grid.ColumnDefinitions>                    <Grid.RowDefinitions>                                                <RowDefinition Height="Auto"/>                        <RowDefinition Height="Auto"/>                        <RowDefinition Height="Auto"/>                    </Grid.RowDefinitions>                     <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">                        <TextBlock Text="Name" Style="{StaticResource RequiredLabel}"/>                        <TextBlock Style="{StaticResource RequiredMarker}" />                    </StackPanel>                    <TextBox Grid.Row="0" Grid.Column="1" Text="{tsfBinding:Column Path=Name}" MaxLength="50" Width="180"/>                     <TextBlock Grid.Row="1" Grid.Column="0" Text="Description" />                    <TextBox Grid.Row="1" Grid.Column="1" Text="{tsfBinding:Column Path=Description}" TextWrapping="Wrap" Height="115" Width="180" ScrollViewer.VerticalScrollBarVisibility="Visible"/>                     <Grid Grid.Row="0" Grid.Column="2" Grid.RowSpan="2" Visibility="{Binding Path=DataContext.CanDelete, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}, Converter={StaticResource ObjectToVisibilityConverter}}">                                                <!--<Grid.Visibility>                            <Binding Path="DataContext.CanDelete" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=GroupBox}" Converter="{StaticResource ObjectToVisibilityConverter}">                                <Binding.ConverterParameter>                                    <sys:Boolean>True</sys:Boolean>                                </Binding.ConverterParameter>                            </Binding>                        </Grid.Visibility>-->                                                <Grid.ColumnDefinitions>                            <ColumnDefinition Width="Auto" />                            <ColumnDefinition Width="Auto" />                            <ColumnDefinition Width="Auto" />                        </Grid.ColumnDefinitions>                        <Grid.RowDefinitions>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                        </Grid.RowDefinitions>                         <TextBlock Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" Text="Press and hold CTRL key to select multiple users from the list." FontSize="{StaticResource SmallerTextSize}" Foreground="Red" HorizontalAlignment="Center"/>                        <TextBlock Grid.Column="0" Grid.Row="1" Text="Member Users" HorizontalAlignment="Left" FontWeight="Bold"/>                        <TextBlock Grid.Column="2" Grid.Row="1" Text="Available Users" HorizontalAlignment="Left" FontWeight="Bold"/>                        <ListBox x:Name="ListBoxCurrentGroupUsers" Grid.Column="0" Grid.Row="2" ItemsSource="{Binding Path=CurrentUsers}" DisplayMemberPath="Value" SelectionMode="Extended" />                        <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">                            <Button Content="&gt;&gt;" Command="{Binding Path=DataContext.RemoveUserCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}}" CommandParameter="{Binding ElementName=ListBoxCurrentGroupUsers, Path=SelectedItems}" ToolTip="Remove Users" Width="Auto" Margin="2"/>                            <Button Content="&lt;&lt;" Command="{Binding Path=DataContext.AddUserCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}}" CommandParameter="{Binding ElementName=ListBoxPossibleGroupUsers, Path=SelectedItems}" ToolTip="Add Users" Width="Auto" Margin="2"/>                        </StackPanel>                        <ListBox x:Name="ListBoxPossibleGroupUsers" Grid.Column="2" Grid.Row="2" ItemsSource="{Binding Path=PossibleUsers}" DisplayMemberPath="Value" SelectionMode="Extended" />                                                    <TextBlock x:Name="TextBlockGroupUsersMessage" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="3" Text="Changes Saved Successfully." Foreground="Navy" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2" Visibility="Collapsed"/>                    </Grid>                                </Grid>                 <uc:DetailViewFooterUserControl DeleteCommand="{Binding DeleteCommand}" ClearCommand="{Binding ClearCommand}" SaveCommand="{Binding SaveCommand}"                    SaveEnabled="{tsfBinding:DataOperation GridManageGroups, Path=(Validation.HasError)}" HorizontalAlignment="Left" />                            </StackPanel>                                </GroupBox>         <GroupBox x:Name="GroupBoxManageRoles">            <HeaderedContentControl.Header>                <TextBlock Text="Manage Application Roles" FontWeight="Bold"/>            </HeaderedContentControl.Header>                        <StackPanel Orientation="Vertical">                 <ComboBox ItemsSource="{tsfBinding:Column Path=ItemsSource}" SelectedItem="{tsfBinding:Column Path=CurrentItem}" Width="250">                    <ComboBox.ItemTemplate>                        <DataTemplate>                            <TextBlock Text="{tsfBinding:Column Path=Name}" TextAlignment="Left" Padding="1" />                        </DataTemplate>                    </ComboBox.ItemTemplate>                </ComboBox>                 <Grid x:Name="GridManageRoles" DataContext="{Binding Path=CurrentItem, Mode=TwoWay}">                    <Grid.ColumnDefinitions>                        <ColumnDefinition Width="Auto"/>                        <ColumnDefinition Width="Auto"/>                    </Grid.ColumnDefinitions>                    <Grid.RowDefinitions>                        <RowDefinition Height="Auto"/>                    </Grid.RowDefinitions>                                        <Grid Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left">                        <Grid.ColumnDefinitions>                            <ColumnDefinition Width="Auto" />                            <ColumnDefinition Width="Auto" />                            <ColumnDefinition Width="Auto" />                        </Grid.ColumnDefinitions>                        <Grid.RowDefinitions>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                        </Grid.RowDefinitions>                         <TextBlock Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" Text="Press and hold CTRL key to select multiple users from the list." FontSize="{StaticResource SmallerTextSize}" Foreground="Red" HorizontalAlignment="Center" />                        <TextBlock Grid.Column="0" Grid.Row="1" Text="Allowed Users" FontWeight="Bold" HorizontalAlignment="Left"/>                        <TextBlock Grid.Column="2" Grid.Row="1" Text="Available Users" FontWeight="Bold" HorizontalAlignment="Left"/>                        <ListBox x:Name="ListBoxCurrentRoleUsers" Grid.Column="0" Grid.Row="2" ItemsSource="{Binding Path=CurrentUsers}" DisplayMemberPath="Value" SelectionMode="Extended" />                        <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">                            <Button Content="&gt;&gt;" Command="{Binding Path=DataContext.RemoveUserCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}}" CommandParameter="{Binding ElementName=ListBoxCurrentRoleUsers, Path=SelectedItems}" ToolTip="Remove Users" Width="Auto" Margin="2"/>                            <Button Content="&lt;&lt;" Command="{Binding Path=DataContext.AddUserCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}}" CommandParameter="{Binding ElementName=ListBoxPossibleRoleUsers, Path=SelectedItems}" ToolTip="Add Users" Width="Auto" Margin="2"/>                        </StackPanel>                        <ListBox x:Name="ListBoxPossibleRoleUsers" Grid.Column="2" Grid.Row="2" ItemsSource="{Binding Path=PossibleUsers}" DisplayMemberPath="Value" SelectionMode="Extended" />                    </Grid>                    <Grid Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right">                        <Grid.ColumnDefinitions>                            <ColumnDefinition Width="Auto" />                            <ColumnDefinition Width="Auto" />                            <ColumnDefinition Width="Auto" />                        </Grid.ColumnDefinitions>                        <Grid.RowDefinitions>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                            <RowDefinition Height="Auto"/>                        </Grid.RowDefinitions>                         <TextBlock Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" Text="Press and hold CTRL key to select multiple groups from the list." FontSize="{StaticResource SmallerTextSize}" Foreground="Red" HorizontalAlignment="Center"/>                         <TextBlock Grid.Column="0" Grid.Row="1" Text="Allowed Groups" HorizontalAlignment="Left" FontWeight="Bold"/>                        <TextBlock Grid.Column="2" Grid.Row="1" Text="Available Groups" HorizontalAlignment="Left" FontWeight="Bold"/>                         <ListBox x:Name="ListBoxCurrentRoleGroups" Grid.Column="0" Grid.Row="2" ItemsSource="{Binding Path=CurrentGroups}" DisplayMemberPath="Value" SelectionMode="Extended" />                        <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">                            <Button Content="&gt;&gt;" Command="{Binding Path=DataContext.RemoveGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}}" CommandParameter="{Binding ElementName=ListBoxCurrentRoleGroups, Path=SelectedItems}" ToolTip="Remove Users" Width="Auto" Margin="2"/>                            <Button Content="&lt;&lt;" Command="{Binding Path=DataContext.AddGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}}" CommandParameter="{Binding ElementName=ListBoxPossibleRoleGroups, Path=SelectedItems}" ToolTip="Add Users" Width="Auto" Margin="2"/>                        </StackPanel>                        <ListBox x:Name="ListBoxPossibleRoleGroups" Grid.Column="2" Grid.Row="2" ItemsSource="{Binding Path=PossibleGroups}" DisplayMemberPath="Value" SelectionMode="Extended" />                    </Grid>                                    </Grid>             </StackPanel>                                </GroupBox>            </StackPanel></UserControl>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t