<UserControl
    x:Class="SimpleRemote.Container.Home_Remote"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:mahControls="http://metro.mahapps.com/winfx/xaml/controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:control="clr-namespace:SimpleRemote.Controls"
    xmlns:dd="clr-namespace:SimpleRemote.Controls.WpfDragDrop"
    xmlns:core="clr-namespace:SimpleRemote.Core"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">

    <UserControl.Resources>
        <RoutedCommand x:Key="Selection" />
        <Style BasedOn="{StaticResource RemoteTreeViewItem}" TargetType="{x:Type control:RemoteTreeViewItem}" />
    </UserControl.Resources>

    <UserControl.CommandBindings>
        <CommandBinding Command="{StaticResource Selection}" Executed="SelectionCommand_Executed" />
    </UserControl.CommandBindings>

    <Grid x:Name="Grid_Main">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{x:Static core:UserSettings.HomeRemoteTreeView_Width}" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <TextBox
            x:Name="Text_Screen"
            Height="26"
            VerticalAlignment="Top"
            HorizontalContentAlignment="Stretch"
            mahControls:TextBoxHelper.ButtonCommand="{StaticResource Selection}"
            mahControls:TextBoxHelper.Watermark="输入关键字进行搜索"
            BorderThickness="0,0,0,1"
            FontSize="14"
            Style="{DynamicResource SearchMetroTextBox}"
            TextChanged="Text_Screen_TextChanged">
            <TextBox.InputBindings>
                <KeyBinding Key="Enter" Command="{StaticResource Selection}" />
            </TextBox.InputBindings>
        </TextBox>

        <TreeView
            x:Name="PART_RemoteTree"
            Margin="0,26,0,0"
            dd:DragDrop.IsDragSource="True"
            dd:DragDrop.IsDropTarget="True"
            BorderBrush="#FFDDDDD8"
            BorderThickness="0,0,0,0"
            KeyDown="TreeView_KeyDown"
            MouseDoubleClick="TreeView_MouseDoubleClick"
            MouseDown="TreeView_MouseDown"
            SelectedItemChanged="TreeView_SelectedItemChanged">
            <TreeView.ContextMenu>
                <ContextMenu
                    x:Name="ContextMenu_Remote"
                    MinWidth="160"
                    HasDropShadow="True">
                    <MenuItem
                        x:Name="MenuItem_Link"
                        Click="MenuItem_Click"
                        Header="连接"
                        InputGestureText="Enter" />
                    <MenuItem
                        x:Name="MenuItem_LinkBackend"
                        Click="MenuItem_Click"
                        Header="连接(后台)" />
                    <MenuItem
                        x:Name="MenuItem_LinkSeparate"
                        Click="MenuItem_Click"
                        Header="连接(独立窗口)" />
                    <Separator />
                    <MenuItem
                        x:Name="MenuItem_New"
                        Click="MenuItem_Click"
                        Header="新建">
                        <MenuItem
                            x:Name="MenuItem_Newrdp"
                            Click="MenuItem_Click"
                            Header="RDP连接"
                            InputGestureText="Ctrl+Shift+R" />
                        <MenuItem
                            x:Name="MenuItem_Newssh"
                            Click="MenuItem_Click"
                            Header="SSH连接"
                            InputGestureText="Ctrl+Shift+S" />
                        <MenuItem
                            x:Name="MenuItem_NewTelnet"
                            Click="MenuItem_Click"
                            Header="Telnet连接"
                            InputGestureText="Ctrl+Shift+T" />
                    </MenuItem>
                    <MenuItem
                        x:Name="MenuItem_NewDir"
                        Click="MenuItem_Click"
                        Header="新建目录"
                        InputGestureText="Ctrl+Shift+N" />
                    <Separator />
                    <MenuItem
                        x:Name="MenuItem_Shear"
                        Click="MenuItem_Click"
                        Header="剪切"
                        InputGestureText="Ctrl+X" />
                    <MenuItem
                        x:Name="MenuItem_Copy"
                        Click="MenuItem_Click"
                        Header="复制"
                        InputGestureText="Ctrl+C" />
                    <MenuItem
                        x:Name="MenuItem_Paste"
                        Click="MenuItem_Click"
                        Header="粘贴"
                        InputGestureText="Ctrl+V" />
                    <Separator />
                    <MenuItem
                        x:Name="MenuItem_Rename"
                        Click="MenuItem_Click"
                        Header="重命名"
                        InputGestureText="F2" />
                    <MenuItem
                        x:Name="MenuItem_Delete"
                        Click="MenuItem_Click"
                        Header="删除"
                        InputGestureText="Delete" />
                </ContextMenu>
            </TreeView.ContextMenu>
        </TreeView>

        <GridSplitter
            Width="5"
            Background="{x:Null}"
            BorderBrush="#FFDDDDD8"
            BorderThickness="0,0,1,0" />
        <ScrollViewer
            x:Name="ScrollViewer"
            Grid.Column="1"
            VerticalScrollBarVisibility="Auto"
            Visibility="Collapsed">
            <Grid Width="380" HorizontalAlignment="Left">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Expander
                    x:Name="Expander_Link"
                    Grid.Row="0"
                    mahControls:ControlsHelper.HeaderFontSize="14"
                    Background="{x:Null}"
                    BorderBrush="{x:Null}"
                    Collapsed="MyExpander_IsExpanded"
                    Expanded="MyExpander_IsExpanded"
                    Foreground="#FF333333"
                    Header="身份认证设置"
                    IsExpanded="{Binding Path=IsExpander1, Mode=TwoWay}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="10" />
                            <RowDefinition Height="26" />
                            <RowDefinition Height="10" />
                            <RowDefinition Height="26" />
                            <RowDefinition Height="10" />
                            <RowDefinition Height="26" />
                            <RowDefinition Height="10" />
                            <RowDefinition Height="26" />
                            <RowDefinition />
                            <RowDefinition Height="10" />
                            <RowDefinition Height="120" />
                            <RowDefinition Height="10" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width="70" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="10" />
                        </Grid.ColumnDefinitions>
                        <TextBlock
                            Grid.Row="1"
                            Grid.Column="1"
                            VerticalAlignment="Center"
                            FontSize="14"
                            Text="名   称："
                            TextWrapping="Wrap" />
                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="1"
                            VerticalAlignment="Center"
                            FontSize="14"
                            Text="地   址："
                            TextWrapping="Wrap" />
                        <TextBlock
                            Grid.Row="5"
                            Grid.Column="1"
                            VerticalAlignment="Center"
                            FontSize="14"
                            Text="用户名："
                            TextWrapping="Wrap" />
                        <TextBlock
                            Grid.Row="7"
                            Grid.Column="1"
                            VerticalAlignment="Center"
                            FontSize="14"
                            Text="密   码："
                            TextWrapping="Wrap" />
                        <TextBlock
                            Grid.Row="10"
                            Grid.Column="1"
                            FontSize="14"
                            Text="描   述："
                            TextWrapping="Wrap" />

                        <TextBox
                            x:Name="TextBox_Name"
                            Grid.Row="1"
                            Grid.Column="2"
                            FontSize="14"
                            LostFocus="TextBox_LostFocus" />
                        <TextBox
                            x:Name="TextBox_Server"
                            Grid.Row="3"
                            Grid.Column="2"
                            FontSize="14"
                            LostFocus="TextBox_LostFocus"
                            Text="{Binding Path=Server, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                            ToolTip="可以使用:指定端口，如：localhost:8080" />
                        <TextBox
                            x:Name="TextBox_UserName"
                            Grid.Row="5"
                            Grid.Column="2"
                            FontSize="14"
                            LostFocus="TextBox_LostFocus"
                            Text="{Binding Path=UserName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        <PasswordBox
                            x:Name="TextBox_Password"
                            Grid.Row="7"
                            Grid.Column="2"
                            VerticalContentAlignment="Stretch"
                            FontSize="14"
                            LostFocus="TextBox_LostFocus"
                            Style="{StaticResource Win8MetroPasswordBox}" />
                        <TextBox
                            x:Name="TextBox_Description"
                            Grid.Row="10"
                            Grid.Column="2"
                            MinHeight="0"
                            FontSize="14"
                            LostFocus="TextBox_LostFocus"
                            Text="{Binding Path=Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                            TextWrapping="Wrap" />

                        <Grid
                            x:Name="Grid_PrivateKey"
                            Grid.Row="8"
                            Grid.ColumnSpan="4">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="10" />
                                <ColumnDefinition Width="70" />
                                <ColumnDefinition />
                                <ColumnDefinition Width="10" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="5" />
                                <RowDefinition Height="20" />
                                <RowDefinition Height="5" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <TextBlock
                                Grid.Row="3"
                                Grid.Column="1"
                                FontSize="14"
                                Text="私   钥："
                                TextWrapping="Wrap"
                                Visibility="{Binding Mode=OneWay, ElementName=TextBox_PrivateKey, Path=Visibility}" />
                            <CheckBox
                                x:Name="CheckBox_PrivateKey"
                                Grid.Row="1"
                                Grid.Column="2"
                                HorizontalAlignment="Left"
                                Click="CheckBox_PrivateKey_Click"
                                Content="使用私钥连接" />
                            <Button
                                x:Name="Button_PrivateKey_Upload"
                                Grid.RowSpan="3"
                                Grid.Column="2"
                                Width="60"
                                Height="24"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                Click="Button_PrivateKey_Upload_Click"
                                Content="浏览"
                                FontSize="11"
                                IsEnabled="{Binding Mode=OneWay, ElementName=CheckBox_PrivateKey, Path=IsChecked}"
                                Style="{StaticResource MetroFlatButton}" />
                            <TextBox
                                x:Name="TextBox_PrivateKey"
                                Grid.Row="11"
                                Grid.Column="2"
                                Height="120"
                                MinHeight="0"
                                FontSize="14"
                                IsReadOnly="True"
                                TextWrapping="Wrap"
                                Visibility="Collapsed" />
                        </Grid>
                    </Grid>
                </Expander>
                <Expander
                    x:Name="Expander_Setting"
                    Grid.Row="1"
                    mahControls:ControlsHelper.HeaderFontSize="14"
                    Background="{x:Null}"
                    BorderBrush="{x:Null}"
                    Collapsed="MyExpander_IsExpanded"
                    Expanded="MyExpander_IsExpanded"
                    Foreground="#FF333333"
                    Header="远程连接设置"
                    IsExpanded="{Binding Path=IsExpander2, Mode=TwoWay}" />
            </Grid>
        </ScrollViewer>
    </Grid>
</UserControl>
