Skip to content

Commit

Permalink
加入支持触摸的辅助方法和测试代码
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Nov 29, 2020
1 parent b502b86 commit f9ac5d1
Show file tree
Hide file tree
Showing 11 changed files with 618 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class MessageToken

public static readonly string NavigationWindow = nameof(NavigationWindow);

public static readonly string TouchDragMoveWindow = nameof(TouchDragMoveWindow);

public static readonly string DialogContainer = nameof(DialogContainer);

public static readonly string LangUpdated = nameof(LangUpdated);
Expand Down
1 change: 1 addition & 0 deletions src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var messageList = new List<string>
"GlowWindow",
"NativeCommonWindow",
"NavigationWindow",
"TouchDragMoveWindow",
"DialogContainer",
"LangUpdated"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Window\NativeCommonWindow.xaml.cs">
<DependentUpon>NativeCommonWindow.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Window\TouchDragMoveWindow.xaml.cs">
<DependentUpon>TouchDragMoveWindow.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Window\NavigationWindow.xaml.cs">
<DependentUpon>NavigationWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -1025,6 +1028,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Window\TouchDragMoveWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Window\NavigationWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@
</data>
<data name="About" xml:space="preserve">
<value>关于</value>

</data>
<data name="Repository" xml:space="preserve">
<value>代码仓库</value>
Expand Down Expand Up @@ -766,4 +765,7 @@
<data name="FlexPanel" xml:space="preserve">
<value>弹性盒子</value>
</data>
<data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>点击打开触摸拖动窗口</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,11 @@ private void UpdateLangs()
/// </summary>
public string OpenNavigationWindow => Lang.OpenNavigationWindow;

/// <summary>
/// 查找类似 点击打开触摸拖动窗口 的本地化字符串。
/// </summary>
public string OpenTouchDragMoveWindow => Lang.OpenTouchDragMoveWindow;

/// <summary>
/// 查找类似 打开无非客户端区域可拖拽窗口 的本地化字符串。
/// </summary>
Expand Down Expand Up @@ -1969,6 +1974,11 @@ public class LangKeys
/// </summary>
public static string OpenNavigationWindow = nameof(OpenNavigationWindow);

/// <summary>
/// 查找类似 点击打开触摸拖动窗口 的本地化字符串。
/// </summary>
public static string OpenTouchDragMoveWindow = nameof(OpenTouchDragMoveWindow);

/// <summary>
/// 查找类似 打开无非客户端区域可拖拽窗口 的本地化字符串。
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<UniformGrid Margin="32" Columns="3" Rows="3" Height="200">
<Button Command="{Binding OpenWindowCmd}" CommandParameter="{x:Static data:MessageToken.NativeCommonWindow}" Content="{ex:Lang Key={x:Static langs:LangKeys.OpenNativeCommonWindow}}"/>
<Button Command="{Binding OpenWindowCmd}" CommandParameter="{x:Static data:MessageToken.NavigationWindow}" Content="{ex:Lang Key={x:Static langs:LangKeys.OpenNavigationWindow}}"/>
<Button Command="{Binding OpenWindowCmd}" CommandParameter="{x:Static data:MessageToken.TouchDragMoveWindow}" Content="{ex:Lang Key={x:Static langs:LangKeys.OpenTouchDragMoveWindow}}"/>
</UniformGrid>
</hc:TransitioningContentControl>
</UserControl>
11 changes: 11 additions & 0 deletions src/Shared/HandyControlDemo_Shared/Window/TouchDragMoveWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Window x:Class="HandyControlDemo.Window.TouchDragMoveWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterScreen"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Title="{ex:Lang Key={x:Static langs:LangKeys.Title}}"
Height="450"
Width="800"
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Windows;
using System.Windows.Input;
using HandyControl.Tools.Helper;

namespace HandyControlDemo.Window
{
public partial class TouchDragMoveWindow
{
public TouchDragMoveWindow()
{
InitializeComponent();

TouchDown += MainWindow_TouchDown;
TouchUp += MainWindow_TouchUp;
}

private void MainWindow_TouchUp(object sender, TouchEventArgs e)
{
_currentTouchCount--;
}

private void MainWindow_TouchDown(object sender, TouchEventArgs e)
{
CaptureTouch(e.TouchDevice);

if (_currentTouchCount == 0)
{
TouchDragMoveWindowHelper.DragMove(this);
}

_currentTouchCount++;
}

private uint _currentTouchCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\SecurityHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\SingleOpenHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\TokenizerHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\TouchDragMoveWindowHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ValidateHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\VisualHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\WindowHelper.cs" />
Expand Down
Loading

0 comments on commit f9ac5d1

Please sign in to comment.