提交 b7728040 编写于 作者: 小时後可胖了's avatar 小时後可胖了

新增SmartWindow控件

新增PackIcon示例
上级 890d0d12
......@@ -4,3 +4,4 @@ SmartUI.Demo/obj/
SmartUI/bin/
SmartUI/obj/
/.vs
/SmartUI/SmartUI.1.0.0.1.nupkg
<Window x:Class="SmartUI.Demo.MainWindow"
<smart:SmartWindow x:Class="SmartUI.Demo.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"
......@@ -6,9 +6,9 @@
xmlns:smart="clr-namespace:SmartUI.Controls;assembly=SmartUI"
xmlns:local="clr-namespace:SmartUI.Demo"
xmlns:assist="clr-namespace:SmartUI.Assist;assembly=SmartUI"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="1000">
<TabControl>
mc:Ignorable="d" Style="{StaticResource DefaultWindowStyle}"
Title="SmartUI" Height="500" Width="1000" WindowStartupLocation="CenterScreen">
<TabControl IsTabStop="False" Margin="0">
<TabItem Header="Button">
<UniformGrid Columns="7" Rows="6">
<Label Content="默认样式"/>
......@@ -54,8 +54,26 @@
<Button Content="禁用按钮" IsEnabled="False" Style="{StaticResource TextButtonStyle}"/>
</UniformGrid>
</TabItem>
<TabItem Header="123">
<TabItem Header="PackIcon">
<ScrollViewer VerticalScrollBarVisibility="Visible" CanContentScroll="True">
<ItemsControl ItemsSource="{Binding Icons}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<HierarchicalDataTemplate>
<StackPanel Orientation="Vertical" Width="50" Height="70" Margin="5" ToolTip="{Binding}">
<smart:PackIcon Kind="{Binding}" VerticalAlignment="Center" Foreground="Gray" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding}" HorizontalAlignment="Center" TextTrimming="WordEllipsis" Foreground="Gray"/>
</StackPanel>
</HierarchicalDataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</TabItem>
</TabControl>
</Window>
</smart:SmartWindow>
......@@ -18,11 +18,12 @@ namespace SmartUI.Demo
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow : SmartUI.Controls.SmartWindow
{
public MainWindow()
{
InitializeComponent();
DataContext = new MainWindowModel();
}
}
}
using SmartUI.Common.Enum;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartUI.Demo
{
public class MainWindowModel : INotifyPropertyChanged
{
private ObservableCollection<PackIconKind> icons;
public ObservableCollection<PackIconKind> Icons
{
get => icons;
set
{
icons = value;
RaisePropertyChanged(nameof(Icons));
}
}
public MainWindowModel()
{
PackIconKind[] array =(PackIconKind[]) Enum.GetValues(typeof(PackIconKind));
Icons = new ObservableCollection<PackIconKind>(array);
}
protected void RaisePropertyChanged(string propertyName)
{
var method = PropertyChanged;
if (method != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -70,6 +70,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="MainWindowModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace SmartUI.Controls
{
public class SmartWindow : Window
{
private TextBlock _title;
public SmartWindow()
{
CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, (a, b) => { WindowState = WindowState.Minimized; }));
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, (a, b) => { WindowState = WindowState.Maximized; }));
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (a, b) => { Close(); }));
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, (a, b) => { WindowState = WindowState.Normal; }));
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_title = GetTemplateChild("title") as TextBlock;
if (_title != null)
{
_title.MouseLeftButtonDown += _title_MouseLeftButtonDown;
}
}
private void _title_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed && e.ClickCount == 1)
{
this.DragMove();
}
else if (e.ClickCount == 2)
{
if (WindowState == WindowState.Maximized)
WindowState = WindowState.Normal;
else if (WindowState == WindowState.Normal)
WindowState = WindowState.Maximized;
}
}
}
}
......@@ -4,7 +4,7 @@ using System.Windows;
using System.Windows.Data;
using SmartUI.Common.Enum;
namespace DiningReservation.UI.Converter
namespace SmartUI.UI.Converter
{
public class DialogButtonConverter : IValueConverter
{
......
......@@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DiningReservation.UI.Converter
namespace SmartUI.UI.Converter
{
public class PassWordConverter : IValueConverter
{
......
......@@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows.Data;
using SmartUI.Common;
namespace DiningReservation.UI.Converter
namespace SmartUI.UI.Converter
{
public class TimestampConverter : IValueConverter
{
......
......@@ -63,6 +63,7 @@
<Compile Include="Controls\NoticeControl.cs" />
<Compile Include="Controls\PackIcon.cs" />
<Compile Include="Controls\PackIconDataFactory.cs" />
<Compile Include="Controls\SmartWindow.cs" />
<Compile Include="Controls\WaterComboBox.cs" />
<Compile Include="Converter\DialogButtonConverter.cs" />
<Compile Include="Converter\PassWordConverter.cs" />
......@@ -81,6 +82,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\WindowStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\TabControlStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -134,10 +139,6 @@
<Content Include="Images\u196.png" />
<Content Include="Images\u301.png" />
<Content Include="Images\u304.png" />
<Content Include="nuget.exe" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -2,16 +2,16 @@
<package >
<metadata>
<id>$id$</id>
<version>1.0.0.0</version>
<version>1.0.0.1</version>
<title>SmartUI</title>
<authors>柯勇</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<projectUrl>http://project_url_here_or_delete_this_line/</projectUrl>
<projectUrl>https://github.com/qq1678167865/smartUI</projectUrl>
<iconUrl>http://icon_url_here_or_delete_this_line/</iconUrl>
<description>WPF UI组件库</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<releaseNotes>SmartUI是是用于构建Wpf程序的一套基础UI框架,内置了丰富的控件样式以及自定义组件,整体风格类似于前端的Element</releaseNotes>
<copyright>$copyright$</copyright>
<tags>Tag1 Tag2</tags>
<tags></tags>
</metadata>
</package>
\ No newline at end of file
......@@ -13,5 +13,6 @@
<ResourceDictionary Source="pack://application:,,,/SmartUI;component/Themes/PackIconStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/SmartUI;component/Themes/LableStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/SmartUI;component/Themes/TabControlStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/SmartUI;component/Themes/WindowStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type control:PackIcon}">
<Viewbox Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Data="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Data}" Fill="{TemplateBinding Foreground}" Stretch="Fill" Margin="2"/>
<Path Data="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Data}" Fill="{TemplateBinding Foreground}" Stretch="Fill" Margin="2"/>
</Viewbox>
</ControlTemplate>
</Setter.Value>
......
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DiningReservation.UI.Themes">
xmlns:local="clr-namespace:SmartUI.UI.Themes">
<Style TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="#FF333333" />
......@@ -149,9 +149,9 @@
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition MaxHeight="18" />
<RowDefinition MaxHeight="0" />
<RowDefinition Height="0.00001*" />
<RowDefinition MaxHeight="18" />
<RowDefinition MaxHeight="0" />
</Grid.RowDefinitions>
<RepeatButton x:Name="DecreaseRepeat" Command="ScrollBar.LineUpCommand" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}">
<Grid Margin="0,0,0,0">
......
......@@ -24,10 +24,10 @@
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TabPanel x:Name="HeaderPanel"
Grid.Row="0" Panel.ZIndex="1"
Margin="0,0,4,-2" IsItemsHost="True" KeyboardNavigation.TabIndex="1" Background="Transparent" />
<Border x:Name="Border" Grid.Row="1" BorderThickness="0 2 0 0" BorderBrush="{TemplateBinding BorderBrush}" KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2">
<Border BorderBrush="{TemplateBinding BorderBrush}" Panel.ZIndex="1" Width="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=ActualWidth}" Grid.Row="0" BorderThickness="0 0 0 2">
<TabPanel x:Name="HeaderPanel" Margin="0,0,4,-2" IsItemsHost="True" KeyboardNavigation.TabIndex="1" Background="Transparent" />
</Border>
<Border x:Name="Border" Grid.Row="1" BorderThickness="0 0 0 0" BorderBrush="{TemplateBinding BorderBrush}" KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2">
<ContentPresenter x:Name="PART_SelectedContentHost" Margin="4" ContentSource="SelectedContent" />
</Border>
</Grid>
......@@ -37,7 +37,7 @@
</Style>
<Style TargetType="TabItem">
<Setter Property="MinWidth" Value="100"/>
<Setter Property="Height" Value="50"/>
<Setter Property="Height" Value="40"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Cursor" Value="Hand"/>
......
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assist="clr-namespace:SmartUI.Assist"
xmlns:smart="clr-namespace:SmartUI.Controls">
<Style x:Key="DefaultWindowStyle" TargetType="{x:Type smart:SmartWindow}">
<Setter Property="AllowsTransparency" Value="True"/>
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type smart:SmartWindow}">
<Border x:Name="border" Background="{DynamicResource BgWhiteColor}" Margin="0 0 8 8" BorderBrush="{DynamicResource BorderLightColor}" BorderThickness="1">
<Border.Effect>
<DropShadowEffect ShadowDepth="8" Color="LightGray" Opacity="0.1"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
<RowDefinition Height="6"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<DockPanel LastChildFill="True" Grid.Row="0">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
<Button assist:ButtonAssist.Icon="WindowMinimize" Command="SystemCommands.MinimizeWindowCommand" Style="{DynamicResource WindowButtonStyle}"/>
<Button x:Name="restore" assist:ButtonAssist.Icon="WindowRestore" Command="SystemCommands.RestoreWindowCommand" Style="{DynamicResource WindowButtonStyle}" Visibility="Collapsed"/>
<Button x:Name="maximize" assist:ButtonAssist.Icon="WindowMaximize" Command="SystemCommands.MaximizeWindowCommand" Style="{DynamicResource WindowButtonStyle}"/>
<Button assist:ButtonAssist.Icon="WindowClose" Command="SystemCommands.CloseWindowCommand" Style="{DynamicResource WindowButtonStyle}"/>
</StackPanel>
<DockPanel LastChildFill="True">
<Image x:Name="icon" DockPanel.Dock="Left" Source="{TemplateBinding Icon}" Width="24" Height="24" VerticalAlignment="Center"/>
<TextBlock x:Name="title" Text="{TemplateBinding Title}" VerticalAlignment="Center" Padding="5" FontSize="13" FontWeight="ExtraBlack"/>
</DockPanel>
</DockPanel>
<Rectangle Height="6" Grid.Row="1">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#CCCCCC" Offset="0.0" />
<GradientStop Color="#DDDDDD" Offset="0.1" />
<GradientStop Color="#FAFAFA" Offset="0.5" />
<GradientStop Color="White" Offset="1.0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<ContentPresenter Grid.Row="2"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="icon" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter TargetName="border" Property="Effect" Value="{x:Null}"/>
<Setter TargetName="border" Property="Margin" Value="0"/>
<Setter TargetName="maximize" Property="Visibility" Value="Collapsed"/>
<Setter TargetName="restore" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="WindowState" Value="Normal">
<Setter TargetName="maximize" Property="Visibility" Value="Visible"/>
<Setter TargetName="restore" Property="Visibility" Value="Collapsed"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="WindowButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Width" Value="50"/>
<Setter Property="Height" Value="35"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<smart:PackIcon Kind="{TemplateBinding assist:ButtonAssist.Icon}" Width="16" Height="16"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#EEEEF2"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="assist:ButtonAssist.Icon" Value="WindowClose"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="#D32424"/>
<Setter Property="Foreground" Value="White"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CalcBinding" version="2.4.0" targetFramework="net452" />
<package id="DynamicExpresso.Core" version="1.3.4.8" targetFramework="net452" />
</packages>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册