|
<UserControl x:Class="CBR.Views.USBDeviceView"
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:Models="clr-namespace:CBR.Core.Models;assembly=CBR.Core"
xmlns:Controls="clr-namespace:CBR.Components.Controls"
xmlns:Converters="clr-namespace:CBR.Components.Converters"
xmlns:ViewModels="clr-namespace:CBR.ViewModels"
xmlns:Views="clr-namespace:CBR.Views"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800">
<UserControl.Resources>
<!--Based treeview item style-->
<Style x:Key="TreeItemItemStyle" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Style.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Trigger.Setters>
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="FontStyle" Value="Italic"/>
</Trigger.Setters>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
<!--DRIVE treeview item style-->
<Style x:Key="DriveItemStyle" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource TreeItemItemStyle}">
</Style>
<!--FOLDER treeview item style-->
<Style x:Key="DirectoryItemStyle" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource TreeItemItemStyle}">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontStyle" Value="Normal"/>
</Style>
<!--FILE treeview item style-->
<Style x:Key="FileItemStyle" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource TreeItemItemStyle}">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontStyle" Value="Normal"/>
</Style>
<!--treeview item style SELECTOR-->
<Views:SysObjectItemStyleSelector x:Key="SysObjectItemStyleSelector"
DriveStyle="{StaticResource DriveItemStyle}"
DirectoryStyle="{StaticResource DirectoryItemStyle}"
FileStyle="{StaticResource FileItemStyle}" />
<!--DRIVE treeview item template-->
<HierarchicalDataTemplate DataType="{x:Type ViewModels:SysDriveViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0"
Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
<!--FOLDER treeview item template-->
<HierarchicalDataTemplate DataType="{x:Type ViewModels:SysDirectoryViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0"
Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
<!--FILE treeview item template-->
<DataTemplate DataType="{x:Type ViewModels:SysFileViewModel}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0"
Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
<!--DEVICE combo item template-->
<DataTemplate x:Key="USBInfoTemplate" DataType="{x:Type Models:DeviceInfo}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Manufacturer}"/>
<TextBlock Text="{Binding Model}"/>
</StackPanel>
</DataTemplate>
<Style x:Key="ItemContStyle" TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsHighlighted}" Value="true">
<Setter Property="Background" Value="DarkGray"/>
</DataTrigger>
</Style.Triggers>
</Style>
<!--NAME list view cell template-->
<DataTemplate x:Key="NameCellTemplate" DataType="{x:Type ViewModels:ListSysObjectViewModel}">
<StackPanel Orientation="Horizontal" x:Name="border">
<Image Width="16" Height="16" Margin="3,0"
Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" VerticalAlignment="Bottom" Grid.ColumnSpan="3" />
<TreeView Grid.Row="1" Name="FolderTree" ItemsSource="{Binding CurrentTreeDrive}" Background="#FFCBCBCB"
ItemContainerStyleSelector="{StaticResource SysObjectItemStyleSelector}"
SelectedValuePath="FullPath" AllowDrop="True"
Drop="FolderTree_Drop" DragOver="FolderTree_DragOver" DragEnter="FolderTree_DragEnter" SelectedItemChanged="FolderTree_SelectedItemChanged" />
<GridSplitter Grid.Column="1" Grid.Row="1" Width="10" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" ShowsPreview="True" />
<ListView Grid.Column="2" Grid.Row="1" Name="listViewContent" AllowDrop="True" Background="#FFCBCBCB"
ItemsSource="{Binding CurrentListContent}" ItemContainerStyle="{StaticResource ItemContStyle}"
Drop="listViewContent_Drop" DragOver="listViewContent_DragOver" DragEnter="listViewContent_DragEnter" DragLeave="listViewContent_DragLeave">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Name" Width="Auto" CellTemplate="{StaticResource NameCellTemplate}" />
<GridViewColumn Header="Last modification" DisplayMemberBinding="{Binding Path=LastModified}" />
<GridViewColumn Header="Type" DisplayMemberBinding="{Binding Path=Type}" />
<GridViewColumn Header="Size" DisplayMemberBinding="{Binding Path=Size}" />
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
WPF and MVVM fan, I practice C # in all its forms from the beginning of the NET Framework without mentioning C ++ / MFC and other software packages such as databases, ASP, WCF, Web & Windows services, Application, and now Core and UWP.
In my wasted hours, I am guilty of having fathered C.B.R. and its cousins C.B.R. for WinRT and UWP on the Windows store.
But apart from that, I am a great handyman ... the house, a rocket stove to heat the jacuzzi and the last one: a wood oven for pizza, bread, and everything that goes inside
https://guillaumewaser.wordpress.com/
https://fouretcompagnie.wordpress.com/