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

+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();
}
}
}