跳到主要内容

github/tai

公开

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

提交记录
新增UI/Controls/TPage.cs+83 −0看文件
@@ -0,0 +1,83 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Diagnostics;
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.Media;
10新增:
11新增:namespace UI.Controls
12新增:{
13新增: public class TPage : Page
14新增: {
15新增: /// <summary>
16新增: /// 是否填充页面而不使用自适应滚动
17新增: /// </summary>
18新增: public bool IsFillPage
19新增: {
20新增: get { return (bool)GetValue(IsFillPageDependencyProperty); }
21新增: set { SetValue(IsFillPageDependencyProperty, value); }
22新增: }
23新增: public static DependencyProperty IsFillPageDependencyProperty = DependencyProperty.Register("IsFillPage", typeof(bool), typeof(TPage));
24新增:
25新增: private PageContainer pageContainer;
26新增: public TPage()
27新增: {
28新增: DefaultStyleKey = typeof(TPage);
29新增: Loaded += TPage_Loaded;
30新增: }
31新增:
32新增: private void TPage_Loaded(object sender, RoutedEventArgs e)
33新增: {
34新增: UpdatePageSize();
35新增: }
36新增:
37新增: public override void OnApplyTemplate()
38新增: {
39新增: base.OnApplyTemplate();
40新增: HandleEvent();
41新增: }
42新增:
43新增: private void HandleEvent()
44新增: {
45新增: if (pageContainer != null)
46新增: {
47新增: pageContainer.SizeChanged -= Pc_SizeChanged;
48新增: }
49新增:
50新增: if (IsFillPage)
51新增: {
52新增: // 查找父容器
53新增: var parent = VisualTreeHelper.GetParent(this);
54新增: if (parent != null)
55新增: {
56新增: while (!(parent is PageContainer))
57新增: {
58新增: parent = VisualTreeHelper.GetParent(parent);
59新增: }
60新增: }
61新增:
62新增: pageContainer = parent as PageContainer;
63新增: if (pageContainer != null)
64新增: {
65新增: pageContainer.SizeChanged += Pc_SizeChanged;
66新增: }
67新增: }
68新增: }
69新增:
70新增: private void Pc_SizeChanged(object sender, SizeChangedEventArgs e)
71新增: {
72新增: UpdatePageSize();
73新增: }
74新增:
75新增: private void UpdatePageSize()
76新增: {
77新增: Width = pageContainer.ActualWidth;
78新增: Height = pageContainer.ActualHeight;
79新增:
80新增: Debug.WriteLine("UpdatePageSize");
81新增: }
82新增: }
83新增:}
修改UI/Themes/Generic.xaml+1 −0看文件
@@ -15,6 +15,7 @@
1515 <ResourceDictionary Source="/Tai;component/Themes/Base/IconSelect.xaml"/>
1616 <ResourceDictionary Source="/Tai;component/Themes/Base/ColorSelect.xaml"/>
1717
18新增: <ResourceDictionary Source="/Tai;component/Themes/TPage.xaml"/>
1819 <ResourceDictionary Source="/Tai;component/Themes/PageContainer.xaml"/>
1920 <ResourceDictionary Source="/Tai;component/Themes/Charts/Charts.xaml"/>
2021 <ResourceDictionary Source="/Tai;component/Themes/Charts/ChartsItemTypeA.xaml"/>
新增UI/Themes/TPage.xaml+16 −0看文件
@@ -0,0 +1,16 @@
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">
4新增: <Style
5新增: TargetType="{x:Type local:TPage}">
6新增: <Setter Property="Template">
7新增: <Setter.Value>
8新增: <ControlTemplate TargetType="{x:Type local:TPage}">
9新增: <Border Background="{TemplateBinding Background}">
10新增: <ContentPresenter Content="{TemplateBinding Page.Content}"/>
11新增: </Border>
12新增: </ControlTemplate>
13新增: </Setter.Value>
14新增: </Setter>
15新增: </Style>
16新增:</ResourceDictionary>
文件末尾没有换行
修改UI/UI.csproj+5 −0看文件
@@ -177,6 +177,7 @@
177177 <Compile Include="Controls\SettingPanel\SettingPanel.cs" />
178178 <Compile Include="Controls\Tabbar\Tabbar.cs" />
179179 <Compile Include="Controls\Toggle\Toggle.cs" />
180新增: <Compile Include="Controls\TPage.cs" />
180181 <Compile Include="Controls\Window\ToastType.cs" />
181182 <Compile Include="Extensions\ListExtensions.cs" />
182183 <Compile Include="Librays\Image\Imager.cs" />
@@ -404,6 +405,10 @@
404405 <SubType>Designer</SubType>
405406 <Generator>MSBuild:Compile</Generator>
406407 </Page>
408新增: <Page Include="Themes\TPage.xaml">
409新增: <SubType>Designer</SubType>
410新增: <Generator>MSBuild:Compile</Generator>
411新增: </Page>
407412 <Page Include="Themes\Window\DefaultWindow.xaml">
408413 <SubType>Designer</SubType>
409414 <Generator>MSBuild:Compile</Generator>