add some demos & styles

1. add window demo
2. add scrollviewer demo
3. add radiobutton style
4. fixed some bugs
5. add research project
This commit is contained in:
NaBian committed 2018-10-23 19:59:59 +08:00
1 parent 0baae519cb
commit fffbdbb4a9
59 files changed
+1114 -159

No files matched your search

+6 -8
View File
@@ -1,11 +1,9 @@
/.vs
/packages
/HandyControl/bin/Debug
/HandyControl/obj/Debug
/HandyControl/bin/Release
/HandyControl/obj/Release
/HandyControlDemo/bin/Debug
/HandyControlDemo/obj/Debug
/HandyControlDemo/bin/Release
/HandyControlDemo/obj/Release
/HandyControl/bin
/HandyControl/obj
/HandyControlDemo/bin
/HandyControlDemo/obj
/DockContainerResearch/bin
/DockContainerResearch/obj
/HandyControl.sln.DotSettings.user
+8
View File
@@ -0,0 +1,8 @@
<Application x:Class="DockBoxResearch.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
+6
View File
@@ -0,0 +1,6 @@
namespace DockBoxResearch
{
public partial class App
{
}
}
@@ -0,0 +1,7 @@
namespace DockBoxResearch.Controls
{
public class DocDockBoxItem : DockBoxItemBase
{
}
}
@@ -0,0 +1,9 @@
using System.Windows.Controls;
namespace DockBoxResearch.Controls
{
public class DocDockBoxItemPanel : Panel
{
}
}
@@ -0,0 +1,9 @@
using System.Windows.Controls;
namespace DockBoxResearch.Controls
{
public class DockBox : Control
{
}
}
@@ -0,0 +1,7 @@
namespace DockBoxResearch.Controls
{
public class DockBoxItem : DockBoxItemBase
{
}
}
@@ -0,0 +1,9 @@
using System.Windows.Controls;
namespace DockBoxResearch.Controls
{
public class DockBoxItemBase : Control
{
}
}
@@ -0,0 +1,9 @@
using System.Windows.Controls;
namespace DockBoxResearch.Controls
{
public class DockBoxItemPanel : Panel
{
}
}
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8A444D0A-E3DD-446F-95C4-0A132179D20F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>DockBoxResearch</RootNamespace>
<AssemblyName>DockBoxResearch</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Controls\DocDockBoxItemPanel.cs" />
<Compile Include="Controls\DockBox.cs" />
<Compile Include="Controls\DockBoxItem.cs" />
<Compile Include="Controls\DockBoxItemBase.cs" />
<Compile Include="Controls\DocDockBoxItem.cs" />
<Compile Include="Controls\DockBoxItemPanel.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Resources\Themes\Basic\Geometries.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HandyControl\HandyControl.csproj">
<Project>{dc966e3d-bcff-4652-98cf-070e5494749a}</Project>
<Name>HandyControl</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\Themes\Styles\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+12
View File
@@ -0,0 +1,12 @@
<Window x:Class="DockBoxResearch.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:DockBoxResearch.Controls"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<controls:DockBox>
</controls:DockBox>
</Window>
+10
View File
@@ -0,0 +1,10 @@
namespace DockBoxResearch
{
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
[assembly: AssemblyTitle("DockContainerResearch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DockContainerResearch")]
[assembly: AssemblyCopyright("Copyright © NaBian 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>
+6
View File
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HandyControl", "HandyContro
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HandyControlDemo", "HandyControlDemo\HandyControlDemo.csproj", "{9A7B52E6-94BB-4E7E-BB6A-7CF6761B79A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DockBoxResearch", "DockContainerResearch\DockBoxResearch.csproj", "{8A444D0A-E3DD-446F-95C4-0A132179D20F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
{9A7B52E6-94BB-4E7E-BB6A-7CF6761B79A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A7B52E6-94BB-4E7E-BB6A-7CF6761B79A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A7B52E6-94BB-4E7E-BB6A-7CF6761B79A7}.Release|Any CPU.Build.0 = Release|Any CPU
{8A444D0A-E3DD-446F-95C4-0A132179D20F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8A444D0A-E3DD-446F-95C4-0A132179D20F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A444D0A-E3DD-446F-95C4-0A132179D20F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A444D0A-E3DD-446F-95C4-0A132179D20F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+9
View File
@@ -0,0 +1,9 @@
using System;
namespace HandyControl.Controls
{
public interface ISingleOpen : IDisposable
{
bool CanDispose { get; }
}
}
+5 -1
View File
@@ -22,7 +22,7 @@ namespace HandyControl.Controls
[TemplatePart(Name = ElementSliderColor, Type = typeof(Panel))]
[TemplatePart(Name = ElementSliderOpacity, Type = typeof(Panel))]
[TemplatePart(Name = ElementPanelRgb, Type = typeof(Panel))]
public class ColorPicker : Control
public class ColorPicker : Control, ISingleOpen
{
#region Constants
@@ -669,5 +669,9 @@ namespace HandyControl.Controls
});
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => RaiseEvent(new RoutedEventArgs(CanceledEvent));
public void Dispose() => Window.GetWindow(this)?.Close();
public bool CanDispose { get; } = true;
}
}
+48 -21
View File
@@ -28,6 +28,10 @@ namespace HandyControl.Controls
private TextBlock _titleBlock;
private bool _showBackground = true;
private FrameworkElement _targetElement;
public override void OnApplyTemplate()
{
if (_titleBlock != null)
@@ -44,6 +48,11 @@ namespace HandyControl.Controls
{
_titleBlock.MouseLeftButtonDown += TitleBlock_OnMouseLeftButtonDown;
}
if (PopupElement != null)
{
_mainBorder.Child = PopupElement;
}
}
internal static readonly DependencyProperty ContentStrProperty = DependencyProperty.Register(
@@ -68,6 +77,16 @@ namespace HandyControl.Controls
if (!IsDialog)
Owner?.Focus();
};
Loaded += (s, e) =>
{
if (!_showBackground)
{
var point = ArithmeticHelper.CalSafePoint(_targetElement, PopupElement, BorderThickness);
Left = point.X;
Top = point.Y;
Opacity = 1;
}
};
try
{
Owner = Application.Current.MainWindow;
@@ -82,17 +101,7 @@ namespace HandyControl.Controls
private void CloseButton_OnClick(object sender, RoutedEventArgs e) => Close();
public UIElement Child
{
get => _mainBorder?.Child;
set
{
if (_mainBorder != null)
{
_mainBorder.Child = value;
}
}
}
public FrameworkElement PopupElement { get; set; }
public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register(
"ShowTitle", typeof(bool), typeof(PopupWindow), new PropertyMetadata(true));
@@ -129,19 +138,37 @@ namespace HandyControl.Controls
}
}
public void Show(FrameworkElement element)
public void Show(FrameworkElement element, bool showBackground = true)
{
var point = ArithmeticHelper.CalSafePoint(element, Child as FrameworkElement);
Left = point.X;
Top = point.Y;
if (!showBackground)
{
Opacity = 0;
AllowsTransparency = true;
WindowStyle = WindowStyle.None;
ShowTitle = false;
MinWidth = 0;
MinHeight = 0;
}
_showBackground = showBackground;
_targetElement = element;
Show();
}
public void ShowDialog(FrameworkElement element)
public void ShowDialog(FrameworkElement element, bool showBackground = true)
{
var point = ArithmeticHelper.CalSafePoint(element, Child as FrameworkElement);
Left = point.X;
Top = point.Y;
if (!showBackground)
{
Opacity = 0;
AllowsTransparency = true;
WindowStyle = WindowStyle.None;
ShowTitle = false;
MinWidth = 0;
MinHeight = 0;
}
_showBackground = showBackground;
_targetElement = element;
ShowDialog();
}
@@ -159,7 +186,7 @@ namespace HandyControl.Controls
AllowsTransparency = true,
WindowStyle = WindowStyle.None,
ContentStr = message,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
WindowStartupLocation = WindowStartupLocation.CenterScreen
};
window.Background = window.FindResource("PrimaryBrush") as SolidColorBrush;
window.Show();
@@ -202,7 +229,7 @@ namespace HandyControl.Controls
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
Child = null;
PopupElement = null;
}
}
}
@@ -16,8 +16,8 @@ namespace HandyControl.Controls
{
private Thickness _tempThickness;
public static readonly DependencyProperty NoUserContentProperty = DependencyProperty.Register(
"NoUserContent", typeof(object), typeof(WindowBorderless), new PropertyMetadata(default(object)));
public static readonly DependencyProperty NonClientAreaContentProperty = DependencyProperty.Register(
"NonClientAreaContent", typeof(object), typeof(WindowBorderless), new PropertyMetadata(default(object)));
public static readonly DependencyProperty CloseButtonHoverBrushProperty = DependencyProperty.Register(
"CloseButtonHoverBrush", typeof(Brush), typeof(WindowBorderless),
@@ -45,20 +45,20 @@ namespace HandyControl.Controls
"OtherButtonHoverForeground", typeof(Brush), typeof(WindowBorderless),
new PropertyMetadata(default(Brush)));
public static readonly DependencyProperty NoUserAreaBackgroundProperty = DependencyProperty.Register(
"NoUserAreaBackground", typeof(Brush), typeof(WindowBorderless),
public static readonly DependencyProperty NonClientAreaBackgroundProperty = DependencyProperty.Register(
"NonClientAreaBackground", typeof(Brush), typeof(WindowBorderless),
new PropertyMetadata(default(Brush)));
public static readonly DependencyProperty NoUserAreaForegroundProperty = DependencyProperty.Register(
"NoUserAreaForeground", typeof(Brush), typeof(WindowBorderless),
public static readonly DependencyProperty NonClientAreaForegroundProperty = DependencyProperty.Register(
"NonClientAreaForeground", typeof(Brush), typeof(WindowBorderless),
new PropertyMetadata(default(Brush)));
public static readonly DependencyProperty NoUserAreaHeightProperty = DependencyProperty.Register(
"NoUserAreaHeight", typeof(double), typeof(WindowBorderless),
public static readonly DependencyProperty NonClientAreaHeightProperty = DependencyProperty.Register(
"NonClientAreaHeight", typeof(double), typeof(WindowBorderless),
new PropertyMetadata(28.0));
public static readonly DependencyProperty ShowNoUserAreaProperty = DependencyProperty.Register(
"ShowNoUserArea", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(true));
public static readonly DependencyProperty ShowNonClientAreaProperty = DependencyProperty.Register(
"ShowNonClientArea", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(true));
public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register(
"ShowTitle", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(default(bool)));
@@ -96,7 +96,7 @@ namespace HandyControl.Controls
GlassFrameThickness = new Thickness(1)
};
BindingOperations.SetBinding(chrome, WindowChrome.CaptionHeightProperty,
new Binding(NoUserAreaHeightProperty.Name) {Source = this});
new Binding(NonClientAreaHeightProperty.Name) {Source = this});
WindowChrome.SetWindowChrome(this, chrome);
Loaded += delegate
@@ -169,10 +169,10 @@ namespace HandyControl.Controls
/// </summary>
private ResizeMode OriginResizeMode { get; set; }
public double NoUserAreaHeight
public double NonClientAreaHeight
{
get => (double)GetValue(NoUserAreaHeightProperty);
set => SetValue(NoUserAreaHeightProperty, value);
get => (double)GetValue(NonClientAreaHeightProperty);
set => SetValue(NonClientAreaHeightProperty, value);
}
public bool IsFullScreen
@@ -181,10 +181,10 @@ namespace HandyControl.Controls
set => SetValue(IsFullScreenProperty, value);
}
public object NoUserContent
public object NonClientAreaContent
{
get => GetValue(NoUserContentProperty);
set => SetValue(NoUserContentProperty, value);
get => GetValue(NonClientAreaContentProperty);
set => SetValue(NonClientAreaContentProperty, value);
}
public Brush CloseButtonHoverBrush
@@ -211,22 +211,22 @@ namespace HandyControl.Controls
set => SetValue(OtherButtonHoverForegroundProperty, value);
}
public Brush NoUserAreaBackground
public Brush NonClientAreaBackground
{
get => (Brush)GetValue(NoUserAreaBackgroundProperty);
set => SetValue(NoUserAreaBackgroundProperty, value);
get => (Brush)GetValue(NonClientAreaBackgroundProperty);
set => SetValue(NonClientAreaBackgroundProperty, value);
}
public Brush NoUserAreaForeground
public Brush NonClientAreaForeground
{
get => (Brush)GetValue(NoUserAreaForegroundProperty);
set => SetValue(NoUserAreaForegroundProperty, value);
get => (Brush)GetValue(NonClientAreaForegroundProperty);
set => SetValue(NonClientAreaForegroundProperty, value);
}
public bool ShowNoUserArea
public bool ShowNonClientArea
{
get => (bool)GetValue(ShowNoUserAreaProperty);
set => SetValue(ShowNoUserAreaProperty, value);
get => (bool)GetValue(ShowNonClientAreaProperty);
set => SetValue(ShowNonClientAreaProperty, value);
}
public bool ShowTitle
+10
View File
@@ -49,6 +49,7 @@
<Compile Include="Controls\Clock\Clock.cs" />
<Compile Include="Controls\Clock\ClockRadioButton.cs" />
<Compile Include="Controls\Growl.cs" />
<Compile Include="Controls\ISingleOpen.cs" />
<Compile Include="Controls\NumericUpDown.cs" />
<Compile Include="Controls\Pagination.cs" />
<Compile Include="Controls\Attach\IconElement.cs" />
@@ -58,6 +59,7 @@
<Compile Include="Controls\Loading\LoadingBase.cs" />
<Compile Include="Controls\Loading\LoadingCircle.cs" />
<Compile Include="Controls\Loading\LoadingLine.cs" />
<Compile Include="Tools\SingleOpenHelper.cs" />
<Compile Include="Controls\Steps\StepBar.cs" />
<Compile Include="Controls\Steps\StepItem.cs" />
<Compile Include="Controls\TabControl\TabControl.cs" />
@@ -194,6 +196,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\RadioButtonBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\TabControlBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -342,6 +348,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\RadioButton.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\ScrollViewer.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -5,7 +5,7 @@
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="6,0,0,0"/>
@@ -15,12 +15,12 @@
<ControlTemplate.Resources>
<Storyboard x:Key="StoryboardCheckedTrue">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.StrokeDashOffset)" Storyboard.TargetName="path">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="StoryboardCheckedFalse">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.StrokeDashOffset)" Storyboard.TargetName="path">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="8"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="8"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
@@ -0,0 +1,89 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="RadioButtonBaseStyle" TargetType="RadioButton">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="6,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<ControlTemplate.Resources>
<Storyboard x:Key="StoryboardCheckedTrue">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="optionMark">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0.5"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="optionMark">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0.5"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="StoryboardCheckedFalse">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="optionMark">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="optionMark">
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Grid x:Name="templateRoot" Background="Transparent" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Height="18" Width="18" x:Name="radioButtonBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="100" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Ellipse x:Name="optionMark" Fill="White" MinWidth="6" MinHeight="6" RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform/>
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
</Border>
<ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="true">
<Setter Property="Visibility" TargetName="contentPresenter" Value="Visible"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryTextBrush}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="true"/>
<Condition Property="IsPressed" Value="true"/>
</MultiTrigger.Conditions>
<Setter Property="Opacity" Value=".8"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="false"/>
<Condition Property="IsPressed" Value="true"/>
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
</MultiTrigger>
<Trigger Property="IsChecked" Value="true">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource StoryboardCheckedTrue}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource StoryboardCheckedFalse}"/>
</Trigger.ExitActions>
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DarkPrimaryBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -145,8 +145,8 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.ColumnSpan="2" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
<ScrollBar x:Name="PART_VerticalScrollBar" Opacity="0.8" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<ScrollBar x:Name="PART_HorizontalScrollBar" Opacity="0.8" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
<ScrollBar x:Name="PART_VerticalScrollBar" Opacity="0" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<ScrollBar x:Name="PART_HorizontalScrollBar" Opacity="0" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
@@ -187,8 +187,8 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.ColumnSpan="2" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
<ScrollBar x:Name="PART_VerticalScrollBar" Opacity="0.8" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<ScrollBar x:Name="PART_HorizontalScrollBar" Opacity="0.8" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
<ScrollBar x:Name="PART_VerticalScrollBar" Opacity="0" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<ScrollBar x:Name="PART_HorizontalScrollBar" Opacity="0" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
+2 -3
View File
@@ -1,10 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base/CheckBoxBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource CheckBoxBaseStyle}" TargetType="CheckBox"></Style>
<Style BasedOn="{StaticResource CheckBoxBaseStyle}" TargetType="CheckBox"/>
</ResourceDictionary>
+2 -2
View File
@@ -239,13 +239,13 @@
<Button Command="{x:Static DataGrid.SelectAllCommand}" Margin="0,0,0,6" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource AllGeometry}" Foreground="{DynamicResource PrimaryBrush}"/>
<DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.ColumnSpan="2" Grid.Row="0" Grid.Column="1" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.ColumnSpan="3" Grid.Column="0" Grid.Row="1"/>
<ScrollBar Style="{StaticResource ScrollBarBaseStyle}" x:Name="PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" Visibility="{TemplateBinding VerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<ScrollBar Style="{StaticResource ScrollBarBaseStyle}" Opacity="0" x:Name="PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" Visibility="{TemplateBinding VerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<Grid Grid.Column="1" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ScrollBar Style="{StaticResource ScrollBarBaseStyle}" VerticalAlignment="Bottom" x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal" Visibility="{TemplateBinding HorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
<ScrollBar Style="{StaticResource ScrollBarBaseStyle}" Opacity="0" VerticalAlignment="Bottom" x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal" Visibility="{TemplateBinding HorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
</Grid>
</Grid>
<ControlTemplate.Triggers>
@@ -0,0 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base/RadioButtonBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource RadioButtonBaseStyle}" TargetType="RadioButton"/>
</ResourceDictionary>
+1
View File
@@ -21,6 +21,7 @@
<ResourceDictionary Source="TextBox.xaml"/>
<ResourceDictionary Source="ComboBox.xaml"/>
<ResourceDictionary Source="CheckBox.xaml"/>
<ResourceDictionary Source="RadioButton.xaml"/>
<ResourceDictionary Source="NumericUpDown.xaml"/>
<ResourceDictionary Source="PasswordBox.xaml"/>
<ResourceDictionary Source="Calendar.xaml"/>
+8 -17
View File
@@ -22,8 +22,8 @@
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="NoUserAreaBackground" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="NoUserAreaForeground" Value="White"/>
<Setter Property="NonClientAreaBackground" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="NonClientAreaForeground" Value="White"/>
<Setter Property="CloseButtonHoverBrush" Value="Red"/>
<Setter Property="CloseButtonHoverForeground" Value="White"/>
<Setter Property="OtherButtonHoverBrush" Value="{DynamicResource DarkPrimaryBrush}"/>
@@ -37,7 +37,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Visibility="{TemplateBinding IsFullScreen,Converter={StaticResource Boolean2VisibilityReConverter}}" Background="{TemplateBinding NoUserAreaBackground}" Name="GridMenu" TextElement.Foreground="{TemplateBinding NoUserAreaForeground}">
<Grid Visibility="{TemplateBinding IsFullScreen,Converter={StaticResource Boolean2VisibilityReConverter}}" Background="{TemplateBinding NonClientAreaBackground}" Name="GridMenu" TextElement.Foreground="{TemplateBinding NonClientAreaForeground}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
@@ -56,11 +56,11 @@
</Grid.ColumnDefinitions>
<ContentPresenter Content="{TemplateBinding Icon}" VerticalAlignment="Center"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<ContentPresenter Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NoUserContent}"/>
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
<ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}"/>
<ResizeGrip x:Name="ResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="1" IsTabStop="False" Visibility="Collapsed" WindowChrome.ResizeGripDirection="BottomRight" />
<ResizeGrip Width="10" Height="10" x:Name="ResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="1" IsTabStop="False" Visibility="Collapsed" WindowChrome.ResizeGripDirection="BottomRight" />
</Grid>
</Border>
<ControlTemplate.Triggers>
@@ -97,7 +97,7 @@
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBrush,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowNoUserArea" Value="False">
<Trigger Property="ShowNonClientArea" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="GridMenu"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
@@ -166,12 +166,12 @@
<StackPanel Margin="0,0,0,32" Orientation="Horizontal" Background="White" HorizontalAlignment="Center">
<Button Command="interactivity:ControlCommands.Cancel" Visibility="{TemplateBinding ShowCancel,Converter={StaticResource Boolean2VisibilityConverter}}" Margin="0,0,16,0" Background="Transparent" Style="{StaticResource ButtonCustom}">
<Border BorderThickness="1" BorderBrush="{DynamicResource PrimaryBrush}" MinWidth="80" Height="30" CornerRadius="4" Background="White">
<TextBlock FontSize="16" Text="{x:Static langs:Lang.Cancel}" Foreground="{DynamicResource PrimaryBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static langs:Lang.Cancel}" Foreground="{DynamicResource PrimaryBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Button>
<Button IsDefault="True" Command="interactivity:ControlCommands.Confirm" Background="Transparent" Style="{StaticResource ButtonCustom}">
<Border MinWidth="80" Height="30" CornerRadius="4" Background="{DynamicResource PrimaryBrush}">
<TextBlock FontSize="16" Text="{x:Static langs:Lang.Confirm}" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static langs:Lang.Confirm}" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Button>
</StackPanel>
@@ -191,15 +191,6 @@
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:.2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
<Style TargetType="controls:ImageBrowser">
+7 -8
View File
@@ -35,10 +35,7 @@ namespace HandyControl.Tools
/// <summary>
/// 计算控件在窗口中的可见坐标
/// </summary>
/// <param name="element"></param>
/// <param name="showElement"></param>
/// <returns></returns>
public static Point CalSafePoint(FrameworkElement element, FrameworkElement showElement)
public static Point CalSafePoint(FrameworkElement element, FrameworkElement showElement, Thickness thickness = default(Thickness))
{
if (element == null || showElement == null) return default(Point);
var point = element.PointToScreen(new Point(0, 0));
@@ -46,10 +43,12 @@ namespace HandyControl.Tools
if (point.X < 0) point.X = 0;
if (point.Y < 0) point.Y = 0;
var maxLeft = SystemParameters.PrimaryScreenWidth -
(double.IsNaN(showElement.Width) ? showElement.ActualWidth : showElement.Width);
var maxTop = SystemParameters.PrimaryScreenHeight -
(double.IsNaN(showElement.Height) ? showElement.ActualHeight : showElement.Height);
var maxLeft = SystemParameters.WorkArea.Width -
((double.IsNaN(showElement.Width) ? showElement.ActualWidth : showElement.Width) +
thickness.Left + thickness.Right);
var maxTop = SystemParameters.WorkArea.Height -
((double.IsNaN(showElement.Height) ? showElement.ActualHeight : showElement.Height) +
thickness.Top + thickness.Bottom);
return new Point(maxLeft > point.X ? point.X : maxLeft, maxTop > point.Y ? point.Y : maxTop);
}
+42
View File
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using HandyControl.Controls;
namespace HandyControl.Tools
{
/// <summary>
/// 该类可以为可视化元素提供单开的功能
/// </summary>
public class SingleOpenHelper
{
private static readonly Dictionary<string, ISingleOpen> OpenDic = new Dictionary<string, ISingleOpen>();
/// <summary>
/// 根据指定的类型创建实例
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T CreateControl<T>() where T : Visual, ISingleOpen, new()
{
var typeStr = typeof(T).FullName;
if (string.IsNullOrEmpty(typeStr)) return default(T);
var temp = new T();
if (!OpenDic.Keys.Contains(typeStr))
{
OpenDic.Add(typeStr, temp);
return temp;
}
var currentCtl = OpenDic[typeStr];
if (currentCtl.CanDispose)
{
currentCtl.Dispose();
OpenDic[typeStr] = temp;
return temp;
}
return default(T);
}
}
}
+10
View File
@@ -32,6 +32,8 @@
public static readonly string WindowDemoCtl = nameof(WindowDemoCtl);
public static readonly string ScrollViewerDemoCtl = nameof(ScrollViewerDemoCtl);
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
@@ -68,6 +70,14 @@
public static readonly string BorderDemoCtl = nameof(BorderDemoCtl);
public static readonly string RadioButtonDemoCtl = nameof(RadioButtonDemoCtl);
public static readonly string NaiveScrollViewerDemoCtl = nameof(NaiveScrollViewerDemoCtl);
public static readonly string CommonWindow = nameof(CommonWindow);
public static readonly string CustomNonClientAreaWindow = nameof(CustomNonClientAreaWindow);
public static readonly string LoadShowContent = nameof(LoadShowContent);
}
}
+14 -2
View File
@@ -18,7 +18,8 @@ var controlList = new List<string>
"TimePickerDemoCtl",
"CirclePanelDemoCtl",
"NumericUpDownDemoCtl",
"WindowDemoCtl"
"WindowDemoCtl",
"ScrollViewerDemoCtl"
};
var styleList = new List<string>
{
@@ -39,7 +40,14 @@ var styleList = new List<string>
"ListBoxDemoCtl",
"MenuDemoCtl",
"TreeViewDemoCtl",
"BorderDemoCtl"
"BorderDemoCtl",
"RadioButtonDemoCtl",
"NaiveScrollViewerDemoCtl"
};
var windowList = new List<string>
{
"CommonWindow",
"CustomNonClientAreaWindow"
};
#>
namespace HandyControlDemo.Data
@@ -53,6 +61,10 @@ namespace HandyControlDemo.Data
<#foreach(var item in styleList){#>
public static readonly string <#=item#> = nameof(<#=item#>);
<#}#>
<#foreach(var item in windowList){#>
public static readonly string <#=item#> = nameof(<#=item#>);
<#}#>
public static readonly string LoadShowContent = nameof(LoadShowContent);
}
+38
View File
@@ -79,6 +79,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Lang.en.resx</DependentUpon>
</Compile>
<Compile Include="Service\DataService.cs" />
<Compile Include="Tools\AssemblyHelper.cs" />
<Compile Include="Tools\Converter\StringRepeatConverter.cs" />
<Compile Include="UserControl\Controls\AnimationPathDemoCtl.xaml.cs">
@@ -111,6 +112,9 @@
<Compile Include="UserControl\Controls\NumericUpDownDemoCtl.xaml.cs">
<DependentUpon>NumericUpDownDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Controls\ScrollViewerDemoCtl.xaml.cs">
<DependentUpon>ScrollViewerDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Controls\StepBarDemoCtl.xaml.cs">
<DependentUpon>StepBarDemoCtl.xaml</DependentUpon>
</Compile>
@@ -165,6 +169,9 @@
<Compile Include="UserControl\Styles\MenuDemoCtl.xaml.cs">
<DependentUpon>MenuDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Styles\NaiveScrollViewerDemoCtl.xaml.cs">
<DependentUpon>NaiveScrollViewerDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Styles\NaiveTabControlDemoCtl.xaml.cs">
<DependentUpon>NaiveTabControlDemoCtl.xaml</DependentUpon>
</Compile>
@@ -177,6 +184,9 @@
<Compile Include="UserControl\Controls\TabControlDemoCtl.xaml.cs">
<DependentUpon>TabControlDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Styles\RadioButtonDemoCtl.xaml.cs">
<DependentUpon>RadioButtonDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Styles\TextBlockDemoCtl.xaml.cs">
<DependentUpon>TextBlockDemoCtl.xaml</DependentUpon>
</Compile>
@@ -194,6 +204,13 @@
<Compile Include="ViewModel\ImageBrowserDemoViewModel.cs" />
<Compile Include="ViewModel\MainViewModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="ViewModel\WindowDemoViewModel.cs" />
<Compile Include="Window\CommonWindow.xaml.cs">
<DependentUpon>CommonWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Window\CustomNonClientAreaWindow.xaml.cs">
<DependentUpon>CustomNonClientAreaWindow.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -278,6 +295,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Controls\ScrollViewerDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Controls\StepBarDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -350,6 +371,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Styles\NaiveScrollViewerDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Styles\NaiveTabControlDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -366,6 +391,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Styles\RadioButtonDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Styles\TextBlockDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -382,6 +411,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window\CommonWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window\CustomNonClientAreaWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@@ -410,6 +447,7 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput>
</Content>
<Resource Include="Resources\Img\RadioButton_16x.png" />
<Resource Include="Resources\Img\BorderElement_16x.png" />
<Resource Include="Resources\Img\ScrollBox_16x.png" />
<Resource Include="Resources\Img\ContextMenu_16x.png" />
+3 -3
View File
@@ -8,7 +8,7 @@
mc:Ignorable="d"
BorderThickness="1"
BorderBrush="#262e2f"
NoUserAreaBackground="#262e2f"
NonClientAreaBackground="#262e2f"
OtherButtonHoverBrush="#888580"
Style="{StaticResource CustomWindowStyle}"
WindowState="Maximized"
@@ -18,9 +18,9 @@
DataContext="{Binding Main,Source={StaticResource Locator}}"
d:DesignHeight="800"
d:DesignWidth="1400">
<controls:WindowBorderless.NoUserContent>
<controls:WindowBorderless.NonClientAreaContent>
<userControl:NoUserContent/>
</controls:WindowBorderless.NoUserContent>
</controls:WindowBorderless.NonClientAreaContent>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" MinWidth="200" MaxWidth="400"/>
+1 -2
View File
@@ -12,5 +12,4 @@ using System.Windows;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.3.4")]
[assembly: AssemblyFileVersion("1.3.4")]
[assembly: AssemblyVersion("1.3.4.*")]
+54
View File
@@ -393,6 +393,33 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 点击打开常规窗口 的本地化字符串。
/// </summary>
public static string OpenCommonWindow {
get {
return ResourceManager.GetString("OpenCommonWindow", resourceCulture);
}
}
/// <summary>
/// 查找类似 点击打开自定义内容窗口 的本地化字符串。
/// </summary>
public static string OpenCustomContentWindow {
get {
return ResourceManager.GetString("OpenCustomContentWindow", resourceCulture);
}
}
/// <summary>
/// 查找类似 点击打开自定义非客户端区域窗口 的本地化字符串。
/// </summary>
public static string OpenCustomNonClientAreaWindow {
get {
return ResourceManager.GetString("OpenCustomNonClientAreaWindow", resourceCulture);
}
}
/// <summary>
/// 查找类似 点击打开图片浏览器 的本地化字符串。
/// </summary>
@@ -402,6 +429,24 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 点击打开消息窗口 的本地化字符串。
/// </summary>
public static string OpenMessageWindow {
get {
return ResourceManager.GetString("OpenMessageWindow", resourceCulture);
}
}
/// <summary>
/// 查找类似 点击打开鼠标跟随窗口 的本地化字符串。
/// </summary>
public static string OpenMouseFollowWindow {
get {
return ResourceManager.GetString("OpenMouseFollowWindow", resourceCulture);
}
}
/// <summary>
/// 查找类似 页码条 的本地化字符串。
/// </summary>
@@ -456,6 +501,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 单选按钮 的本地化字符串。
/// </summary>
public static string RadioButton {
get {
return ResourceManager.GetString("RadioButton", resourceCulture);
}
}
/// <summary>
/// 查找类似 注册 的本地化字符串。
/// </summary>
@@ -324,4 +324,22 @@
<data name="RightClickHere" xml:space="preserve">
<value>Right click here </value>
</data>
<data name="RadioButton" xml:space="preserve">
<value>RadioButton</value>
</data>
<data name="OpenMessageWindow" xml:space="preserve">
<value>open message window</value>
</data>
<data name="OpenCommonWindow" xml:space="preserve">
<value>open common window</value>
</data>
<data name="OpenCustomNonClientAreaWindow" xml:space="preserve">
<value>open custom Non-client Area window</value>
</data>
<data name="OpenMouseFollowWindow" xml:space="preserve">
<value>open mouse follow window</value>
</data>
<data name="OpenCustomContentWindow" xml:space="preserve">
<value>open custom content window</value>
</data>
</root>
@@ -304,4 +304,22 @@
<data name="RightClickHere" xml:space="preserve">
<value>在这里右击</value>
</data>
<data name="RadioButton" xml:space="preserve">
<value>单选按钮</value>
</data>
<data name="OpenMessageWindow" xml:space="preserve">
<value>点击打开消息窗口</value>
</data>
<data name="OpenCommonWindow" xml:space="preserve">
<value>点击打开常规窗口</value>
</data>
<data name="OpenCustomNonClientAreaWindow" xml:space="preserve">
<value>点击打开自定义非客户端区域窗口</value>
</data>
<data name="OpenMouseFollowWindow" xml:space="preserve">
<value>点击打开鼠标跟随窗口</value>
</data>
<data name="OpenCustomContentWindow" xml:space="preserve">
<value>点击打开自定义内容窗口</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

@@ -20,6 +20,16 @@
</DrawingBrush.Drawing>
</DrawingBrush>
<LinearGradientBrush x:Key="MenuButtonBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="#F2F2F2" Offset="1"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ToolBarBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#F5F4F5" Offset="0"/>
<GradientStop Color="#D1CFD1" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="MainBackgroundBrush" Color="{StaticResource MainBackgroundColor}"/>
</ResourceDictionary>
+52
View File
@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Globalization;
using HandyControlDemo.Data;
using HandyControlDemo.Tools.Converter;
namespace HandyControlDemo.Service
{
public class DataService
{
public List<DemoDataModel> GetDemoDataList()
{
var list = new List<DemoDataModel>();
for (var i = 1; i <= 6; i++)
{
var dataList = new List<DemoDataModel>();
for (int j = 0; j < 3; j++)
{
dataList.Add(new DemoDataModel
{
Index = j,
IsSelected = j % 2 == 0,
Name = $"SubName{j}",
Type = (DemoType)j
});
}
var model = new DemoDataModel
{
Index = i,
IsSelected = i % 2 == 0,
Name = $"Name{i}",
Type = (DemoType)i,
DataList = dataList
};
list.Add(model);
}
return list;
}
public List<string> GetComboBoxDemoDataList()
{
var converter = new StringRepeatConverter();
var list = new List<string>();
for (var i = 1; i <= 9; i++)
{
list.Add(converter.Convert(Properties.Langs.Lang.Text, null, i, CultureInfo.CurrentCulture)?.ToString());
}
return list;
}
}
}
@@ -0,0 +1,79 @@
<UserControl x:Class="HandyControlDemo.UserControl.ScrollViewerDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="White"
Width="550"
Height="600">
<controls:TransitioningContentControl>
<Grid Margin="32">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}">
<controls:ScrollViewer Orientation="Horizontal" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" IsEnableInertia="True">
<StackPanel Orientation="Horizontal">
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
</StackPanel>
</controls:ScrollViewer>
</Border>
<Border Grid.Row="1" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,16,0,0">
<controls:ScrollViewer IsEnableInertia="True">
<WrapPanel Orientation="Horizontal">
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
</WrapPanel>
</controls:ScrollViewer>
</Border>
</Grid>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,11 @@
// ReSharper disable once CheckNamespace
namespace HandyControlDemo.UserControl
{
public partial class ScrollViewerDemoCtl
{
public ScrollViewerDemoCtl()
{
InitializeComponent();
}
}
}
@@ -2,8 +2,17 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:data="clr-namespace:HandyControlDemo.Data"
DataContext="{Binding WindowDemo,Source={StaticResource Locator}}"
Background="White">
<controls:TransitioningContentControl>
<UniformGrid Margin="32" Columns="3" Rows="2" Height="200">
<Button Command="{Binding OpenWindowCmd}" CommandParameter="{x:Static data:MessageToken.CommonWindow}" Content="{x:Static langs:Lang.OpenCommonWindow}"/>
<Button Command="{Binding OpenWindowCmd}" CommandParameter="{x:Static data:MessageToken.CustomNonClientAreaWindow}" Content="{x:Static langs:Lang.OpenCustomNonClientAreaWindow}"/>
<Button Click="ButtonMessage_OnClick" Content="{x:Static langs:Lang.OpenMessageWindow}"/>
<Button Click="ButtonCustomContent_OnClick" Content="{x:Static langs:Lang.OpenCustomContentWindow}"/>
<Button Name="ButtonMouseFollow" Click="ButtonMouseFollow_OnClick" Content="{x:Static langs:Lang.OpenMouseFollowWindow}"/>
</UniformGrid>
</controls:TransitioningContentControl>
</UserControl>
@@ -1,4 +1,8 @@
// ReSharper disable once CheckNamespace
using System.Windows;
using HandyControl.Controls;
using HandyControl.Tools;
// ReSharper disable once CheckNamespace
namespace HandyControlDemo.UserControl
{
public partial class WindowDemoCtl
@@ -7,5 +11,40 @@ namespace HandyControlDemo.UserControl
{
InitializeComponent();
}
private void ButtonMessage_OnClick(object sender, RoutedEventArgs e)
{
PopupWindow.ShowDialog(Properties.Langs.Lang.GrowlAsk, showCancel: true);
}
private void ButtonMouseFollow_OnClick(object sender, RoutedEventArgs e)
{
var picker = SingleOpenHelper.CreateControl<ColorPicker>();
var window = new PopupWindow
{
PopupElement = picker
};
picker.SelectedColorChanged += delegate { window.Close(); };
picker.Canceled += delegate { window.Close(); };
window.Show(ButtonMouseFollow, false);
}
private void ButtonCustomContent_OnClick(object sender, RoutedEventArgs e)
{
var picker = SingleOpenHelper.CreateControl<ColorPicker>();
var window = new PopupWindow
{
PopupElement = picker,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
AllowsTransparency = true,
WindowStyle = WindowStyle.None,
MinWidth = 0,
MinHeight = 0,
Title = Properties.Langs.Lang.ColorPicker
};
picker.SelectedColorChanged += delegate { window.Close(); };
picker.Canceled += delegate { window.Close(); };
window.Show();
}
}
}
@@ -25,11 +25,21 @@
<Image Source="../../Resources/Img/Toggle_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Tag="{x:Static data:MessageToken.CheckBoxDemoCtl}" Content="{x:Static langs:Lang.CheckBox}">
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.RadioButtonDemoCtl}" Content="{x:Static langs:Lang.RadioButton}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/RadioButton_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.CheckBoxDemoCtl}" Content="{x:Static langs:Lang.CheckBox}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/CheckBox_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.NaiveScrollViewerDemoCtl}" Content="{x:Static langs:Lang.ScrollViewer}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/ScrollBox_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Tag="{x:Static data:MessageToken.TextBlockDemoCtl}" Content="{x:Static langs:Lang.TextBlock}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/TextBlock_16x.png" Stretch="Uniform"/>
@@ -75,27 +85,27 @@
<Image Source="../../Resources/Img/TabPage_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.DataGridDemoCtl}" Content="{x:Static langs:Lang.DataGrid}">
<ListBoxItem Tag="{x:Static data:MessageToken.DataGridDemoCtl}" Content="{x:Static langs:Lang.DataGrid}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/DataGrid_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.TreeViewDemoCtl}" Content="{x:Static langs:Lang.TreeView}">
<ListBoxItem Tag="{x:Static data:MessageToken.TreeViewDemoCtl}" Content="{x:Static langs:Lang.TreeView}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/TreeView_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.ListBoxDemoCtl}" Content="{x:Static langs:Lang.ListBox}">
<ListBoxItem Tag="{x:Static data:MessageToken.ListBoxDemoCtl}" Content="{x:Static langs:Lang.ListBox}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/ListBox_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.MenuDemoCtl}" Content="{x:Static langs:Lang.Menu}">
<ListBoxItem Tag="{x:Static data:MessageToken.MenuDemoCtl}" Content="{x:Static langs:Lang.Menu}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/ContextMenu_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.BorderDemoCtl}" Content="{x:Static langs:Lang.Border1}">
<ListBoxItem Tag="{x:Static data:MessageToken.BorderDemoCtl}" Content="{x:Static langs:Lang.Border1}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/BorderElement_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
@@ -104,7 +114,7 @@
</TabItem>
<TabItem Header="{x:Static langs:Lang.Controls}">
<ListBox BorderThickness="0" SelectionMode="Single">
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.NumericUpDownDemoCtl}" Content="{x:Static langs:Lang.NumericUpDown}">
<ListBoxItem Tag="{x:Static data:MessageToken.NumericUpDownDemoCtl}" Content="{x:Static langs:Lang.NumericUpDown}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/NumericListBox_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
@@ -179,7 +189,12 @@
<Image Source="../../Resources/Img/TabPage_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem IsEnabled="False" Tag="{x:Static data:MessageToken.WindowDemoCtl}" Content="{x:Static langs:Lang.Window}">
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.ScrollViewerDemoCtl}" Content="{x:Static langs:Lang.ScrollViewer}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/ScrollBox_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.WindowDemoCtl}" Content="{x:Static langs:Lang.Window}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/WindowsForm_16x.png" Stretch="Uniform"/>
</controls:EdgeElement.LeftContent>
@@ -6,13 +6,13 @@
Background="White"
Width="400">
<controls:TransitioningContentControl>
<StackPanel Margin="32" HorizontalAlignment="Center">
<CheckBox VerticalAlignment="Center" Content="{x:Static langs:Lang.Selected}" IsChecked="True"/>
<CheckBox Margin="0,16,0,0" VerticalAlignment="Center" Content="{x:Static langs:Lang.Selected}" IsChecked="True" IsEnabled="False"/>
<CheckBox Margin="0,16,0,0" VerticalAlignment="Center" Content="{x:Static langs:Lang.Selected}"/>
<CheckBox Margin="0,16,0,0" VerticalAlignment="Center" Content="{x:Static langs:Lang.Selected}" IsEnabled="False"/>
<CheckBox Margin="0,16,0,0" VerticalAlignment="Center" Content="{x:Static langs:Lang.Selected}" IsChecked="{x:Null}"/>
<CheckBox Margin="0,16,0,0" VerticalAlignment="Center" Content="{x:Static langs:Lang.Selected}" IsChecked="{x:Null}" IsEnabled="False"/>
<StackPanel Margin="32" HorizontalAlignment="Center" VerticalAlignment="Center">
<CheckBox Content="{x:Static langs:Lang.CheckBox}" IsChecked="True"/>
<CheckBox Margin="0,16,0,0" Content="{x:Static langs:Lang.CheckBox}" IsChecked="True" IsEnabled="False"/>
<CheckBox Margin="0,16,0,0" Content="{x:Static langs:Lang.CheckBox}"/>
<CheckBox Margin="0,16,0,0" Content="{x:Static langs:Lang.CheckBox}" IsEnabled="False"/>
<CheckBox Margin="0,16,0,0" Content="{x:Static langs:Lang.CheckBox}" IsChecked="{x:Null}"/>
<CheckBox Margin="0,16,0,0" Content="{x:Static langs:Lang.CheckBox}" IsChecked="{x:Null}" IsEnabled="False"/>
</StackPanel>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,79 @@
<UserControl x:Class="HandyControlDemo.UserControl.NaiveScrollViewerDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="White"
Width="550"
Height="600">
<controls:TransitioningContentControl>
<Grid Margin="32">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
<StackPanel Orientation="Horizontal">
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
</StackPanel>
</ScrollViewer>
</Border>
<Border Grid.Row="1" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,16,0,0">
<ScrollViewer>
<WrapPanel Orientation="Horizontal">
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
<Border Style="{StaticResource BorderRegionStyle}" Width="200" Height="200" Margin="10,10,32,10">
<Border Background="{StaticResource PrimaryBrush}">
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Border>
</Border>
</WrapPanel>
</ScrollViewer>
</Border>
</Grid>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,11 @@
// ReSharper disable once CheckNamespace
namespace HandyControlDemo.UserControl
{
public partial class NaiveScrollViewerDemoCtl
{
public NaiveScrollViewerDemoCtl()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,16 @@
<UserControl x:Class="HandyControlDemo.UserControl.RadioButtonDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="White"
Width="400">
<controls:TransitioningContentControl>
<StackPanel Margin="32" HorizontalAlignment="Center" VerticalAlignment="Center">
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}" IsChecked="True" IsEnabled="False"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}" IsEnabled="False"/>
</StackPanel>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,11 @@
// ReSharper disable once CheckNamespace
namespace HandyControlDemo.UserControl
{
public partial class RadioButtonDemoCtl
{
public RadioButtonDemoCtl()
{
InitializeComponent();
}
}
}
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Globalization;
using GalaSoft.MvvmLight;
using HandyControlDemo.Tools.Converter;
using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
@@ -21,16 +20,6 @@ namespace HandyControlDemo.ViewModel
set => Set(ref _dataList, value);
}
public ComboBoxDemoViewModel()
{
var converter = new StringRepeatConverter();
var list = new List<string>();
for (var i = 1; i <= 9; i++)
{
list.Add(converter.Convert(Properties.Langs.Lang.Text, null, i, CultureInfo.CurrentCulture)?.ToString());
}
DataList = list;
}
public ComboBoxDemoViewModel(DataService dataService) => DataList = dataService.GetComboBoxDemoDataList();
}
}
+11 -29
View File
@@ -5,6 +5,7 @@ using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging;
using HandyControlDemo.Data;
using HandyControlDemo.Service;
using HandyControlDemo.Tools;
namespace HandyControlDemo.ViewModel
@@ -28,38 +29,17 @@ namespace HandyControlDemo.ViewModel
/// </summary>
private List<DemoDataModel> _dataList;
/// <summary>
/// 当前选中的列表项
/// </summary>
private ListBoxItem _listBoxItemCurrent;
#endregion
public MainViewModel()
public MainViewModel(DataService dataService)
{
Messenger.Default.Register<object>(this, MessageToken.LoadShowContent, obj => SubContent = obj);
var list = new List<DemoDataModel>();
for (var i = 1; i <= 6; i++)
{
var dataList = new List<DemoDataModel>();
for (int j = 0; j < 3; j++)
{
dataList.Add(new DemoDataModel
{
Index = j,
IsSelected = j % 2 == 0,
Name = $"SubName{j}",
Type = (DemoType)j
});
}
var model = new DemoDataModel
{
Index = i,
IsSelected = i % 2 == 0,
Name = $"Name{i}",
Type = (DemoType)i,
DataList = dataList
};
list.Add(model);
}
DataList = list;
DataList = dataService.GetDemoDataList();
}
#region 属性
@@ -116,12 +96,14 @@ namespace HandyControlDemo.ViewModel
{
if (item.Tag is string tag)
{
if (item.Content.Equals(ContentTitle)) return;
if (Equals(_listBoxItemCurrent, item)) return;
_listBoxItemCurrent = item;
ContentTitle = item.Content;
Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{tag}"), MessageToken.LoadShowContent);
}
else
{
_listBoxItemCurrent = null;
ContentTitle = null;
SubContent = null;
}
@@ -2,6 +2,7 @@
using System.Windows;
using CommonServiceLocator;
using GalaSoft.MvvmLight.Ioc;
using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
@@ -11,10 +12,13 @@ namespace HandyControlDemo.ViewModel
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
SimpleIoc.Default.Register<DataService>();
SimpleIoc.Default.Register<MainViewModel>();
SimpleIoc.Default.Register<GrowlDemoViewModel>();
SimpleIoc.Default.Register<ImageBrowserDemoViewModel>();
SimpleIoc.Default.Register<ComboBoxDemoViewModel>();
SimpleIoc.Default.Register<WindowDemoViewModel>();
}
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -30,6 +34,8 @@ namespace HandyControlDemo.ViewModel
public ComboBoxDemoViewModel ComboBoxDemo => ServiceLocator.Current.GetInstance<ComboBoxDemoViewModel>();
public WindowDemoViewModel WindowDemo => ServiceLocator.Current.GetInstance<WindowDemoViewModel>();
#endregion
}
}
@@ -0,0 +1,19 @@
using System;
using GalaSoft.MvvmLight.CommandWpf;
using HandyControlDemo.Tools;
namespace HandyControlDemo.ViewModel
{
public class WindowDemoViewModel
{
public RelayCommand<string> OpenWindowCmd => new Lazy<RelayCommand<string>>(() => new RelayCommand<string>(OpenWindow)).Value;
private void OpenWindow(string windowTag)
{
if (AssemblyHelper.CreateInternalInstance($"Window.{windowTag}") is System.Windows.Window window)
{
window.ShowDialog();
}
}
}
}
+17
View File
@@ -0,0 +1,17 @@
<controls:WindowBorderless x:Class="HandyControlDemo.Window.CommonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
mc:Ignorable="d"
ShowTitle="True"
Background="#f0f0f0"
WindowStartupLocation="CenterScreen"
Style="{StaticResource CustomWindowStyle}"
Title="{x:Static langs:Lang.Title}"
Height="450"
Width="800">
<Border Background="{StaticResource MainContentBackground}"/>
</controls:WindowBorderless>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.Window
{
public partial class CommonWindow
{
public CommonWindow()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,61 @@
<controls:WindowBorderless x:Class="HandyControlDemo.Window.CustomNonClientAreaWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
mc:Ignorable="d"
OtherButtonForeground="{StaticResource PrimaryTextBrush}"
CloseButtonForeground="{StaticResource PrimaryTextBrush}"
OtherButtonHoverBrush="{StaticResource PrimaryTextBrush}"
NonClientAreaBackground="{StaticResource ToolBarBackground}"
NonClientAreaHeight="69"
Background="#f0f0f0"
WindowStartupLocation="CenterScreen"
Style="{StaticResource CustomWindowStyle}"
Title="{x:Static langs:Lang.Title}"
Height="450"
Width="800">
<controls:WindowBorderless.NonClientAreaContent>
<StackPanel Orientation="Horizontal" Height="69">
<Path Data="{StaticResource LogoGeometry}" Width="40" Height="40" Stretch="Uniform" Fill="#F76B1C" Margin="20,0,0,0"></Path>
<Button Style="{StaticResource ButtonCustom}" Margin="32,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="5" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource ErrorGeometry}"></Path>
</Border>
</Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource AskGeometry}"></Path>
</Border>
</Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource InfoGeometry}"></Path>
</Border>
</Button>
<Button Style="{StaticResource ButtonCustom}" Margin="32,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="5" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource ErrorGeometry}"></Path>
</Border>
</Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource AskGeometry}"></Path>
</Border>
</Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource AllGeometry}"></Path>
</Border>
</Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource InfoGeometry}"></Path>
</Border>
</Button>
</StackPanel>
</controls:WindowBorderless.NonClientAreaContent>
<Border Background="{StaticResource MainContentBackground}"/>
</controls:WindowBorderless>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.Window
{
public partial class CustomNonClientAreaWindow
{
public CustomNonClientAreaWindow()
{
InitializeComponent();
}
}
}