Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Nov 28, 2020
2 parents 02771ba + 35bbccd commit 6fb1670
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<a href="https://github.com/xsnakes" target="_blank"><img style="border-radius:50%!important" width="64px" alt="xsnakes" src="https://avatars1.githubusercontent.com/u/4363683?s=64&v=4"></a>
<a href="https://github.com/mmasdivins" target="_blank"><img style="border-radius:50%!important" width="64px" alt="mmasdivins" src="https://avatars1.githubusercontent.com/u/63245359?s=64&v=4"></a>
<a href="https://github.com/GF-Huang" target="_blank"><img style="border-radius:50%!important" width="64px" alt="GF-Huang" src="https://avatars1.githubusercontent.com/u/4510984?s=64v=4"></a>
<a href="https://github.com/cuiliang" target="_blank"><img style="border-radius:50%!important" width="64px" alt="cuiliang" src="https://avatars2.githubusercontent.com/u/1972649?s=64&v=4"></a>
<a href="https://github.com/lwqwag" target="_blank"><img style="border-radius:50%!important" width="64px" alt="lwqwag" src="https://avatars3.githubusercontent.com/u/29883542?s=64&v=4"></a>

## Backers

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ This project is based on [HandyControl](https://github.com/handyOrg/HandyControl
<a href="https://github.com/xsnakes" target="_blank"><img style="border-radius:50%!important" width="64px" alt="xsnakes" src="https://avatars1.githubusercontent.com/u/4363683?s=64&v=4"></a>
<a href="https://github.com/mmasdivins" target="_blank"><img style="border-radius:50%!important" width="64px" alt="mmasdivins" src="https://avatars1.githubusercontent.com/u/63245359?s=64&v=4"></a>
<a href="https://github.com/GF-Huang" target="_blank"><img style="border-radius:50%!important" width="64px" alt="GF-Huang" src="https://avatars1.githubusercontent.com/u/4510984?s=64v=4"></a>
<a href="https://github.com/cuiliang" target="_blank"><img style="border-radius:50%!important" width="64px" alt="cuiliang" src="https://avatars2.githubusercontent.com/u/1972649?s=64&v=4"></a>
<a href="https://github.com/lwqwag" target="_blank"><img style="border-radius:50%!important" width="64px" alt="lwqwag" src="https://avatars3.githubusercontent.com/u/29883542?s=64&v=4"></a>

## Backers

Expand Down
4 changes: 2 additions & 2 deletions build/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Task("Build")
var settingsNet50 = new DotNetCoreBuildSettings
{
Configuration = "Release",
Framework = "net5.0",
OutputDirectory = "lib/net5.0"
Framework = "net5.0-windows",
OutputDirectory = "lib/net5.0-windows"
};

DotNetCoreBuild("../src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj", settingsNet40);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<hc:TransitioningContentControl>
<TabControl Style="{StaticResource TabControlInLine}">
<TabItem Header="{ex:Lang Key={x:Static langs:LangKeys.Common}}">
<DataGrid HeadersVisibility="All" RowHeaderWidth="60" AutoGenerateColumns="False" ItemsSource="{Binding DataList}">
<DataGrid hc:DataGridAttach.CanUnselectRowsWithBlankArea="True" HeadersVisibility="All" RowHeaderWidth="60" AutoGenerateColumns="False" ItemsSource="{Binding DataList}">
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected,RelativeSource={RelativeSource AncestorType=DataGridRow}}"/>
Expand Down
34 changes: 34 additions & 0 deletions src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using HandyControl.Data;

namespace HandyControl.Controls
Expand Down Expand Up @@ -307,5 +308,38 @@ private static void UpdateItems(ItemContainerGenerator generator, int itemsCount
}

private static void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e) => e.Row.Header = (e.Row.GetIndex() + 1).ToString();

public static readonly DependencyProperty CanUnselectAllWithBlankAreaProperty = DependencyProperty.RegisterAttached(
"CanUnselectAllWithBlankArea", typeof(bool), typeof(DataGridAttach), new PropertyMetadata(ValueBoxes.FalseBox, OnCanUnselectAllWithBlankAreaChanged));

private static void OnCanUnselectAllWithBlankAreaChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is DataGrid dataGrid)
{
if ((bool)e.NewValue)
{
dataGrid.PreviewMouseDown += DataGrid_PreviewMouseDown;
}
else
{
dataGrid.PreviewMouseDown -= DataGrid_PreviewMouseDown;
}
}
}

private static void DataGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (sender is DataGrid dataGrid && e.OriginalSource is System.Windows.Controls.ScrollViewer)
{
dataGrid.CommitEdit();
dataGrid.UnselectAll();
}
}

public static void SetCanUnselectAllWithBlankArea(DependencyObject element, bool value)
=> element.SetValue(CanUnselectAllWithBlankAreaProperty, value);

public static bool GetCanUnselectAllWithBlankArea(DependencyObject element)
=> (bool) element.GetValue(CanUnselectAllWithBlankAreaProperty);
}
}
37 changes: 36 additions & 1 deletion src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
Expand Down Expand Up @@ -109,6 +110,40 @@ public static void SetShowInTaskManager(DependencyObject element, bool value)
=> element.SetValue(ShowInTaskManagerProperty, ValueBoxes.BooleanBox(value));

public static bool GetShowInTaskManager(DependencyObject element)
=> (bool) element.GetValue(ShowInTaskManagerProperty);
=> (bool)element.GetValue(ShowInTaskManagerProperty);

public static readonly DependencyProperty HideWhenClosingProperty = DependencyProperty.RegisterAttached(
"HideWhenClosing", typeof(bool), typeof(WindowAttach), new PropertyMetadata(ValueBoxes.FalseBox, OnHideWhenClosingChanged));

private static void OnHideWhenClosingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is System.Windows.Window window)
{
var v = (bool)e.NewValue;
if (v)
{
window.Closing += Window_Closing;
}
else
{
window.Closing -= Window_Closing;
}
}
}

private static void Window_Closing(object sender, CancelEventArgs e)
{
if (sender is System.Windows.Window window)
{
window.Hide();
e.Cancel = true;
}
}

public static void SetHideWhenClosing(DependencyObject element, bool value)
=> element.SetValue(HideWhenClosingProperty, value);

public static bool GetHideWhenClosing(DependencyObject element)
=> (bool) element.GetValue(HideWhenClosingProperty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Height="18" Width="18" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" x:Name="checkBoxBorder" Background="{TemplateBinding Background}" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
<hc:SimplePanel Grid.Column="0" Height="18" Width="18" x:Name="markGrid" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Path UseLayoutRounding="True" x:Name="path" StrokeDashOffset="8" StrokeDashArray="8,8" Width="12" Height="12" Data="{StaticResource CheckedGeometry}" StrokeThickness="2" Stretch="Uniform" Stroke="{DynamicResource TextIconBrush}"/>
<Border Height="18" Width="18" x:Name="checkBoxBorder" Background="{TemplateBinding Background}" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
<hc:SimplePanel Grid.Column="0" Height="18" Width="18" x:Name="markGrid">
<Path FlowDirection="LeftToRight" UseLayoutRounding="True" x:Name="path" StrokeDashOffset="8" StrokeDashArray="8,8" Width="12" Height="12" Data="{StaticResource CheckedGeometry}" StrokeThickness="2" Stretch="Uniform" Stroke="{DynamicResource TextIconBrush}"/>
<Rectangle x:Name="indeterminateMark" RadiusX="2" RadiusY="2" Fill="{DynamicResource PrimaryBrush}" Margin="2" Opacity="0"/>
</hc:SimplePanel>
<ContentPresenter x:Name="contentPresenter" Visibility="Collapsed" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
Expand Down Expand Up @@ -103,4 +103,4 @@
</Setter>
</Style>

</ResourceDictionary>
</ResourceDictionary>

0 comments on commit 6fb1670

Please sign in to comment.