跳到主要内容

github/tai

公开

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

提交记录
修改UI/App.xaml.cs+99 −0看文件
@@ -5,9 +5,14 @@ using System;
55using System.Collections.Generic;
66using System.Configuration;
77using System.Data;
8新增:using System.Drawing;
89using System.Linq;
910using System.Threading.Tasks;
1011using System.Windows;
12新增:using System.Windows.Controls;
13新增:using System.Windows.Resources;
14新增:using UI.Controls.Window;
15新增:using UI.ViewModels;
1116
1217namespace UI
1318{
@@ -17,6 +22,15 @@ namespace UI
1722 public partial class App : Application
1823 {
1924 private readonly ServiceProvider serviceProvider;
25新增:
26新增: // 状态栏图标
27新增: private System.Windows.Forms.NotifyIcon statusBarIcon;
28新增:
29新增: // 保活窗口
30新增: private HideWindow keepaliveWindow;
31新增:
32新增: // 状态栏图标菜单
33新增: private ContextMenu contextMenu;
2034 public App()
2135 {
2236 var serviceCollection = new ServiceCollection();
@@ -24,16 +38,101 @@ namespace UI
2438 serviceProvider = serviceCollection.BuildServiceProvider();
2539
2640 }
41新增:
42新增: #region 状态栏图标
43新增: /// <summary>
44新增: /// 初始化状态栏图标
45新增: /// </summary>
46新增: private void InitStatusBarIcon()
47新增: {
48新增: CreateStatusBarIconMenu();
49新增:
50新增: statusBarIcon = new System.Windows.Forms.NotifyIcon();
51新增:
52新增: statusBarIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(
53新增: System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name);
54新增:
55新增: statusBarIcon.Visible = true;
56新增: statusBarIcon.MouseClick += NotifyIcon_MouseClick;
57新增: statusBarIcon.MouseDoubleClick += NotifyIcon_MouseDoubleClick;
58新增: }
59新增: private void NotifyIcon_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
60新增: {
61新增: if (e.Button == System.Windows.Forms.MouseButtons.Right)
62新增: {
63新增: //右键单击弹出托盘菜单
64新增: contextMenu.IsOpen = true;
65新增: //激活主窗口,用于处理关闭托盘菜单
66新增: App.Current.MainWindow.Activate();
67新增: }
68新增: }
69新增: private void NotifyIcon_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e)
70新增: {
71新增: if (e.Button == System.Windows.Forms.MouseButtons.Left)
72新增: {
73新增: //双击托盘图标显示主窗口
74新增: ShowMainWindow();
75新增: }
76新增: }
77新增:
78新增: /// <summary>
79新增: /// 创建状态栏图标菜单
80新增: /// </summary>
81新增: private void CreateStatusBarIconMenu()
82新增: {
83新增: contextMenu = new ContextMenu();
84新增: App.Current.Deactivated += (e, c) =>
85新增: {
86新增: contextMenu.IsOpen = false;
87新增: };
88新增: var mainWindowMenuItem = new MenuItem();
89新增: mainWindowMenuItem.Header = "主界面";
90新增: mainWindowMenuItem.Click += MainWindowMenuItem_Click;
91新增:
92新增: contextMenu.Items.Add(mainWindowMenuItem);
93新增: }
94新增:
95新增: private void MainWindowMenuItem_Click(object sender, RoutedEventArgs e)
96新增: {
97新增: ShowMainWindow();
98新增: }
99新增: #endregion
100新增:
27101 private void ConfigureServices(IServiceCollection services)
28102 {
29103 services.AddSingleton<IObserver, Observer>();
30104 services.AddSingleton<IMain, Main>();
105新增:
106新增: services.AddSingleton<MainViewModel>();
107新增: services.AddTransient<MainWindow>();
31108 }
32109
33110 private void OnStartup(object sender, StartupEventArgs e)
34111 {
35112 var main = serviceProvider.GetService<IMain>();
36113 main.Run();
114新增:
115新增: // 创建保活窗口
116新增: keepaliveWindow = new HideWindow();
117新增: keepaliveWindow.Title = "Tai Keepalive";
118新增: keepaliveWindow.ShowInTaskbar = false;
119新增: keepaliveWindow.WindowStyle = WindowStyle.None;
120新增: keepaliveWindow.OverridesDefaultStyle = true;
121新增: keepaliveWindow.Show();
122新增:
123新增: InitStatusBarIcon();
124新增: }
125新增:
126新增: private void ShowMainWindow()
127新增: {
128新增: var mainWindow = serviceProvider.GetService<MainWindow>();
129新增: var dataContext = serviceProvider.GetService<MainViewModel>();
130新增: mainWindow.DataContext = dataContext;
131新增: dataContext.SelectGroup(-1);
132新增: ////dataContext.Uri = nameof(IndexPage);
133新增: mainWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
134新增: mainWindow.Show();
135新增: mainWindow.Activate();
37136 }
38137 }
39138}
新增UI/Base/Color/ColorTypes.cs+63 −0看文件
@@ -0,0 +1,63 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Text;
4新增:
5新增:namespace UI.Base.Color
6新增:{
7新增: public enum ColorTypes
8新增: {
9新增: /// <summary>
10新增: /// 红色
11新增: /// </summary>
12新增: Red,
13新增: /// <summary>
14新增: /// 橙色
15新增: /// </summary>
16新增: Orange,
17新增: /// <summary>
18新增: /// 黄色
19新增: /// </summary>
20新增: Yellow,
21新增: /// <summary>
22新增: /// 金色
23新增: /// </summary>
24新增: Gold,
25新增: /// <summary>
26新增: /// 绿色
27新增: /// </summary>
28新增: Green,
29新增: /// <summary>
30新增: /// 碧绿色
31新增: /// </summary>
32新增: Aquamarine,
33新增: /// <summary>
34新增: /// 青色
35新增: /// </summary>
36新增: Cyan,
37新增: /// <summary>
38新增: /// 蓝色
39新增: /// </summary>
40新增: Blue,
41新增: /// <summary>
42新增: /// 紫色
43新增: /// </summary>
44新增: Violet,
45新增: /// <summary>
46新增: /// 粉色
47新增: /// </summary>
48新增: Pink,
49新增: /// <summary>
50新增: /// 灰色
51新增: /// </summary>
52新增: Gray,
53新增: /// <summary>
54新增: /// 黑色
55新增: /// </summary>
56新增: Black,
57新增: /// <summary>
58新增: /// 白色
59新增: /// </summary>
60新增: White
61新增:
62新增: }
63新增:}
新增UI/Base/Color/Colors.cs+54 −0看文件
@@ -0,0 +1,54 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Text;
4新增:using System.Windows.Media;
5新增:
6新增:namespace UI.Base.Color
7新增:{
8新增: public class Colors
9新增: {
10新增: public struct IColor
11新增: {
12新增: /// <summary>
13新增: /// 颜色名称
14新增: /// </summary>
15新增: public string Name;
16新增: /// <summary>
17新增: /// 颜色
18新增: /// </summary>
19新增: public string Color;
20新增: }
21新增: public static Dictionary<ColorTypes, IColor> ColorList = new Dictionary<ColorTypes, IColor>() {
22新增: {ColorTypes.Aquamarine,new IColor{Name="碧绿", Color="#00AA90"} },
23新增: {ColorTypes.Black,new IColor{Name="暗黑", Color="#080808"} },
24新增: {ColorTypes.Blue,new IColor{Name="蓝色", Color="#0078d4"} },
25新增: {ColorTypes.Cyan,new IColor{Name="青色", Color="#51A8DD"} },
26新增: {ColorTypes.Gold,new IColor{Name="金色", Color="#EFBB24"} },
27新增: {ColorTypes.Gray,new IColor{Name="灰色", Color="#828282"} },
28新增: {ColorTypes.Green,new IColor{Name="绿色", Color="#56C773"} },
29新增: {ColorTypes.Orange,new IColor{Name="橙色", Color="#E98B2A"} },
30新增: {ColorTypes.Pink,new IColor{Name="粉红", Color="#B5495B"} },
31新增: {ColorTypes.Red,new IColor{Name="赤红", Color="#F3221B"} },
32新增: {ColorTypes.Violet,new IColor{Name="紫色", Color="#77428D"} },
33新增: {ColorTypes.Yellow,new IColor{Name="黄色", Color="#FFC408"} },
34新增: {ColorTypes.White,new IColor{Name="白色", Color="#FFFFFF"} },
35新增:
36新增: };
37新增:
38新增: public static IColor Get(ColorTypes color)
39新增: {
40新增: return ColorList[color];
41新增: }
42新增: public static SolidColorBrush GetColor(ColorTypes color, double opacity = 1)
43新增: {
44新增: return GetFromString(ColorList[color].Color, opacity);
45新增: }
46新增: public static SolidColorBrush GetFromString(string color, double opacity = 1)
47新增: {
48新增: return new SolidColorBrush((System.Windows.Media.Color)ColorConverter.ConvertFromString(color))
49新增: {
50新增: Opacity = opacity
51新增: };
52新增: }
53新增: }
54新增:}
新增UI/Controls/Base/Icon.cs+46 −0看文件
@@ -0,0 +1,46 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Text;
4新增:using System.Windows;
5新增:using System.Windows.Controls;
6新增:using System.Windows.Media;
7新增:
8新增:namespace UI.Controls.Base
9新增:{
10新增: public class Icon : Control
11新增: {
12新增: public IconTypes IconType
13新增: {
14新增: get { return (IconTypes)GetValue(IconTypeProperty); }
15新增: set { SetValue(IconTypeProperty, value); }
16新增: }
17新增: public static readonly DependencyProperty IconTypeProperty =
18新增: DependencyProperty.Register("IconType",
19新增: typeof(IconTypes),
20新增: typeof(Icon), new PropertyMetadata(IconTypes.Back, new PropertyChangedCallback(OnIconTypeChanged)));
21新增:
22新增: private static void OnIconTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
23新增: {
24新增: var control = d as Icon;
25新增: if (e.NewValue != e.OldValue)
26新增: {
27新增: control.Unicode = IconConverter.ToUnicode((IconTypes)e.NewValue);
28新增: }
29新增: }
30新增:
31新增: public string Unicode
32新增: {
33新增: get { return (string)GetValue(UnicodeProperty); }
34新增: set { SetValue(UnicodeProperty, value); }
35新增: }
36新增: public static readonly DependencyProperty UnicodeProperty =
37新增: DependencyProperty.Register("Unicode",
38新增: typeof(string),
39新增: typeof(Icon),
40新增: new PropertyMetadata(IconConverter.ToUnicode(IconTypes.Back)));
41新增: public Icon()
42新增: {
43新增: DefaultStyleKey = typeof(Icon);
44新增: }
45新增: }
46新增:}
新增UI/Controls/Base/IconConverter.cs+130 −0看文件
@@ -0,0 +1,130 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Linq;
4新增:using System.Text;
5新增:
6新增:namespace UI.Controls.Base
7新增:{
8新增: public class IconConverter
9新增: {
10新增: private static Dictionary<IconTypes, string> iconUnicodes = new Dictionary<IconTypes, string>()
11新增: {
12新增: {IconTypes.None,""},
13新增: {IconTypes.Back,"\xE72B"},
14新增: {IconTypes.Calendar,"\xE787"},
15新增: {IconTypes.ChevronDown,"\xE70D"},
16新增: {IconTypes.CheckMark,"\xE73E"},
17新增: {IconTypes.CompletedSolid,"\xEC61"},
18新增: {IconTypes.RadioBtnOn,"\xECCB"},
19新增: {IconTypes.StatusCircleOuter,"\xF136"},
20新增: {IconTypes.AcceptMedium,"\xF78C"},
21新增: {IconTypes.Accept,"\xE8FB"},
22新增: {IconTypes.Timer,"\xE91E"},
23新增: {IconTypes.StatusCircleQuestionMark,"\xF142"},
24新增: {IconTypes.ProjectDocument,"\xF759"},
25新增: {IconTypes.AutomateFlow,"\xE3F5"},
26新增: {IconTypes.FlashAuto,"\xE95C"},
27新增: {IconTypes.ProductVariant,"\xEE30"},
28新增: {IconTypes.AppIconDefault,"\xECAA"},
29新增: {IconTypes.ChromeMinimize,"\xE921"},
30新增: {IconTypes.ChromeClose,"\xE8BB"},
31新增: {IconTypes.ChromeRestore,"\xE923"},
32新增: {IconTypes.CalculatorMultiply,"\xE947"},
33新增: {IconTypes.SquareShape,"\xF1A6"},
34新增: {IconTypes.More,"\xE712"},
35新增: {IconTypes.AppIconDefaultList,"\xEFDE"},
36新增: {IconTypes.ClipboardList,"\xF0E3"},
37新增: {IconTypes.Settings,"\xE713"},
38新增: {IconTypes.ChromeBack,"\xE830"},
39新增: {IconTypes.BulletedList,"\xE8FD"},
40新增: {IconTypes.CalculatorAddition,"\xE948"},
41新增: {IconTypes.DeviceRun,"\xE401"},
42新增: {IconTypes.ProcessingRun,"\xE404"},
43新增: {IconTypes.Product,"\xECDC"},
44新增: {IconTypes.FileTemplate,"\xF2E6"},
45新增: {IconTypes.DeviceOff,"\xE402"},
46新增: {IconTypes.FlowChart,"\xE9D4"},
47新增: {IconTypes.DownloadDocument,"\xF549"},
48新增: {IconTypes.Delete,"\xE74D"},
49新增: {IconTypes.EditStyle,"\xEF60"},
50新增: {IconTypes.OpenWithMirrored,"\xEA5C"},
51新增: {IconTypes.FileCode,"\xF30E"},
52新增: {IconTypes.BuildIssue,"\xF319"},
53新增: {IconTypes.WebEnvironment,"\xE3DB"},
54新增: {IconTypes.DesktopScreenshot,"\xF5D9"},
55新增: {IconTypes.MusicInCollectionFill,"\xEA36"},
56新增: {IconTypes.NetworkTower,"\xEC05"},
57新增: {IconTypes.KeyboardClassic,"\xE765"},
58新增: {IconTypes.FabricSyncFolder,"\xF0A7"},
59新增: {IconTypes.DateTime12,"\xF38F"},
60新增: {IconTypes.DateTime,"\xEC92"},
61新增: {IconTypes.MyNetwork,"\xEC27"},
62新增: {IconTypes.WifiEthernet,"\xEE77"},
63新增: {IconTypes.NormalWeight,"\xF4EF"},
64新增: {IconTypes.Message,"\xE8BD"},
65新增: {IconTypes.Download,"\xE896"},
66新增: {IconTypes.Storyboard,"\xF308"},
67新增: {IconTypes.HandsFree,"\xEAD0"},
68新增: {IconTypes.PlaybackRate1x,"\xEC57"},
69新增: {IconTypes.ProcessingCancel,"\xE403"},
70新增: {IconTypes.Volume2,"\xE994"},
71新增: {IconTypes.Game,"\xE7FC"},
72新增: {IconTypes.NewsSearch,"\xF4E9"},
73新增: {IconTypes.Share,"\xE72D"},
74新增: {IconTypes.PageCheckedin,"\xF104"},
75新增: {IconTypes.EntityExtraction,"\xE467"},
76新增: {IconTypes.RecycleBin,"\xEF87"},
77新增: {IconTypes.Ringer,"\xEA8F"},
78新增: {IconTypes.Rocket,"\xF3B3"},
79新增: {IconTypes.Robot,"\xE99A"},
80新增: {IconTypes.Puzzle,"\xEA86"},
81新增: {IconTypes.RainShowersDay,"\xE9C3"},
82新增: {IconTypes.Plug,"\xF300"},
83新增: {IconTypes.Pinned,"\xE840"},
84新增: {IconTypes.PlayerSettings,"\xEF58"},
85新增: {IconTypes.Permissions,"\xE8D7"},
86新增: {IconTypes.PasswordField,"\xF6AA"},
87新增: {IconTypes.OfficeStoreLogo,"\xEDCF"},
88新增: {IconTypes.NUIFace,"\xEB68"},
89新增: {IconTypes.MyMoviesTV,"\xEE6C"},
90新增: {IconTypes.MicrosoftTranslatorLogo,"\xF782"},
91新增: {IconTypes.Microphone,"\xE720"},
92新增: {IconTypes.MailAlert,"\xED80"},
93新增: {IconTypes.Lock,"\xE72E"},
94新增: {IconTypes.Lightbulb,"\xEA80"},
95新增: {IconTypes.LightningBolt,"\xE945"},
96新增: {IconTypes.Insights,"\xE3AF"},
97新增: {IconTypes.Home,"\xE80F"},
98新增: {IconTypes.Heart,"\xEB51"},
99新增: {IconTypes.HeartFill,"\xEB52"},
100新增: {IconTypes.Flower,"\xF54E"},
101新增: {IconTypes.FieldReadOnly,"\xF442"},
102新增: {IconTypes.FangBody,"\xECEB"},
103新增: {IconTypes.EventToDoLogo,"\xF869"},
104新增: {IconTypes.Emoji,"\xE899"},
105新增: {IconTypes.DrillDown,"\xF532"},
106新增: {IconTypes.Diamond,"\xED02"},
107新增: {IconTypes.Decimals,"\xF218"},
108新增: {IconTypes.Crown,"\xED01"},
109新增: {IconTypes.Color,"\xE790"},
110新增: {IconTypes.CloudSecure,"\xE4D5"},
111新增: {IconTypes.CloudImportExport,"\xEE55"},
112新增: {IconTypes.Cat,"\xED7F"},
113新增: {IconTypes.Car,"\xE804"},
114新增: {IconTypes.Bug,"\xEBE8"},
115新增: {IconTypes.ChevronUp,"\xE70E"},
116新增: {IconTypes.BIDashboard,"\xF543"},
117新增:
118新增:
119新增: };
120新增: public static string ToUnicode(IconTypes iconType)
121新增: {
122新增: return iconUnicodes[iconType];
123新增: }
124新增: public static IconTypes ToType(string unicode)
125新增: {
126新增: var type = iconUnicodes.Where(m => m.Value == unicode).Select(s => s.Key).FirstOrDefault();
127新增: return type;
128新增: }
129新增: }
130新增:}
新增UI/Controls/Base/IconTypes.cs+142 −0看文件
@@ -0,0 +1,142 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Text;
4新增:
5新增:namespace UI.Controls.Base
6新增:{
7新增: /// <summary>
8新增: /// 图标类型
9新增: /// </summary>
10新增: public enum IconTypes
11新增: {
12新增: /// <summary>
13新增: /// 无
14新增: /// </summary>
15新增: None,
16新增: /// <summary>
17新增: /// 返回
18新增: /// </summary>
19新增: Back,
20新增: /// <summary>
21新增: /// 日历
22新增: /// </summary>
23新增: Calendar,
24新增: /// <summary>
25新增: /// 下V
26新增: /// </summary>
27新增: ChevronDown,
28新增: /// <summary>
29新增: /// 上V
30新增: /// </summary>
31新增: ChevronUp,
32新增: /// <summary>
33新增: /// 复选标记
34新增: /// </summary>
35新增: CheckMark,
36新增: /// <summary>
37新增: /// 已完成标记
38新增: /// </summary>
39新增: CompletedSolid,
40新增: /// <summary>
41新增: /// 单选按钮on
42新增: /// </summary>
43新增: RadioBtnOn,
44新增: StatusCircleOuter,
45新增: AcceptMedium,
46新增: Accept,
47新增: Timer,
48新增: StatusCircleQuestionMark,
49新增: ProjectDocument,
50新增: AutomateFlow,
51新增: FlashAuto,
52新增: ProductVariant,
53新增: AppIconDefault,
54新增: ChromeMinimize,
55新增: ChromeClose,
56新增: ChromeRestore,
57新增: CalculatorMultiply,
58新增: SquareShape,
59新增: More,
60新增: AppIconDefaultList,
61新增: ClipboardList,
62新增: Settings,
63新增: ChromeBack,
64新增: BulletedList,
65新增: CalculatorAddition,
66新增: DeviceRun,
67新增: ProcessingRun,
68新增: Product,
69新增: FileTemplate,
70新增: DeviceOff,
71新增: FlowChart,
72新增: DownloadDocument,
73新增: Delete,
74新增: EditStyle,
75新增: OpenWithMirrored,
76新增: FileCode,
77新增: BuildIssue,
78新增: WebEnvironment,
79新增: DesktopScreenshot,
80新增: MusicInCollectionFill,
81新增: NetworkTower,
82新增: KeyboardClassic,
83新增: FabricSyncFolder,
84新增: DateTime12,
85新增: DateTime,
86新增: MyNetwork,
87新增: WifiEthernet,
88新增: NormalWeight,
89新增: Message,
90新增: Download,
91新增: Storyboard,
92新增: HandsFree,
93新增: PlaybackRate1x,
94新增: ProcessingCancel,
95新增: Volume2,
96新增: Game,
97新增: NewsSearch,
98新增: Share,
99新增: PageCheckedin,
100新增: EntityExtraction,
101新增: RecycleBin,
102新增: Ringer,
103新增: Rocket,
104新增: Robot,
105新增: Puzzle,
106新增: RainShowersDay,
107新增: Plug,
108新增: Pinned,
109新增: PlayerSettings,
110新增: Permissions,
111新增: PasswordField,
112新增: OfficeStoreLogo,
113新增: NUIFace,
114新增: MyMoviesTV,
115新增: MicrosoftTranslatorLogo,
116新增: Microphone,
117新增: MailAlert,
118新增: Lock,
119新增: Lightbulb,
120新增: LightningBolt,
121新增: Insights,
122新增: Home,
123新增: Heart,
124新增: HeartFill,
125新增: Flower,
126新增: FieldReadOnly,
127新增: FangBody,
128新增: EventToDoLogo,
129新增: Emoji,
130新增: DrillDown,
131新增: Diamond,
132新增: Decimals,
133新增: Crown,
134新增: Color,
135新增: CloudSecure,
136新增: CloudImportExport,
137新增: Cat,
138新增: Car,
139新增: Bug,
140新增: BIDashboard
141新增: }
142新增:}
新增UI/Controls/Command.cs+39 −0看文件
@@ -0,0 +1,39 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Linq;
4新增:using System.Text;
5新增:using System.Threading.Tasks;
6新增:using System.Windows.Input;
7新增:
8新增:namespace UI.Controls
9新增:{
10新增: public class Command : ICommand
11新增: {
12新增: private Action<object> _action;
13新增:
14新增: public Command(Action<object> action)
15新增: {
16新增: _action = action;
17新增: }
18新增:
19新增:
20新增: #region ICommand Members
21新增: public bool CanExecute(object parameter)
22新增: {
23新增: return true;
24新增: }
25新增: public event EventHandler CanExecuteChanged;
26新增: public void Execute(object parameter)
27新增: {
28新增: _action(parameter);
29新增: OnExecuted();
30新增: }
31新增: public delegate void ExecutedHandler(object parameter);
32新增: public event ExecutedHandler Executed;
33新增: public void OnExecuted()
34新增: {
35新增: Executed?.Invoke(null);
36新增: }
37新增: #endregion
38新增: }
39新增:}
新增UI/Controls/Navigation/Models/NavigationItemModel.cs+20 −0看文件
@@ -0,0 +1,20 @@
1新增:
2新增:using System;
3新增:using System.Collections.Generic;
4新增:using System.Text;
5新增:using UI.Base.Color;
6新增:using UI.Controls.Base;
7新增:
8新增:namespace UI.Controls.Navigation.Models
9新增:{
10新增: public class NavigationItemModel
11新增: {
12新增: public int ID { get; set; }
13新增: public string Title { get; set; }
14新增: public IconTypes Icon { get; set; }
15新增: public ColorTypes IconColor { get; set; }
16新增: public string BadgeText { get; set; }
17新增: public string Uri { get; set; }
18新增: //public bool IsSelected { get; set; }
19新增: }
20新增:}
新增UI/Controls/Navigation/Navigation.cs+430 −0看文件
@@ -0,0 +1,430 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Collections.ObjectModel;
4新增:using System.Collections.Specialized;
5新增:using System.Linq;
6新增:using System.Text;
7新增:using System.Windows;
8新增:using System.Windows.Controls;
9新增:using System.Windows.Media;
10新增:using System.Windows.Media.Animation;
11新增:using UI.Controls.Navigation.Models;
12新增:
13新增:namespace UI.Controls.Navigation
14新增:{
15新增: public class Navigation : Control
16新增: {
17新增: public ContextMenu ItemContextMenu
18新增: {
19新增: get { return (ContextMenu)GetValue(ItemContextMenuProperty); }
20新增: set { SetValue(SelectedItemProperty, value); }
21新增: }
22新增: public static readonly DependencyProperty ItemContextMenuProperty =
23新增: DependencyProperty.Register("ItemContextMenu", typeof(ContextMenu), typeof(Navigation));
24新增:
25新增: public NavigationItemModel SelectedItem
26新增: {
27新增: get { return (NavigationItemModel)GetValue(SelectedItemProperty); }
28新增: set { SetValue(SelectedItemProperty, value); }
29新增: }
30新增: public static readonly DependencyProperty SelectedItemProperty =
31新增: DependencyProperty.Register("SelectedItem", typeof(NavigationItemModel), typeof(Navigation), new PropertyMetadata(new PropertyChangedCallback(OnSelectedItemChanged)));
32新增:
33新增: private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
34新增: {
35新增: var control = d as Navigation;
36新增: if (e.NewValue != e.OldValue)
37新增: {
38新增: var newItem = e.NewValue as NavigationItemModel;
39新增: var oldItem = e.OldValue as NavigationItemModel;
40新增: if (newItem != null && control.ItemsDictionary.ContainsKey(newItem.ID))
41新增: {
42新增: control.ItemsDictionary[newItem.ID].IsSelected = true;
43新增: }
44新增: if (oldItem != null && control.ItemsDictionary.ContainsKey(oldItem.ID))
45新增: {
46新增: control.ItemsDictionary[oldItem.ID].IsSelected = false;
47新增: }
48新增: control.ScrollToActive();
49新增: }
50新增: }
51新增:
52新增: public bool IsShowNavigation
53新增: {
54新增: get { return (bool)GetValue(IsShowNavigationProperty); }
55新增: set { SetValue(IsShowNavigationProperty, value); }
56新增: }
57新增: public static readonly DependencyProperty IsShowNavigationProperty =
58新增: DependencyProperty.Register("IsShowNavigation", typeof(bool), typeof(Navigation), new PropertyMetadata(true, new PropertyChangedCallback(OnIsShowNavigationChanged)));
59新增:
60新增: private static void OnIsShowNavigationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
61新增: {
62新增: var control = d as Navigation;
63新增: if (e.NewValue != e.OldValue)
64新增: {
65新增: if (control.IsShowNavigation && control.Visibility == Visibility.Collapsed && control.WindowWidth > 700)
66新增: {
67新增: control.Visibility = Visibility.Visible;
68新增: }
69新增: if (!control.IsShowNavigation && control.Visibility == Visibility.Visible)
70新增: {
71新增: control.Visibility = Visibility.Collapsed;
72新增: }
73新增: }
74新增: }
75新增:
76新增: public object TopExtContent
77新增: {
78新增: get { return (object)GetValue(TopExtContentProperty); }
79新增: set { SetValue(TopExtContentProperty, value); }
80新增: }
81新增: public static readonly DependencyProperty TopExtContentProperty =
82新增: DependencyProperty.Register("TopExtContent", typeof(object), typeof(Navigation));
83新增: public object BottomExtContent
84新增: {
85新增: get { return (object)GetValue(BottomExtContentProperty); }
86新增: set { SetValue(BottomExtContentProperty, value); }
87新增: }
88新增: public static readonly DependencyProperty BottomExtContentProperty =
89新增: DependencyProperty.Register("BottomExtContent", typeof(object), typeof(Navigation));
90新增: public ObservableCollection<NavigationItemModel> Data
91新增: {
92新增: get
93新增: {
94新增: return (ObservableCollection<NavigationItemModel>)GetValue(DataProperty);
95新增: }
96新增: set
97新增: {
98新增: SetValue(DataProperty, value);
99新增: }
100新增: }
101新增: public static readonly DependencyProperty DataProperty =
102新增: DependencyProperty.Register("Data", typeof(ObservableCollection<NavigationItemModel>), typeof(Navigation), new PropertyMetadata(new PropertyChangedCallback(OnDataChanged)));
103新增:
104新增: private static void OnDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
105新增: {
106新增: var control = d as Navigation;
107新增: if (e.NewValue != e.OldValue)
108新增: {
109新增: if (control.Data != null)
110新增: {
111新增: control.Data.CollectionChanged += control.Data_CollectionChanged;
112新增: }
113新增: foreach (var item in control.Data)
114新增: {
115新增: control.AddItem(item);
116新增: }
117新增: }
118新增: }
119新增:
120新增: public double WindowWidth
121新增: {
122新增: get
123新增: {
124新增: return (double)GetValue(WindowWidthProperty);
125新增: }
126新增: set
127新增: {
128新增: SetValue(WindowWidthProperty, value);
129新增: }
130新增: }
131新增: public static readonly DependencyProperty WindowWidthProperty =
132新增: DependencyProperty.Register("WindowWidth", typeof(double), typeof(Navigation), new PropertyMetadata(new PropertyChangedCallback(OnWindowWidthChanged)));
133新增:
134新增: private static void OnWindowWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
135新增: {
136新增: var control = d as Navigation;
137新增: if (control.IsShowNavigation)
138新增: {
139新增: if ((double)e.NewValue <= 700)
140新增: {
141新增: control.Visibility = Visibility.Collapsed;
142新增: }
143新增: else
144新增: {
145新增:
146新增: control.Visibility = Visibility.Visible;
147新增: }
148新增: }
149新增: }
150新增:
151新增:
152新增: #region items property
153新增:
154新增:
155新增: //protected static PropertyChangedCallback ItemsPropertyChangedCallback = new PropertyChangedCallback(ItemsPropertyChanged);
156新增:
157新增: //public static DependencyProperty ItemsProperty = DependencyProperty.RegisterAttached("Items", typeof(ObservableCollection<NavigationItemModel>), typeof(Navigation), new PropertyMetadata(null, ItemsPropertyChangedCallback));
158新增:
159新增: //private static void ItemsPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
160新增: //{
161新增: // var control = (Navigation)sender;
162新增: // if (control == null)
163新增: // {
164新增: // return;
165新增: // }
166新增: // control.UnregisterItems(e.OldValue as ObservableCollection<NavigationItemModel>);
167新增: // control.RegisterItems(e.NewValue as ObservableCollection<NavigationItemModel>);
168新增: //}
169新增:
170新增: //public ObservableCollection<NavigationItemModel> Items
171新增: //{
172新增: // get
173新增: // {
174新增: // return (ObservableCollection<NavigationItemModel>)GetValue(ItemsProperty);
175新增: // }
176新增: // set
177新增: // {
178新增: // SetValue(ItemsProperty, value);
179新增: // }
180新增: //}
181新增:
182新增: //protected void UnregisterItems(ObservableCollection<NavigationItemModel> items)
183新增: //{
184新增: // if (items == null)
185新增: // {
186新增: // return;
187新增: // }
188新增: // items.CollectionChanged -= ItemsChanged;
189新增: //}
190新增:
191新增: //protected void RegisterItems(ObservableCollection<NavigationItemModel> items)
192新增: //{
193新增: // if (items == null)
194新增: // {
195新增: // return;
196新增: // }
197新增: // items.CollectionChanged += ItemsChanged;
198新增: //}
199新增:
200新增: //protected virtual void ItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
201新增: //{
202新增: // if (e.Action == NotifyCollectionChangedAction.Add)
203新增: // {
204新增: // foreach (var item in e.NewItems)
205新增: // {
206新增: // var data = item as NavigationItemModel;
207新增: // AddItem(data);
208新增: // }
209新增: // }
210新增: // else if (e.Action == NotifyCollectionChangedAction.Remove)
211新增: // {
212新增: // foreach (var item in e.OldItems)
213新增: // {
214新增: // var data = item as NavigationItemModel;
215新增: // RemoveItem(data);
216新增: // }
217新增: // }
218新增: //}
219新增: #endregion
220新增: public event RoutedEventHandler OnSelected;
221新增: public event RoutedEventHandler OnMouseRightButtonUP;
222新增:
223新增: private StackPanel ItemsPanel;
224新增: private Dictionary<int, NavigationItem> ItemsDictionary;
225新增:
226新增: // 选中标记块
227新增: private Border ActiveBlock;
228新增: // 动画
229新增: Storyboard storyboard;
230新增: public Navigation()
231新增: {
232新增: DefaultStyleKey = typeof(Navigation);
233新增: ItemsDictionary = new Dictionary<int, NavigationItem>();
234新增: storyboard = new Storyboard();
235新增: }
236新增:
237新增: private void Data_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
238新增: {
239新增: if (e.Action == NotifyCollectionChangedAction.Add)
240新增: {
241新增: foreach (var item in e.NewItems)
242新增: {
243新增: AddItem(item as NavigationItemModel);
244新增: }
245新增: }
246新增: if (e.Action == NotifyCollectionChangedAction.Remove)
247新增: {
248新增: foreach (var item in e.OldItems)
249新增: {
250新增: RemoveItem(item as NavigationItemModel);
251新增: }
252新增: }
253新增: if (e.Action == NotifyCollectionChangedAction.Replace)
254新增: {
255新增: foreach (var ritem in e.NewItems)
256新增: {
257新增: var item = ritem as NavigationItemModel;
258新增: var id = item.ID;
259新增: ItemsDictionary[id].Icon = item.Icon;
260新增: ItemsDictionary[id].Title = item.Title;
261新增:
262新增: }
263新增: }
264新增: }
265新增:
266新增: public override void OnApplyTemplate()
267新增: {
268新增: base.OnApplyTemplate();
269新增: ItemsPanel = GetTemplateChild("ItemsPanel") as StackPanel;
270新增: ActiveBlock = GetTemplateChild("ActiveBlock") as Border;
271新增:
272新增: Render();
273新增: }
274新增: private int CreateID()
275新增: {
276新增: if (ItemsDictionary.Count == 0)
277新增: {
278新增: return 1;
279新增: }
280新增: return ItemsDictionary.Max(m => m.Key) + 1;
281新增: }
282新增: private void AddItem(NavigationItemModel item)
283新增: {
284新增: if (ItemsPanel != null)
285新增: {
286新增: var navItem = new NavigationItem();
287新增: int id = item.ID == null ? CreateID() : item.ID;
288新增: item.ID = id;
289新增: navItem.ID = id;
290新增: navItem.Title = item.Title;
291新增: navItem.Icon = item.Icon;
292新增: navItem.IconColor = item.IconColor;
293新增: navItem.BadgeText = item.BadgeText;
294新增: navItem.Uri = item.Uri;
295新增: //navItem.IsSelected = item.IsSelected;
296新增: if (!string.IsNullOrEmpty(item.Title))
297新增: {
298新增: navItem.MouseUp += NavItem_MouseUp;
299新增: }
300新增: ItemsPanel.Children.Add(navItem);
301新增: ItemsDictionary.Add(id, navItem);
302新增: //if (item.IsSelected)
303新增: //{
304新增: // SelectedItem = item;
305新增: //}
306新增: }
307新增: }
308新增:
309新增: private void NavItem_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
310新增: {
311新增: var navitem = sender as NavigationItem;
312新增: if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
313新增: {
314新增: //左键选中
315新增: SelectedItem = Data.Where(m => m.ID == navitem.ID).FirstOrDefault();
316新增: OnSelected?.Invoke(this, null);
317新增: ScrollToActive();
318新增: }
319新增: if (e.ChangedButton == System.Windows.Input.MouseButton.Right)
320新增: {
321新增: //右键
322新增: var args = new RoutedEventArgs();
323新增: args.RoutedEvent = e.RoutedEvent;
324新增: args.Source = Data.Where(m => m.ID == navitem.ID).FirstOrDefault();
325新增: OnMouseRightButtonUP?.Invoke(this, args);
326新增: }
327新增: }
328新增:
329新增: private void RemoveItem(NavigationItemModel item)
330新增: {
331新增: var navItem = ItemsDictionary[item.ID];
332新增: ItemsPanel.Children.Remove(navItem);
333新增: ItemsDictionary.Remove(item.ID);
334新增: }
335新增: private void Render()
336新增: {
337新增: if (Data != null)
338新增: {
339新增: foreach (var item in Data)
340新增: {
341新增: AddItem(item);
342新增: }
343新增:
344新增: }
345新增: }
346新增:
347新增: private void ScrollToActive()
348新增: {
349新增: // 获取选中项
350新增: if (SelectedItem == null)
351新增: {
352新增: return;
353新增: }
354新增: var item = ItemsDictionary[SelectedItem.ID];
355新增: var index = Data.IndexOf(SelectedItem);
356新增:
357新增: //ActiveBlock.Height = item.ActualHeight * Data.Count;
358新增:
359新增: // 选中项的坐标
360新增: Point relativePoint = item.TransformToAncestor(this).Transform(new Point(0, 0));
361新增:
362新增: // 创建动画
363新增:
364新增: // 设定动画方向
365新增: var activeBlockTTF = (ActiveBlock.RenderTransform as TransformGroup).Children[0] as TranslateTransform;
366新增:
367新增: //var transformGroup = new TransformGroup();
368新增: //transformGroup.Children.Add(new TranslateTransform(0, activeBlockTTF.Y));
369新增: //transformGroup.Children.Add(new ScaleTransform(1, 1, 0, 0));
370新增:
371新增: //ActiveBlock.RenderTransform = transformGroup;
372新增:
373新增:
374新增: storyboard.Children.Clear();
375新增: DoubleAnimation scrollAnimation = new DoubleAnimation();
376新增: //scrollAnimation.From = activeBlockTTF.Y;
377新增: scrollAnimation.To = relativePoint.Y + 8;
378新增:
379新增: scrollAnimation.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseIn };
380新增: Storyboard.SetTarget(scrollAnimation, ActiveBlock);
381新增: Storyboard.SetTargetProperty(scrollAnimation, new PropertyPath("RenderTransform.Children[0].Y"));
382新增:
383新增: scrollAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.35));
384新增:
385新增: // 伸缩动画
386新增: DoubleAnimation stretchAnimation = new DoubleAnimation();
387新增: stretchAnimation.AutoReverse = true;
388新增: stretchAnimation.To = 1.6;
389新增: stretchAnimation.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseIn };
390新增: Storyboard.SetTarget(stretchAnimation, ActiveBlock);
391新增: Storyboard.SetTargetProperty(stretchAnimation, new PropertyPath("RenderTransform.Children[1].ScaleY"));
392新增: stretchAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.35));
393新增:
394新增: if (relativePoint.Y > activeBlockTTF.Y)
395新增: {
396新增: // 向下移动
397新增:
398新增: var transformGroup = new TransformGroup();
399新增: transformGroup.Children.Add(new TranslateTransform(0, activeBlockTTF.Y));
400新增: transformGroup.Children.Add(new ScaleTransform(1, 1, 0, 200));
401新增:
402新增: ActiveBlock.RenderTransform = transformGroup;
403新增:
404新增: //stretchAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3));
405新增:
406新增:
407新增: }
408新增: else
409新增: {
410新增: var transformGroup = new TransformGroup();
411新增: transformGroup.Children.Add(new TranslateTransform(0, activeBlockTTF.Y));
412新增: transformGroup.Children.Add(new ScaleTransform(1, 1, 0, 0));
413新增:
414新增: ActiveBlock.RenderTransform = transformGroup;
415新增: //var transformGroup = new TransformGroup();
416新增: //transformGroup.Children.Add(new TranslateTransform(0, activeBlockTTF.Y));
417新增: //transformGroup.Children.Add(new ScaleTransform(1, .1, 0, 0));
418新增:
419新增: //ActiveBlock.RenderTransform = transformGroup;
420新增: }
421新增:
422新增:
423新增: storyboard.Children.Add(stretchAnimation);
424新增:
425新增: storyboard.Children.Add(scrollAnimation);
426新增:
427新增: storyboard.Begin();
428新增: }
429新增: }
430新增:}
新增UI/Controls/Navigation/NavigationItem.cs+139 −0看文件
@@ -0,0 +1,139 @@
1新增:
2新增:using System;
3新增:using System.Collections.Generic;
4新增:using System.Text;
5新增:using System.Windows;
6新增:using System.Windows.Controls;
7新增:using System.Windows.Input;
8新增:using System.Windows.Media;
9新增:using UI.Base.Color;
10新增:using UI.Controls.Base;
11新增:
12新增:namespace UI.Controls.Navigation
13新增:{
14新增: public class NavigationItem : Control
15新增: {
16新增: public int ID
17新增: {
18新增: get { return (int)GetValue(IDProperty); }
19新增: set { SetValue(IDProperty, value); }
20新增: }
21新增: public static readonly DependencyProperty IDProperty =
22新增: DependencyProperty.Register("ID",
23新增: typeof(int),
24新增: typeof(NavigationItem));
25新增:
26新增: public ICommand Command
27新增: {
28新增: get { return (ICommand)GetValue(CommandProperty); }
29新增: set { SetValue(CommandProperty, value); }
30新增: }
31新增: public static readonly DependencyProperty CommandProperty =
32新增: DependencyProperty.Register("Command",
33新增: typeof(ICommand),
34新增: typeof(NavigationItem));
35新增:
36新增: public object CommandParameter
37新增: {
38新增: get { return (object)GetValue(CommandParameterProperty); }
39新增: set { SetValue(CommandParameterProperty, value); }
40新增: }
41新增: public static readonly DependencyProperty CommandParameterProperty =
42新增: DependencyProperty.Register("CommandParameter",
43新增: typeof(object),
44新增: typeof(NavigationItem));
45新增: public IconTypes Icon
46新增: {
47新增: get { return (IconTypes)GetValue(IconProperty); }
48新增: set { SetValue(IconProperty, value); }
49新增: }
50新增: public static readonly DependencyProperty IconProperty =
51新增: DependencyProperty.Register("Icon",
52新增: typeof(IconTypes),
53新增: typeof(NavigationItem), new PropertyMetadata(IconTypes.None));
54新增: public ColorTypes IconColor
55新增: {
56新增: get { return (ColorTypes)GetValue(IconColorProperty); }
57新增: set { SetValue(IconColorProperty, value); }
58新增: }
59新增: public static readonly DependencyProperty IconColorProperty =
60新增: DependencyProperty.Register("IconColor",
61新增: typeof(ColorTypes),
62新增: typeof(NavigationItem), new PropertyMetadata(ColorTypes.Blue));
63新增: public SolidColorBrush IconColorBrush
64新增: {
65新增: get { return (SolidColorBrush)GetValue(IconColorBrushProperty); }
66新增: set { SetValue(IconColorBrushProperty, value); }
67新增: }
68新增: public static readonly DependencyProperty IconColorBrushProperty =
69新增: DependencyProperty.Register("IconColorBrush",
70新增: typeof(SolidColorBrush),
71新增: typeof(NavigationItem), new PropertyMetadata(UI.Base.Color.Colors.GetColor(ColorTypes.Blue)));
72新增:
73新增: public string Title
74新增: {
75新增: get { return (string)GetValue(TitleProperty); }
76新增: set { SetValue(TitleProperty, value); }
77新增: }
78新增: public static readonly DependencyProperty TitleProperty =
79新增: DependencyProperty.Register("Title",
80新增: typeof(string),
81新增: typeof(NavigationItem), new PropertyMetadata(string.Empty));
82新增:
83新增: public string BadgeText
84新增: {
85新增: get { return (string)GetValue(BadgeTextProperty); }
86新增: set { SetValue(BadgeTextProperty, value); }
87新增: }
88新增: public static readonly DependencyProperty BadgeTextProperty =
89新增: DependencyProperty.Register("BadgeText",
90新增: typeof(string),
91新增: typeof(NavigationItem), new PropertyMetadata(string.Empty));
92新增: public string Uri
93新增: {
94新增: get { return (string)GetValue(UriProperty); }
95新增: set { SetValue(UriProperty, value); }
96新增: }
97新增: public static readonly DependencyProperty UriProperty =
98新增: DependencyProperty.Register("Uri",
99新增: typeof(string),
100新增: typeof(NavigationItem), new PropertyMetadata(string.Empty));
101新增:
102新增: public bool IsSelected
103新增: {
104新增: get { return (bool)GetValue(IsSelectedProperty); }
105新增: set { SetValue(IsSelectedProperty, value); }
106新增: }
107新增: public static readonly DependencyProperty IsSelectedProperty =
108新增: DependencyProperty.Register("IsSelected",
109新增: typeof(bool),
110新增: typeof(NavigationItem), new PropertyMetadata(false));
111新增:
112新增: public delegate void NavigationEventHandler(object sender, MouseButtonEventArgs e);
113新增: public event NavigationEventHandler MouseUp;
114新增: public NavigationItem()
115新增: {
116新增: DefaultStyleKey = typeof(NavigationItem);
117新增: }
118新增: protected override void OnMouseUp(MouseButtonEventArgs e)
119新增: {
120新增: base.OnMouseUp(e);
121新增: MouseUp?.Invoke(this, e);
122新增: if (e.ChangedButton == MouseButton.Left)
123新增: {
124新增: Command?.Execute(CommandParameter);
125新增: }
126新增: }
127新增:
128新增: protected override void OnMouseEnter(MouseEventArgs e)
129新增: {
130新增: base.OnMouseEnter(e);
131新增: VisualStateManager.GoToState(this, "MouseOver", true);
132新增: }
133新增: protected override void OnMouseLeave(MouseEventArgs e)
134新增: {
135新增: base.OnMouseLeave(e);
136新增: VisualStateManager.GoToState(this, "Normal", true);
137新增: }
138新增: }
139新增:}
新增UI/Controls/PageContainer.cs+160 −0看文件
@@ -0,0 +1,160 @@
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.Input;
10新增:
11新增:namespace UI.Controls
12新增:{
13新增: public class PageContainer : Control
14新增: {
15新增: #region 依赖属性
16新增: public string Title
17新增: {
18新增: get { return (string)GetValue(TitleProperty); }
19新增: set { SetValue(TitleProperty, value); }
20新增: }
21新增: public static readonly DependencyProperty TitleProperty =
22新增: DependencyProperty.Register("Title",
23新增: typeof(string),
24新增: typeof(PageContainer));
25新增:
26新增: public IServiceProvider ServiceProvider
27新增: {
28新增: get { return (IServiceProvider)GetValue(ServiceProviderProperty); }
29新增: set { SetValue(ServiceProviderProperty, value); }
30新增: }
31新增: public static readonly DependencyProperty ServiceProviderProperty =
32新增: DependencyProperty.Register("ServiceProvider", typeof(IServiceProvider), typeof(PageContainer));
33新增:
34新增: public object Content
35新增: {
36新增: get { return (object)GetValue(ContentProperty); }
37新增: set { SetValue(ContentProperty, value); }
38新增: }
39新增: public static readonly DependencyProperty ContentProperty =
40新增: DependencyProperty.Register("Content", typeof(object), typeof(PageContainer), new PropertyMetadata("Content undefined!"));
41新增:
42新增: public string Uri
43新增: {
44新增: get { return (string)GetValue(UriProperty); }
45新增: set { SetValue(UriProperty, value); }
46新增: }
47新增: public static readonly DependencyProperty UriProperty =
48新增: DependencyProperty.Register("Uri", typeof(string), typeof(PageContainer), new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnUriChanged)));
49新增:
50新增: private static void OnUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
51新增: {
52新增: var control = d as PageContainer;
53新增: if (e.NewValue != e.OldValue)
54新增: {
55新增: control.LoadPage();
56新增: }
57新增: }
58新增:
59新增: public bool IsShowTilteBar
60新增: {
61新增: get { return (bool)GetValue(IsShowTilteBarProperty); }
62新增: set { SetValue(IsShowTilteBarProperty, value); }
63新增: }
64新增: public static readonly DependencyProperty IsShowTilteBarProperty =
65新增: DependencyProperty.Register("IsShowTilteBar",
66新增: typeof(bool),
67新增: typeof(PageContainer), new PropertyMetadata(false, new PropertyChangedCallback(OnIsShowTitleBarChanged)));
68新增:
69新增: private static void OnIsShowTitleBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
70新增: {
71新增: var control = d as PageContainer;
72新增: if (e.NewValue != e.OldValue)
73新增: {
74新增: control.TitleBarVisibility = control.IsShowTilteBar ? Visibility.Visible : Visibility.Collapsed;
75新增: }
76新增: }
77新增: public Visibility TitleBarVisibility
78新增: {
79新增: get { return (Visibility)GetValue(TitleBarVisibilityProperty); }
80新增: set { SetValue(TitleBarVisibilityProperty, value); }
81新增: }
82新增: public static readonly DependencyProperty TitleBarVisibilityProperty =
83新增: DependencyProperty.Register("TitleBarVisibility",
84新增: typeof(Visibility),
85新增: typeof(PageContainer), new PropertyMetadata(Visibility.Collapsed));
86新增:
87新增: public Command BackCommand
88新增: {
89新增: get { return (Command)GetValue(BackCommandProperty); }
90新增: set { SetValue(BackCommandProperty, value); }
91新增: }
92新增: public static readonly DependencyProperty BackCommandProperty =
93新增: DependencyProperty.Register("BackCommand",
94新增: typeof(Command),
95新增: typeof(PageContainer));
96新增: #endregion
97新增:
98新增: private readonly string ProjectName;
99新增: private List<string> Historys;
100新增: private int Index = -1, OldIndex = -1;
101新增: private Frame Frame;
102新增: public PageContainer()
103新增: {
104新增: DefaultStyleKey = typeof(PageContainer);
105新增: ProjectName = App.Current.GetType().Assembly.GetName().Name;
106新增: Historys = new List<string>();
107新增: BackCommand = new Command(new Action<object>(OnBackCommand));
108新增: NavigationCommands.BrowseBack.InputGestures.Clear();
109新增: NavigationCommands.BrowseForward.InputGestures.Clear();
110新增: }
111新增:
112新增: private void OnBackCommand(object obj)
113新增: {
114新增: if (Index - 1 >= 0)
115新增: {
116新增: OldIndex = Index;
117新增: Index--;
118新增: Uri = Historys[Index];
119新增: Historys.RemoveRange(Index + 1, Historys.Count - (Index + 1));
120新增: }
121新增: }
122新增:
123新增: private void LoadPage()
124新增: {
125新增: if (Uri != string.Empty)
126新增: {
127新增:
128新增: Type pageType = Type.GetType(ProjectName + ".Views." + Uri);
129新增: Type pageVMType = Type.GetType(ProjectName + ".ViewModels." + Uri + "VM");
130新增: if (pageType != null && ServiceProvider != null)
131新增: {
132新增: var page = ServiceProvider.GetService(pageType) as Page;
133新增: if (page != null)
134新增: {
135新增: var pageVM = ServiceProvider.GetService(pageVMType);
136新增: if (pageVM != null)
137新增: {
138新增: page.DataContext = pageVM;
139新增: }
140新增: Content = page;
141新增: //处理历史记录
142新增: if (OldIndex == Index)
143新增: {
144新增: //新开
145新增: Historys.Add(Uri);
146新增: Index++;
147新增: }
148新增: OldIndex = Index;
149新增: }
150新增: else
151新增: {
152新增: Debug.WriteLine("找不到Page:" + Uri + ",请确认已被注入");
153新增: }
154新增:
155新增: }
156新增:
157新增: }
158新增: }
159新增: }
160新增:}
新增UI/Controls/Window/DefaultWindow.cs+228 −0看文件
@@ -0,0 +1,228 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.ComponentModel;
4新增:using System.Drawing;
5新增:using System.Linq;
6新增:using System.Runtime.InteropServices;
7新增:using System.Text;
8新增:using System.Threading.Tasks;
9新增:using System.Windows;
10新增:using System.Windows.Input;
11新增:using System.Windows.Interop;
12新增:using System.Windows.Media;
13新增:using System.Windows.Media.Imaging;
14新增:
15新增:namespace UI.Controls.Window
16新增:{
17新增: public class DefaultWindow : System.Windows.Window
18新增: {
19新增: #region 1.依赖属性
20新增:
21新增:
22新增: #region 最小化按钮显示状态
23新增:
24新增: public static readonly DependencyProperty MinimizeVisibilityProperty = DependencyProperty.Register("MinimizeVisibility", typeof(Visibility), typeof(DefaultWindow));
25新增:
26新增: /// <summary>
27新增: /// 最小化按钮显示状态
28新增: /// </summary>
29新增: public Visibility MinimizeVisibility
30新增: {
31新增: get { return (Visibility)GetValue(MinimizeVisibilityProperty); }
32新增: set { SetValue(MinimizeVisibilityProperty, value); }
33新增: }
34新增: #endregion
35新增:
36新增: #region 最大化按钮显示状态
37新增:
38新增: public static readonly DependencyProperty MaximizeVisibilityProperty = DependencyProperty.Register("MaximizeVisibility", typeof(Visibility), typeof(DefaultWindow));
39新增:
40新增: /// <summary>
41新增: /// 最大化按钮显示状态
42新增: /// </summary>
43新增: public Visibility MaximizeVisibility
44新增: {
45新增: get { return (Visibility)GetValue(MaximizeVisibilityProperty); }
46新增: set { SetValue(MaximizeVisibilityProperty, value); }
47新增: }
48新增: #endregion
49新增:
50新增: #region 关闭按钮显示状态
51新增:
52新增: public static readonly DependencyProperty CloseVisibilityProperty = DependencyProperty.Register("CloseVisibility", typeof(Visibility), typeof(DefaultWindow));
53新增:
54新增: /// <summary>
55新增: /// 关闭按钮显示状态
56新增: /// </summary>
57新增: public Visibility CloseVisibility
58新增: {
59新增: get { return (Visibility)GetValue(CloseVisibilityProperty); }
60新增: set { SetValue(CloseVisibilityProperty, value); }
61新增: }
62新增: #endregion
63新增:
64新增: #region 拓展内容
65新增: public static readonly DependencyProperty ExtElementProperty = DependencyProperty.Register("ExtElement", typeof(object), typeof(DefaultWindow));
66新增: /// <summary>
67新增: /// 拓展内容
68新增: /// </summary>
69新增: public object ExtElement
70新增: {
71新增: get { return GetValue(ExtElementProperty); }
72新增: set { SetValue(ExtElementProperty, value); }
73新增: }
74新增: #endregion
75新增:
76新增:
77新增:
78新增: #region 是否穿透窗口
79新增:
80新增: public static readonly DependencyProperty IsThruWindowProperty = DependencyProperty.Register("IsThruWindow", typeof(bool), typeof(DefaultWindow), new PropertyMetadata(false));
81新增:
82新增: /// <summary>
83新增: /// 是否穿透窗口
84新增: /// </summary>
85新增: public bool IsThruWindow
86新增: {
87新增: get { return (bool)GetValue(IsThruWindowProperty); }
88新增: set { SetValue(IsThruWindowProperty, value); }
89新增: }
90新增: #endregion
91新增: #endregion
92新增:
93新增: #region 3.初始化
94新增: public DefaultWindow()
95新增: {
96新增: this.DefaultStyleKey = typeof(DefaultWindow);
97新增: //添加当前窗体到窗体集合
98新增:
99新增: //命令绑定
100新增: this.CommandBindings.Add(new CommandBinding(DefaultWindowCommands.MinimizeWindowCommand, OnMinimizeWindowCommand));
101新增: this.CommandBindings.Add(new CommandBinding(DefaultWindowCommands.MaximizeWindowCommand, OnMaximizeWindowCommand));
102新增: this.CommandBindings.Add(new CommandBinding(DefaultWindowCommands.RestoreWindowCommand, OnRestoreWindowCommand));
103新增: this.CommandBindings.Add(new CommandBinding(DefaultWindowCommands.CloseWindowCommand, OnCloseWindowCommand));
104新增:
105新增: // 获取程序图标
106新增: if (Icon == null)
107新增: {
108新增: Icon = ToImageSource(System.Drawing.Icon.ExtractAssociatedIcon(
109新增: System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name));
110新增: }
111新增:
112新增: Loaded += new RoutedEventHandler(window_Loaded);
113新增:
114新增:
115新增: }
116新增:
117新增: [DllImport("gdi32.dll", SetLastError = true)]
118新增: private static extern bool DeleteObject(IntPtr hObject);
119新增:
120新增: public static ImageSource ToImageSource(Icon icon)
121新增: {
122新增: Bitmap bitmap = icon.ToBitmap();
123新增: IntPtr hBitmap = bitmap.GetHbitmap();
124新增:
125新增: ImageSource wpfBitmap = Imaging.CreateBitmapSourceFromHBitmap(
126新增: hBitmap,
127新增: IntPtr.Zero,
128新增: Int32Rect.Empty,
129新增: BitmapSizeOptions.FromEmptyOptions());
130新增:
131新增: if (!DeleteObject(hBitmap))
132新增: {
133新增: throw new Win32Exception();
134新增: }
135新增:
136新增: return wpfBitmap;
137新增: }
138新增:
139新增: private void window_Loaded(object sender, RoutedEventArgs e)
140新增: {
141新增: OnSystemButtonsVisibility();
142新增: }
143新增:
144新增:
145新增:
146新增:
147新增: public override void OnApplyTemplate()
148新增: {
149新增: base.OnApplyTemplate();
150新增: }
151新增:
152新增:
153新增: /// <summary>
154新增: /// 根据窗口ResizeMode设置系统按钮的可视状态
155新增: /// </summary>
156新增: private void OnSystemButtonsVisibility()
157新增: {
158新增: switch (ResizeMode)
159新增: {
160新增: case ResizeMode.NoResize:
161新增: //仅显示关闭按钮
162新增: MinimizeVisibility = Visibility.Collapsed;
163新增: MaximizeVisibility = Visibility.Collapsed;
164新增: CloseVisibility = Visibility.Visible;
165新增: break;
166新增: case ResizeMode.CanResize:
167新增: MinimizeVisibility = Visibility.Visible;
168新增: MaximizeVisibility = Visibility.Visible;
169新增: CloseVisibility = Visibility.Visible;
170新增: break;
171新增: case ResizeMode.CanMinimize:
172新增: MinimizeVisibility = Visibility.Visible;
173新增: MaximizeVisibility = Visibility.Collapsed;
174新增: CloseVisibility = Visibility.Visible;
175新增: break;
176新增: }
177新增: }
178新增: #endregion
179新增:
180新增: #region 5.命令
181新增:
182新增: private void OnCloseWindowCommand(object sender, ExecutedRoutedEventArgs e)
183新增: {
184新增: Close();
185新增: }
186新增:
187新增: private void OnRestoreWindowCommand(object sender, ExecutedRoutedEventArgs e)
188新增: {
189新增: WindowState = WindowState.Normal;
190新增: }
191新增:
192新增: private void OnMaximizeWindowCommand(object sender, ExecutedRoutedEventArgs e)
193新增: {
194新增: WindowState = WindowState.Maximized;
195新增: }
196新增:
197新增: private void OnMinimizeWindowCommand(object sender, ExecutedRoutedEventArgs e)
198新增: {
199新增: WindowState = WindowState.Minimized;
200新增: }
201新增:
202新增: #endregion
203新增:
204新增: #region 6.事件
205新增:
206新增: protected override void OnSourceInitialized(EventArgs e)
207新增: {
208新增: base.OnSourceInitialized(e);
209新增: if (IsThruWindow)
210新增: {
211新增: IntPtr hwnd = new WindowInteropHelper(this).Handle; uint extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
212新增: SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
213新增: }
214新增: }
215新增: #endregion
216新增:
217新增: #region win32
218新增: private const int WS_EX_TRANSPARENT = 0x20;
219新增: private const int GWL_EXSTYLE = (-20);
220新增:
221新增: [DllImport("user32", EntryPoint = "SetWindowLong")]
222新增: private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
223新增:
224新增: [DllImport("user32", EntryPoint = "GetWindowLong")]
225新增: private static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
226新增: #endregion
227新增: }
228新增:}
新增UI/Controls/Window/DefaultWindowCommands.cs+19 −0看文件
@@ -0,0 +1,19 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Linq;
4新增:using System.Text;
5新增:using System.Threading.Tasks;
6新增:using System.Windows.Input;
7新增:
8新增:namespace UI.Controls.Window
9新增:{
10新增: public class DefaultWindowCommands
11新增: {
12新增: public static RoutedUICommand MinimizeWindowCommand { get; } = new RoutedUICommand("", "MinimizeWindowCommand", typeof(DefaultWindowCommands));
13新增: public static RoutedUICommand RestoreWindowCommand { get; } = new RoutedUICommand("", "RestoreWindowCommand", typeof(DefaultWindowCommands));
14新增: public static RoutedUICommand MaximizeWindowCommand { get; } = new RoutedUICommand("", "MaximizeWindowCommand", typeof(DefaultWindowCommands));
15新增: public static RoutedUICommand CloseWindowCommand { get; } = new RoutedUICommand("", "CloseWindowCommand", typeof(DefaultWindowCommands));
16新增:
17新增: public static RoutedUICommand LogoButtonClickCommand { get; } = new RoutedUICommand("", "LogoButtonClickCommand", typeof(DefaultWindowCommands));
18新增: }
19新增:}
新增UI/Controls/Window/HideWindow.cs+19 −0看文件
@@ -0,0 +1,19 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Linq;
4新增:using System.Text;
5新增:using System.Threading.Tasks;
6新增:
7新增:namespace UI.Controls.Window
8新增:{
9新增: /// <summary>
10新增: /// 隐藏窗口
11新增: /// </summary>
12新增: public class HideWindow : System.Windows.Window
13新增: {
14新增: public HideWindow()
15新增: {
16新增: this.DefaultStyleKey = typeof(HideWindow);
17新增: }
18新增: }
19新增:}
修改UI/MainWindow.xaml+45 −4看文件
@@ -1,12 +1,53 @@
1删除:<Window x:Class="UI.MainWindow"
1新增:<ui:DefaultWindow x:Class="UI.MainWindow"
22 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66 xmlns:local="clr-namespace:UI"
77 mc:Ignorable="d"
8删除: Title="MainWindow" Height="450" Width="800">
8新增: xmlns:ui="clr-namespace:UI.Controls.Window"
9新增: Title="Tai - 时间管家" Height="450" Width="800"
10新增: xmlns:control="clr-namespace:UI.Controls"
11新增: xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
12新增: xmlns:Navigation="clr-namespace:UI.Controls.Navigation"
13新增: x:Name="Window">
914 <Grid>
10删除:
15新增: <!--主要功能-->
16新增: <Grid>
17新增: <Grid.ColumnDefinitions>
18新增: <ColumnDefinition Width="auto"/>
19新增: <ColumnDefinition Width="*"/>
20新增: </Grid.ColumnDefinitions>
21新增: <Navigation:Navigation x:Name="Navigation" Margin="0,32,0,0" Data="{Binding Items,Mode=TwoWay}" Width="80" WindowWidth="{Binding ElementName=Window,Path=ActualWidth}" IsShowNavigation="{Binding IsShowNavigation,Mode=TwoWay}" SelectedItem="{Binding NavSelectedItem,Mode=TwoWay}">
22新增: <i:Interaction.Triggers>
23新增: <i:EventTrigger EventName="OnSelected">
24新增: <i:InvokeCommandAction Command="{Binding OnSelectedCommand}" CommandParameter="{Binding ElementName=Navigation}"/>
25新增: </i:EventTrigger>
26新增: <i:EventTrigger EventName="OnMouseRightButtonUP">
27新增: <!--<vm:EventCommand Command="{Binding OnMouseRightButtonUPCommand}" />-->
28新增: </i:EventTrigger>
29新增: </i:Interaction.Triggers>
30新增: <!--<Navigation:Navigation.TopExtContent>
31新增: <TextBlock Text="test"/>
32新增: </Navigation:Navigation.TopExtContent>-->
33新增: <Navigation:Navigation.BottomExtContent>
34新增: <Navigation:NavigationItem Icon="Settings" Title="设置" Uri="SettingsPage" Command="{Binding GotoPageCommand}" CommandParameter="SettingsPage"/>
35新增: </Navigation:Navigation.BottomExtContent>
36新增: <Navigation:Navigation.ContextMenu>
37新增: <ContextMenu>
38新增: <MenuItem Header="新建分组" Command="{Binding ShowGroupModalCommand}">
39新增: <!--<MenuItem.Icon>
40新增: <base:Icon IconType="CalculatorAddition" FontSize="12"/>
41新增: </MenuItem.Icon>-->
42新增: </MenuItem>
43新增: </ContextMenu>
44新增: </Navigation:Navigation.ContextMenu>
45新增: </Navigation:Navigation>
46新增:
47新增: <Border Grid.Column="1" Background="#f9f9f9" Margin="0,40,10,10" CornerRadius="5" BorderThickness="1,1,1,1" BorderBrush="#ccc">
48新增: <control:PageContainer ServiceProvider="{Binding ServiceProvider}" Uri="{Binding Uri,Mode=TwoWay}" Title="{Binding Title}" IsShowTilteBar="{Binding IsShowTitleBar,Mode=TwoWay}"/>
49新增: </Border>
50新增:
51新增: </Grid>
1152 </Grid>
12删除:</Window>
53新增:</ui:DefaultWindow>
修改UI/MainWindow.xaml.cs+2 −1看文件
@@ -13,13 +13,14 @@ using System.Windows.Media;
1313using System.Windows.Media.Imaging;
1414using System.Windows.Navigation;
1515using System.Windows.Shapes;
16新增:using UI.Controls.Window;
1617
1718namespace UI
1819{
1920 /// <summary>
2021 /// MainWindow.xaml 的交互逻辑
2122 /// </summary>
22删除: public partial class MainWindow : Window
23新增: public partial class MainWindow : DefaultWindow
2324 {
2425 public MainWindow()
2526 {
新增UI/Models/MainWindowModel.cs+74 −0看文件
@@ -0,0 +1,74 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Collections.ObjectModel;
4新增:using System.Linq;
5新增:using System.Text;
6新增:using System.Threading.Tasks;
7新增:using UI.Controls.Navigation.Models;
8新增:
9新增:namespace UI.Models
10新增:{
11新增: public class MainWindowModel : UINotifyPropertyChanged
12新增: {
13新增: private IServiceProvider ServiceProvider_;
14新增: public IServiceProvider ServiceProvider
15新增: {
16新增: get { return ServiceProvider_; }
17新增: set { ServiceProvider_ = value; OnPropertyChanged(); }
18新增: }
19新增:
20新增: private string Uri_;
21新增: public string Uri
22新增: {
23新增: get { return Uri_; }
24新增: set { Uri_ = value; OnPropertyChanged(); }
25新增: }
26新增:
27新增: private object Data_;
28新增: /// <summary>
29新增: /// 页面传递数据
30新增: /// </summary>
31新增: public object Data
32新增: {
33新增: get { return Data_; }
34新增: set { Data_ = value; OnPropertyChanged(); }
35新增: }
36新增:
37新增: public ObservableCollection<NavigationItemModel> Items { get; set; }
38新增:
39新增: private double NavigationWidth_ = 220;
40新增: public double NavigationWidth
41新增: {
42新增: get { return NavigationWidth_; }
43新增: set { NavigationWidth_ = value; OnPropertyChanged(); }
44新增: }
45新增:
46新增: private bool IsShowNavigation_ = true;
47新增: public bool IsShowNavigation
48新增: {
49新增: get { return IsShowNavigation_; }
50新增: set { IsShowNavigation_ = value; OnPropertyChanged(); }
51新增: }
52新增:
53新增: private string Title_;
54新增: public string Title
55新增: {
56新增: get { return Title_; }
57新增: set { Title_ = value; OnPropertyChanged(); }
58新增: }
59新增: private bool IsShowTitleBar_ = false;
60新增: public bool IsShowTitleBar
61新增: {
62新增: get { return IsShowTitleBar_; }
63新增: set { IsShowTitleBar_ = value; OnPropertyChanged(); }
64新增: }
65新增:
66新增:
67新增: private NavigationItemModel NavSelectedItem_;
68新增: public NavigationItemModel NavSelectedItem
69新增: {
70新增: get { return NavSelectedItem_; }
71新增: set { NavSelectedItem_ = value; OnPropertyChanged(); }
72新增: }
73新增: }
74新增:}
新增UI/Models/UINotifyPropertyChanged.cs+26 −0看文件
@@ -0,0 +1,26 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.ComponentModel;
4新增:using System.Linq;
5新增:using System.Runtime.CompilerServices;
6新增:using System.Text;
7新增:using System.Threading.Tasks;
8新增:
9新增:namespace UI.Models
10新增:{
11新增: public class UINotifyPropertyChanged : INotifyPropertyChanged
12新增: {
13新增: public event PropertyChangedEventHandler PropertyChanged;
14新增:
15新增: public void OnPropertyChanged([CallerMemberName] string propertyName = "")
16新增: {
17新增:
18新增: PropertyChangedEventHandler handler = PropertyChanged;
19新增: if (handler != null)
20新增: {
21新增: handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
22新增: }
23新增:
24新增: }
25新增: }
26新增:}
新增UI/Resources/Fonts/SegMDL2.ttf看文件

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

新增UI/Resources/Fonts/fabric-icons.ttf看文件

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

新增UI/TextTemplate.ico看文件

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

新增UI/Themes/Base/Icon.xaml+26 −0看文件
@@ -0,0 +1,26 @@
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">
4新增: <Style TargetType="{x:Type local:Icon}">
5新增: <Setter Property="SnapsToDevicePixels"
6新增: Value="true" />
7新增:
8新增: <Setter Property="MinWidth" Value="18"/>
9新增: <Setter Property="MinHeight" Value="18"/>
10新增: <Setter Property="FontSize" Value="16"/>
11新增: <Setter Property="FontFamily" Value="pack://application:,,,/Tai;component/Resources/Fonts/#Fabric MDL2 Assets"/>
12新增: <Setter Property="Background" Value="Transparent"/>
13新增:
14新增: <Setter Property="Template">
15新增: <Setter.Value>
16新增: <ControlTemplate TargetType="{x:Type local:Icon}">
17新增: <Border Background="{TemplateBinding Background}">
18新增:
19新增: <TextBlock Text="{TemplateBinding Unicode}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" VerticalAlignment="Center" HorizontalAlignment="Center" TextOptions.TextFormattingMode="Ideal" SnapsToDevicePixels="True" />
20新增: </Border>
21新增:
22新增: </ControlTemplate>
23新增: </Setter.Value>
24新增: </Setter>
25新增: </Style>
26新增:</ResourceDictionary>
文件末尾没有换行
新增UI/Themes/Generic.xaml+11 −0看文件
@@ -0,0 +1,11 @@
1新增:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2新增: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3新增: <ResourceDictionary.MergedDictionaries>
4新增: <ResourceDictionary Source="/Tai;component/Themes/Window/HideWindow.xaml" />
5新增: <ResourceDictionary Source="/Tai;component/Themes/Window/DefaultWindow.xaml" />
6新增: <ResourceDictionary Source="/Tai;component/Themes/Navigation/NavigationItem.xaml"/>
7新增: <ResourceDictionary Source="/Tai;component/Themes/Navigation/Navigation.xaml"/>
8新增: <ResourceDictionary Source="/Tai;component/Themes/Base/Icon.xaml"/>
9新增:
10新增: </ResourceDictionary.MergedDictionaries>
11新增:</ResourceDictionary>
文件末尾没有换行
新增UI/Themes/Navigation/Navigation.xaml+45 −0看文件
@@ -0,0 +1,45 @@
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.Navigation"
4新增: >
5新增: <Style TargetType="{x:Type local:Navigation}">
6新增: <Setter Property="SnapsToDevicePixels"
7新增: Value="true" />
8新增: <Setter Property="MinWidth" Value="44"/>
9新增: <Setter Property="Height" Value="auto"/>
10新增: <Setter Property="Background" Value="Transparent"/>
11新增: <Setter Property="Template">
12新增: <Setter.Value>
13新增: <ControlTemplate TargetType="{x:Type local:Navigation}">
14新增: <Border Background="{TemplateBinding Background}">
15新增: <Grid Margin="10">
16新增: <Grid.RowDefinitions>
17新增: <RowDefinition Height="auto"/>
18新增: <RowDefinition Height="*"/>
19新增: <RowDefinition Height="auto"/>
20新增:
21新增: </Grid.RowDefinitions>
22新增: <ContentPresenter Content="{TemplateBinding TopExtContent}"/>
23新增: <Grid Grid.Row="1" Background="Transparent" x:Name="MenuGrid">
24新增: <Border x:Name="ActiveBlock" Width="5" Height="25" CornerRadius="2" Background="#0067c0" HorizontalAlignment="Left" VerticalAlignment="Top" Panel.ZIndex="9" RenderTransformOrigin="0,0">
25新增: <Border.RenderTransform>
26新增: <TransformGroup>
27新增: <TranslateTransform X="0" Y="0"></TranslateTransform>
28新增: <ScaleTransform CenterX="0" CenterY="0" ScaleY="1"/>
29新增: </TransformGroup>
30新增: </Border.RenderTransform>
31新增: </Border>
32新增: <ScrollViewer VerticalScrollBarVisibility="Auto">
33新增: <StackPanel x:Name="ItemsPanel"/>
34新增: </ScrollViewer>
35新增: </Grid>
36新增:
37新增: <ContentPresenter Content="{TemplateBinding BottomExtContent}" Grid.Row="2"/>
38新增: </Grid>
39新增: </Border>
40新增:
41新增: </ControlTemplate>
42新增: </Setter.Value>
43新增: </Setter>
44新增: </Style>
45新增:</ResourceDictionary>
文件末尾没有换行
新增UI/Themes/Navigation/NavigationItem.xaml+119 −0看文件
@@ -0,0 +1,119 @@
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.Navigation"
4新增: xmlns:base="clr-namespace:UI.Controls.Base">
5新增: <Style TargetType="{x:Type local:NavigationItem}">
6新增: <Setter Property="SnapsToDevicePixels"
7新增: Value="true" />
8新增: <Setter Property="Width" Value="60"/>
9新增: <!--<Setter Property="MinHeight" Value="44"/>-->
10新增: <Setter Property="Height" Value="60"/>
11新增: <Setter Property="Background" Value="Transparent"/>
12新增: <Setter Property="Template">
13新增: <Setter.Value>
14新增: <ControlTemplate TargetType="{x:Type local:NavigationItem}">
15新增: <Border Background="{TemplateBinding Background}" CornerRadius="5" x:Name="Border">
16新增: <!--<Border.Background>
17新增: <SolidColorBrush Color="{TemplateBinding Background}" Opacity="1"/>
18新增: </Border.Background>-->
19新增: <VisualStateManager.VisualStateGroups>
20新增: <VisualStateGroup x:Name="CommonStates">
21新增: <VisualStateGroup.Transitions>
22新增: <VisualTransition GeneratedDuration="0:0:0.15" />
23新增: <VisualTransition GeneratedDuration="0"
24新增: To="Pressed" />
25新增: </VisualStateGroup.Transitions>
26新增: <VisualState x:Name="Normal" />
27新增: <VisualState x:Name="MouseOver">
28新增: <Storyboard>
29新增: <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
30新增: Storyboard.TargetName="Border">
31新增: <EasingColorKeyFrame KeyTime="0"
32新增: Value="#eaeaea" />
33新增: </ColorAnimationUsingKeyFrames>
34新增: </Storyboard>
35新增: </VisualState>
36新增: <VisualState x:Name="Pressed">
37新增:
38新增: </VisualState>
39新增: </VisualStateGroup>
40新增: </VisualStateManager.VisualStateGroups>
41新增: <Grid Margin="5">
42新增: <!--<Rectangle x:Name="Line" Height="1" Width="auto" Fill="{DynamicResource SubBorderBrush}" Visibility="Collapsed" Margin="20,0"/>-->
43新增: <Grid x:Name="Content">
44新增: <!--<Grid.ColumnDefinitions>
45新增: <ColumnDefinition Width="15"/>
46新增: <ColumnDefinition Width="25"/>
47新增: <ColumnDefinition Width="*"/>
48新增: <ColumnDefinition Width="44"/>
49新增: </Grid.ColumnDefinitions>-->
50新增: <!--<Rectangle x:Name="CheckMark" Width="2" Fill="{TemplateBinding IconColorBrush}" Visibility="Hidden" Margin="0,10"/>-->
51新增: <!--<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">-->
52新增: <!--图标-->
53新增: <base:Icon x:Name="Icon" IconType="{TemplateBinding Icon}" Foreground="{Binding ElementName=Title,Path=Foreground}" VerticalAlignment="Center" Grid.Column="1" FontSize="20" RenderTransformOrigin="0,0">
54新增: <base:Icon.RenderTransform>
55新增: <TranslateTransform X="0" Y="-5"/>
56新增:
57新增: <!--中心点<TranslateTransform X="0" Y="0"/>-->
58新增: </base:Icon.RenderTransform>
59新增: </base:Icon>
60新增: <!--<base:Icon HorizontalAlignment="Center" IconType="{TemplateBinding Icon}" Foreground="Red" Grid.Column="1" FontSize="20" RenderTransformOrigin="0,0">
61新增:
62新增: </base:Icon>-->
63新增: <!--标题-->
64新增: <TextBlock x:Name="Title" RenderOptions.EdgeMode="Aliased" Text="{TemplateBinding Title}" Grid.Column="2" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="10" Foreground="#5c5c5c" Margin="0,5,0,0"/>
65新增: <!--</StackPanel>-->
66新增: <!--徽标-->
67新增: <!--<TextBlock Text="{TemplateBinding BadgeText}" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,20,0"/>-->
68新增:
69新增: </Grid>
70新增: </Grid>
71新增:
72新增: </Border>
73新增: <ControlTemplate.Triggers>
74新增: <Trigger Property="Title" Value="{x:Null}">
75新增: <Setter Property="Height" Value="15"/>
76新增:
77新增: <!--<Setter Property="Visibility" TargetName="Line" Value="Visible"/>-->
78新增: <Setter Property="Visibility" TargetName="Content" Value="Collapsed"/>
79新增: </Trigger>
80新增: <Trigger Property="IsSelected" Value="True">
81新增: <!--<Setter Property="Background" Value="White"/>-->
82新增: <Setter TargetName="Title" Property="Foreground" Value="#0067c0"/>
83新增: <Setter TargetName="Title" Property="Visibility" Value="Collapsed"/>
84新增:
85新增: <!--<Setter Property="Visibility" TargetName="CheckMark" Value="Visible"/>-->
86新增: </Trigger>
87新增:
88新增: <MultiTrigger>
89新增: <MultiTrigger.Conditions>
90新增: <Condition Property="IsSelected" Value="True"/>
91新增: </MultiTrigger.Conditions>
92新增: <MultiTrigger.EnterActions>
93新增: <BeginStoryboard>
94新增: <Storyboard>
95新增: <ColorAnimation Duration="0:0:0.3"
96新增: Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Border" To="White" />
97新增: <DoubleAnimation Duration="0:0:0.2"
98新增: Storyboard.TargetProperty="(base:Icon.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="Icon" To="0" />
99新增: </Storyboard>
100新增: </BeginStoryboard>
101新增: </MultiTrigger.EnterActions>
102新增: <MultiTrigger.ExitActions>
103新增: <BeginStoryboard>
104新增: <Storyboard>
105新增: <ColorAnimation Duration="0:0:0.3"
106新增: Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Border" To="Transparent" />
107新增: <DoubleAnimation Duration="0:0:0.2"
108新增: Storyboard.TargetProperty="(base:Icon.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="Icon" To="-5" />
109新增: </Storyboard>
110新增: </BeginStoryboard>
111新增: </MultiTrigger.ExitActions>
112新增: </MultiTrigger>
113新增:
114新增: </ControlTemplate.Triggers>
115新增: </ControlTemplate>
116新增: </Setter.Value>
117新增: </Setter>
118新增: </Style>
119新增:</ResourceDictionary>
文件末尾没有换行
新增UI/Themes/Window/DefaultWindow.xaml+219 −0看文件
@@ -0,0 +1,219 @@
1新增:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2新增: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3新增: xmlns:w="clr-namespace:UI.Controls.Window">
4新增: <Style x:Key="WindowSystemButton" TargetType="{x:Type Button}">
5新增: <Setter Property="Background" Value="Transparent"/>
6新增: <Setter Property="OverridesDefaultStyle" Value="True"/>
7新增: <Setter Property="VerticalContentAlignment" Value="Center"/>
8新增: <Setter Property="HorizontalContentAlignment" Value="Center"/>
9新增: <Setter Property="FontFamily" Value="/Tai;component/Resources/Fonts/#Segoe MDL2 Assets"/>
10新增: <Setter Property="Foreground" Value="{DynamicResource StandardTextBrush}"/>
11新增: <!--<Setter Property="FontWeight" Value="Bold"/>-->
12新增: <Setter Property="FontSize" Value="10"/>
13新增:
14新增: <Setter Property="Template">
15新增: <Setter.Value>
16新增: <ControlTemplate TargetType="{x:Type Button}">
17新增: <Border
18新增: Background="{TemplateBinding Background}"
19新增: SnapsToDevicePixels="true">
20新增: <ContentPresenter Name="Presenter" Margin="{TemplateBinding Padding}"
21新增: VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
22新增: HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
23新增: RecognizesAccessKey="True"
24新增: SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
25新增: </Border>
26新增: <ControlTemplate.Triggers>
27新增: <Trigger Property="IsEnabled" Value="false">
28新增: <!--<Setter Property="Foreground" Value="{DynamicResource ButtonTextDisabled}"/>-->
29新增: </Trigger>
30新增: <Trigger Property="IsMouseOver" Value="True">
31新增: <Setter Property="Background" Value="{DynamicResource StandardMouseHoverBrush}" />
32新增: <Setter Property="Foreground" Value="{DynamicResource PrimaryColorBrush}"/>
33新增: </Trigger>
34新增: <Trigger Property="IsPressed" Value="True">
35新增: <Setter Property="Background" Value="{DynamicResource StandardMousePressedBrush}" />
36新增: <!--<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" />
37新增: <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderPressed}"/>
38新增: <Setter Property="Foreground" Value="{DynamicResource ButtonTextPressed}"/>-->
39新增: </Trigger>
40新增: <Trigger Property="IsFocused" Value="true">
41新增: <!--<Setter TargetName="Chrome" Property="BorderBrush" Value="{DynamicResource Accent}" />-->
42新增: </Trigger>
43新增: </ControlTemplate.Triggers>
44新增: </ControlTemplate>
45新增: </Setter.Value>
46新增: </Setter>
47新增: </Style>
48新增: <Style TargetType="{x:Type w:DefaultWindow}">
49新增: <Setter Property="BorderThickness" Value="1" />
50新增: <Setter Property="BorderBrush" Value="{DynamicResource StandardColorBrush}" />
51新增: <Setter Property="Background" Value="White" />
52新增: <!--<Setter Property="Logo" Value="{DynamicResource WindowLogo}" />-->
53新增: <Setter Property="Foreground" Value="{DynamicResource StandardTextBrush}" />
54新增:
55新增: <Setter Property="ResizeMode" Value="CanResizeWithGrip" />
56新增: <Setter Property="UseLayoutRounding" Value="True" />
57新增: <Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
58新增: <Setter Property="WindowChrome.WindowChrome">
59新增: <Setter.Value>
60新增: <WindowChrome
61新增: CaptionHeight="32"
62新增: CornerRadius="0" GlassFrameThickness="1" UseAeroCaptionButtons="False" NonClientFrameEdges="None" />
63新增: </Setter.Value>
64新增: </Setter>
65新增: <Setter Property="Template">
66新增: <Setter.Value>
67新增: <ControlTemplate TargetType="{x:Type w:DefaultWindow}">
68新增: <ControlTemplate.Resources>
69新增:
70新增: <Storyboard x:Key="Storyboardload">
71新增: <DoubleAnimation Storyboard.TargetName="WindowBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:0.1" From="0" To="1" >
72新增: </DoubleAnimation>
73新增: </Storyboard>
74新增:
75新增: </ControlTemplate.Resources>
76新增: <Border x:Name="WindowBorder"
77新增: Margin="{Binding Source={x:Static SystemParameters.WindowNonClientFrameThickness}}">
78新增: <Border
79新增:
80新增: BorderThickness="{TemplateBinding BorderThickness}"
81新增: BorderBrush="{TemplateBinding BorderBrush}"
82新增: Background="#f3f3f3"
83新增: >
84新增: <AdornerDecorator>
85新增: <Grid x:Name="WindowContent">
86新增:
87新增: <!--<Grid.RowDefinitions>
88新增: <RowDefinition Height="Auto"></RowDefinition>
89新增: <RowDefinition Height="*"></RowDefinition>
90新增:
91新增: </Grid.RowDefinitions>-->
92新增:
93新增: <!--标题栏-->
94新增: <Grid
95新增: x:Name="TitleBar"
96新增: Panel.ZIndex="999"
97新增: Height="{DynamicResource WindowTitleBarHeight}"
98新增: VerticalAlignment="Top">
99新增: <Grid.ColumnDefinitions>
100新增: <ColumnDefinition Width="Auto"></ColumnDefinition>
101新增: <ColumnDefinition Width="*"></ColumnDefinition>
102新增:
103新增: </Grid.ColumnDefinitions>
104新增:
105新增: <Grid Grid.Column="0"
106新增: Panel.ZIndex="3">
107新增: <!--标题区域-->
108新增: <StackPanel Orientation="Horizontal" Margin="15,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center">
109新增: <Image Source="{TemplateBinding Icon}" Stretch="Uniform" Width="18"/>
110新增: <TextBlock Text="{TemplateBinding Title}" IsEnabled="{TemplateBinding IsActive}" Foreground="#5c5c5c" Margin="15,0,0,0"/>
111新增: </StackPanel>
112新增: <!--<TextBlock Text="{TemplateBinding Title}" IsEnabled="{TemplateBinding IsActive}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="15,0,0,0"/>-->
113新增:
114新增: </Grid>
115新增: <Grid Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top"
116新增: WindowChrome.IsHitTestVisibleInChrome="True"
117新增: Panel.ZIndex="3">
118新增: <!--系统按钮区域-->
119新增:
120新增: <StackPanel Orientation="Horizontal">
121新增: <!--最小化-->
122新增: <Button
123新增: ToolTip="最小化"
124新增: Width="46"
125新增: Height="32"
126新增: Style="{StaticResource WindowSystemButton}"
127新增: Content="&#xE921;"
128新增: Command="{x:Static w:DefaultWindowCommands.MinimizeWindowCommand}"
129新增: Visibility="{TemplateBinding MinimizeVisibility}"/>
130新增:
131新增: <!--最大化-->
132新增: <Button
133新增: x:Name="MaximizeButton"
134新增: ToolTip="最大化"
135新增: Width="46"
136新增: Height="32"
137新增: Style="{StaticResource WindowSystemButton}"
138新增: Content="&#xE922;"
139新增: Command="{x:Static w:DefaultWindowCommands.MaximizeWindowCommand}"
140新增: Visibility="{TemplateBinding MaximizeVisibility}"/>
141新增: <!--还原-->
142新增: <Button
143新增: x:Name="RestoreButton"
144新增: ToolTip="向下还原"
145新增: Width="46"
146新增: Height="32"
147新增: Style="{StaticResource WindowSystemButton}"
148新增: Content="&#xE923;"
149新增: Command="{x:Static w:DefaultWindowCommands.RestoreWindowCommand}"
150新增: Visibility="Collapsed"/>
151新增: <!--关闭-->
152新增: <Button
153新增: ToolTip="关闭"
154新增: Width="46"
155新增: Height="32"
156新增: Style="{StaticResource WindowSystemButton}"
157新增: Content="&#xE8BB;"
158新增: Command="{x:Static w:DefaultWindowCommands.CloseWindowCommand}"
159新增: Visibility="{TemplateBinding CloseVisibility}"/>
160新增:
161新增: </StackPanel>
162新增:
163新增:
164新增: </Grid>
165新增: </Grid>
166新增:
167新增:
168新增:
169新增: <!--窗体内容-->
170新增: <ContentPresenter Grid.Row="1"/>
171新增:
172新增: </Grid>
173新增: </AdornerDecorator>
174新增: </Border>
175新增: </Border>
176新增: <ControlTemplate.Triggers>
177新增: <MultiTrigger>
178新增: <MultiTrigger.Conditions>
179新增: <Condition Property="WindowState" Value="Normal" />
180新增: <Condition Property="MaximizeVisibility" Value="Visible" />
181新增: </MultiTrigger.Conditions>
182新增: <Setter TargetName="MaximizeButton" Property="Visibility" Value="Visible" />
183新增: <Setter TargetName="RestoreButton" Property="Visibility" Value="Collapsed" />
184新增: </MultiTrigger>
185新增: <Trigger Property="WindowState" Value="Maximized">
186新增: <!--最大化时调整外边距,否则显示不完整-->
187新增: <Setter TargetName="WindowContent" Property="Margin" Value="7"/>
188新增: <Setter TargetName="MaximizeButton" Property="Visibility" Value="Collapsed" />
189新增: <Setter TargetName="RestoreButton" Property="Visibility" Value="Visible" />
190新增: </Trigger>
191新增:
192新增: <!--<Trigger Property="WindowState" Value="Normal">
193新增: <Setter TargetName="MaximizeButton" Property="Visibility" Value="Visible" />
194新增: <Setter TargetName="RestoreButton" Property="Visibility" Value="Collapsed" />
195新增: </Trigger>-->
196新增: <!--<EventTrigger RoutedEvent="Window.Loaded">
197新增: -->
198新增: <!--窗口载入动画-->
199新增: <!--
200新增: <BeginStoryboard Storyboard="{StaticResource Storyboardload}">
201新增: </BeginStoryboard>
202新增:
203新增: </EventTrigger>-->
204新增: <Trigger Property="WindowStyle" Value="None">
205新增: <Setter TargetName="WindowBorder" Property="Margin" Value="0"/>
206新增: <Setter Property="BorderThickness" Value="0"/>
207新增: <Setter TargetName="TitleBar" Property="Visibility" Value="Collapsed" />
208新增: <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
209新增: <!--<Setter Property="BorderBrush" Value="Transparent" />-->
210新增: </Trigger>
211新增: </ControlTemplate.Triggers>
212新增: </ControlTemplate>
213新增: </Setter.Value>
214新增: </Setter>
215新增:
216新增: </Style>
217新增:
218新增:
219新增:</ResourceDictionary>
文件末尾没有换行
新增UI/Themes/Window/HideWindow.xaml+18 −0看文件
@@ -0,0 +1,18 @@
1新增:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2新增: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3新增: xmlns:w="clr-namespace:UI.Controls.Window">
4新增: <Style TargetType="{x:Type w:HideWindow}">
5新增: <Setter Property="Background" Value="Transparent" />
6新增: <Setter Property="ResizeMode" Value="NoResize" />
7新增: <Setter Property="Width" Value="0" />
8新增: <Setter Property="Height" Value="0" />
9新增: <Setter Property="Visibility" Value="Collapsed" />
10新增: <Setter Property="Template">
11新增: <Setter.Value>
12新增: <ControlTemplate TargetType="{x:Type w:HideWindow}">
13新增: <TextBlock Text="test" Foreground="Red"/>
14新增: </ControlTemplate>
15新增: </Setter.Value>
16新增: </Setter>
17新增: </Style>
18新增:</ResourceDictionary>
文件末尾没有换行
修改UI/UI.csproj+56 −0看文件
@@ -34,6 +34,9 @@
3434 <ErrorReport>prompt</ErrorReport>
3535 <WarningLevel>4</WarningLevel>
3636 </PropertyGroup>
37新增: <PropertyGroup>
38新增: <ApplicationIcon>TextTemplate.ico</ApplicationIcon>
39新增: </PropertyGroup>
3740 <ItemGroup>
3841 <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
3942 <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
@@ -46,12 +49,17 @@
4649 </Reference>
4750 <Reference Include="System" />
4851 <Reference Include="System.Data" />
52新增: <Reference Include="System.Drawing" />
4953 <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
5054 <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
5155 </Reference>
5256 <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
5357 <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
5458 </Reference>
59新增: <Reference Include="System.Windows.Forms" />
60新增: <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
61新增: <HintPath>..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll</HintPath>
62新增: </Reference>
5563 <Reference Include="System.Xml" />
5664 <Reference Include="Microsoft.CSharp" />
5765 <Reference Include="System.Core" />
@@ -70,6 +78,17 @@
7078 <Generator>MSBuild:Compile</Generator>
7179 <SubType>Designer</SubType>
7280 </ApplicationDefinition>
81新增: <Compile Include="Base\Color\Colors.cs" />
82新增: <Compile Include="Base\Color\ColorTypes.cs" />
83新增: <Compile Include="Controls\Base\Icon.cs" />
84新增: <Compile Include="Controls\Base\IconConverter.cs" />
85新增: <Compile Include="Controls\Base\IconTypes.cs" />
86新增: <Compile Include="Controls\Navigation\Models\NavigationItemModel.cs" />
87新增: <Compile Include="Controls\Navigation\Navigation.cs" />
88新增: <Compile Include="Controls\Navigation\NavigationItem.cs" />
89新增: <Compile Include="Models\MainWindowModel.cs" />
90新增: <Compile Include="Models\UINotifyPropertyChanged.cs" />
91新增: <Compile Include="ViewModels\MainViewModel.cs" />
7392 <Page Include="MainWindow.xaml">
7493 <Generator>MSBuild:Compile</Generator>
7594 <SubType>Designer</SubType>
@@ -78,10 +97,39 @@
7897 <DependentUpon>App.xaml</DependentUpon>
7998 <SubType>Code</SubType>
8099 </Compile>
100新增: <Compile Include="Controls\Command.cs" />
101新增: <Compile Include="Controls\PageContainer.cs" />
102新增: <Compile Include="Controls\Window\DefaultWindow.cs" />
103新增: <Compile Include="Controls\Window\DefaultWindowCommands.cs" />
104新增: <Compile Include="Controls\Window\HideWindow.cs" />
81105 <Compile Include="MainWindow.xaml.cs">
82106 <DependentUpon>MainWindow.xaml</DependentUpon>
83107 <SubType>Code</SubType>
84108 </Compile>
109新增: <Page Include="Themes\Base\Icon.xaml">
110新增: <Generator>MSBuild:Compile</Generator>
111新增: <SubType>Designer</SubType>
112新增: </Page>
113新增: <Page Include="Themes\Generic.xaml">
114新增: <SubType>Designer</SubType>
115新增: <Generator>MSBuild:Compile</Generator>
116新增: </Page>
117新增: <Page Include="Themes\Navigation\Navigation.xaml">
118新增: <Generator>MSBuild:Compile</Generator>
119新增: <SubType>Designer</SubType>
120新增: </Page>
121新增: <Page Include="Themes\Navigation\NavigationItem.xaml">
122新增: <Generator>MSBuild:Compile</Generator>
123新增: <SubType>Designer</SubType>
124新增: </Page>
125新增: <Page Include="Themes\Window\DefaultWindow.xaml">
126新增: <SubType>Designer</SubType>
127新增: <Generator>MSBuild:Compile</Generator>
128新增: </Page>
129新增: <Page Include="Themes\Window\HideWindow.xaml">
130新增: <SubType>Designer</SubType>
131新增: <Generator>MSBuild:Compile</Generator>
132新增: </Page>
85133 </ItemGroup>
86134 <ItemGroup>
87135 <Compile Include="Properties\AssemblyInfo.cs">
@@ -106,6 +154,8 @@
106154 <Generator>SettingsSingleFileGenerator</Generator>
107155 <LastGenOutput>Settings.Designer.cs</LastGenOutput>
108156 </None>
157新增: <Resource Include="Resources\Fonts\fabric-icons.ttf" />
158新增: <Resource Include="Resources\Fonts\SegMDL2.ttf" />
109159 </ItemGroup>
110160 <ItemGroup>
111161 <None Include="App.config" />
@@ -116,5 +166,11 @@
116166 <Name>Core</Name>
117167 </ProjectReference>
118168 </ItemGroup>
169新增: <ItemGroup>
170新增: <Folder Include="Resources\Icons\" />
171新增: </ItemGroup>
172新增: <ItemGroup>
173新增: <Resource Include="TextTemplate.ico" />
174新增: </ItemGroup>
119175 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
120176</Project>
文件末尾没有换行
新增UI/ViewModels/MainViewModel.cs+88 −0看文件
@@ -0,0 +1,88 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Linq;
4新增:using System.Text;
5新增:using System.Threading.Tasks;
6新增:using UI.Controls;
7新增:using UI.Controls.Navigation.Models;
8新增:using UI.Models;
9新增:
10新增:namespace UI.ViewModels
11新增:{
12新增: public class MainViewModel : MainWindowModel
13新增: {
14新增: private readonly IServiceProvider serviceProvider;
15新增:
16新增: public Command OnSelectedCommand { get; set; }
17新增: public Command GotoPageCommand { get; set; }
18新增:
19新增: public MainViewModel(
20新增: IServiceProvider serviceProvider
21新增: )
22新增: {
23新增: this.serviceProvider = serviceProvider;
24新增:
25新增: ServiceProvider = serviceProvider;
26新增: Uri = "IndexPage";
27新增: Title = "Project Event";
28新增: OnSelectedCommand = new Command(new Action<object>(OnSelectedCommandHandle));
29新增: GotoPageCommand = new Command(new Action<object>(OnGotoPageCommand));
30新增:
31新增:
32新增: Items = new System.Collections.ObjectModel.ObservableCollection<Controls.Navigation.Models.NavigationItemModel>();
33新增:
34新增: PropertyChanged += MainViewModel_PropertyChanged;
35新增:
36新增: InitNavigation();
37新增: }
38新增:
39新增: private void MainViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
40新增: {
41新增: if (e.PropertyName == nameof(Uri))
42新增: {
43新增: //if (Uri == nameof(IndexPage))
44新增: //{
45新增: // Data = null;
46新增: //}
47新增: }
48新增: }
49新增:
50新增: public void SelectGroup(int ID)
51新增: {
52新增: NavSelectedItem = Items.Where(m => m.ID == ID).FirstOrDefault();
53新增: }
54新增:
55新增:
56新增: private void OnGotoPageCommand(object obj)
57新增: {
58新增: Uri = obj.ToString();
59新增: }
60新增:
61新增: private void OnSelectedCommandHandle(object obj)
62新增: {
63新增: if (!string.IsNullOrEmpty(NavSelectedItem.Uri))
64新增: {
65新增: Uri = NavSelectedItem.Uri;
66新增: }
67新增: }
68新增:
69新增: private void InitNavigation()
70新增: {
71新增: Items.Add(new Controls.Navigation.Models.NavigationItemModel()
72新增: {
73新增: Icon = Controls.Base.IconTypes.AppIconDefaultList,
74新增: Title = "概览",
75新增: ID = -1
76新增:
77新增: });
78新增: Items.Add(new Controls.Navigation.Models.NavigationItemModel()
79新增: {
80新增: Icon = Controls.Base.IconTypes.BIDashboard,
81新增: Title = "统计",
82新增: ID = 1
83新增:
84新增: });
85新增: NavSelectedItem = Items[0];
86新增: }
87新增: }
88新增:}
修改UI/packages.config+1 −0看文件
@@ -1,5 +1,6 @@
11<?xml version="1.0" encoding="utf-8"?>
22<packages>
3新增: <package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net461" />
34 <package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net461" />
45 <package id="Microsoft.Extensions.DependencyInjection" version="6.0.0" targetFramework="net461" />
56 <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="6.0.0" targetFramework="net461" />