init
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<base:BaseView x:Class="HamburgerMenu.HamburgerMenuView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:base="clr-namespace:DTS.Common.Base;assembly=DTS.Common"
|
||||
xmlns:behaviors="clr-namespace:DTS.Common.Behaviors;assembly=DTS.Common"
|
||||
xmlns:controls="clr-namespace:DTS.Common.Controls;assembly=DTS.Common"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:strings="clr-namespace:HamburgerMenu"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:converters="clr-namespace:DTS.Common.Converters;assembly=DTS.Common"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="20" d:DesignWidth="20"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:controls2="clr-namespace:DTS.Common.Controls;assembly=DTS.Common">
|
||||
<base:BaseView.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/DTS.Common;component/Themes/CommonStyles.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/DTS.Common;component/Controls/combobox.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="ListView">
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource TTS_ListViewItemStyle}"/>
|
||||
</Style>
|
||||
<Style TargetType="TextBox" BasedOn="{StaticResource TTS_TextBoxStyle}"/>
|
||||
<Style TargetType="TextBlock" BasedOn="{StaticResource TTS_TextBlockStyle}"/>
|
||||
<Style TargetType="CheckBox" BasedOn="{StaticResource PageContentCheckBoxStyle}" />
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource TTS_ComboBoxStyle}"/>
|
||||
<Style TargetType="GridViewColumnHeader" BasedOn="{StaticResource Gray_GridViewColumnHeaderStyle}"/>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
<Style TargetType="{x:Type ContextMenu}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ContextMenu}">
|
||||
<Border BorderThickness="1" CornerRadius="4" BorderBrush="Black" x:Name="Border" Background="White">
|
||||
<StackPanel ClipToBounds="True" Orientation="Vertical" IsItemsHost="True" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="White" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<converters:InverseBooleanConverter x:Key="InverseBoolConverter" />
|
||||
</ResourceDictionary>
|
||||
</base:BaseView.Resources>
|
||||
<Grid>
|
||||
<Button Width="16" Height="14" Click="Hamburger_Click" Background="Transparent" BorderThickness="0"
|
||||
AutomationProperties.AutomationId="Button_HamburgerMenu" IsEnabled="{Binding IsEnabled}">
|
||||
<Path Width="14" Height="12" Fill="Black" Stretch="Uniform"
|
||||
Data="M0 10 L12 10 L12 9 L0 9 Z
|
||||
M0 6 L12 6 L12 5 L0 5 Z
|
||||
M0 1 L12 1 L12 2 L0 2 Z"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</base:BaseView>
|
||||
@@ -0,0 +1,105 @@
|
||||
using DTS.Common.Interface.Menu.HamburgerMenu;
|
||||
using System.Windows.Controls;
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace HamburgerMenu
|
||||
{
|
||||
/// <inheritdoc cref="IHamburgerMenuView" />
|
||||
/// <summary>
|
||||
/// Interaction logic for HamburgerMenuView.xaml
|
||||
/// </summary>
|
||||
public partial class HamburgerMenuView : IHamburgerMenuView
|
||||
{
|
||||
public HamburgerMenuView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Hamburger_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
var vm = (IHamburgerMenuViewModel)DataContext;
|
||||
var cm = vm.GetContextMenu();
|
||||
cm.PlacementTarget = sender as Button;
|
||||
cm.IsOpen = true;
|
||||
}
|
||||
/*
|
||||
private void GridViewColumnHeaderSearchable_OnSearch(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var searchTerm = (string)e.OriginalSource;
|
||||
var columnTag = (sender as GridViewColumnHeaderSearchable)?.Tag;
|
||||
var viewModel = (IHardwareListViewModel)DataContext;
|
||||
viewModel.Filter(columnTag, searchTerm);
|
||||
}
|
||||
private void GridViewColumnHeader_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var vm = (IHardwareListViewModel)DataContext;
|
||||
var columnTag = (sender as GridViewColumnHeaderSearchable)?.Tag ??
|
||||
Utils.FindChild<GridViewColumnHeaderSearchable>((DependencyObject)e.OriginalSource, null)?.Tag ??
|
||||
(e.OriginalSource as GridViewColumnHeader)?.Tag;
|
||||
vm?.Sort(columnTag, true);
|
||||
}
|
||||
|
||||
private void MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (!(sender is ListView lv))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var index = GetCurrentIndex(e.GetPosition, lv);
|
||||
if (index >= 0 && index < lv.Items.Count)
|
||||
{
|
||||
var vm = (IHardwareListViewModel)lv.DataContext;
|
||||
vm.MouseDoubleClick(index);
|
||||
}
|
||||
}
|
||||
|
||||
private delegate Point GetPositionDelegate(IInputElement element);
|
||||
private int GetCurrentIndex(GetPositionDelegate getPosition, ListView lv)
|
||||
{
|
||||
var index = -1;
|
||||
for (var i = 0; i < lv.Items.Count; i++)
|
||||
{
|
||||
var item = GetListViewItem(i, lv);
|
||||
if (item == null)
|
||||
continue;
|
||||
if (IsMouseOverTarget(item, getPosition))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
private static ListViewItem GetListViewItem(int index, ListView lv)
|
||||
{
|
||||
return lv.ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem;
|
||||
}
|
||||
private static bool IsMouseOverTarget(Visual target, GetPositionDelegate getPosition)
|
||||
{
|
||||
var bounds = VisualTreeHelper.GetDescendantBounds(target);
|
||||
var mousePos = getPosition((IInputElement)target);
|
||||
return bounds.Contains(mousePos);
|
||||
}
|
||||
|
||||
private void TreeviewButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if( !(sender is Control control)){ return; }
|
||||
|
||||
if( !(control.DataContext is IHardware hardware)){ return; }
|
||||
|
||||
if( !(DataContext is IHardwareListViewModel hardwareListViewModel)){ return; }
|
||||
|
||||
SLICE6TreeViewPopup.IsOpen = false;
|
||||
hardwareListViewModel.SLICE6TreeView.DataContext = hardwareListViewModel;
|
||||
|
||||
SLICE6TreeViewPopup.PlacementTarget = control;
|
||||
SLICE6TreeViewPopup.Child = null;
|
||||
hardwareListViewModel.LoadTreeView(hardware.SerialNumber);
|
||||
|
||||
SLICE6TreeViewPopup.Child = (UIElement)hardwareListViewModel.SLICE6TreeView;
|
||||
SLICE6TreeViewPopup.IsOpen = true;
|
||||
SLICE6TreeViewPopup.PlacementTarget = control;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user