├── .gitattributes
├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── donate.jpg
├── screenshot
├── 1.0.4
│ ├── Snipaste_2019-05-29_11-45-14.jpg
│ ├── Snipaste_2019-05-29_11-45-55.jpg
│ ├── Snipaste_2019-05-29_11-46-10.jpg
│ └── Snipaste_2019-05-29_11-50-30.jpg
├── 1.0.5
│ ├── tray menu.jpg
│ ├── update location.jpg
│ └── update window.jpg
├── 1.0.7
│ └── Snipaste_2019-07-02_09-36-42.jpg
├── 1.1.8
│ └── option.jpg
├── 1.2.0
│ ├── busytray.jpg
│ ├── darkmode.jpg
│ ├── data.jpg
│ ├── newdata.jpg
│ ├── options.jpg
│ ├── options_style.jpg
│ └── restcountdown.jpg
├── 1.4.2
│ └── Snipaste_2021-11-19_03-08-51.jpg
├── Snipaste_2019-04-25_09-57-21.jpg
├── Snipaste_2019-04-25_09-57-46.jpg
├── dark_tipwindow.jpg
└── tipwindow.jpg
└── src
└── Local
├── Project1.UI
├── Assets
│ ├── IconFonts
│ │ ├── FabExMDL2.3.36.ttf
│ │ └── SegMDL2.ttf
│ ├── Images
│ │ └── sunglasses.png
│ └── Themes
│ │ ├── Default
│ │ ├── Button.xaml
│ │ ├── CheckBox.xaml
│ │ ├── ComboBox.xaml
│ │ ├── Config.xaml
│ │ ├── ContextMenu.xaml
│ │ ├── ListBox.xaml
│ │ ├── ListView.xaml
│ │ ├── Menu.xaml
│ │ ├── MessageBox.xaml
│ │ ├── ScrollBar.xaml
│ │ ├── Style.xaml
│ │ ├── TabControl.xaml
│ │ ├── TextBlock.xaml
│ │ ├── ToolTip.xaml
│ │ └── Window.xaml
│ │ └── Pink
│ │ ├── Button.xaml
│ │ ├── CheckBox.xaml
│ │ ├── ComboBox.xaml
│ │ ├── Config.xaml
│ │ ├── ContextMenu.xaml
│ │ ├── ListBox.xaml
│ │ ├── ListView.xaml
│ │ ├── Menu.xaml
│ │ ├── MessageBox.xaml
│ │ ├── Resources
│ │ └── sakura.jpg
│ │ ├── ScrollBar.xaml
│ │ ├── Style.xaml
│ │ ├── TextBlock.xaml
│ │ ├── ToolTip.xaml
│ │ └── Window.xaml
├── Controls
│ ├── ChartControl
│ │ ├── Chart.cs
│ │ ├── ChartItem.cs
│ │ └── Models
│ │ │ └── ChartDataModel.cs
│ ├── CheckButton.cs
│ ├── Commands
│ │ ├── Project1UIInputCommands.cs
│ │ └── Project1UIWindowCommands.cs
│ ├── CompareView.cs
│ ├── ContentCard.cs
│ ├── Converters
│ │ ├── BrushToColorConverter.cs
│ │ ├── Project1UIIconToUnicodeConverter.cs
│ │ └── StringConverter.cs
│ ├── Data
│ │ └── TextAlignmentData.cs
│ ├── DatePicker
│ │ ├── DatePicker.cs
│ │ └── ItemList.cs
│ ├── Enums
│ │ ├── ControlPoint.cs
│ │ ├── DesignItemType.cs
│ │ ├── Project1UIButtonType.cs
│ │ ├── Project1UIIconType.cs
│ │ └── Project1UIInputType.cs
│ ├── Icon.cs
│ ├── Models
│ │ ├── ContainerModel.cs
│ │ ├── DesignItemModel.cs
│ │ ├── DesignTextAlignment.cs
│ │ └── ElementModel.cs
│ ├── Project1UIButton.cs
│ ├── Project1UIChart.cs
│ ├── Project1UIColorSelect.cs
│ ├── Project1UIDesignContainer.cs
│ ├── Project1UIDesignItem.cs
│ ├── Project1UIIcon.cs
│ ├── Project1UIInput.cs
│ ├── Project1UIKeyboardInput.cs
│ ├── Project1UIListView.cs
│ ├── Project1UIModal.cs
│ ├── Project1UIProcessBar.cs
│ ├── Project1UIToast.cs
│ ├── Project1UIWindow.cs
│ ├── TimeBox.cs
│ ├── ToastManager.cs
│ └── Toggle.cs
├── Cores
│ ├── BitmapImager.cs
│ ├── IconFonts.cs
│ ├── Project1UIColor.cs
│ ├── Theme.cs
│ ├── UIDefaultSetting.cs
│ ├── UINotifyPropertyChanged.cs
│ └── WindowsCollection.cs
├── Project1.UI.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── Themes
│ ├── Chart
│ ├── Chart.xaml
│ └── ChartItem.xaml
│ ├── CheckButton.xaml
│ ├── CompareView.xaml
│ ├── ContentCard.xaml
│ ├── DatePicker
│ ├── DatePicker.xaml
│ └── ItemList.xaml
│ ├── Generic.xaml
│ ├── Icon.xaml
│ ├── Project1UIButton.xaml
│ ├── Project1UIChart.xaml
│ ├── Project1UIColorSelect.xaml
│ ├── Project1UIDesignItem.xaml
│ ├── Project1UIIcon.xaml
│ ├── Project1UIInput.xaml
│ ├── Project1UIKeyboardInput.xaml
│ ├── Project1UIModal.xaml
│ ├── Project1UIProcessBar.xaml
│ ├── Project1UIToast.xaml
│ ├── Project1UIWindow.xaml
│ ├── TimeBox.xaml
│ └── Toggle.xaml
├── ProjectEye
├── App.xaml
├── App.xaml.cs
├── Core
│ ├── AudioHelper.cs
│ ├── BusyVerdictHelper.cs
│ ├── DataReportImageHelper.cs
│ ├── Enums
│ │ └── SoundType.cs
│ ├── FileHelper.cs
│ ├── LogHelper.cs
│ ├── Models
│ │ ├── EyesTest
│ │ │ ├── EyesTestListModel.cs
│ │ │ └── EyesTestModel.cs
│ │ ├── Options
│ │ │ ├── AnimationModel.cs
│ │ │ ├── BehaviorModel.cs
│ │ │ ├── ComboxModel.cs
│ │ │ ├── GeneralModel.cs
│ │ │ ├── KeyboardShortcutModel.cs
│ │ │ ├── OptionsModel.cs
│ │ │ ├── StyleModel.cs
│ │ │ ├── ThemeModel.cs
│ │ │ └── TomatoModel.cs
│ │ ├── Statistic
│ │ │ ├── StatisticListModel.cs
│ │ │ ├── StatisticModel.cs
│ │ │ └── TomatoModel.cs
│ │ └── WindowModel.cs
│ ├── Net
│ │ ├── GithubRelease.cs
│ │ └── HttpDownload.cs
│ ├── ProcessHelper.cs
│ ├── RestEventHandler.cs
│ ├── ScreenExtensions.cs
│ ├── Service
│ │ ├── BackgroundWorkerService.cs
│ │ ├── CacheService.cs
│ │ ├── ConfigService.cs
│ │ ├── EyesTestService.cs
│ │ ├── IService.cs
│ │ ├── KeyboardShortcutsService.cs
│ │ ├── MainService.cs
│ │ ├── NotificationService.cs
│ │ ├── PreAlertService.cs
│ │ ├── RestService.cs
│ │ ├── ScreenService.cs
│ │ ├── ServiceCollection.cs
│ │ ├── SoundService.cs
│ │ ├── StatisticService.cs
│ │ ├── SystemResourcesService.cs
│ │ ├── ThemeService.cs
│ │ ├── TomatoService.cs
│ │ └── TrayService.cs
│ ├── ShortcutHelper.cs
│ ├── TypeExtensions.cs
│ ├── Win32APIHelper.cs
│ ├── WindowManager.cs
│ └── XmlExtensions.cs
├── Database
│ ├── SQLiteBuilder.cs
│ ├── SQLiteConfiguration.cs
│ └── StatisticContext.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── Models
│ ├── EyesTestModel.cs
│ ├── OptionsModel.cs
│ ├── StatisticModel.cs
│ ├── TipModel.cs
│ ├── TipViewDesignModel.cs
│ ├── UI
│ │ └── UIDesignModel.cs
│ ├── UINotifyPropertyChanged.cs
│ └── UpdateModel.cs
├── ProjectEye.Local.sln
├── ProjectEye.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ ├── ControlStyle
│ │ └── Button.xaml
│ ├── Converters
│ │ ├── NumberToStringConver.cs
│ │ └── SliderValueToWidthConver.cs
│ ├── Fonts
│ │ └── FabExMDL2.3.36.ttf
│ ├── Language
│ │ ├── en.xaml
│ │ └── zh.xaml
│ ├── Themes
│ │ ├── Blue
│ │ │ ├── Button.xaml
│ │ │ ├── CheckBox.xaml
│ │ │ ├── ComboBox.xaml
│ │ │ ├── Config.xaml
│ │ │ ├── ContentCard.xaml
│ │ │ ├── ContextMenu.xaml
│ │ │ ├── Images
│ │ │ │ └── tipImage.png
│ │ │ ├── ListBox.xaml
│ │ │ ├── ListView.xaml
│ │ │ ├── Menu.xaml
│ │ │ ├── MessageBox.xaml
│ │ │ ├── ScrollBar.xaml
│ │ │ ├── Slider.xaml
│ │ │ ├── Style.xaml
│ │ │ ├── TabControl.xaml
│ │ │ ├── TextBlock.xaml
│ │ │ ├── Toggle.xaml
│ │ │ ├── ToolTip.xaml
│ │ │ └── Window.xaml
│ │ └── Dark
│ │ │ ├── Button.xaml
│ │ │ ├── Chart
│ │ │ ├── Chart.xaml
│ │ │ └── ChartItem.xaml
│ │ │ ├── CheckBox.xaml
│ │ │ ├── CheckButton.xaml
│ │ │ ├── ComboBox.xaml
│ │ │ ├── CompareView.xaml
│ │ │ ├── Config.xaml
│ │ │ ├── ContentCard.xaml
│ │ │ ├── ContextMenu.xaml
│ │ │ ├── DatePicker
│ │ │ ├── DatePicker.xaml
│ │ │ └── ItemList.xaml
│ │ │ ├── Images
│ │ │ └── tipImage.png
│ │ │ ├── ListBox.xaml
│ │ │ ├── ListView.xaml
│ │ │ ├── Menu.xaml
│ │ │ ├── MessageBox.xaml
│ │ │ ├── ScrollBar.xaml
│ │ │ ├── Slider.xaml
│ │ │ ├── Style.xaml
│ │ │ ├── TabControl.xaml
│ │ │ ├── TextBlock.xaml
│ │ │ ├── Toggle.xaml
│ │ │ ├── ToolTip.xaml
│ │ │ └── Window.xaml
│ ├── break.png
│ ├── coffee_lover.png
│ ├── coffee_lover2.png
│ ├── conference_presentation__monochromatic.png
│ ├── creative_process_.png
│ ├── desktop-computer.ico
│ ├── dizzy.ico
│ ├── ecology.png
│ ├── files_and_folder.png
│ ├── gear_2699.png
│ ├── green-tomato-1.ico
│ ├── green-tomato-10.ico
│ ├── green-tomato-2.ico
│ ├── green-tomato-3.ico
│ ├── green-tomato-4.ico
│ ├── green-tomato-5.ico
│ ├── green-tomato-6.ico
│ ├── green-tomato-7.ico
│ ├── green-tomato-8.ico
│ ├── green-tomato-9.ico
│ ├── growth_monochromatic.png
│ ├── hammer-and-wrench_1f6e0.png
│ ├── office_work_.png
│ ├── office_work_2.png
│ ├── overheated.ico
│ ├── product_manager.png
│ ├── red-tomato-1.ico
│ ├── red-tomato-10.ico
│ ├── red-tomato-2.ico
│ ├── red-tomato-3.ico
│ ├── red-tomato-4.ico
│ ├── red-tomato-5.ico
│ ├── red-tomato-6.ico
│ ├── red-tomato-7.ico
│ ├── red-tomato-8.ico
│ ├── red-tomato-9.ico
│ ├── relentless.wav
│ ├── rest.png
│ ├── sleeping.ico
│ ├── sunglasses.ico
│ ├── tomato.ico
│ ├── tomato.png
│ ├── web_developer.png
│ ├── web_developer2.png
│ └── work.png
├── ViewModels
│ ├── AsyncCommand.cs
│ ├── Command.cs
│ ├── ContributorsViewModel.cs
│ ├── EyesTestViewModel.cs
│ ├── IViewModel.cs
│ ├── OptionsViewModel.cs
│ ├── StatisticViewModel.cs
│ ├── TipViewDesignViewModel.cs
│ ├── TipViewModel.cs
│ ├── UpdateViewModel.cs
│ └── ViewModelEventHandler.cs
├── Views
│ ├── ContributorsWindow.xaml
│ ├── ContributorsWindow.xaml.cs
│ ├── EyesTestWindow.xaml
│ ├── EyesTestWindow.xaml.cs
│ ├── OptionsWindow.xaml
│ ├── OptionsWindow.xaml.cs
│ ├── StatisticWindow.xaml
│ ├── StatisticWindow.xaml.cs
│ ├── TipViewDesignWindow.xaml
│ ├── TipViewDesignWindow.xaml.cs
│ ├── TipWindow.xaml
│ ├── TipWindow.xaml.cs
│ ├── UpdateWindow.xaml
│ └── UpdateWindow.xaml.cs
├── costura32
│ └── SQLite.Interop.dll
└── costura64
│ └── SQLite.Interop.dll
├── ProjectEyeBug
├── App.xaml
├── App.xaml.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── ProjectEyeBug.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── explosion.png
└── packages.config
└── ProjectEyeUp
├── Program.cs
├── ProjectEyeUp.csproj
└── Properties
└── AssemblyInfo.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | custom: http://thelittlepandaisbehind.com/donate.html
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Plan shit
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Project Eye
2 |
3 | 一个基于 `20-20-20` 规则的用眼休息提醒软件(Windows),帮助你保持健康的工作状态,追踪每天的用眼情况。
4 |
5 | 你可以设定好提醒间隔时间(默认20分钟)和休息时间(默认20秒),当程序启动后开始计时,每到达一次提醒间隔时间,就会弹出一个覆盖全屏幕的窗口提示该休息了。默认情况下你可以选择 `跳过` 或 `开始休息` ,选择 `跳过` 窗口将关闭并重新开始计时,选择 `开始休息` 程序会以从设定的休息时间(秒)开始倒计时,此时你应该将视线离开屏幕眺望远方至少6米远处放松双眼,当倒计时结束程序会播放提示音通知你。
6 |
7 |
8 |
9 |
10 |
11 | ## 什么是20-20-20规则
12 |
13 | 即每 **20** 分钟,将注意力集中在至少 **20** 英尺( **6** 米)远的地方 **20** 秒。遵循这个规则可以有效地缓解你的用眼疲劳,保护视力健康。
14 |
15 | [参考资料:https://opto.ca/health-library/the-20-20-20-rule](https://opto.ca/health-library/the-20-20-20-rule)
16 |
17 | ## 亮点
18 |
19 | - 全屏状态(全屏游戏、全屏看视频)免打扰功能;
20 | - 进程跳过白名单设置功能,在运行白名单中的程序时不弹出提醒;
21 | - 多个扩展显示器支持;
22 | - 数据统计,用眼时长、休息时长、跳过次数;
23 | - 离开监听,当检测到用户离开电脑时停止计时直到回来;
24 | - 所见即所得地自定义(设计)全屏提示窗口;
25 | - 番茄时钟功能;
26 |
27 | *部分功能需要自行在选项中开启才生效。*
28 |
29 | ## 下载安装
30 |
31 | 你可以在这里 [Releases](https://github.com/Planshit/ProjectEye/releases) 下载所有发布版本编译好的EXE文件压缩包,一般是ProjectEye.zip,解压后直接双击ProjectEye.exe即可运行,无需安装。
32 |
33 | 成功启动后你将在右下角的状态栏中看到 😎 图标,右键显示菜单,双击启动或关闭番茄时钟模式。
34 |
35 | ## 运行环境
36 |
37 | OS: Windows7/10
38 |
39 | Runtime: [.NET Framework 4.5+](https://dotnet.microsoft.com/download/dotnet-framework)
40 |
41 | ## 其他
42 |
43 | [帮助文档](https://littlepanda.gitbook.io/project-eye/)
44 |
--------------------------------------------------------------------------------
/donate.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/donate.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.4/Snipaste_2019-05-29_11-45-14.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.4/Snipaste_2019-05-29_11-45-14.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.4/Snipaste_2019-05-29_11-45-55.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.4/Snipaste_2019-05-29_11-45-55.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.4/Snipaste_2019-05-29_11-46-10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.4/Snipaste_2019-05-29_11-46-10.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.4/Snipaste_2019-05-29_11-50-30.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.4/Snipaste_2019-05-29_11-50-30.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.5/tray menu.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.5/tray menu.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.5/update location.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.5/update location.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.5/update window.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.5/update window.jpg
--------------------------------------------------------------------------------
/screenshot/1.0.7/Snipaste_2019-07-02_09-36-42.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.0.7/Snipaste_2019-07-02_09-36-42.jpg
--------------------------------------------------------------------------------
/screenshot/1.1.8/option.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.1.8/option.jpg
--------------------------------------------------------------------------------
/screenshot/1.2.0/busytray.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.2.0/busytray.jpg
--------------------------------------------------------------------------------
/screenshot/1.2.0/darkmode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.2.0/darkmode.jpg
--------------------------------------------------------------------------------
/screenshot/1.2.0/data.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.2.0/data.jpg
--------------------------------------------------------------------------------
/screenshot/1.2.0/newdata.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.2.0/newdata.jpg
--------------------------------------------------------------------------------
/screenshot/1.2.0/options.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.2.0/options.jpg
--------------------------------------------------------------------------------
/screenshot/1.2.0/options_style.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.2.0/options_style.jpg
--------------------------------------------------------------------------------
/screenshot/1.2.0/restcountdown.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.2.0/restcountdown.jpg
--------------------------------------------------------------------------------
/screenshot/1.4.2/Snipaste_2021-11-19_03-08-51.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/1.4.2/Snipaste_2021-11-19_03-08-51.jpg
--------------------------------------------------------------------------------
/screenshot/Snipaste_2019-04-25_09-57-21.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/Snipaste_2019-04-25_09-57-21.jpg
--------------------------------------------------------------------------------
/screenshot/Snipaste_2019-04-25_09-57-46.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/Snipaste_2019-04-25_09-57-46.jpg
--------------------------------------------------------------------------------
/screenshot/dark_tipwindow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/dark_tipwindow.jpg
--------------------------------------------------------------------------------
/screenshot/tipwindow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/screenshot/tipwindow.jpg
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/IconFonts/FabExMDL2.3.36.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/src/Local/Project1.UI/Assets/IconFonts/FabExMDL2.3.36.ttf
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/IconFonts/SegMDL2.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/src/Local/Project1.UI/Assets/IconFonts/SegMDL2.ttf
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Images/sunglasses.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/src/Local/Project1.UI/Assets/Images/sunglasses.png
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Default/CheckBox.xaml:
--------------------------------------------------------------------------------
1 |
5 |
72 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Default/ContextMenu.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
35 |
36 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Default/Style.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Default/TextBlock.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
12 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Default/ToolTip.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
43 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Pink/ContextMenu.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
35 |
36 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Pink/Resources/sakura.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Planshit/ProjectEye/50519089db349ef7ce60534078c6b7d49e5ba76b/src/Local/Project1.UI/Assets/Themes/Pink/Resources/sakura.jpg
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Pink/Style.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Pink/TextBlock.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
12 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Assets/Themes/Pink/ToolTip.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
43 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/ChartControl/Models/ChartDataModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Controls.ChartControl.Models
8 | {
9 | ///
10 | /// 图表数据模型
11 | ///
12 | public class ChartDataModel
13 | {
14 | ///
15 | /// 值
16 | ///
17 | public double Value { get; set; }
18 | ///
19 | /// 列名
20 | ///
21 | public string Tag { get; set; }
22 | ///
23 | /// 悬浮文本
24 | ///
25 | public string PopupText { get; set; }
26 | ///
27 | /// 是否选中
28 | ///
29 | public bool IsSelected { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/CheckButton.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Controls.Enums;
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 |
10 | namespace Project1.UI.Controls
11 | {
12 | public class CheckButton : Control
13 | {
14 |
15 | ///
16 | /// 是否选中
17 | ///
18 | public bool Checked
19 | {
20 | get { return (bool)GetValue(CheckedProperty); }
21 | set { SetValue(CheckedProperty, value); }
22 | }
23 | public static readonly DependencyProperty CheckedProperty =
24 | DependencyProperty.Register("Checked", typeof(bool), typeof(CheckButton), new PropertyMetadata(false));
25 |
26 | ///
27 | /// 内容
28 | ///
29 | public string Content
30 | {
31 | get { return (string)GetValue(ContentProperty); }
32 | set { SetValue(ContentProperty, value); }
33 | }
34 | public static readonly DependencyProperty ContentProperty =
35 | DependencyProperty.Register("Content", typeof(string), typeof(CheckButton));
36 |
37 | public CheckButton()
38 | {
39 | DefaultStyleKey = typeof(CheckButton);
40 | }
41 |
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Commands/Project1UIInputCommands.cs:
--------------------------------------------------------------------------------
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 Project1.UI.Controls.Commands
9 | {
10 | public static class Project1UIInputCommands
11 | {
12 | public static RoutedUICommand ClearTextCommand { get; } = new RoutedUICommand("", "ClearTextCommand", typeof(Project1UIInputCommands));
13 | public static RoutedUICommand CommonOpenFileDialog { get; } = new RoutedUICommand("", "CommonOpenFileDialog", typeof(Project1UIInputCommands));
14 |
15 |
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Commands/Project1UIWindowCommands.cs:
--------------------------------------------------------------------------------
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 Project1.UI.Controls.Commands
9 | {
10 | public static class Project1UIWindowCommands
11 | {
12 | public static RoutedUICommand MinimizeWindowCommand { get; } = new RoutedUICommand("", "MinimizeWindowCommand", typeof(Project1UIWindowCommands));
13 | public static RoutedUICommand RestoreWindowCommand { get; } = new RoutedUICommand("", "RestoreWindowCommand", typeof(Project1UIWindowCommands));
14 | public static RoutedUICommand MaximizeWindowCommand { get; } = new RoutedUICommand("", "MaximizeWindowCommand", typeof(Project1UIWindowCommands));
15 | public static RoutedUICommand CloseWindowCommand { get; } = new RoutedUICommand("", "CloseWindowCommand", typeof(Project1UIWindowCommands));
16 |
17 | public static RoutedUICommand LogoButtonClickCommand { get; } = new RoutedUICommand("", "LogoButtonClickCommand", typeof(Project1UIWindowCommands));
18 |
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/ContentCard.cs:
--------------------------------------------------------------------------------
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.Controls;
7 |
8 | namespace Project1.UI.Controls
9 | {
10 | public class ContentCard : ContentControl
11 | {
12 | public ContentCard()
13 | {
14 | DefaultStyleKey = typeof(ContentCard);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Converters/BrushToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Data;
9 | using System.Windows.Media;
10 |
11 | namespace Project1.UI.Controls.Converters
12 | {
13 | [ValueConversion(typeof(Brush), typeof(Color))]
14 | public class BrushToColorConverter : IValueConverter
15 | {
16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | var res = (Color)((value as Brush).GetValue(SolidColorBrush.ColorProperty));
19 | res.ScA = (float)parameter;
20 | return res;
21 | }
22 |
23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | throw new NotImplementedException();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Converters/Project1UIIconToUnicodeConverter.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Controls.Enums;
2 | using Project1.UI.Cores;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Data;
11 |
12 | namespace Project1.UI.Controls.Converters
13 | {
14 | public class Project1UIIconToUnicodeConverter : IValueConverter
15 | {
16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | var icon = (Project1UIIconType)value;
19 | string result = IconFonts.GetUnicodeString(icon);
20 | return result;
21 | }
22 |
23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | throw new NotImplementedException();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Converters/StringConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace Project1.UI.Controls.Converters
10 | {
11 | [ValueConversion(typeof(object), typeof(string))]
12 | public class StringConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | return value == null ? null : value.ToString();
17 | }
18 |
19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20 | {
21 | throw new NotImplementedException();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Data/TextAlignmentData.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Controls.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Project1.UI.Controls.Data
9 | {
10 | public class TextAlignmentData
11 | {
12 | private List data;
13 | public TextAlignmentData()
14 | {
15 | data = new List();
16 | data.Add(new DesignTextAlignment()
17 | {
18 |
19 | DisplayName = "左",
20 | Value = 0
21 | });
22 | data.Add(new DesignTextAlignment()
23 | {
24 |
25 | DisplayName = "中",
26 | Value = 1
27 | });
28 | data.Add(new DesignTextAlignment()
29 | {
30 |
31 | DisplayName = "右",
32 | Value = 2
33 | });
34 | }
35 | public DesignTextAlignment this[int index]
36 | {
37 | get
38 | {
39 | var result = data.Find(m => m.Value == index);
40 | if (result != null)
41 | {
42 | return result;
43 | }
44 | return data[0];
45 | }
46 | }
47 | public List ToList()
48 | {
49 | return data;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Enums/ControlPoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Controls.Enums
8 | {
9 | public enum ControlPoint
10 | {
11 | ///
12 | /// 左上角
13 | ///
14 | LeftTop,
15 | ///
16 | /// 左下角
17 | ///
18 | LeftBottom,
19 | ///
20 | /// 右上角
21 | ///
22 | RightTop,
23 | ///
24 | /// 右下角
25 | ///
26 | RightBottom
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Enums/DesignItemType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Controls.Enums
8 | {
9 | ///
10 | /// 设计元素类型
11 | ///
12 | public enum DesignItemType
13 | {
14 | ///
15 | /// 图片
16 | ///
17 | Image,
18 | ///
19 | /// 文本
20 | ///
21 | Text,
22 | ///
23 | /// 按钮
24 | ///
25 | Button
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Enums/Project1UIButtonType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Controls.Enums
8 | {
9 | ///
10 | /// 按钮类型
11 | ///
12 | public enum Project1UIButtonType
13 | {
14 | ///
15 | /// 纯文本
16 | ///
17 | Text,
18 | ///
19 | /// 图标加文本
20 | ///
21 | TextIconFont
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Enums/Project1UIInputType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Controls.Enums
8 | {
9 | ///
10 | /// 输入框类型
11 | ///
12 | public enum Project1UIInputType
13 | {
14 | ///
15 | /// 文本输入框
16 | ///
17 | Text,
18 | ///
19 | /// 文件选择框
20 | ///
21 | FileSelect,
22 | ///
23 | /// 文件夹选择框
24 | ///
25 | FolderSelect,
26 | ///
27 | /// 数字输入框
28 | ///
29 | Number
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Icon.cs:
--------------------------------------------------------------------------------
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;
7 | using System.Windows.Controls;
8 |
9 | namespace Project1.UI.Controls
10 | {
11 | ///
12 | /// Fabric icon
13 | ///
14 | public class Icon : Control
15 | {
16 | #region 图标
17 | ///
18 | /// Fabric icon unicode
19 | ///
20 | public string Unicode
21 | {
22 | get { return (string)GetValue(UnicodeProperty); }
23 | set { SetValue(UnicodeProperty, value); }
24 | }
25 | public static readonly DependencyProperty UnicodeProperty =
26 | DependencyProperty.Register("Unicode",
27 | typeof(string),
28 | typeof(Icon),
29 | new PropertyMetadata("E783"));
30 |
31 |
32 | #endregion
33 |
34 | public Icon()
35 | {
36 | DefaultStyleKey = typeof(Icon);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Models/ContainerModel.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Cores;
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.Media;
8 |
9 | namespace Project1.UI.Controls.Models
10 | {
11 | public class ContainerModel : UINotifyPropertyChanged
12 | {
13 | private double Opacity_;
14 | public double Opacity
15 | {
16 | get
17 | {
18 | return Opacity_;
19 | }
20 | set
21 | {
22 | Opacity_ = value;
23 | OnPropertyChanged();
24 | }
25 | }
26 | private Brush Background_;
27 | public Brush Background
28 | {
29 | get
30 | {
31 |
32 | return Background_;
33 | }
34 | set
35 | {
36 | Background_ = value;
37 | OnPropertyChanged();
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Models/DesignTextAlignment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Controls.Models
8 | {
9 | public class DesignTextAlignment
10 | {
11 | public string DisplayName { get; set; }
12 | public int Value { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Models/ElementModel.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Controls.Enums;
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.Media;
8 |
9 | namespace Project1.UI.Controls.Models
10 | {
11 | ///
12 | /// 元素模型
13 | ///
14 | public class ElementModel
15 | {
16 | ///
17 | /// 类型
18 | ///
19 | public DesignItemType Type { get; set; }
20 | ///
21 | /// X坐标
22 | ///
23 | public double X { get; set; }
24 | ///
25 | /// Y坐标
26 | ///
27 | public double Y { get; set; }
28 | ///
29 | /// 宽
30 | ///
31 | public double Width { get; set; }
32 | ///
33 | /// 高
34 | ///
35 | public double Height { get; set; }
36 | ///
37 | /// 文字颜色
38 | ///
39 | public Brush TextColor { get; set; }
40 | ///
41 | /// 是否是粗体文本
42 | ///
43 | public bool IsTextBold { get; set; }
44 | ///
45 | /// 不透明度
46 | ///
47 | public double Opacity { get; set; }
48 | ///
49 | /// 文本
50 | ///
51 | public string Text { get; set; }
52 | ///
53 | /// 元素样式名
54 | ///
55 | public string Style { get; set; }
56 | ///
57 | /// 图片路径
58 | ///
59 | public string Image { get; set; }
60 | ///
61 | /// 字体大小
62 | ///
63 | public double FontSize { get; set; }
64 | ///
65 | /// 命令
66 | ///
67 | public string Command { get; set; }
68 | ///
69 | /// 文本对齐方式
70 | ///
71 | public int TextAlignment { get; set; }
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Project1UIButton.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Controls.Enums;
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 |
10 | namespace Project1.UI.Controls
11 | {
12 | public class Project1UIButton : Button
13 | {
14 |
15 | //按钮圆角半径
16 | ///
17 | /// 按钮圆角半径
18 | ///
19 | public CornerRadius CornerRadius
20 | {
21 | get { return (CornerRadius)GetValue(CornerRadiusProperty); }
22 | set { SetValue(CornerRadiusProperty, value); }
23 | }
24 | public static readonly DependencyProperty CornerRadiusProperty =
25 | DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(Project1UIButton));
26 |
27 | //图标对齐方式
28 | ///
29 | /// 图标对齐方式(仅支持左右)
30 | ///
31 | public HorizontalAlignment IconAlignment
32 | {
33 | get { return (HorizontalAlignment)GetValue(IconAlignmentProperty); }
34 | set { SetValue(IconAlignmentProperty, value); }
35 | }
36 | public static readonly DependencyProperty IconAlignmentProperty =
37 | DependencyProperty.Register("IconAlignment", typeof(HorizontalAlignment), typeof(Project1UIButton));
38 | //图标
39 | ///
40 | /// 图标
41 | ///
42 | public Project1UIIconType Icon
43 | {
44 | get { return (Project1UIIconType)GetValue(IconProperty); }
45 | set { SetValue(IconProperty, value); }
46 | }
47 | public static readonly DependencyProperty IconProperty =
48 | DependencyProperty.Register("Icon", typeof(Project1UIIconType), typeof(Project1UIButton),new PropertyMetadata(Project1UIIconType.Null));
49 | //图标大小
50 | ///
51 | /// 图标大小
52 | ///
53 | public double IconSize
54 | {
55 | get { return (double)GetValue(IconSizeProperty); }
56 | set { SetValue(IconSizeProperty, value); }
57 | }
58 | public static readonly DependencyProperty IconSizeProperty =
59 | DependencyProperty.Register("IconSize", typeof(double), typeof(Project1UIButton));
60 |
61 | public Project1UIButton()
62 | {
63 | DefaultStyleKey = typeof(Project1UIButton);
64 |
65 | }
66 |
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Project1UIColorSelect.cs:
--------------------------------------------------------------------------------
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;
7 | using System.Windows.Controls;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 |
11 | namespace Project1.UI.Controls
12 | {
13 | ///
14 | /// 颜色选择控件
15 | ///
16 | public class Project1UIColorSelect : Control
17 | {
18 | ///
19 | /// 当前选择颜色
20 | ///
21 | public Brush Color
22 | {
23 | get { return (Brush)GetValue(ColorProperty); }
24 | set { SetValue(ColorProperty, value); }
25 | }
26 | public static readonly DependencyProperty ColorProperty =
27 | DependencyProperty.Register("Color", typeof(Brush), typeof(Project1UIColorSelect), new PropertyMetadata(Brushes.Black));
28 |
29 | public Project1UIColorSelect()
30 | {
31 | DefaultStyleKey = typeof(Project1UIColorSelect);
32 | ToolTip = "选择颜色";
33 | }
34 | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
35 | {
36 | base.OnMouseLeftButtonDown(e);
37 | System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();
38 |
39 | if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
40 |
41 | {
42 |
43 | System.Drawing.SolidBrush sb = new System.Drawing.SolidBrush(colorDialog.Color);
44 |
45 | SolidColorBrush solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B));
46 |
47 | Color = solidColorBrush;
48 |
49 | }
50 |
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Project1UIIcon.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Controls.Enums;
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 |
10 | namespace Project1.UI.Controls
11 | {
12 | public class Project1UIIcon : Control
13 | {
14 | public Project1UIIconType Icon
15 | {
16 | get { return (Project1UIIconType)GetValue(IconProperty); }
17 | set { SetValue(IconProperty, value); }
18 | }
19 | public static readonly DependencyProperty IconProperty =
20 | DependencyProperty.Register("Icon", typeof(Project1UIIconType), typeof(Project1UIIcon), new PropertyMetadata(Project1UIIconType.Null));
21 |
22 | public Project1UIIcon()
23 | {
24 | DefaultStyleKey = typeof(Project1UIIcon);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Project1UIKeyboardInput.cs:
--------------------------------------------------------------------------------
1 |
2 | using Project1.UI.Controls.Commands;
3 | using Project1.UI.Controls.Enums;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Diagnostics;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Input;
13 |
14 | namespace Project1.UI.Controls
15 | {
16 | public class Project1UIKeyboardInput : Control
17 | {
18 | public string Placeholder
19 | {
20 | get { return (string)GetValue(PlaceholderProperty); }
21 | set { SetValue(PlaceholderProperty, value); }
22 | }
23 |
24 | public static readonly DependencyProperty PlaceholderProperty =
25 | DependencyProperty.Register("Placeholder", typeof(string), typeof(Project1UIKeyboardInput), new PropertyMetadata(""));
26 |
27 | public string KeyText
28 | {
29 | get { return (string)GetValue(KeyTextProperty); }
30 | set { SetValue(KeyTextProperty, value); }
31 | }
32 |
33 | public static readonly DependencyProperty KeyTextProperty =
34 | DependencyProperty.Register("KeyText", typeof(string), typeof(Project1UIKeyboardInput), new PropertyMetadata(""));
35 | public Project1UIKeyboardInput()
36 | {
37 | this.DefaultStyleKey = typeof(Project1UIKeyboardInput);
38 | this.CommandBindings.Add(new CommandBinding(Project1UIInputCommands.ClearTextCommand, OnClearTextCommand));
39 |
40 | }
41 |
42 | private void OnClearTextCommand(object sender, ExecutedRoutedEventArgs e)
43 | {
44 | KeyText = string.Empty;
45 | }
46 |
47 | protected override void OnMouseDown(MouseButtonEventArgs e)
48 | {
49 | base.OnMouseDown(e);
50 | Focus();
51 | }
52 | protected override void OnKeyDown(KeyEventArgs e)
53 | {
54 | base.OnKeyDown(e);
55 | string key;
56 | if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key != Key.LeftCtrl)
57 | {
58 | key = "CTRL + " + e.Key.ToString();
59 | }
60 | else
61 | {
62 | key = e.Key.ToString();
63 | }
64 | KeyText = key;
65 | }
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Project1UIListView.cs:
--------------------------------------------------------------------------------
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;
7 | using System.Windows.Controls;
8 |
9 | namespace Project1.UI.Controls
10 | {
11 | public class Project1UIListView : ListView
12 | {
13 | public object Selected
14 | {
15 | get { return (object)GetValue(SelectedProperty); }
16 | set { SetValue(SelectedProperty, value); }
17 | }
18 | public static readonly DependencyProperty SelectedProperty =
19 | DependencyProperty.Register("Selected", typeof(object), typeof(Project1UIListView));
20 |
21 | public Project1UIListView()
22 | {
23 |
24 | }
25 | protected override void OnSelectionChanged(SelectionChangedEventArgs e)
26 | {
27 | base.OnSelectionChanged(e);
28 | Selected = SelectedItems;
29 |
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/ToastManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Controls
8 | {
9 | public static class ToastManager
10 | {
11 | private static Project1UIToast toast_;
12 |
13 | public static void Add(Project1UIToast toast)
14 | {
15 | if (toast_ != null)
16 | {
17 | toast_.Hide();
18 | }
19 | toast_ = toast;
20 | }
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Controls/Toggle.cs:
--------------------------------------------------------------------------------
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;
7 | using System.Windows.Controls;
8 | using System.Windows.Input;
9 |
10 | namespace Project1.UI.Controls
11 | {
12 | public class Toggle : Control
13 | {
14 | public bool IsChecked
15 | {
16 | get { return (bool)GetValue(IsCheckedProperty); }
17 | set { SetValue(IsCheckedProperty, value); }
18 | }
19 | public static readonly DependencyProperty IsCheckedProperty =
20 | DependencyProperty.Register("IsChecked", typeof(bool), typeof(Toggle), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnIsCheckedChanged)));
21 |
22 | private static void OnIsCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
23 | {
24 | var control = d as Toggle;
25 | if (e.OldValue != e.NewValue && control.Text == "关")
26 | {
27 | control.Text = control.IsChecked ? control.OnText : control.OffText;
28 | }
29 | VisualStateManager.GoToState(control, control.IsChecked ? "On" : "Off", true);
30 | }
31 |
32 | public string OnText
33 | {
34 | get { return (string)GetValue(OnTextProperty); }
35 | set { SetValue(OnTextProperty, value); }
36 | }
37 | public static readonly DependencyProperty OnTextProperty =
38 | DependencyProperty.Register("OnText", typeof(string), typeof(Toggle), new PropertyMetadata("开"));
39 | public string OffText
40 | {
41 | get { return (string)GetValue(OffTextProperty); }
42 | set { SetValue(OffTextProperty, value); }
43 | }
44 | public static readonly DependencyProperty OffTextProperty =
45 | DependencyProperty.Register("OffText", typeof(string), typeof(Toggle), new PropertyMetadata("关"));
46 | public string Text
47 | {
48 | get { return (string)GetValue(TextProperty); }
49 | set { SetValue(TextProperty, value); }
50 | }
51 | public static readonly DependencyProperty TextProperty =
52 | DependencyProperty.Register("Text", typeof(string), typeof(Toggle), new PropertyMetadata("关"));
53 |
54 | public Toggle()
55 | {
56 | DefaultStyleKey = typeof(Toggle);
57 | }
58 | public override void OnApplyTemplate()
59 | {
60 | base.OnApplyTemplate();
61 | VisualStateManager.GoToState(this, IsChecked ? "On" : "Off", true);
62 | }
63 | protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
64 | {
65 | base.OnMouseLeftButtonUp(e);
66 | IsChecked = !IsChecked;
67 | VisualStateManager.GoToState(this, IsChecked ? "On" : "Off", true);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Cores/BitmapImager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Media.Imaging;
9 | using System.Windows.Resources;
10 |
11 | namespace Project1.UI.Cores
12 | {
13 | public static class BitmapImager
14 | {
15 |
16 | public static BitmapImage Load(string filePath)
17 | {
18 | var bitmap = new BitmapImage();
19 | bitmap.BeginInit();
20 | if (filePath.IndexOf("pack://") != -1)
21 | {
22 | StreamResourceInfo info = Application.GetResourceStream(new Uri(filePath, UriKind.RelativeOrAbsolute));
23 | using (var st = info.Stream)
24 | {
25 | bitmap.StreamSource = st;
26 | bitmap.EndInit();
27 | bitmap.Freeze();
28 | }
29 | }
30 | else
31 | {
32 | if (!File.Exists(filePath))
33 | {
34 | return null;
35 | }
36 | byte[] imageData;
37 | using (var fileStream = new FileStream(@filePath, FileMode.Open, FileAccess.Read))
38 |
39 | using (var binaryReader = new BinaryReader(fileStream))
40 | {
41 | imageData = binaryReader.ReadBytes((int)fileStream.Length);
42 | bitmap.StreamSource = new MemoryStream(imageData);
43 | bitmap.EndInit();
44 | bitmap.Freeze();
45 | }
46 | }
47 |
48 | return bitmap;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Cores/Project1UIColor.cs:
--------------------------------------------------------------------------------
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.Media;
7 |
8 | namespace Project1.UI.Cores
9 | {
10 | public class Project1UIColor
11 | {
12 |
13 | ///
14 | /// 红色
15 | ///
16 | public static SolidColorBrush Red { get; set; } = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f63b36"));
17 | ///
18 | /// 绿色
19 | ///
20 | public static SolidColorBrush Green { get; set; } = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#24cf5f"));
21 | ///
22 | /// 黑色
23 | ///
24 | public static SolidColorBrush Black { get; set; } = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#424242"));
25 |
26 | public static Color Yellow { get; set; } = (Color)ColorConverter.ConvertFromString("#fff000");
27 |
28 | ///
29 | /// 黄色
30 | ///
31 | public static SolidColorBrush YellowBrush { get; set; } = new SolidColorBrush(Yellow);
32 |
33 | ///
34 | /// 紫色
35 | ///
36 | public static Color Violet { get; set; } = (Color)ColorConverter.ConvertFromString("#0000EF");
37 | ///
38 | /// 紫色笔刷
39 | ///
40 | public static SolidColorBrush VioletBrush { get; set; } = new SolidColorBrush(Violet);
41 |
42 | ///
43 | /// 主题色
44 | ///
45 | public static SolidColorBrush ThemeColor { get; set; } = VioletBrush;
46 |
47 | public static SolidColorBrush Get(string color, double opacity = 1)
48 | {
49 | return new SolidColorBrush((Color)ColorConverter.ConvertFromString(color))
50 | {
51 | Opacity = opacity
52 | };
53 | }
54 | public static Color GetMediaColor(string color)
55 | {
56 | return (Color)ColorConverter.ConvertFromString(color);
57 |
58 | }
59 |
60 | public static Color BrushToColor(Brush value, double opacity = 1)
61 | {
62 | var b = value;
63 | var res = (Color)b.GetValue(SolidColorBrush.ColorProperty);
64 | res.ScA = (float)opacity;
65 | return res;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Cores/UIDefaultSetting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Project1.UI.Cores
8 | {
9 | ///
10 | /// UI默认设置
11 | ///
12 | public class UIDefaultSetting
13 | {
14 | ///
15 | /// 获取或设置主题名
16 | ///
17 | public static string DefaultThemeName { get; set; } = "Default";
18 | ///
19 | /// 获取或设置主题路径
20 | ///
21 | public static string DefaultThemePath { get; set; } = null;
22 | ///
23 | /// 获取或设置主题颜色
24 | ///
25 | public static string DefaultThemeColor { get; set; } = "#ffc83d";
26 | ///
27 | /// 获取主题全路径
28 | ///
29 | public static string DefaultThemeFullPath
30 | {
31 | get
32 | {
33 | return DefaultThemePath != null ? DefaultThemePath + DefaultThemeName : "/Project1.UI;component/Assets/Themes/" + DefaultThemeName;
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Cores/UINotifyPropertyChanged.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Project1.UI.Cores
9 | {
10 | public class UINotifyPropertyChanged : INotifyPropertyChanged
11 | {
12 | public event PropertyChangedEventHandler PropertyChanged;
13 |
14 | public void OnPropertyChanged(string propertyName = "")
15 | {
16 |
17 | PropertyChangedEventHandler handler = PropertyChanged;
18 | if (handler != null)
19 | {
20 | handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
21 | }
22 |
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Cores/WindowsCollection.cs:
--------------------------------------------------------------------------------
1 | using Project1.UI.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Project1.UI.Cores
9 | {
10 | public class WindowsCollection
11 | {
12 | private static readonly List _windows = new List();
13 |
14 | public Project1UIWindow this[int index]
15 | {
16 | get
17 | {
18 | return _windows[index];
19 | }
20 | set
21 | {
22 | _windows[index] = value;
23 | }
24 | }
25 |
26 | public static void Add(Project1UIWindow _window)
27 | {
28 |
29 | _windows.Add(_window);
30 |
31 | }
32 |
33 | public static void Remove(Project1UIWindow _window)
34 | {
35 |
36 | _windows.Remove(_window);
37 |
38 | }
39 | public static List ToList()
40 | {
41 | return _windows;
42 | }
43 |
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Windows;
5 |
6 | // 有关程序集的一般信息由以下
7 | // 控制。更改这些特性值可修改
8 | // 与程序集关联的信息。
9 | [assembly: AssemblyTitle("Project1.UI")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("Project1.UI")]
14 | [assembly: AssemblyCopyright("Copyright © 2018")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
18 |
19 | // 将 ComVisible 设置为 false 会使此程序集中的类型
20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
25 | [assembly: Guid("b441ce6c-d252-4683-9f39-211f17794f56")]
26 |
27 | // 程序集的版本信息由下列四个值组成:
28 | //
29 | // 主版本
30 | // 次版本
31 | // 生成号
32 | // 修订号
33 | //
34 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
35 | //通过使用 "*",如下所示:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 | [assembly: AssemblyVersion("1.0.0.0")]
38 | [assembly: AssemblyFileVersion("1.0.0.0")]
39 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Project1.UI.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/CheckButton.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/ContentCard.xaml:
--------------------------------------------------------------------------------
1 |
6 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/DatePicker/ItemList.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/Icon.xaml:
--------------------------------------------------------------------------------
1 |
6 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/Project1UIChart.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/Project1UIColorSelect.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/Project1UIIcon.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/Project1UIProcessBar.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/Local/Project1.UI/Themes/TimeBox.xaml:
--------------------------------------------------------------------------------
1 |
6 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/AudioHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace ProjectEye.Core
5 | {
6 | /*
7 | * https://stackoverflow.com/questions/45422255/determine-if-windows-is-currently-playing-sound
8 | */
9 | ///
10 | /// 声音辅助类
11 | ///
12 | public class AudioHelper
13 | {
14 | ///
15 | /// 指示系统当前是否在播放声音
16 | ///
17 | ///
18 | public static bool IsWindowsPlayingSound()
19 | {
20 | try
21 | {
22 | IMMDeviceEnumerator enumerator = (IMMDeviceEnumerator)(new MMDeviceEnumerator());
23 | IMMDevice speakers = enumerator.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
24 | IAudioMeterInformation meter = (IAudioMeterInformation)speakers.Activate(typeof(IAudioMeterInformation).GUID, 0, IntPtr.Zero);
25 | if (meter != null)
26 | {
27 |
28 | float value = meter.GetPeakValue();
29 |
30 | // this is a bit tricky. 0 is the official "no sound" value
31 | // but for example, if you open a video and plays/stops with it (w/o killing the app/window/stream),
32 | // the value will not be zero, but something really small (around 1E-09)
33 | // so, depending on your context, it is up to you to decide
34 | // if you want to test for 0 or for a small value
35 | return value > 1E-08;
36 | }
37 | else
38 | {
39 | return false;
40 | }
41 | }
42 | catch (Exception ec)
43 | {
44 | LogHelper.Warning(ec.ToString());
45 | return false;
46 | }
47 | }
48 |
49 | [ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")]
50 | private class MMDeviceEnumerator
51 | {
52 | }
53 |
54 | private enum EDataFlow
55 | {
56 | eRender,
57 | eCapture,
58 | eAll,
59 | }
60 |
61 | private enum ERole
62 | {
63 | eConsole,
64 | eMultimedia,
65 | eCommunications,
66 | }
67 |
68 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("A95664D2-9614-4F35-A746-DE8DB63617E6")]
69 | private interface IMMDeviceEnumerator
70 | {
71 | void NotNeeded();
72 | IMMDevice GetDefaultAudioEndpoint(EDataFlow dataFlow, ERole role);
73 | // the rest is not defined/needed
74 | }
75 |
76 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("D666063F-1587-4E43-81F1-B948E807363F")]
77 | private interface IMMDevice
78 | {
79 | [return: MarshalAs(UnmanagedType.IUnknown)]
80 | object Activate([MarshalAs(UnmanagedType.LPStruct)] Guid iid, int dwClsCtx, IntPtr pActivationParams);
81 | // the rest is not defined/needed
82 | }
83 |
84 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("C02216F6-8C67-4B5B-9D00-D008E73E0064")]
85 | private interface IAudioMeterInformation
86 | {
87 | float GetPeakValue();
88 | // the rest is not defined/needed
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/BusyVerdictHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace ProjectEye.Core
4 | {
5 | ///
6 | /// 繁忙判断帮助类
7 | /// 用于判断用户的繁忙状态
8 | ///
9 | public class BusyVerdictHelper
10 | {
11 | private readonly static string[] MusicApps = {
12 | "cloudmusic",""};
13 | ///
14 | /// 指示用户当前是否是在看视频
15 | ///
16 | ///
17 | public static bool IsWatchingVideo()
18 | {
19 | Process[] processes = Process.GetProcesses();
20 | //processes.Where(m => m.ProcessName)
21 |
22 | return false;
23 | }
24 |
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Enums/SoundType.cs:
--------------------------------------------------------------------------------
1 | namespace ProjectEye.Core.Enums
2 | {
3 | public enum SoundType
4 | {
5 | ///
6 | /// 休息结束
7 | ///
8 | RestOverSound,
9 | ///
10 | /// 番茄时钟工作开始
11 | ///
12 | TomatoWorkStartSound,
13 | ///
14 | /// 番茄时钟工作结束
15 | ///
16 | TomatoWorkEndSound,
17 | ///
18 | /// 其他
19 | ///
20 | Other
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/FileHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace ProjectEye.Core
5 | {
6 | public class FileHelper
7 | {
8 | ///
9 | /// 在运行目录写入文件
10 | ///
11 | /// 路径
12 | /// 内容
13 | public static void Write(string path, string contents, bool isRunPath = true)
14 | {
15 | if (isRunPath)
16 | {
17 | path = AppDomain.CurrentDomain.BaseDirectory + path;
18 | }
19 | string dir = Path.GetDirectoryName(path);
20 | if (!Directory.Exists(dir))
21 | {
22 | Directory.CreateDirectory(dir);
23 | }
24 | File.WriteAllText(path, contents);
25 | }
26 | ///
27 | /// 在运行目录中读取一个文件
28 | ///
29 | ///
30 | ///
31 | public static string Read(string path)
32 | {
33 | path = AppDomain.CurrentDomain.BaseDirectory + path;
34 | if (File.Exists(path))
35 | {
36 | return File.ReadAllText(path);
37 | }
38 | return string.Empty;
39 | }
40 | ///
41 | /// 在运行目录中判断文件是否存在
42 | ///
43 | ///
44 | ///
45 | public static bool Exists(string path)
46 | {
47 | path = AppDomain.CurrentDomain.BaseDirectory + path;
48 | return File.Exists(path);
49 |
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/LogHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace ProjectEye.Core
5 | {
6 | public class LogHelper
7 | {
8 | public enum Level
9 | {
10 | ///
11 | /// 调试
12 | ///
13 | DEBUG,
14 | ///
15 | /// 错误
16 | ///
17 | ERROR,
18 | ///
19 | /// 警告
20 | ///
21 | WARNING
22 | }
23 | public static void Debug(string text, bool write = false, bool console = true)
24 | {
25 | Log(Level.DEBUG, text, write, console);
26 | }
27 | public static void Error(string text, bool write = true, bool console = true)
28 | {
29 | Log(Level.ERROR, text, write, console);
30 | }
31 | public static void Warning(string text, bool write = true, bool console = true)
32 | {
33 | Log(Level.WARNING, text, write, console);
34 | }
35 | private static void Log(Level level, string text, bool write = false, bool console = true)
36 | {
37 | string log = LogFormat(level, text);
38 | if (write)
39 | {
40 | //写入日志文件
41 | WriteFile(level, log);
42 | }
43 | if (console)
44 | {
45 | //在debug模式下打印到输出
46 | System.Diagnostics.Debug.WriteLine(log);
47 | }
48 | }
49 | private static void WriteFile(Level level, string text)
50 | {
51 | try
52 | {
53 | string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
54 | "Log",
55 | $"{level.ToString()}_{DateTime.Now.ToString("yyyy_MM_dd")}.log");
56 | string dir = Path.GetDirectoryName(filePath);
57 | if (!Directory.Exists(dir))
58 | {
59 | Directory.CreateDirectory(dir);
60 | }
61 | File.AppendAllText(filePath, text);
62 | }
63 | catch
64 | {
65 | //...
66 | }
67 | }
68 | private static string LogFormat(Level level, string text)
69 | {
70 | string logText = $"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}] [{level.ToString()}]\r\n{text}\r\n------------------------\r\n\r\n";
71 | return logText;
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/EyesTest/EyesTestListModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace ProjectEye.Core.Models.EyesTest
5 | {
6 | [XmlRootAttribute("EyesTestList")]
7 | public class EyesTestListModel
8 | {
9 | public List Data { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/EyesTest/EyesTestModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml.Serialization;
3 |
4 | namespace ProjectEye.Core.Models.EyesTest
5 | {
6 | [XmlRootAttribute("EyesTest")]
7 | public class EyesTestModel
8 | {
9 | ///
10 | /// 统计日期
11 | ///
12 | public DateTime Date { get; set; }
13 | ///
14 | /// 分数
15 | ///
16 | public double Score { get; set; } = 0;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/AnimationModel.cs:
--------------------------------------------------------------------------------
1 | using static Project1.UI.Controls.Project1UIWindow;
2 |
3 | namespace ProjectEye.Core.Models.Options
4 | {
5 | public class AnimationModel
6 | {
7 | public int ID { get; set; }
8 | ///
9 | /// 动画名
10 | ///
11 | public string DisplayName { get; set; }
12 | ///
13 | /// 动画类型
14 | ///
15 | public AnimationType AnimationType { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/BehaviorModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using System.Xml.Serialization;
3 |
4 | namespace ProjectEye.Core.Models.Options
5 | {
6 | ///
7 | /// 行为模型
8 | ///
9 | [XmlRootAttribute("Behavior")]
10 | public class BehaviorModel
11 | {
12 | ///
13 | /// 全屏时跳过休息
14 | ///
15 | public bool IsFullScreenBreak { get; set; } = false;
16 | ///
17 | /// 是否启用进程跳过功能
18 | ///
19 | public bool IsBreakProgressList { get; set; } = false;
20 | ///
21 | /// 跳过进程名单
22 | ///
23 | public ObservableCollection BreakProgressList { get; set; } = new ObservableCollection();
24 | ///
25 | /// 是否禁用跳过休息(为true时将不允许跳过而是直接进入休息
26 | ///
27 | public bool IsDisabledSkip { get; set; } = false;
28 | ///
29 | /// 超时未选择时进入休息状态
30 | ///
31 | public bool IsHandleTimeoutRest { get; set; } = true;
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/ComboxModel.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace ProjectEye.Core.Models.Options
4 | {
5 | [XmlRootAttribute("ComboxModel")]
6 | public class ComboxModel
7 | {
8 | public string DisplayName { get; set; } = "请选择";
9 |
10 | public string Value { get; set; } = "0";
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/GeneralModel.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace ProjectEye.Core.Models.Options
4 | {
5 | ///
6 | /// 通用设置模型
7 | ///
8 | [XmlRootAttribute("General")]
9 | public class GeneralModel
10 | {
11 | ///
12 | /// 开机启动
13 | ///
14 | public bool Startup { get; set; } = false;
15 | ///
16 | /// 不要提醒
17 | ///
18 | public bool Noreset { get; set; } = false;
19 | ///
20 | /// 统计数据
21 | ///
22 | public bool Data { get; set; } = false;
23 | ///
24 | /// 休息结束提示音
25 | ///
26 | public bool Sound { get; set; } = true;
27 | ///
28 | /// 离开监听
29 | ///
30 | public bool LeaveListener { get; set; } = false;
31 | ///
32 | /// 提醒间隔时间(单位:分钟)
33 | ///
34 | public int WarnTime { get; set; } = 20;
35 | ///
36 | /// 休息结束提示音效文件路径,为空时使用默认
37 | ///
38 | public string SoundPath { get; set; } = "";
39 | ///
40 | /// 休息时间(单位:秒)
41 | ///
42 | public int RestTime { get; set; } = 20;
43 | ///
44 | /// 是否启用一周数据分析
45 | ///
46 | public bool IsWeekDataAnalysis { get; set; } = false;
47 | ///
48 | /// 是否是番茄时钟模式
49 | ///
50 | public bool IsTomatoMode { get; set; } = false;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/KeyboardShortcutModel.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace ProjectEye.Core.Models.Options
4 | {
5 | [XmlRootAttribute("KeyboardShortcut")]
6 | public class KeyboardShortcutModel
7 | {
8 | ///
9 | /// 休息快捷键
10 | ///
11 | public string Reset { get; set; } = "";
12 | ///
13 | /// 不休息快捷键
14 | ///
15 | public string NoReset { get; set; } = "";
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/OptionsModel.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace ProjectEye.Core.Models.Options
4 | {
5 | [XmlRootAttribute("Options")]
6 | public class OptionsModel
7 | {
8 | ///
9 | /// 通用设置
10 | ///
11 | public GeneralModel General { get; set; }
12 | ///
13 | /// 外观
14 | ///
15 | public StyleModel Style { get; set; }
16 | ///
17 | /// 快捷键
18 | ///
19 | public KeyboardShortcutModel KeyboardShortcuts { get; set; }
20 | ///
21 | /// 行为
22 | ///
23 | public BehaviorModel Behavior { get; set; }
24 | ///
25 | /// 番茄模式
26 | ///
27 | public TomatoModel Tomato { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/ThemeModel.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace ProjectEye.Core.Models.Options
4 | {
5 | [XmlRootAttribute("theme")]
6 | public class ThemeModel
7 | {
8 | public int ID { get; set; }
9 | public string DisplayName { get; set; } = "默认";
10 |
11 | public string ThemeName { get; set; } = "Default";
12 | public string ThemeColor { get; set; } = "#ffc83d";
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Options/TomatoModel.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace ProjectEye.Core.Models.Options
4 | {
5 | [XmlRootAttribute("Tomato")]
6 | public class TomatoModel
7 | {
8 | ///
9 | /// 工作时间
10 | ///
11 | public int WorkMinutes { get; set; } = 25;
12 | ///
13 | /// 短休息
14 | ///
15 | public int ShortRestMinutes { get; set; } = 5;
16 | ///
17 | /// 长休息
18 | ///
19 | public int LongRestMinutes { get; set; } = 30;
20 | ///
21 | /// 是否开启工作开始提示音
22 | ///
23 | public bool IsWorkStartSound { get; set; } = true;
24 | ///
25 | /// 是否开启工作结束提示音
26 | ///
27 | public bool IsWorkEndSound { get; set; } = true;
28 | ///
29 | /// 工作开始提示音路径
30 | ///
31 | public string WorkStartSoundPath { get; set; } = "";
32 | ///
33 | /// 工作结束提示音路径
34 | ///
35 | public string WorkEndSoundPath { get; set; } = "";
36 | ///
37 | /// 是否开启交互模式
38 | ///
39 | public bool IsEnabledInteractiveModel { get; set; } = false;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Statistic/StatisticListModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace ProjectEye.Core.Models.Statistic
5 | {
6 | [XmlRootAttribute("StatisticList")]
7 | public class StatisticListModel
8 | {
9 | public List Data { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Statistic/StatisticModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml.Serialization;
3 |
4 | namespace ProjectEye.Core.Models.Statistic
5 | {
6 | [XmlRootAttribute("Statistic")]
7 | public class StatisticModel
8 | {
9 | public int ID { get; set; }
10 | ///
11 | /// 统计日期
12 | ///
13 | public DateTime Date { get; set; }
14 | ///
15 | /// 用眼时长(单位小时)
16 | ///
17 | public double WorkingTime { get; set; } = 0;
18 | ///
19 | /// 休息时长(单位分钟)
20 | ///
21 | public double ResetTime { get; set; } = 0;
22 | ///
23 | /// 跳过次数
24 | ///
25 | public int SkipCount { get; set; } = 0;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/Statistic/TomatoModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ProjectEye.Core.Models.Statistic
4 | {
5 | ///
6 | /// 番茄工作数据统计实体模型
7 | ///
8 | public class TomatoModel
9 | {
10 | public int ID { get; set; }
11 | ///
12 | /// 统计日期
13 | ///
14 | public DateTime Date { get; set; }
15 | ///
16 | /// 番茄数,每完成4次工作并休息获得一个
17 | ///
18 | public int TomatoCount { get; set; }
19 | ///
20 | /// 重启次数
21 | ///
22 | public int RestartCount { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Models/WindowModel.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace ProjectEye.Core.Models
4 | {
5 | public class WindowModel
6 | {
7 | ///
8 | /// 窗口实例
9 | ///
10 | public Window window { get; set; }
11 | ///
12 | /// 所在屏幕(驱动名称)
13 | ///
14 | public string screen { get; set; }
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/ProcessHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 |
4 | namespace ProjectEye.Core
5 | {
6 | public class ProcessHelper
7 | {
8 | public static bool Run(string filename, string[] args)
9 | {
10 | try
11 | {
12 | string arguments = "";
13 | foreach (string arg in args)
14 | {
15 | arguments += $"\"{arg}\" ";
16 | }
17 | arguments = arguments.Trim();
18 | Process process = new Process();
19 | ProcessStartInfo startInfo = new ProcessStartInfo(filename, arguments);
20 | process.StartInfo = startInfo;
21 | process.Start();
22 | return true;
23 | }
24 | catch (Exception ex)
25 | {
26 | LogHelper.Warning(ex.ToString());
27 | return false;
28 | }
29 |
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/RestEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace ProjectEye.Core
2 | {
3 | public delegate void RestEventHandler(object sender, int timed);
4 | }
5 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/ScreenExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace ProjectEye.Core
7 | {
8 | public static class ScreenExtensions
9 | {
10 | public struct Dpi
11 | {
12 | public uint x { get; set; }
13 | public uint y { get; set; }
14 |
15 | }
16 | public static Dpi GetDpi(this System.Windows.Forms.Screen screen, DpiType dpiType)
17 | {
18 | Dpi dpi = new Dpi();
19 | var pnt = new System.Drawing.Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1);
20 | var mon = MonitorFromPoint(pnt, 2/*MONITOR_DEFAULTTONEAREST*/);
21 |
22 | Win32APIHelper.RtlGetVersion(out Win32APIHelper.OsVersionInfo osVersionInfo);
23 | if (osVersionInfo.MajorVersion != 10)
24 | {
25 | Matrix m =
26 | PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
27 | dpi.x = (uint)m.M11 * 96; // notice it's divided by 96 already
28 | dpi.y = (uint)m.M22 * 96; // notice it's divided by 96 already
29 |
30 | }
31 | else
32 | {
33 | uint dpiX, dpiY;
34 | GetDpiForMonitor(mon, dpiType, out dpiX, out dpiY);
35 | dpi.x = dpiX;
36 | dpi.y = dpiY;
37 | }
38 | return dpi;
39 |
40 | }
41 |
42 | //https://msdn.microsoft.com/en-us/library/windows/desktop/dd145062(v=vs.85).aspx
43 | [DllImport("User32.dll")]
44 | private static extern IntPtr MonitorFromPoint([In] System.Drawing.Point pt, [In] uint dwFlags);
45 |
46 | //https://msdn.microsoft.com/en-us/library/windows/desktop/dn280510(v=vs.85).aspx
47 | [DllImport("Shcore.dll")]
48 | private static extern IntPtr GetDpiForMonitor([In] IntPtr hmonitor, [In] DpiType dpiType, [Out] out uint dpiX, [Out] out uint dpiY);
49 | }
50 |
51 | //https://msdn.microsoft.com/en-us/library/windows/desktop/dn280511(v=vs.85).aspx
52 | public enum DpiType
53 | {
54 | Effective = 0,
55 | Angular = 1,
56 | Raw = 2,
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/BackgroundWorkerService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 |
5 | namespace ProjectEye.Core.Service
6 | {
7 | ///
8 | /// 管理整个程序的后台工作任务
9 | ///
10 | public class BackgroundWorkerService : IService
11 | {
12 | ///
13 | /// 获取当前是否正在执行后台任务
14 | ///
15 | public bool IsBusy
16 | {
17 | get
18 | {
19 | return backgroundWorker != null ? backgroundWorker.IsBusy : false;
20 | }
21 | }
22 | public delegate void EventHandler();
23 | public event EventHandler OnCompleted, DoWork;
24 |
25 | private BackgroundWorker backgroundWorker;
26 | private List actions;
27 |
28 | public BackgroundWorkerService()
29 | {
30 | backgroundWorker = new BackgroundWorker();
31 | backgroundWorker.DoWork += BackgroundWorker_DoWork;
32 | backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted;
33 | actions = new List();
34 | }
35 | public void Init()
36 | {
37 | DoWork?.Invoke();
38 | }
39 |
40 | private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
41 | {
42 | OnCompleted?.Invoke();
43 | }
44 |
45 | private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
46 | {
47 | for (int i = 0; i < actions.Count; i++)
48 | {
49 | actions[i].Invoke();
50 | actions.Remove(actions[i]);
51 | }
52 | }
53 |
54 | public void AddAction(Action action)
55 | {
56 | actions.Add(action);
57 | }
58 |
59 | public void Run()
60 | {
61 | if (!backgroundWorker.IsBusy)
62 | {
63 | DoWork?.Invoke();
64 | backgroundWorker.RunWorkerAsync();
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/CacheService.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Caching;
2 |
3 | namespace ProjectEye.Core.Service
4 | {
5 | ///
6 | /// 内存缓存 Service
7 | ///
8 | public class CacheService : IService
9 | {
10 | private readonly ObjectCache cache;
11 | public CacheService()
12 | {
13 | cache = MemoryCache.Default;
14 | }
15 | public void Init()
16 | {
17 |
18 | }
19 | public object this[string key]
20 | {
21 | get
22 | {
23 | var result = cache.Get(key);
24 | if (result != null)
25 | {
26 | cache.Remove(key);
27 | }
28 | return result;
29 | }
30 | set
31 | {
32 | cache.Set(key, value, null);
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/IService.cs:
--------------------------------------------------------------------------------
1 | namespace ProjectEye.Core.Service
2 | {
3 | public interface IService
4 | {
5 | void Init();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/KeyboardShortcutsService.cs:
--------------------------------------------------------------------------------
1 | using ProjectEye.ViewModels;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Windows.Input;
5 |
6 | namespace ProjectEye.Core.Service
7 | {
8 | public class KeyboardShortcutsService : IService
9 | {
10 | private Dictionary keycommands;
11 | public KeyboardShortcutsService()
12 | {
13 | keycommands = new Dictionary();
14 | }
15 | ///
16 | /// 设置快捷键命令
17 | ///
18 | ///
19 | ///
20 | public void Set(string key, Command command)
21 | {
22 | if (keycommands.ContainsKey(key))
23 | {
24 | keycommands[key] = command;
25 | }
26 | else
27 | {
28 | keycommands.Add(key, command);
29 | }
30 | }
31 | public void Init()
32 | {
33 |
34 | }
35 | ///
36 | /// 执行快捷键命令
37 | ///
38 | ///
39 | public void Execute(KeyEventArgs keyEventArgs, object parameter = null)
40 | {
41 | string key;
42 | if (keyEventArgs.KeyboardDevice.Modifiers == ModifierKeys.Control && keyEventArgs.Key != Key.LeftCtrl)
43 | {
44 | key = "CTRL + " + keyEventArgs.Key.ToString();
45 | }
46 | else
47 | {
48 | key = keyEventArgs.Key.ToString();
49 | }
50 | if (keycommands.ContainsKey(key))
51 | {
52 | Debug.WriteLine("执行快捷键命令:" + key);
53 | keycommands[key].Execute(parameter);
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/NotificationService.cs:
--------------------------------------------------------------------------------
1 | namespace ProjectEye.Core.Service
2 | {
3 | class NotificationService
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/RestService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Threading;
3 |
4 | namespace ProjectEye.Core.Service
5 | {
6 | public class RestService : IService
7 | {
8 | ///
9 | /// 计时器
10 | ///
11 | private readonly DispatcherTimer timer;
12 |
13 | private int timed = 0;
14 |
15 | ///
16 | /// 倒计时更改时发生
17 | ///
18 | public event RestEventHandler TimeChanged;
19 | ///
20 | /// 休息结束时发生
21 | ///
22 | public event RestEventHandler RestCompleted;
23 | ///
24 | /// 进入休息状态时发生
25 | ///
26 | public event RestEventHandler RestStart;
27 | private readonly ConfigService config;
28 | private readonly MainService main;
29 | public RestService(
30 | ConfigService config,
31 | MainService main)
32 | {
33 | this.config = config;
34 | this.main = main;
35 | //初始化计时器
36 | timer = new DispatcherTimer();
37 | timer.Tick += new EventHandler(timer_Tick);
38 | timer.Interval = new TimeSpan(0, 0, 1);
39 |
40 | }
41 |
42 |
43 |
44 | public void Init()
45 | {
46 | }
47 | ///
48 | /// 开始休息
49 | ///
50 | public void Start()
51 | {
52 | timed = config.options.General.RestTime;
53 | timer.Start();
54 | RestStart?.Invoke(this, timed);
55 | }
56 | ///
57 | /// 休息结束
58 | ///
59 | private void End()
60 | {
61 | WindowManager.Hide("TipWindow");
62 | timer.Stop();
63 | timed = config.options.General.RestTime;
64 | main.ReStartWorkTimerWatch();
65 | OnResetCompleted();
66 |
67 | }
68 | private void timer_Tick(object sender, EventArgs e)
69 | {
70 | if (timed <= 1)
71 | {
72 | End();
73 | }
74 | else
75 | {
76 | timed--;
77 | OnTimeChanged();
78 | }
79 | }
80 | private void OnTimeChanged()
81 | {
82 | TimeChanged?.Invoke(this, timed);
83 | }
84 | private void OnResetCompleted()
85 | {
86 | RestCompleted?.Invoke(this, 0);
87 | }
88 |
89 |
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/ScreenService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Interop;
4 | using System.Windows.Threading;
5 |
6 | namespace ProjectEye.Core.Service
7 | {
8 | ///
9 | /// 屏幕监听服务
10 | /// 用于处理插拔显示器时创建和刷新提示窗口
11 | ///
12 | public class ScreenService : IService
13 | {
14 | private const int WM_DISPLAYCHANGE = 0x007e;
15 | private const int ga = 0x020A;
16 | private readonly DispatcherTimer timer;
17 | private HwndSource source;
18 | private readonly HwndSourceHook hwndSourceHook;
19 | public ScreenService()
20 | {
21 | hwndSourceHook = new HwndSourceHook(WndProc);
22 |
23 | timer = new DispatcherTimer();
24 | timer.Tick += new EventHandler(timer_Tick);
25 | timer.Interval = new TimeSpan(0, 0, 3);
26 |
27 | }
28 |
29 | private void timer_Tick(object sender, EventArgs e)
30 | {
31 | timer.Stop();
32 | WindowManager.UpdateAllScreensWindow("TipWindow", true);
33 | }
34 |
35 | public void Init()
36 | {
37 | //创建一个隐藏的窗口,用于接收显示器拔插消息
38 | Window hookWindow = new Window();
39 | hookWindow.Width = 0;
40 | hookWindow.Height = 0;
41 | hookWindow.ShowInTaskbar = false;
42 | hookWindow.WindowStyle = WindowStyle.None;
43 | //hookWindow.WindowState = WindowState.Minimized;
44 | hookWindow.Visibility = Visibility.Hidden;
45 | hookWindow.SourceInitialized += new EventHandler(hookWindow_SourceInitialized);
46 | hookWindow.Show();
47 | }
48 |
49 | public void Dispose()
50 | {
51 | if (source != null)
52 | {
53 | source.RemoveHook(hwndSourceHook);
54 | source.Dispose();
55 | }
56 | }
57 |
58 | private void hookWindow_SourceInitialized(object sender, EventArgs e)
59 | {
60 | source = HwndSource.FromHwnd(new WindowInteropHelper((Window)sender).Handle);
61 | source.AddHook(hwndSourceHook);
62 |
63 | }
64 |
65 |
66 |
67 | private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
68 | {
69 | switch (msg)
70 | {
71 | case WM_DISPLAYCHANGE:
72 | timer.Start();
73 | break;
74 | }
75 | return IntPtr.Zero;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/Local/ProjectEye/Core/Service/ServiceCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 |
6 | namespace ProjectEye.Core.Service
7 | {
8 | public class ServiceCollection
9 | {
10 | ///
11 | /// 已创建的实例
12 | ///
13 | private IList