跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
新增UI/Controls/Base/IconSelect.cs+180 −0看文件
@@ -0,0 +1,180 @@
1新增:using Core.Librarys;
2新增:using System;
3新增:using System.Collections.Generic;
4新增:using System.Linq;
5新增:using System.Text;
6新增:using System.Threading.Tasks;
7新增:using System.Windows;
8新增:using System.Windows.Controls;
9新增:using System.Windows.Input;
10新增:
11新增:namespace UI.Controls.Base
12新增:{
13新增: public class IconSelect : Control
14新增: {
15新增: public List<string> Icons
16新增: {
17新增: get { return (List<string>)GetValue(DaysProperty); }
18新增: set { SetValue(DaysProperty, value); }
19新增: }
20新增: public static readonly DependencyProperty DaysProperty =
21新增: DependencyProperty.Register("Icons",
22新增: typeof(List<string>),
23新增: typeof(IconSelect)
24新增: );
25新增:
26新增: /// <summary>
27新增: /// 图片链接
28新增: /// </summary>
29新增: public string URL
30新增: {
31新增: get { return (string)GetValue(URLProperty); }
32新增: set { SetValue(URLProperty, value); }
33新增: }
34新增: public static readonly DependencyProperty URLProperty =
35新增: DependencyProperty.Register("URL",
36新增: typeof(string),
37新增: typeof(IconSelect));
38新增:
39新增:
40新增: public bool IsOpen
41新增: {
42新增: get { return (bool)GetValue(IsOpenProperty); }
43新增: set { SetValue(IsOpenProperty, value); }
44新增: }
45新增: public static readonly DependencyProperty IsOpenProperty =
46新增: DependencyProperty.Register("IsOpen",
47新增: typeof(bool),
48新增: typeof(IconSelect), new PropertyMetadata(new PropertyChangedCallback(OnPropertyChanged)));
49新增:
50新增: private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
51新增: {
52新增: var control = d as IconSelect;
53新增: if (e.Property == IsOpenProperty)
54新增: {
55新增: control.HandleHook();
56新增: }
57新增: }
58新增: private Win32API.LowLevelKeyboardProc mouseProc;
59新增: private static IntPtr hookMouseID = IntPtr.Zero;
60新增: private IntPtr hook;
61新增: private bool IsFirstClick = false;
62新增: private Border SelectContainer;
63新增:
64新增:
65新增: #region hook
66新增: private void HandleHook()
67新增: {
68新增: if (IsOpen)
69新增: {
70新增: // 设置键盘钩子
71新增: hook = Win32API.SetMouseHook(mouseProc);
72新增: }
73新增: else
74新增: {
75新增: Win32API.UnhookWindowsHookEx(hook);
76新增: }
77新增: }
78新增: private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
79新增: {
80新增:
81新增: if (nCode >= 0)
82新增: {
83新增: if (wParam == (IntPtr)Win32API.WM_LBUTTONDBLCLK || wParam == (IntPtr)Win32API.WM_WHEEL)
84新增: {
85新增: if (!IsFirstClick)
86新增: {
87新增: bool isInControl = IsInControl();
88新增:
89新增: if (!isInControl)
90新增: {
91新增: IsOpen = false;
92新增: }
93新增: }
94新增: IsFirstClick = false;
95新增: }
96新增:
97新增: }
98新增:
99新增: return Win32API.CallNextHookEx(hookMouseID, nCode, wParam, lParam);
100新增: }
101新增: private bool IsInControl()
102新增: {
103新增: var p = Mouse.GetPosition(SelectContainer);
104新增: if (p.X < 0 || p.Y < 0 || p.X > SelectContainer.ActualWidth || p.Y > SelectContainer.ActualHeight)
105新增: {
106新增: return false;
107新增: }
108新增:
109新增:
110新增: return true;
111新增: }
112新增: #endregion
113新增:
114新增: public Command ShowSelectCommand { get; set; }
115新增: public Command FileSelectCommand { get; set; }
116新增:
117新增: public IconSelect()
118新增: {
119新增: DefaultStyleKey = typeof(IconSelect);
120新增: URL = "pack://application:,,,/Tai;component/Resources/Emoji/(1).png";
121新增: ShowSelectCommand = new Command(new Action<object>(OnShowSelect));
122新增: FileSelectCommand = new Command(new Action<object>(OnFileSelect));
123新增: mouseProc = HookCallback;
124新增:
125新增: Unloaded += IconSelect_Unloaded;
126新增: LoadIcons();
127新增: }
128新增:
129新增: private void LoadIcons()
130新增: {
131新增: var list = new List<string>();
132新增: for (int i = 1; i < 45; i++)
133新增: {
134新增: list.Add($"pack://application:,,,/Tai;component/Resources/Emoji/({i}).png");
135新增: }
136新增: Icons = list;
137新增: }
138新增: private void OnShowSelect(object obj)
139新增: {
140新增: IsOpen = true;
141新增: IsFirstClick = true;
142新增: }
143新增:
144新增: private void OnFileSelect(object obj)
145新增: {
146新增: Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
147新增:
148新增:
149新增: dlg.Filter = "PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg";
150新增:
151新增:
152新增: bool? result = dlg.ShowDialog();
153新增:
154新增:
155新增: if (result == true)
156新增: {
157新增: URL = dlg.FileName;
158新增: }
159新增: }
160新增:
161新增: public override void OnApplyTemplate()
162新增: {
163新增: base.OnApplyTemplate();
164新增:
165新增: SelectContainer = GetTemplateChild("SelectContainer") as Border;
166新增: }
167新增:
168新增: private void IconSelect_Unloaded(object sender, RoutedEventArgs e)
169新增: {
170新增: Win32API.UnhookWindowsHookEx(hook);
171新增: }
172新增:
173新增: protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
174新增: {
175新增: base.OnMouseLeftButtonDown(e);
176新增: }
177新增:
178新增:
179新增: }
180新增:}
新增UI/Resources/Emoji/(1).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(10).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(11).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(12).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(13).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(14).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(15).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(16).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(17).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(18).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(19).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(2).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(20).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(21).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(22).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(23).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(24).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(25).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(26).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(27).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(28).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(29).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(3).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(30).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(31).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(32).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(33).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(34).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(35).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(36).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(37).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(38).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(39).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(4).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(40).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(41).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(42).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(43).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(44).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(5).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(6).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(7).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(8).png看文件

二进制文件,不显示改动。

新增UI/Resources/Emoji/(9).png看文件

二进制文件,不显示改动。

新增UI/Themes/Base/IconSelect.xaml+133 −0看文件
@@ -0,0 +1,133 @@
1新增:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2新增: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3新增: xmlns:local="clr-namespace:UI.Controls.Base" xmlns:button="clr-namespace:UI.Controls.Button">
4新增: <Style TargetType="{x:Type local:IconSelect}">
5新增: <Setter Property="SnapsToDevicePixels"
6新增: Value="true" />
7新增: <Setter Property="Background" Value="Transparent"/>
8新增:
9新增: <Setter Property="Template">
10新增: <Setter.Value>
11新增: <ControlTemplate TargetType="{x:Type local:IconSelect}">
12新增: <Border Background="{TemplateBinding Background}" SnapsToDevicePixels="True" BorderBrush="#f7f8fa" CornerRadius="20" BorderThickness="2" Width="100" Height="100">
13新增: <Border.InputBindings>
14新增: <MouseBinding Gesture="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=ShowSelectCommand}"/>
15新增: </Border.InputBindings>
16新增: <Grid>
17新增: <local:Img HorizontalAlignment="Center" VerticalAlignment="Center" URL="{TemplateBinding URL}" Width="50" Height="50"/>
18新增:
19新增: <Popup
20新增: x:Name="Popup"
21新增: Placement="Bottom"
22新增: IsOpen="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=IsOpen,Mode=TwoWay}" AllowsTransparency="True"
23新增: >
24新增: <Border
25新增: x:Name="SelectContainer"
26新增: CornerRadius="10"
27新增: BorderBrush="#CCC"
28新增: BorderThickness="1"
29新增: Background="White" Padding="10" Width="275" MaxHeight="300" Margin="10">
30新增: <Border.Effect>
31新增: <DropShadowEffect BlurRadius="6" ShadowDepth="2" Direction="315" Color="Gray" Opacity=".1"/>
32新增: </Border.Effect>
33新增: <Grid>
34新增: <Grid.RowDefinitions>
35新增: <RowDefinition Height="auto"/>
36新增: <RowDefinition Height="*"/>
37新增: <RowDefinition Height="auto"/>
38新增: </Grid.RowDefinitions>
39新增:
40新增: <TextBlock Text="选择图标" VerticalAlignment="Center" HorizontalAlignment="Left"/>
41新增:
42新增: <ScrollViewer Grid.Row="1">
43新增: <ListView Grid.Row="1" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=Icons}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=URL,Mode=TwoWay}" Margin="0,10,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
44新增: <!--<i:Interaction.Triggers>
45新增: <i:EventTrigger EventName="MouseLeftButtonUp">
46新增: <i:InvokeCommandAction Command="{Binding GotoDetailCommand}"
47新增: CommandParameter="{Binding SelectedItem}" />
48新增: </i:EventTrigger>
49新增: </i:Interaction.Triggers>-->
50新增: <ListBox.Resources>
51新增: <Style TargetType="{x:Type ListView}">
52新增: <Setter Property="OverridesDefaultStyle" Value="True"/>
53新增:
54新增: <Setter Property="Template">
55新增: <Setter.Value>
56新增: <ControlTemplate TargetType="{x:Type ListView}">
57新增: <Border>
58新增: <ItemsPresenter />
59新增: </Border>
60新增: </ControlTemplate>
61新增: </Setter.Value>
62新增: </Setter>
63新增: </Style>
64新增: <Style TargetType="{x:Type ListViewItem}">
65新增: <Setter Property="OverridesDefaultStyle" Value="True"/>
66新增: <Setter Property="Foreground" Value="#1a1a1a"/>
67新增:
68新增: <Setter Property="Template">
69新增: <Setter.Value>
70新增: <ControlTemplate TargetType="{x:Type ListViewItem}">
71新增: <Border BorderBrush="Transparent" BorderThickness="2" x:Name="Border" Background="White" Margin="0,0,0,0" Padding="0" Width="35" Height="35" CornerRadius="5">
72新增: <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
73新增: </Border>
74新增: <ControlTemplate.Triggers>
75新增:
76新增: <Trigger Property="IsMouseOver" Value="True">
77新增: <Setter TargetName="Border" Property="Background" Value="#FFE8E6FF"/>
78新增: <!--<Setter TargetName="Border" Property="BorderBrush" Value="#2b20d9"/>-->
79新增:
80新增: </Trigger>
81新增: <Trigger Property="IsSelected" Value="True">
82新增: <Setter TargetName="Border" Property="Background" Value="#2b20d9"/>
83新增: <Setter Property="Foreground" Value="White"/>
84新增:
85新增: <!--<Setter TargetName="Border" Property="BorderBrush" Value="#2b20d9"/>-->
86新增:
87新增: </Trigger>
88新增: </ControlTemplate.Triggers>
89新增: </ControlTemplate>
90新增: </Setter.Value>
91新增: </Setter>
92新增:
93新增: </Style>
94新增: </ListBox.Resources>
95新增: <ListBox.ItemsPanel>
96新增: <ItemsPanelTemplate>
97新增: <WrapPanel/>
98新增: </ItemsPanelTemplate>
99新增: </ListBox.ItemsPanel>
100新增: <ListView.ItemTemplate>
101新增: <DataTemplate>
102新增:
103新增: <WrapPanel Orientation="Horizontal">
104新增: <Border >
105新增:
106新增: <local:Img URL="{Binding}" Width="25" Height="25"/>
107新增:
108新增: </Border>
109新增:
110新增: </WrapPanel>
111新增:
112新增: </DataTemplate>
113新增: </ListView.ItemTemplate>
114新增: </ListView>
115新增: </ScrollViewer>
116新增: <button:Button Grid.Row="2" Icon="FileImage" HorizontalAlignment="Right" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=FileSelectCommand}" Content="自定义图片" Width="120"/>
117新增: </Grid>
118新增: </Border>
119新增:
120新增: </Popup>
121新增: </Grid>
122新增: </Border>
123新增: <ControlTemplate.Triggers>
124新增:
125新增: <Trigger Property="IsMouseOver" Value="True">
126新增: <Setter Property="Background" Value="#FFE8E6FF"/>
127新增: </Trigger>
128新增: </ControlTemplate.Triggers>
129新增: </ControlTemplate>
130新增: </Setter.Value>
131新增: </Setter>
132新增: </Style>
133新增:</ResourceDictionary>
文件末尾没有换行
修改UI/Themes/Generic.xaml+1 −0看文件
@@ -12,6 +12,7 @@
1212 <ResourceDictionary Source="/Tai;component/Themes/Base/CheckBox.xaml"/>
1313 <ResourceDictionary Source="/Tai;component/Themes/Base/Text.xaml"/>
1414 <ResourceDictionary Source="/Tai;component/Themes/Base/View.xaml"/>
15新增: <ResourceDictionary Source="/Tai;component/Themes/Base/IconSelect.xaml"/>
1516
1617 <ResourceDictionary Source="/Tai;component/Themes/PageContainer.xaml"/>
1718 <ResourceDictionary Source="/Tai;component/Themes/Charts/Charts.xaml"/>
修改UI/UI.csproj+51 −0看文件
@@ -129,6 +129,7 @@
129129 <Compile Include="Base\Color\ColorTypes.cs" />
130130 <Compile Include="Controls\Base\EmptyData.cs" />
131131 <Compile Include="Controls\Base\CheckBox.cs" />
132新增: <Compile Include="Controls\Base\IconSelect.cs" />
132133 <Compile Include="Controls\Base\Img.cs" />
133134 <Compile Include="Controls\Base\Placeholder.cs" />
134135 <Compile Include="Controls\Base\Icon.cs" />
@@ -239,6 +240,10 @@
239240 <Generator>MSBuild:Compile</Generator>
240241 <SubType>Designer</SubType>
241242 </Page>
243新增: <Page Include="Themes\Base\IconSelect.xaml">
244新增: <Generator>MSBuild:Compile</Generator>
245新增: <SubType>Designer</SubType>
246新增: </Page>
242247 <Page Include="Themes\Base\View.xaml">
243248 <Generator>MSBuild:Compile</Generator>
244249 <SubType>Designer</SubType>
@@ -457,6 +462,52 @@
457462 <ItemGroup>
458463 <Resource Include="Resources\Icons\taibusy.ico" />
459464 </ItemGroup>
465新增: <ItemGroup>
466新增: <Resource Include="Resources\Emoji\%281%29.png" />
467新增: <Resource Include="Resources\Emoji\%2810%29.png" />
468新增: <Resource Include="Resources\Emoji\%2811%29.png" />
469新增: <Resource Include="Resources\Emoji\%2812%29.png" />
470新增: <Resource Include="Resources\Emoji\%2813%29.png" />
471新增: <Resource Include="Resources\Emoji\%2814%29.png" />
472新增: <Resource Include="Resources\Emoji\%2815%29.png" />
473新增: <Resource Include="Resources\Emoji\%2816%29.png" />
474新增: <Resource Include="Resources\Emoji\%2817%29.png" />
475新增: <Resource Include="Resources\Emoji\%2818%29.png" />
476新增: <Resource Include="Resources\Emoji\%2819%29.png" />
477新增: <Resource Include="Resources\Emoji\%282%29.png" />
478新增: <Resource Include="Resources\Emoji\%2820%29.png" />
479新增: <Resource Include="Resources\Emoji\%2821%29.png" />
480新增: <Resource Include="Resources\Emoji\%2822%29.png" />
481新增: <Resource Include="Resources\Emoji\%2823%29.png" />
482新增: <Resource Include="Resources\Emoji\%2824%29.png" />
483新增: <Resource Include="Resources\Emoji\%2825%29.png" />
484新增: <Resource Include="Resources\Emoji\%2826%29.png" />
485新增: <Resource Include="Resources\Emoji\%2827%29.png" />
486新增: <Resource Include="Resources\Emoji\%2828%29.png" />
487新增: <Resource Include="Resources\Emoji\%2829%29.png" />
488新增: <Resource Include="Resources\Emoji\%283%29.png" />
489新增: <Resource Include="Resources\Emoji\%2830%29.png" />
490新增: <Resource Include="Resources\Emoji\%2831%29.png" />
491新增: <Resource Include="Resources\Emoji\%2832%29.png" />
492新增: <Resource Include="Resources\Emoji\%2833%29.png" />
493新增: <Resource Include="Resources\Emoji\%2834%29.png" />
494新增: <Resource Include="Resources\Emoji\%2835%29.png" />
495新增: <Resource Include="Resources\Emoji\%2836%29.png" />
496新增: <Resource Include="Resources\Emoji\%2837%29.png" />
497新增: <Resource Include="Resources\Emoji\%2838%29.png" />
498新增: <Resource Include="Resources\Emoji\%2839%29.png" />
499新增: <Resource Include="Resources\Emoji\%284%29.png" />
500新增: <Resource Include="Resources\Emoji\%2840%29.png" />
501新增: <Resource Include="Resources\Emoji\%2841%29.png" />
502新增: <Resource Include="Resources\Emoji\%2842%29.png" />
503新增: <Resource Include="Resources\Emoji\%2843%29.png" />
504新增: <Resource Include="Resources\Emoji\%2844%29.png" />
505新增: <Resource Include="Resources\Emoji\%285%29.png" />
506新增: <Resource Include="Resources\Emoji\%286%29.png" />
507新增: <Resource Include="Resources\Emoji\%287%29.png" />
508新增: <Resource Include="Resources\Emoji\%288%29.png" />
509新增: <Resource Include="Resources\Emoji\%289%29.png" />
510新增: </ItemGroup>
460511 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
461512 <PropertyGroup>
462513 <PathMap>$(MSBuildProjectDirectory)=Tai</PathMap>
修改UI/ViewModels/CategoryPageVM.cs+1 −1看文件
@@ -107,7 +107,7 @@ namespace UI.ViewModels
107107 mainVM.Toast("请选择一个分类图标", Controls.Window.ToastType.Error, Controls.Base.IconTypes.CriticalErrorSolid);
108108 return;
109109 }
110删除: if (new FileInfo(EditIconFile).Length > 1000000)
110新增: if (EditIconFile.IndexOf("pack://") ==-1 && new FileInfo(EditIconFile).Length > 1000000)
111111 {
112112 mainVM.Toast("图标文件不能超过1MB", Controls.Window.ToastType.Error, Controls.Base.IconTypes.CriticalErrorSolid);
113113 return;
修改UI/Views/CategoryPage.xaml+1 −1看文件
@@ -33,7 +33,7 @@
3333 <input:InputBox Error="{Binding EditErrorText}" IsShowError="{Binding IsEditError,Mode=TwoWay}" Text="{Binding EditName,Mode=TwoWay}" MaxLength="10" Margin="0,10,0,0"/>
3434
3535 <TextBlock Text="分类图标" Margin="0,10,0,0"/>
36删除: <select:ImageSelect URL="{Binding EditIconFile,Mode=TwoWay}" ImageWidth="50" ImageHeight="50" HorizontalAlignment="Left" Margin="0,10,0,0" Width="100" Height="100" />
36新增: <base:IconSelect URL="{Binding EditIconFile,Mode=TwoWay}" HorizontalAlignment="Left" Margin="0,10,0,0" />
3737 </StackPanel>
3838
3939 <Button:Button Grid.Row="2" HorizontalAlignment="Right" Text="?创建:更新" Value="{Binding IsCreate}" Width="120" Margin="0,0,10,0" VerticalAlignment="Center" Command="{Binding EditDoneCommand}">