├── .gitattributes
├── .gitignore
├── README.md
├── Richasy-Controls-UWP.sln
├── Richasy-Controls-UWP
├── Converter
│ ├── BoolToBrushConverter.cs
│ └── ConverterTools.cs
├── Extensions
│ ├── IndicatorExtension.cs
│ └── PressExtension.cs
├── Interaction
│ ├── ActionButton.cs
│ ├── ExtraButton.cs
│ ├── ExtraTextBox.cs
│ ├── IconButton
│ │ ├── IconButton.xaml
│ │ └── IconButton.xaml.cs
│ ├── Interaction.xaml
│ └── NumberBox
│ │ ├── NumberBox.xaml
│ │ └── NumberBox.xaml.cs
├── Layout
│ ├── CustomGridView.cs
│ ├── CustomListView.cs
│ ├── MenuListView
│ │ ├── MenuListView.xaml
│ │ └── MenuListView.xaml.cs
│ └── ThreeStageView
│ │ ├── ThreeStageView.Navigate.cs
│ │ ├── ThreeStageView.Properties.cs
│ │ ├── ThreeStageView.cs
│ │ └── ThreeStageView.xaml
├── Models
│ ├── Event
│ │ ├── AfterBackEventArgs.cs
│ │ ├── BeforeBackEventArgs.cs
│ │ ├── PaneStateChangedEventArgs.cs
│ │ └── StageChangedEventArgs.cs
│ ├── Interface
│ │ ├── IAppBarComboBoxItem.cs
│ │ └── ICenterPopupHeader.cs
│ └── UI
│ │ ├── AppBarComboBoxItem.cs
│ │ ├── NavigateItem.cs
│ │ ├── NotifyPropertyBase.cs
│ │ └── RichasyPage.cs
├── Popups
│ ├── CenterPopup
│ │ ├── CenterPopup.xaml
│ │ └── CenterPopup.xaml.cs
│ ├── TipPopup
│ │ ├── TipPopup.xaml
│ │ └── TipPopup.xaml.cs
│ └── WaitingPopup
│ │ ├── WaitingPopup.xaml
│ │ └── WaitingPopup.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── Richasy_Controls_UWP.rd.xml
├── Richasy-Controls-UWP.csproj
├── Richasy-Controls-UWP.nuspec
├── Themes
│ └── Generic.xaml
└── Widgets
│ ├── AppBarComboBoxButton
│ ├── AppBarComboBoxButton.xaml
│ └── AppBarComboBoxButton.xaml.cs
│ ├── Bubble
│ ├── Bubble.cs
│ ├── Bubble.xaml
│ └── BubbleView.cs
│ ├── CenterPopupHeader
│ ├── CenterPopupHeader.xaml
│ └── CenterPopupHeader.xaml.cs
│ ├── IconTextBlock
│ ├── IconTextBlock.xaml
│ └── IconTextBlock.xaml.cs
│ └── VersionBlock
│ ├── VersionBlock.xaml
│ └── VersionBlock.xaml.cs
└── SampleApp
├── App.xaml
├── App.xaml.cs
├── Assets
├── LockScreenLogo.scale-200.png
├── SplashScreen.scale-200.png
├── Square150x150Logo.scale-200.png
├── Square44x44Logo.scale-200.png
├── Square44x44Logo.targetsize-24_altform-unplated.png
├── StoreLogo.png
└── Wide310x150Logo.scale-200.png
├── MainPage.xaml
├── MainPage.xaml.cs
├── Models
├── Enum
│ ├── ColorType.cs
│ └── MenuItemType.cs
└── UI
│ └── MenuItem.cs
├── Package.appxmanifest
├── Pages
├── Interaction
│ ├── ButtonPage.xaml
│ ├── ButtonPage.xaml.cs
│ ├── InputPage.xaml
│ └── InputPage.xaml.cs
└── Popups
│ ├── CenterPopupPage.xaml
│ ├── CenterPopupPage.xaml.cs
│ ├── TipPopupPage.xaml
│ ├── TipPopupPage.xaml.cs
│ ├── WaitingPopupPage.xaml
│ └── WaitingPopupPage.xaml.cs
├── Properties
├── AssemblyInfo.cs
└── Default.rd.xml
├── SampleApp.csproj
└── Themes
├── Converter.xaml
├── Dark.xaml
├── Light.xaml
└── View.xaml
/.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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 控件集说明
2 |
3 | ## 简介
4 |
5 | 过去一年多的时间,我开发了不少UWP应用,积攒下来一些常用的控件、效果,或者用的比较多的类。其中有些是我自己写的,有些不是。这里只做收集整理,实用为上。
6 |
7 | ## 使用
8 |
9 | > nuget: [Richasy.Controls.UWP](https://www.nuget.org/packages/Richasy.Controls.UWP/)
10 |
11 | 本来打算写控件说明的,不过有点多,先放着。感兴趣的话可以看SampleApp里的内容,里面涵盖了控件的使用方法,当然,可能比较简陋,因为这个示例应用只是我一边写控件一边测试的工具,并没有把它当成应用来做。
12 |
13 | ## 感谢
14 |
15 | *排名不分先后*
16 |
17 | - [cnbluefire/MaterialLibs](https://github.com/cnbluefire/MaterialLibs)
18 | - [JustinXinLiu/Continuity](https://github.com/JustinXinLiu/Continuity)
19 | - [WindowsCommunityToolkit](https://github.com/windows-toolkit/WindowsCommunityToolkit)
20 | - [WinUI](https://github.com/microsoft/microsoft-ui-xaml)
21 | - [Win2D](https://github.com/microsoft/Win2D)
--------------------------------------------------------------------------------
/Richasy-Controls-UWP.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30204.135
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp", "SampleApp\SampleApp.csproj", "{3D895890-590F-4792-A719-33D163984C8C}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Richasy-Controls-UWP", "Richasy-Controls-UWP\Richasy-Controls-UWP.csproj", "{6DF7DF36-C97C-4D0A-BF60-511905CE072B}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|ARM = Debug|ARM
14 | Debug|ARM64 = Debug|ARM64
15 | Debug|x64 = Debug|x64
16 | Debug|x86 = Debug|x86
17 | Release|Any CPU = Release|Any CPU
18 | Release|ARM = Release|ARM
19 | Release|ARM64 = Release|ARM64
20 | Release|x64 = Release|x64
21 | Release|x86 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|Any CPU.ActiveCfg = Debug|x86
25 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|ARM.ActiveCfg = Debug|ARM
26 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|ARM.Build.0 = Debug|ARM
27 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|ARM.Deploy.0 = Debug|ARM
28 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|ARM64.ActiveCfg = Debug|ARM64
29 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|ARM64.Build.0 = Debug|ARM64
30 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|ARM64.Deploy.0 = Debug|ARM64
31 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|x64.ActiveCfg = Debug|x64
32 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|x64.Build.0 = Debug|x64
33 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|x64.Deploy.0 = Debug|x64
34 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|x86.ActiveCfg = Debug|x86
35 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|x86.Build.0 = Debug|x86
36 | {3D895890-590F-4792-A719-33D163984C8C}.Debug|x86.Deploy.0 = Debug|x86
37 | {3D895890-590F-4792-A719-33D163984C8C}.Release|Any CPU.ActiveCfg = Release|x86
38 | {3D895890-590F-4792-A719-33D163984C8C}.Release|ARM.ActiveCfg = Release|ARM
39 | {3D895890-590F-4792-A719-33D163984C8C}.Release|ARM.Build.0 = Release|ARM
40 | {3D895890-590F-4792-A719-33D163984C8C}.Release|ARM.Deploy.0 = Release|ARM
41 | {3D895890-590F-4792-A719-33D163984C8C}.Release|ARM64.ActiveCfg = Release|ARM64
42 | {3D895890-590F-4792-A719-33D163984C8C}.Release|ARM64.Build.0 = Release|ARM64
43 | {3D895890-590F-4792-A719-33D163984C8C}.Release|ARM64.Deploy.0 = Release|ARM64
44 | {3D895890-590F-4792-A719-33D163984C8C}.Release|x64.ActiveCfg = Release|x64
45 | {3D895890-590F-4792-A719-33D163984C8C}.Release|x64.Build.0 = Release|x64
46 | {3D895890-590F-4792-A719-33D163984C8C}.Release|x64.Deploy.0 = Release|x64
47 | {3D895890-590F-4792-A719-33D163984C8C}.Release|x86.ActiveCfg = Release|x86
48 | {3D895890-590F-4792-A719-33D163984C8C}.Release|x86.Build.0 = Release|x86
49 | {3D895890-590F-4792-A719-33D163984C8C}.Release|x86.Deploy.0 = Release|x86
50 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|ARM.ActiveCfg = Debug|ARM
53 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|ARM.Build.0 = Debug|ARM
54 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|ARM64.ActiveCfg = Debug|ARM64
55 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|ARM64.Build.0 = Debug|ARM64
56 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|x64.ActiveCfg = Debug|x64
57 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|x64.Build.0 = Debug|x64
58 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|x86.ActiveCfg = Debug|x86
59 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Debug|x86.Build.0 = Debug|x86
60 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|Any CPU.Build.0 = Release|Any CPU
62 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|ARM.ActiveCfg = Release|ARM
63 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|ARM.Build.0 = Release|ARM
64 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|ARM64.ActiveCfg = Release|ARM64
65 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|ARM64.Build.0 = Release|ARM64
66 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|x64.ActiveCfg = Release|x64
67 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|x64.Build.0 = Release|x64
68 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|x86.ActiveCfg = Release|x86
69 | {6DF7DF36-C97C-4D0A-BF60-511905CE072B}.Release|x86.Build.0 = Release|x86
70 | EndGlobalSection
71 | GlobalSection(SolutionProperties) = preSolution
72 | HideSolutionNode = FALSE
73 | EndGlobalSection
74 | GlobalSection(ExtensibilityGlobals) = postSolution
75 | SolutionGuid = {D9E340B7-8431-44CF-9B22-B16A0D766F5C}
76 | EndGlobalSection
77 | EndGlobal
78 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Converter/BoolToBrushConverter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Toolkit.Uwp.UI.Converters;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Windows.UI.Xaml;
8 | using Windows.UI.Xaml.Data;
9 | using Windows.UI.Xaml.Media;
10 |
11 | namespace Richasy.Controls.UWP.Converter
12 | {
13 | public class BoolToBrushConverter : DependencyObject, IValueConverter
14 | {
15 | public Brush TrueBrush
16 | {
17 | get { return (Brush)GetValue(TrueBrushProperty); }
18 | set { SetValue(TrueBrushProperty, value); }
19 | }
20 |
21 | // Using a DependencyProperty as the backing store for TrueBrush. This enables animation, styling, binding, etc...
22 | public static readonly DependencyProperty TrueBrushProperty =
23 | DependencyProperty.Register("TrueBrush", typeof(Brush), typeof(BoolToBrushConverter), new PropertyMetadata(null));
24 |
25 | public Brush FalseBrush
26 | {
27 | get { return (Brush)GetValue(FalseBrushProperty); }
28 | set { SetValue(FalseBrushProperty, value); }
29 | }
30 |
31 | // Using a DependencyProperty as the backing store for FalseBrush. This enables animation, styling, binding, etc...
32 | public static readonly DependencyProperty FalseBrushProperty =
33 | DependencyProperty.Register("FalseBrush", typeof(Brush), typeof(BoolToBrushConverter), new PropertyMetadata(null));
34 |
35 | public object Convert(object value, Type targetType, object parameter, string language)
36 | {
37 | bool boolValue = value is bool && (bool)value;
38 |
39 | if (ConverterTools.TryParseBool(parameter))
40 | {
41 | boolValue = !boolValue;
42 | }
43 |
44 | return ConverterTools.Convert(boolValue ? TrueBrush : FalseBrush, targetType);
45 | }
46 |
47 | public object ConvertBack(object value, Type targetType, object parameter, string language)
48 | {
49 | bool result = Equals(value, ConverterTools.Convert(TrueBrush, value.GetType()));
50 |
51 | if (ConverterTools.TryParseBool(parameter))
52 | {
53 | result = !result;
54 | }
55 |
56 | return result;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Converter/ConverterTools.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml.Markup;
7 |
8 | namespace Richasy.Controls.UWP.Converter
9 | {
10 | ///
11 | /// Static class used to provide internal tools
12 | ///
13 | internal static class ConverterTools
14 | {
15 | ///
16 | /// Helper method to safely cast an object to a boolean
17 | ///
18 | /// Parameter to cast to a boolean
19 | /// Bool value or false if cast failed
20 | internal static bool TryParseBool(object parameter)
21 | {
22 | var parsed = false;
23 | if (parameter != null)
24 | {
25 | bool.TryParse(parameter.ToString(), out parsed);
26 | }
27 |
28 | return parsed;
29 | }
30 |
31 | ///
32 | /// Helper method to convert a value from a source type to a target type.
33 | ///
34 | /// The value to convert
35 | /// The target type
36 | /// The converted value
37 | internal static object Convert(object value, Type targetType)
38 | {
39 | if (targetType.IsInstanceOfType(value))
40 | {
41 | return value;
42 | }
43 | else
44 | {
45 | return XamlBindingHelper.ConvertValue(targetType, value);
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Extensions/PressExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Numerics;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Windows.Foundation;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Hosting;
10 |
11 | namespace Richasy.Controls.UWP.Extensions
12 | {
13 | public class PressExtension
14 | {
15 | private static Vector3 HoverScale = new Vector3(1.08f, 1.08f, 1f);
16 | private static Vector3 ActionScale = new Vector3(0.94f, 0.94f, 1f);
17 |
18 | public static string GetTargetElementName(FrameworkElement obj)
19 | {
20 | return (string)obj.GetValue(TargetElementNameProperty);
21 | }
22 |
23 | public static void SetTargetElementName(FrameworkElement obj, string value)
24 | {
25 | obj.SetValue(TargetElementNameProperty, value);
26 | }
27 |
28 | // Using a DependencyProperty as the backing store for TargetElementName. This enables animation, styling, binding, etc...
29 | public static readonly DependencyProperty TargetElementNameProperty =
30 | DependencyProperty.RegisterAttached("TargetElementName", typeof(string), typeof(PressExtension), new PropertyMetadata("", (s, a) =>
31 | {
32 | if (s is FrameworkElement sender)
33 | {
34 | if (a.NewValue != a.OldValue)
35 | {
36 | var isOldEmpty = string.IsNullOrEmpty(a.OldValue.ToString());
37 | var isNewEmpty = string.IsNullOrEmpty(a.NewValue.ToString());
38 |
39 | if (isOldEmpty && isNewEmpty) return;
40 | if (isOldEmpty)
41 | {
42 | RemoveAnimations(sender);
43 | if (sender.IsLoaded)
44 | {
45 | var newTarget = sender.FindName(a.NewValue.ToString()) as FrameworkElement;
46 | AddAnimations(newTarget);
47 | }
48 | else
49 | {
50 | sender.Loaded += Sender_Loaded;
51 | void Sender_Loaded(object _, RoutedEventArgs e)
52 | {
53 | sender.Loaded -= Sender_Loaded;
54 | var newTarget = sender.FindName(a.NewValue.ToString()) as FrameworkElement;
55 | AddAnimations(newTarget);
56 | }
57 | }
58 | }
59 | else
60 | {
61 | AddAnimations(sender);
62 | if (sender.IsLoaded)
63 | {
64 | var oldTarget = sender.FindName(a.OldValue.ToString()) as FrameworkElement;
65 | RemoveAnimations(oldTarget);
66 | }
67 | else
68 | {
69 | sender.Loaded += Sender_Loaded;
70 | void Sender_Loaded(object _, RoutedEventArgs e)
71 | {
72 | sender.Loaded -= Sender_Loaded;
73 | var oldTarget = sender.FindName(a.OldValue.ToString()) as FrameworkElement;
74 | RemoveAnimations(oldTarget);
75 | }
76 | }
77 | }
78 | }
79 | }
80 | }));
81 |
82 |
83 |
84 | public static bool GetIsEnabled(DependencyObject obj)
85 | {
86 | return (bool)obj.GetValue(IsEnabledProperty);
87 | }
88 |
89 | public static void SetIsEnabled(DependencyObject obj, bool value)
90 | {
91 | obj.SetValue(IsEnabledProperty, value);
92 | }
93 |
94 | // Using a DependencyProperty as the backing store for IsEnabled. This enables animation, styling, binding, etc...
95 | public static readonly DependencyProperty IsEnabledProperty =
96 | DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(PressExtension), new PropertyMetadata(false, (s, a) =>
97 | {
98 | if (s is FrameworkElement sender)
99 | {
100 | if (a.NewValue != a.OldValue)
101 | {
102 | var targetName = GetTargetElementName(sender);
103 |
104 | if (a.NewValue is true)
105 | {
106 | if (string.IsNullOrEmpty(targetName))
107 | {
108 | AddAnimations(sender);
109 | }
110 |
111 | sender.PointerPressed += OnPointerPressed;
112 | sender.PointerReleased += OnPointerReleased;
113 | sender.PointerEntered += OnPointerEntered;
114 | sender.PointerExited += OnPointerExited;
115 | sender.PointerCanceled += OnPointerCanceled;
116 | }
117 | else
118 | {
119 | if (string.IsNullOrEmpty(targetName))
120 | {
121 | RemoveAnimations(sender);
122 | }
123 |
124 | sender.PointerPressed -= OnPointerPressed;
125 | sender.PointerReleased -= OnPointerReleased;
126 | sender.PointerEntered -= OnPointerEntered;
127 | sender.PointerExited -= OnPointerExited;
128 | sender.PointerCanceled -= OnPointerCanceled;
129 | }
130 |
131 | }
132 | }
133 | }));
134 |
135 | private static void OnPointerCanceled(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
136 | {
137 | var test = sender as FrameworkElement;
138 | var target = GetTarget(test);
139 |
140 | if (test != null && target != null)
141 | {
142 | var rect = new Rect(0, 0, test.ActualWidth, test.ActualHeight);
143 | var cp = e.GetCurrentPoint(test);
144 |
145 | if (rect.Contains(cp.Position))
146 | {
147 | ElementCompositionPreview.GetElementVisual(target).Scale = HoverScale;
148 | }
149 | else
150 | {
151 | ElementCompositionPreview.GetElementVisual(target).Scale = Vector3.One;
152 | }
153 | }
154 | }
155 |
156 | private static void OnPointerExited(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
157 | {
158 | var test = sender as FrameworkElement;
159 | var target = GetTarget(test);
160 | if (test != null && target != null)
161 | {
162 | ElementCompositionPreview.GetElementVisual(target).Scale = Vector3.One;
163 | }
164 | }
165 |
166 | private static void OnPointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
167 | {
168 | var test = sender as FrameworkElement;
169 | var target = GetTarget(test);
170 | if (test != null && target != null)
171 | {
172 | ElementCompositionPreview.GetElementVisual(target).Scale = HoverScale;
173 | }
174 | }
175 |
176 | private static void OnPointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
177 | {
178 | var test = sender as FrameworkElement;
179 | var target = GetTarget(test);
180 |
181 | if (test != null && target != null)
182 | {
183 | var rect = new Rect(0, 0, test.ActualWidth, test.ActualHeight);
184 | var cp = e.GetCurrentPoint(test);
185 |
186 | if (rect.Contains(cp.Position))
187 | {
188 | ElementCompositionPreview.GetElementVisual(target).Scale = HoverScale;
189 | }
190 | else
191 | {
192 | ElementCompositionPreview.GetElementVisual(target).Scale = Vector3.One;
193 | }
194 | }
195 | }
196 |
197 | private static void OnPointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
198 | {
199 | var test = sender as FrameworkElement;
200 | var target = GetTarget(test);
201 | if (test != null && target != null)
202 | {
203 | ElementCompositionPreview.GetElementVisual(target).Scale = ActionScale;
204 | }
205 | }
206 |
207 | private static FrameworkElement GetTarget(FrameworkElement sender)
208 | {
209 | if (sender == null) return null;
210 |
211 | var targetName = GetTargetElementName(sender);
212 | var target = sender;
213 | if (!string.IsNullOrEmpty(targetName))
214 | {
215 | target = sender.FindName(targetName) as FrameworkElement;
216 | }
217 |
218 | return target;
219 | }
220 |
221 | private static void AddAnimations(FrameworkElement element)
222 | {
223 | if (element == null) return;
224 | var visual = ElementCompositionPreview.GetElementVisual(element);
225 | var compositor = visual.Compositor;
226 |
227 | var centerPointBind = compositor.CreateExpressionAnimation("Vector3(this.Target.Size.X / 2, this.Target.Size.Y / 2, 0f)");
228 | visual.StartAnimation("CenterPoint", centerPointBind);
229 |
230 | var imp = compositor.CreateImplicitAnimationCollection();
231 |
232 | var scaleAnimation = compositor.CreateVector3KeyFrameAnimation();
233 | scaleAnimation.InsertExpressionKeyFrame(1f, "this.FinalValue");
234 | scaleAnimation.Duration = TimeSpan.FromSeconds(0.2d);
235 | scaleAnimation.Target = "Scale";
236 | imp["Scale"] = scaleAnimation;
237 |
238 | visual.ImplicitAnimations = imp;
239 | }
240 |
241 | private static void RemoveAnimations(FrameworkElement element)
242 | {
243 | if (element == null) return;
244 | var visual = ElementCompositionPreview.GetElementVisual(element);
245 | visual.ImplicitAnimations = null;
246 | visual.StopAnimation("Scale");
247 | visual.StopAnimation("CenterPoint");
248 | visual.CenterPoint = Vector3.Zero;
249 | visual.Scale = Vector3.One;
250 | }
251 | }
252 | }
253 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Interaction/ActionButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml;
7 | using Windows.UI.Xaml.Controls;
8 | using Windows.UI.Xaml.Controls.Primitives;
9 |
10 | namespace Richasy.Controls.UWP.Interaction
11 | {
12 | public class ActionButton:ExtraButton
13 | {
14 | public ActionButton()
15 | {
16 | this.DefaultStyleKey = typeof(ActionButton);
17 | }
18 |
19 | public IconElement Icon
20 | {
21 | get { return (IconElement)GetValue(IconProperty); }
22 | set { SetValue(IconProperty, value); }
23 | }
24 |
25 | // Using a DependencyProperty as the backing store for Icon. This enables animation, styling, binding, etc...
26 | public static readonly DependencyProperty IconProperty =
27 | DependencyProperty.Register("Icon", typeof(IconElement), typeof(ActionButton), new PropertyMetadata(null));
28 |
29 | public double Diameter
30 | {
31 | get { return (double)GetValue(DiameterProperty); }
32 | set { SetValue(DiameterProperty, value); }
33 | }
34 |
35 | // Using a DependencyProperty as the backing store for Diameter. This enables animation, styling, binding, etc...
36 | public static readonly DependencyProperty DiameterProperty =
37 | DependencyProperty.Register("Diameter", typeof(double), typeof(ActionButton), new PropertyMetadata(double.NaN,new PropertyChangedCallback(Diameter_Changed)));
38 |
39 | private static void Diameter_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
40 | {
41 | if(e.NewValue!=null && e.NewValue is double meter)
42 | {
43 | var instance = d as ActionButton;
44 | instance.Width = instance.Height = meter;
45 | instance.CornerRadius = new CornerRadius(meter / 2.0);
46 | }
47 | }
48 |
49 | public bool IsLoading
50 | {
51 | get { return (bool)GetValue(IsLoadingProperty); }
52 | set { SetValue(IsLoadingProperty, value); }
53 | }
54 |
55 | // Using a DependencyProperty as the backing store for IsLoading. This enables animation, styling, binding, etc...
56 | public static readonly DependencyProperty IsLoadingProperty =
57 | DependencyProperty.Register("IsLoading", typeof(bool), typeof(ActionButton), new PropertyMetadata(false,new PropertyChangedCallback(IsLoading_Changed)));
58 |
59 | private static void IsLoading_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
60 | {
61 | if(e.NewValue is bool isLoading)
62 | {
63 | var instance = d as ActionButton;
64 | instance.IsEnabled = !isLoading;
65 | if (isLoading)
66 | {
67 | VisualStateManager.GoToState(instance, "Loading", true);
68 | }
69 | else
70 | {
71 | VisualStateManager.GoToState(instance, "Default", true);
72 | }
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Interaction/ExtraButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI;
7 | using Windows.UI.Xaml;
8 | using Windows.UI.Xaml.Controls;
9 | using Windows.UI.Xaml.Media;
10 |
11 | namespace Richasy.Controls.UWP.Interaction
12 | {
13 | public class ExtraButton:Button
14 | {
15 | public ExtraButton()
16 | {
17 | this.DefaultStyleKey = typeof(ExtraButton);
18 | }
19 | public Brush PointerOverBackground
20 | {
21 | get { return (Brush)GetValue(PointerOverBackgroundProperty); }
22 | set { SetValue(PointerOverBackgroundProperty, value); }
23 | }
24 | public static readonly DependencyProperty PointerOverBackgroundProperty =
25 | DependencyProperty.Register("PointerOverBackground", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
26 |
27 | public Brush PointerOverForeground
28 | {
29 | get { return (Brush)GetValue(PointerOverForegroundProperty); }
30 | set { SetValue(PointerOverForegroundProperty, value); }
31 | }
32 |
33 | public static readonly DependencyProperty PointerOverForegroundProperty =
34 | DependencyProperty.Register("PointerOverForeground", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
35 |
36 | public Brush PointerOverBorderBrush
37 | {
38 | get { return (Brush)GetValue(PointerOverBorderBrushProperty); }
39 | set { SetValue(PointerOverBorderBrushProperty, value); }
40 | }
41 | public static readonly DependencyProperty PointerOverBorderBrushProperty =
42 | DependencyProperty.Register("PointerOverBorderBrush", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
43 |
44 | public Brush PressBackground
45 | {
46 | get { return (Brush)GetValue(PressBackgroundProperty); }
47 | set { SetValue(PressBackgroundProperty, value); }
48 | }
49 | public static readonly DependencyProperty PressBackgroundProperty =
50 | DependencyProperty.Register("PressBackground", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
51 |
52 | public Brush PressForeground
53 | {
54 | get { return (Brush)GetValue(PressForegroundProperty); }
55 | set { SetValue(PressForegroundProperty, value); }
56 | }
57 |
58 | public static readonly DependencyProperty PressForegroundProperty =
59 | DependencyProperty.Register("PressForeground", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
60 | public Brush PressBorderBrush
61 | {
62 | get { return (Brush)GetValue(PressBorderBrushProperty); }
63 | set { SetValue(PressBorderBrushProperty, value); }
64 | }
65 |
66 | public static readonly DependencyProperty PressBorderBrushProperty =
67 | DependencyProperty.Register("PressBorderBrush", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
68 |
69 | public Brush DisabledBackground
70 | {
71 | get { return (Brush)GetValue(DisabledBackgroundProperty); }
72 | set { SetValue(DisabledBackgroundProperty, value); }
73 | }
74 | public static readonly DependencyProperty DisabledBackgroundProperty =
75 | DependencyProperty.Register("DisabledBackground", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
76 |
77 | public Brush DisabledForeground
78 | {
79 | get { return (Brush)GetValue(DisabledForegroundProperty); }
80 | set { SetValue(DisabledForegroundProperty, value); }
81 | }
82 |
83 | public static readonly DependencyProperty DisabledForegroundProperty =
84 | DependencyProperty.Register("DisabledForeground", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
85 |
86 | public Brush DisabledBorderBrush
87 | {
88 | get { return (Brush)GetValue(DisabledBorderBrushProperty); }
89 | set { SetValue(DisabledBorderBrushProperty, value); }
90 | }
91 | public static readonly DependencyProperty DisabledBorderBrushProperty =
92 | DependencyProperty.Register("DisabledBorderBrush", typeof(Brush), typeof(ExtraButton), new PropertyMetadata(null));
93 |
94 |
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Interaction/ExtraTextBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml;
7 | using Windows.UI.Xaml.Controls;
8 | using Windows.UI.Xaml.Media;
9 |
10 | namespace Richasy.Controls.UWP.Interaction
11 | {
12 | public class ExtraTextBox : TextBox
13 | {
14 | public ExtraTextBox()
15 | {
16 | this.DefaultStyleKey = typeof(ExtraTextBox);
17 | }
18 | public Brush PointerOverBackground
19 | {
20 | get { return (Brush)GetValue(PointerOverBackgroundProperty); }
21 | set { SetValue(PointerOverBackgroundProperty, value); }
22 | }
23 | public static readonly DependencyProperty PointerOverBackgroundProperty =
24 | DependencyProperty.Register("PointerOverBackground", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
25 |
26 | public Brush PointerOverForeground
27 | {
28 | get { return (Brush)GetValue(PointerOverForegroundProperty); }
29 | set { SetValue(PointerOverForegroundProperty, value); }
30 | }
31 |
32 | public static readonly DependencyProperty PointerOverForegroundProperty =
33 | DependencyProperty.Register("PointerOverForeground", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
34 |
35 | public Brush PointerOverBorderBrush
36 | {
37 | get { return (Brush)GetValue(PointerOverBorderBrushProperty); }
38 | set { SetValue(PointerOverBorderBrushProperty, value); }
39 | }
40 | public static readonly DependencyProperty PointerOverBorderBrushProperty =
41 | DependencyProperty.Register("PointerOverBorderBrush", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
42 |
43 | public Brush DisabledBackground
44 | {
45 | get { return (Brush)GetValue(DisabledBackgroundProperty); }
46 | set { SetValue(DisabledBackgroundProperty, value); }
47 | }
48 | public static readonly DependencyProperty DisabledBackgroundProperty =
49 | DependencyProperty.Register("DisabledBackground", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
50 |
51 | public Brush DisabledForeground
52 | {
53 | get { return (Brush)GetValue(DisabledForegroundProperty); }
54 | set { SetValue(DisabledForegroundProperty, value); }
55 | }
56 |
57 | public static readonly DependencyProperty DisabledForegroundProperty =
58 | DependencyProperty.Register("DisabledForeground", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
59 |
60 | public Brush DisabledBorderBrush
61 | {
62 | get { return (Brush)GetValue(DisabledBorderBrushProperty); }
63 | set { SetValue(DisabledBorderBrushProperty, value); }
64 | }
65 | public static readonly DependencyProperty DisabledBorderBrushProperty =
66 | DependencyProperty.Register("DisabledBorderBrush", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
67 |
68 | public Brush FocusBackground
69 | {
70 | get { return (Brush)GetValue(FocusBackgroundProperty); }
71 | set { SetValue(FocusBackgroundProperty, value); }
72 | }
73 |
74 | // Using a DependencyProperty as the backing store for FocusBackground. This enables animation, styling, binding, etc...
75 | public static readonly DependencyProperty FocusBackgroundProperty =
76 | DependencyProperty.Register("FocusBackground", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
77 |
78 | public Brush FocusForeground
79 | {
80 | get { return (Brush)GetValue(FocusForegroundProperty); }
81 | set { SetValue(FocusForegroundProperty, value); }
82 | }
83 |
84 | // Using a DependencyProperty as the backing store for FocusForeground. This enables animation, styling, binding, etc...
85 | public static readonly DependencyProperty FocusForegroundProperty =
86 | DependencyProperty.Register("FocusForeground", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
87 |
88 | public Brush FocusBorderBrush
89 | {
90 | get { return (Brush)GetValue(FocusBorderBrushProperty); }
91 | set { SetValue(FocusBorderBrushProperty, value); }
92 | }
93 |
94 | // Using a DependencyProperty as the backing store for FocusBorderBrush. This enables animation, styling, binding, etc...
95 | public static readonly DependencyProperty FocusBorderBrushProperty =
96 | DependencyProperty.Register("FocusBorderBrush", typeof(Brush), typeof(ExtraTextBox), new PropertyMetadata(null));
97 |
98 | public ElementTheme FocusTheme
99 | {
100 | get { return (ElementTheme)GetValue(FocusThemeProperty); }
101 | set { SetValue(FocusThemeProperty, value); }
102 | }
103 |
104 | // Using a DependencyProperty as the backing store for FocusRequestTheme. This enables animation, styling, binding, etc...
105 | public static readonly DependencyProperty FocusThemeProperty =
106 | DependencyProperty.Register("FocusTheme", typeof(ElementTheme), typeof(ExtraTextBox), new PropertyMetadata(ElementTheme.Light));
107 |
108 |
109 | ///
110 | /// 类型是ActionButton
111 | ///
112 | public Style DeleteButtonStyle
113 | {
114 | get { return (Style)GetValue(DeleteButtonStyleProperty); }
115 | set { SetValue(DeleteButtonStyleProperty, value); }
116 | }
117 |
118 | // Using a DependencyProperty as the backing store for DeleteButtonStyle. This enables animation, styling, binding, etc...
119 | public static readonly DependencyProperty DeleteButtonStyleProperty =
120 | DependencyProperty.Register("DeleteButtonStyle", typeof(Style), typeof(ExtraTextBox), new PropertyMetadata(null));
121 |
122 |
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Interaction/IconButton/IconButton.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
27 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Interaction/IconButton/IconButton.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.Foundation;
7 | using Windows.Foundation.Collections;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Controls.Primitives;
11 | using Windows.UI.Xaml.Data;
12 | using Windows.UI.Xaml.Input;
13 | using Windows.UI.Xaml.Media;
14 | using Windows.UI.Xaml.Navigation;
15 |
16 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
17 |
18 | namespace Richasy.Controls.UWP.Interaction
19 | {
20 | public sealed partial class IconButton : ExtraButton
21 | {
22 | public IconButton()
23 | {
24 | this.InitializeComponent();
25 | }
26 |
27 |
28 |
29 | public IconElement Icon
30 | {
31 | get { return (IconElement)GetValue(IconProperty); }
32 | set { SetValue(IconProperty, value); }
33 | }
34 |
35 | // Using a DependencyProperty as the backing store for Icon. This enables animation, styling, binding, etc...
36 | public static readonly DependencyProperty IconProperty =
37 | DependencyProperty.Register("Icon", typeof(IconElement), typeof(IconButton), new PropertyMetadata(null,new PropertyChangedCallback(Icon_Changed)));
38 |
39 |
40 | private static void Icon_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
41 | {
42 | var instance = d as IconButton;
43 | if (e.NewValue != null && e.NewValue is IconElement icon)
44 | {
45 | instance.IconBlock.Visibility = Visibility.Visible;
46 | }
47 | else
48 | {
49 | instance.IconBlock.Visibility = Visibility.Collapsed;
50 | }
51 | }
52 |
53 |
54 | public string Text
55 | {
56 | get { return (string)GetValue(TextProperty); }
57 | set { SetValue(TextProperty, value); }
58 | }
59 |
60 | // Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
61 | public static readonly DependencyProperty TextProperty =
62 | DependencyProperty.Register("Text", typeof(string), typeof(IconButton), new PropertyMetadata(""));
63 |
64 |
65 | public bool IsLoading
66 | {
67 | get { return (bool)GetValue(IsLoadingProperty); }
68 | set { SetValue(IsLoadingProperty, value); }
69 | }
70 |
71 | // Using a DependencyProperty as the backing store for IsLoading. This enables animation, styling, binding, etc...
72 | public static readonly DependencyProperty IsLoadingProperty =
73 | DependencyProperty.Register("IsLoading", typeof(bool), typeof(IconButton), new PropertyMetadata(false, new PropertyChangedCallback(IsLoading_Changed)));
74 |
75 | private static void IsLoading_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
76 | {
77 | var instance = d as IconButton;
78 | if (e.NewValue != e.OldValue && e.NewValue is bool isload)
79 | {
80 | if (isload)
81 | {
82 | instance.IsEnabled = false;
83 | instance.IconBlock.Visibility = Visibility.Collapsed;
84 | instance.LoadingRing.Visibility = Visibility.Visible;
85 | }
86 | else
87 | {
88 | instance.IsEnabled = true;
89 | instance.LoadingRing.Visibility = Visibility.Collapsed;
90 | if (instance.Icon!=null)
91 | instance.IconBlock.Visibility = Visibility.Visible;
92 | }
93 | }
94 | }
95 |
96 | public double GutterWidth
97 | {
98 | get { return (double)GetValue(GutterWidthProperty); }
99 | set { SetValue(GutterWidthProperty, value); }
100 | }
101 |
102 | // Using a DependencyProperty as the backing store for GutterWidth. This enables animation, styling, binding, etc...
103 | public static readonly DependencyProperty GutterWidthProperty =
104 | DependencyProperty.Register("GutterWidth", typeof(double), typeof(IconButton), new PropertyMetadata(6.0,new PropertyChangedCallback(GutterWidth_Changed)));
105 |
106 | private static void GutterWidth_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
107 | {
108 | if (e.NewValue != null && e.NewValue is double width)
109 | {
110 | var instance = d as IconButton;
111 | instance.IconBlock.Margin = new Thickness(0, 0, width, 0);
112 | instance.LoadingRing.Margin= new Thickness(0, 0, width, 0);
113 | }
114 | }
115 |
116 | public Style TextStyle
117 | {
118 | get { return (Style)GetValue(TextStyleProperty); }
119 | set { SetValue(TextStyleProperty, value); }
120 | }
121 |
122 | // Using a DependencyProperty as the backing store for TextStyle. This enables animation, styling, binding, etc...
123 | public static readonly DependencyProperty TextStyleProperty =
124 | DependencyProperty.Register("TextStyle", typeof(Style), typeof(IconButton), new PropertyMetadata(null,new PropertyChangedCallback(TextStyle_Changed)));
125 |
126 | private static void TextStyle_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
127 | {
128 | if (e.NewValue != null && e.NewValue is Style style)
129 | {
130 | var instance = d as IconButton;
131 | instance.NameTextBlock.Style = style;
132 | }
133 | }
134 |
135 | public Style ProgressRingStyle
136 | {
137 | get { return (Style)GetValue(ProgressRingStyleProperty); }
138 | set { SetValue(ProgressRingStyleProperty, value); }
139 | }
140 |
141 | // Using a DependencyProperty as the backing store for ProgressRingStyle. This enables animation, styling, binding, etc...
142 | public static readonly DependencyProperty ProgressRingStyleProperty =
143 | DependencyProperty.Register("ProgressRingStyle", typeof(Style), typeof(IconButton), new PropertyMetadata(null));
144 |
145 |
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Interaction/NumberBox/NumberBox.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
51 |
52 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/CustomGridView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml.Controls;
7 |
8 | namespace Richasy.Controls.UWP.Layout
9 | {
10 | public class CustomGridView:GridView
11 | {
12 | private ScrollViewer _scrollViewer;
13 | public CustomGridView()
14 | {
15 | this.DefaultStyleKey = typeof(GridView);
16 | }
17 | public event EventHandler ViewChanged;
18 | public event EventHandler ArriveBottom;
19 | protected override void OnApplyTemplate()
20 | {
21 | _scrollViewer = GetTemplateChild("ScrollViewer") as ScrollViewer;
22 | if (_scrollViewer != null)
23 | _scrollViewer.ViewChanged += ScrollViewer_ViewChanged;
24 | base.OnApplyTemplate();
25 | }
26 |
27 | private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
28 | {
29 | if (_scrollViewer.ExtentHeight - _scrollViewer.ViewportHeight - _scrollViewer.VerticalOffset < 10)
30 | {
31 | ArriveBottom?.Invoke(sender, EventArgs.Empty);
32 | }
33 | ViewChanged?.Invoke(sender, e);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/CustomListView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml.Controls;
7 |
8 | namespace Richasy.Controls.UWP.Layout
9 | {
10 | public class CustomListView : ListView
11 | {
12 | private ScrollViewer _scrollViewer;
13 | public CustomListView()
14 | {
15 | this.DefaultStyleKey = typeof(ListView);
16 | }
17 | public event EventHandler ViewChanged;
18 | public event EventHandler ArriveBottom;
19 | protected override void OnApplyTemplate()
20 | {
21 | _scrollViewer = GetTemplateChild("ScrollViewer") as ScrollViewer;
22 | if (_scrollViewer != null)
23 | _scrollViewer.ViewChanged += ScrollViewer_ViewChanged;
24 | base.OnApplyTemplate();
25 | }
26 |
27 | private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
28 | {
29 | if (_scrollViewer.ExtentHeight - _scrollViewer.ViewportHeight - _scrollViewer.VerticalOffset < 10)
30 | {
31 | ArriveBottom?.Invoke(sender, EventArgs.Empty);
32 | }
33 | ViewChanged?.Invoke(sender, e);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/MenuListView/MenuListView.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/MenuListView/MenuListView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Extensions;
2 | using Richasy.Controls.UWP.Models.UI;
3 | using System;
4 | using System.Collections;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Runtime.InteropServices.WindowsRuntime;
9 | using Windows.Foundation;
10 | using Windows.Foundation.Collections;
11 | using Windows.UI.Xaml;
12 | using Windows.UI.Xaml.Controls;
13 | using Windows.UI.Xaml.Controls.Primitives;
14 | using Windows.UI.Xaml.Data;
15 | using Windows.UI.Xaml.Input;
16 | using Windows.UI.Xaml.Media;
17 | using Windows.UI.Xaml.Navigation;
18 |
19 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
20 |
21 | namespace Richasy.Controls.UWP.Layout
22 | {
23 | public sealed partial class MenuListView : UserControl
24 | {
25 | private NavigateItemBase _selectedItem;
26 | public NavigateItemBase SelectedItem
27 | {
28 | get => _selectedItem;
29 | set
30 | {
31 | _selectedItem = value;
32 | MenuView.SelectedItem = value;
33 | SelectedItemChanged?.Invoke(this, value);
34 | }
35 | }
36 | public MenuListView()
37 | {
38 | this.InitializeComponent();
39 | }
40 |
41 | public event EventHandler SelectedItemChanged;
42 |
43 | private void MenuView_ItemClick(object sender, ItemClickEventArgs e)
44 | {
45 | if (!e.ClickedItem.Equals(SelectedItem))
46 | {
47 | if (ItemsSource != null)
48 | {
49 | foreach (var item in ItemsSource)
50 | {
51 | (item as NavigateItemBase).IsSelected = item.Equals(e.ClickedItem);
52 | }
53 | }
54 | SelectedItem = e.ClickedItem as NavigateItemBase;
55 | }
56 | }
57 |
58 | public ICollection ItemsSource
59 | {
60 | get { return (ICollection)GetValue(ItemsSourceProperty); }
61 | set { SetValue(ItemsSourceProperty, value); }
62 | }
63 |
64 | // Using a DependencyProperty as the backing store for ItemsSource. This enables animation, styling, binding, etc...
65 | public static readonly DependencyProperty ItemsSourceProperty =
66 | DependencyProperty.Register("ItemsSource", typeof(ICollection), typeof(MenuListView), new PropertyMetadata(null));
67 |
68 | public DataTemplate ItemWideTemplate
69 | {
70 | get { return (DataTemplate)GetValue(ItemWideTemplateProperty); }
71 | set { SetValue(ItemWideTemplateProperty, value); }
72 | }
73 |
74 | // Using a DependencyProperty as the backing store for ItemTemplate. This enables animation, styling, binding, etc...
75 | public static readonly DependencyProperty ItemWideTemplateProperty =
76 | DependencyProperty.Register("ItemWideTemplate", typeof(DataTemplate), typeof(MenuListView), new PropertyMetadata(null));
77 |
78 |
79 | public DataTemplate ItemNarrowTemplate
80 | {
81 | get { return (DataTemplate)GetValue(ItemNarrowTemplateProperty); }
82 | set { SetValue(ItemNarrowTemplateProperty, value); }
83 | }
84 |
85 | // Using a DependencyProperty as the backing store for ItemNarrowTemplate. This enables animation, styling, binding, etc...
86 | public static readonly DependencyProperty ItemNarrowTemplateProperty =
87 | DependencyProperty.Register("ItemNarrowTemplate", typeof(DataTemplate), typeof(MenuListView), new PropertyMetadata(null));
88 |
89 |
90 |
91 | public Style ListViewStyle
92 | {
93 | get { return (Style)GetValue(ListViewStyleProperty); }
94 | set { SetValue(ListViewStyleProperty, value); }
95 | }
96 |
97 | // Using a DependencyProperty as the backing store for ListViewStyle. This enables animation, styling, binding, etc...
98 | public static readonly DependencyProperty ListViewStyleProperty =
99 | DependencyProperty.Register("ListViewStyle", typeof(Style), typeof(MenuListView), new PropertyMetadata(null));
100 |
101 | public string SignName
102 | {
103 | get { return (string)GetValue(SignNameProperty); }
104 | set { SetValue(SignNameProperty, value); }
105 | }
106 |
107 | // Using a DependencyProperty as the backing store for SignName. This enables animation, styling, binding, etc...
108 | public static readonly DependencyProperty SignNameProperty =
109 | DependencyProperty.Register("SignName", typeof(string), typeof(MenuListView), new PropertyMetadata(null,new PropertyChangedCallback(SignName_Changed)));
110 |
111 | private static void SignName_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
112 | {
113 | if(e.NewValue!=null && e.NewValue is string signName)
114 | {
115 | var instance = d as MenuListView;
116 | var view = instance.MenuView;
117 | IndicatorExtension.SetName(view, signName);
118 | IndicatorExtension.SetIsScaleEnabled(view, true);
119 | }
120 | }
121 |
122 | public bool IsNarrow
123 | {
124 | get { return (bool)GetValue(IsNarrowProperty); }
125 | set { SetValue(IsNarrowProperty, value); }
126 | }
127 |
128 | // Using a DependencyProperty as the backing store for IsNarrow. This enables animation, styling, binding, etc...
129 | public static readonly DependencyProperty IsNarrowProperty =
130 | DependencyProperty.Register("IsNarrow", typeof(bool), typeof(MenuListView), new PropertyMetadata(false,new PropertyChangedCallback(IsNarrow_Changed)));
131 |
132 | private static void IsNarrow_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
133 | {
134 | if(e.NewValue is bool isNarrow)
135 | {
136 | var instance = d as MenuListView;
137 | instance.MenuView.ItemTemplate = isNarrow ? instance.ItemNarrowTemplate : instance.ItemWideTemplate;
138 | }
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/ThreeStageView/ThreeStageView.Navigate.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Models.Event;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Windows.UI.Core;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Media.Animation;
11 |
12 | namespace Richasy.Controls.UWP.Layout
13 | {
14 | public partial class ThreeStageView
15 | {
16 | public List> NavigateFrameHistoryList = new List>();
17 |
18 | public event CancelEventHandler BeforeBack;
19 | public event EventHandler AfterBack;
20 |
21 | private void OnBackrequested(object sender, BackRequestedEventArgs e)
22 | {
23 | // 判断应用当前是否有页面可以回退,没有则继续冒泡
24 | bool result = Back();
25 | if (result)
26 | e.Handled = true;
27 | }
28 | public void NavigateToPage(Type type, object parameter = null, bool isBack = false, NavigationTransitionInfo transitionInfo = null)
29 | {
30 | if (SubSplitView.DisplayMode == SplitViewDisplayMode.CompactOverlay)
31 | IsSubPaneOpen = false;
32 | var last = NavigateFrameHistoryList.LastOrDefault();
33 | bool isRepeat = false;
34 | if (last != null && last.Item1 == type && last.Item2 == parameter)
35 | isRepeat = true;
36 | if (type != null)
37 | {
38 | if (transitionInfo == null)
39 | {
40 | if (isBack)
41 | transitionInfo = new EntranceNavigationTransitionInfo();
42 | else
43 | transitionInfo = new DrillInNavigationTransitionInfo();
44 | }
45 | NavigateFrame.Navigate(type, parameter, transitionInfo);
46 | if (!isBack)
47 | {
48 | if (!isRepeat)
49 | {
50 | NavigateFrameHistoryList.Add(new Tuple(type, parameter));
51 | }
52 | if (NavigateFrameHistoryList.Count > 1)
53 | {
54 | CanGoBack = true;
55 | }
56 | }
57 | }
58 | }
59 | public void ClearCache()
60 | {
61 | var cacheSize = NavigateFrame.CacheSize;
62 | NavigateFrame.CacheSize = 0;
63 | NavigateFrame.CacheSize = cacheSize;
64 | }
65 |
66 | public bool Back()
67 | {
68 | bool hasHistory = NavigateFrameHistoryList.Count <= 1;
69 | var beforeArgs = new BeforeBackEventArgs(false, IsSubPaneOpen);
70 |
71 | int c = NavigateFrameHistoryList.Count - 2;
72 | var last = hasHistory ? NavigateFrameHistoryList[c] : null;
73 |
74 | if (hasHistory)
75 | {
76 | beforeArgs.NavigatePreviousType = last.Item1;
77 | beforeArgs.NavigatePreviousParameter = last.Item2;
78 | }
79 |
80 | BeforeBack?.Invoke(this, beforeArgs);
81 |
82 | if (!beforeArgs.Cancel)
83 | {
84 | if (!hasHistory)
85 | return false;
86 | NavigateFrameHistoryList.RemoveAt(NavigateFrameHistoryList.Count - 1);
87 | if (NavigateFrameHistoryList.Count <= 1)
88 | {
89 | CanGoBack = false;
90 | }
91 | NavigateToPage(last.Item1, last.Item2, true);
92 | var afterArgs = new AfterBackEventArgs();
93 | afterArgs.NavigatePreviousType = last.Item1;
94 | afterArgs.NavigatePreviousParameter = last.Item2;
95 | AfterBack?.Invoke(this, afterArgs);
96 | }
97 | return true;
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/ThreeStageView/ThreeStageView.Properties.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Models.Event;
2 | using System;
3 | using Windows.UI.Xaml;
4 | using Windows.UI.Xaml.Media;
5 |
6 | namespace Richasy.Controls.UWP.Layout
7 | {
8 | public partial class ThreeStageView
9 | {
10 | public event EventHandler AppPaneStateChanged;
11 | public event EventHandler SubPaneStateChanged;
12 | public object AppPane
13 | {
14 | get { return (object)GetValue(AppPaneProperty); }
15 | set { SetValue(AppPaneProperty, value); }
16 | }
17 |
18 | // Using a DependencyProperty as the backing store for AppPane. This enables animation, styling, binding, etc...
19 | public static readonly DependencyProperty AppPaneProperty =
20 | DependencyProperty.Register("AppPane", typeof(object), typeof(ThreeStageView), new PropertyMetadata(null));
21 |
22 | public object SubPane
23 | {
24 | get { return (object)GetValue(SubPaneProperty); }
25 | set { SetValue(SubPaneProperty, value); }
26 | }
27 |
28 | // Using a DependencyProperty as the backing store for SubPane. This enables animation, styling, binding, etc...
29 | public static readonly DependencyProperty SubPaneProperty =
30 | DependencyProperty.Register("SubPane", typeof(object), typeof(ThreeStageView), new PropertyMetadata(null));
31 |
32 | public Brush AppPaneBackground
33 | {
34 | get { return (Brush)GetValue(AppPaneBackgroundProperty); }
35 | set { SetValue(AppPaneBackgroundProperty, value); }
36 | }
37 |
38 | // Using a DependencyProperty as the backing store for AppPaneBackground. This enables animation, styling, binding, etc...
39 | public static readonly DependencyProperty AppPaneBackgroundProperty =
40 | DependencyProperty.Register("AppPaneBackground", typeof(Brush), typeof(ThreeStageView), new PropertyMetadata(null));
41 |
42 | public Brush SubPaneBackground
43 | {
44 | get { return (Brush)GetValue(SubPaneBackgroundProperty); }
45 | set { SetValue(SubPaneBackgroundProperty, value); }
46 | }
47 |
48 | // Using a DependencyProperty as the backing store for SubPaneBackground. This enables animation, styling, binding, etc...
49 | public static readonly DependencyProperty SubPaneBackgroundProperty =
50 | DependencyProperty.Register("SubPaneBackground", typeof(Brush), typeof(ThreeStageView), new PropertyMetadata(null));
51 |
52 | public Brush PageBackground
53 | {
54 | get { return (Brush)GetValue(PageBackgroundProperty); }
55 | set { SetValue(PageBackgroundProperty, value); }
56 | }
57 |
58 | // Using a DependencyProperty as the backing store for PageBackground. This enables animation, styling, binding, etc...
59 | public static readonly DependencyProperty PageBackgroundProperty =
60 | DependencyProperty.Register("PageBackground", typeof(Brush), typeof(ThreeStageView), new PropertyMetadata(null));
61 |
62 |
63 |
64 | public double AppPaneOpenLength
65 | {
66 | get { return (double)GetValue(AppPaneOpenLengthProperty); }
67 | set { SetValue(AppPaneOpenLengthProperty, value); }
68 | }
69 |
70 | // Using a DependencyProperty as the backing store for AppPaneOpenLength. This enables animation, styling, binding, etc...
71 | public static readonly DependencyProperty AppPaneOpenLengthProperty =
72 | DependencyProperty.Register("AppPaneOpenLength", typeof(double), typeof(ThreeStageView), new PropertyMetadata(310.0));
73 |
74 | public double AppPaneCompactWidth
75 | {
76 | get { return (double)GetValue(AppPaneCompactWidthProperty); }
77 | set { SetValue(AppPaneCompactWidthProperty, value); }
78 | }
79 |
80 | // Using a DependencyProperty as the backing store for AppPaneCompactWidth. This enables animation, styling, binding, etc...
81 | public static readonly DependencyProperty AppPaneCompactWidthProperty =
82 | DependencyProperty.Register("AppPaneCompactWidth", typeof(double), typeof(ThreeStageView), new PropertyMetadata(80.0));
83 |
84 | public double SubPaneOpenWidth
85 | {
86 | get { return (double)GetValue(SubPaneOpenWidthProperty); }
87 | set { SetValue(SubPaneOpenWidthProperty, value); }
88 | }
89 |
90 | // Using a DependencyProperty as the backing store for SubPaneOpenWidth. This enables animation, styling, binding, etc...
91 | public static readonly DependencyProperty SubPaneOpenWidthProperty =
92 | DependencyProperty.Register("SubPaneOpenWidth", typeof(double), typeof(ThreeStageView), new PropertyMetadata(400.0));
93 |
94 | public double SubPaneCompactWidth
95 | {
96 | get { return (double)GetValue(SubPaneCompactWidthProperty); }
97 | set { SetValue(SubPaneCompactWidthProperty, value); }
98 | }
99 |
100 | // Using a DependencyProperty as the backing store for SubPaneCompactWidth. This enables animation, styling, binding, etc...
101 | public static readonly DependencyProperty SubPaneCompactWidthProperty =
102 | DependencyProperty.Register("SubPaneCompactWidth", typeof(double), typeof(ThreeStageView), new PropertyMetadata(0.0));
103 |
104 | public bool IsAppPaneOpen
105 | {
106 | get { return (bool)GetValue(IsAppPaneOpenProperty); }
107 | set { SetValue(IsAppPaneOpenProperty, value); }
108 | }
109 |
110 | // Using a DependencyProperty as the backing store for IsAppPaneOpen. This enables animation, styling, binding, etc...
111 | public static readonly DependencyProperty IsAppPaneOpenProperty =
112 | DependencyProperty.Register("IsAppPaneOpen", typeof(bool), typeof(ThreeStageView), new PropertyMetadata(true,new PropertyChangedCallback(IsAppPaneOpen_Changed)));
113 |
114 | private static void IsAppPaneOpen_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
115 | {
116 | if(e.NewValue is bool isopen && e.NewValue != e.OldValue)
117 | {
118 | var instance = d as ThreeStageView;
119 | instance.AppPaneStateChanged?.Invoke(instance, new PaneStateChangedEventArgs(isopen));
120 | }
121 | }
122 |
123 | public bool IsSubPaneOpen
124 | {
125 | get { return (bool)GetValue(IsSubPaneOpenProperty); }
126 | set { SetValue(IsSubPaneOpenProperty, value); }
127 | }
128 |
129 | // Using a DependencyProperty as the backing store for IsSubPaneOpen. This enables animation, styling, binding, etc...
130 | public static readonly DependencyProperty IsSubPaneOpenProperty =
131 | DependencyProperty.Register("IsSubPaneOpen", typeof(bool), typeof(ThreeStageView), new PropertyMetadata(false,new PropertyChangedCallback(IsSubPaneOpen_Changed)));
132 | private static void IsSubPaneOpen_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
133 | {
134 | if (e.NewValue is bool isopen && e.NewValue!=e.OldValue)
135 | {
136 | var instance = d as ThreeStageView;
137 | instance.SubPaneStateChanged?.Invoke(instance, new PaneStateChangedEventArgs(isopen));
138 | }
139 | }
140 |
141 | public double ExpendStateBreakpoint
142 | {
143 | get { return (double)GetValue(ExpendStateBreakpointProperty); }
144 | set { SetValue(ExpendStateBreakpointProperty, value); }
145 | }
146 |
147 | // Using a DependencyProperty as the backing store for ExpendStateBreakpoint. This enables animation, styling, binding, etc...
148 | public static readonly DependencyProperty ExpendStateBreakpointProperty =
149 | DependencyProperty.Register("ExpendStateBreakpoint", typeof(double), typeof(ThreeStageView), new PropertyMetadata(1500.0));
150 |
151 | public double CompactStateBreakpoint
152 | {
153 | get { return (double)GetValue(CompactStateBreakpointProperty); }
154 | set { SetValue(CompactStateBreakpointProperty, value); }
155 | }
156 |
157 | // Using a DependencyProperty as the backing store for CompactStateBreakpoint. This enables animation, styling, binding, etc...
158 | public static readonly DependencyProperty CompactStateBreakpointProperty =
159 | DependencyProperty.Register("CompactStateBreakpoint", typeof(double), typeof(ThreeStageView), new PropertyMetadata(1000.0));
160 |
161 | public bool CanGoBack
162 | {
163 | get { return (bool)GetValue(CanGoBackProperty); }
164 | set { SetValue(CanGoBackProperty, value); }
165 | }
166 |
167 | // Using a DependencyProperty as the backing store for CanGoBack. This enables animation, styling, binding, etc...
168 | public static readonly DependencyProperty CanGoBackProperty =
169 | DependencyProperty.Register("CanGoBack", typeof(bool), typeof(ThreeStageView), new PropertyMetadata(false));
170 |
171 |
172 |
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/ThreeStageView/ThreeStageView.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Models.Event;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.Foundation;
7 | using Windows.UI.Core;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Data;
11 | using Windows.UI.Xaml.Documents;
12 | using Windows.UI.Xaml.Input;
13 | using Windows.UI.Xaml.Media;
14 |
15 | // The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235
16 |
17 | namespace Richasy.Controls.UWP.Layout
18 | {
19 | [TemplatePart(Name = NavigateFrameName,Type = typeof(Frame))]
20 | [TemplatePart(Name = AppSplitViewName, Type = typeof(SplitView))]
21 | [TemplatePart(Name = SubSplitViewName, Type = typeof(SplitView))]
22 | public partial class ThreeStageView : Control
23 | {
24 | public Frame NavigateFrame;
25 | private SplitView AppSplitView;
26 | private SplitView SubSplitView;
27 |
28 | private const string NavigateFrameName = "NavigateFrame";
29 | private const string AppSplitViewName = "AppSplitView";
30 | private const string SubSplitViewName = "SubSplitView";
31 | private const string CompactStateName = "Compact";
32 | private const string DefaultStateName = "Default";
33 | private const string ExpandStateName = "Expand";
34 |
35 | public event EventHandler StageChanged;
36 |
37 | public ThreeStageView()
38 | {
39 | this.DefaultStyleKey = typeof(ThreeStageView);
40 | this.SizeChanged += ThreeStageView_SizeChanged;
41 | SystemNavigationManager.GetForCurrentView().BackRequested += OnBackrequested;
42 | }
43 | protected override void OnApplyTemplate()
44 | {
45 | NavigateFrame = GetTemplateChild(NavigateFrameName) as Frame;
46 | AppSplitView = GetTemplateChild(AppSplitViewName) as SplitView;
47 | SubSplitView = GetTemplateChild(SubSplitViewName) as SplitView;
48 | AppSplitView.PaneClosed += AppSplitView_PaneClosed;
49 | AppSplitView.PaneOpened += AppSplitView_PaneOpened;
50 | SubSplitView.PaneClosed += SubSplitView_PaneClosed;
51 | SubSplitView.PaneOpened += SubSplitView_PaneOpened;
52 | base.OnApplyTemplate();
53 | }
54 |
55 | private void SubSplitView_PaneOpened(SplitView sender, object args)
56 | {
57 | if (!IsSubPaneOpen)
58 | IsSubPaneOpen = true;
59 | }
60 |
61 | private void SubSplitView_PaneClosed(SplitView sender, object args)
62 | {
63 | if (IsSubPaneOpen)
64 | IsSubPaneOpen = false;
65 | }
66 |
67 | private void AppSplitView_PaneOpened(SplitView sender, object args)
68 | {
69 | if (!IsAppPaneOpen)
70 | IsAppPaneOpen = true;
71 | }
72 |
73 | private void AppSplitView_PaneClosed(SplitView sender, object args)
74 | {
75 | if (IsAppPaneOpen)
76 | IsAppPaneOpen = false;
77 | }
78 |
79 | private void ThreeStageView_SizeChanged(object sender, SizeChangedEventArgs e)
80 | {
81 | string prevName = GetCurrentStateName(e.PreviousSize);
82 | string currentName = GetCurrentStateName(e.NewSize);
83 | VisualStateManager.GoToState(this, currentName, false);
84 | if (prevName != currentName)
85 | {
86 | var args = new StageChangedEventArgs();
87 | args.CurrentSize = e.NewSize;
88 | args.StageName = currentName;
89 | StageChanged?.Invoke(this, args);
90 | }
91 | }
92 |
93 | private string GetCurrentStateName(Size size)
94 | {
95 | double width = size.Width;
96 | string name = "";
97 | if (width <= CompactStateBreakpoint)
98 | name = CompactStateName;
99 | else if (width < ExpendStateBreakpoint)
100 | name = DefaultStateName;
101 | else
102 | name = ExpandStateName;
103 | return name;
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Layout/ThreeStageView/ThreeStageView.xaml:
--------------------------------------------------------------------------------
1 |
5 |
60 |
61 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/Event/AfterBackEventArgs.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 Richasy.Controls.UWP.Models.Event
8 | {
9 | public class AfterBackEventArgs:EventArgs
10 | {
11 | public Type NavigatePreviousType { get; set; }
12 | public object NavigatePreviousParameter { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/Event/BeforeBackEventArgs.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 Richasy.Controls.UWP.Models.Event
9 | {
10 | public class BeforeBackEventArgs : CancelEventArgs
11 | {
12 | public bool IsSubPaneOpen { get; set; }
13 | public Type NavigatePreviousType { get; set; }
14 | public object NavigatePreviousParameter { get; set; }
15 | public BeforeBackEventArgs() : base()
16 | {
17 |
18 | }
19 | public BeforeBackEventArgs(bool isCancel, bool isSubPaneOpen) : base(isCancel)
20 | {
21 |
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/Event/PaneStateChangedEventArgs.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 Richasy.Controls.UWP.Models.Event
8 | {
9 | public class PaneStateChangedEventArgs:EventArgs
10 | {
11 | public bool IsOpen { get; set; }
12 | public PaneStateChangedEventArgs()
13 | {
14 |
15 | }
16 | public PaneStateChangedEventArgs(bool isOpen)
17 | {
18 | IsOpen = isOpen;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/Event/StageChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.Foundation;
7 |
8 | namespace Richasy.Controls.UWP.Models.Event
9 | {
10 | public class StageChangedEventArgs:EventArgs
11 | {
12 | public string StageName { get; set; }
13 | public Size CurrentSize { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/Interface/IAppBarComboBoxItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml.Controls;
7 |
8 | namespace Richasy.Controls.UWP.Models.Interface
9 | {
10 | public interface IAppBarComboBoxItem
11 | {
12 | bool IsSelected { get; set; }
13 | IconElement Icon { get; set; }
14 | string Tag { get; set; }
15 | string Text { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/Interface/ICenterPopupHeader.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 Richasy.Controls.UWP.Models.Interface
8 | {
9 | public interface ICenterPopupHeader
10 | {
11 | event EventHandler CloseButtonClick;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/UI/AppBarComboBoxItem.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Models.Interface;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Windows.UI.Xaml.Controls;
8 |
9 | namespace Richasy.Controls.UWP.Models.UI
10 | {
11 | public class AppBarComboBoxItem : NotifyPropertyBase, IAppBarComboBoxItem
12 | {
13 | public string Text { get; set; }
14 | public string Tag { get; set; }
15 | private bool _isSelected;
16 | public bool IsSelected
17 | {
18 | get => _isSelected;
19 | set => Set(ref _isSelected, value);
20 | }
21 | public IconElement Icon { get; set; }
22 | public static AppBarComboBoxItem Line = new AppBarComboBoxItem();
23 | public AppBarComboBoxItem()
24 | {
25 |
26 | }
27 | public AppBarComboBoxItem(string text, string tag, IconElement icon = null, bool isSelected = false)
28 | {
29 | Text = text;
30 | Tag = tag;
31 | Icon = icon;
32 | IsSelected = isSelected;
33 | }
34 |
35 | public override bool Equals(object obj)
36 | {
37 | return obj is AppBarComboBoxItem item &&
38 | Text == item.Text &&
39 | Tag == item.Tag;
40 | }
41 |
42 | public override int GetHashCode()
43 | {
44 | int hashCode = 1124388417;
45 | hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Text);
46 | hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Tag);
47 | return hashCode;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/UI/NavigateItem.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 Richasy.Controls.UWP.Models.UI
8 | {
9 | public class NavigateItemBase : NotifyPropertyBase
10 | {
11 | public string Name { get; set; }
12 | private bool _isSelected;
13 | public bool IsSelected
14 | {
15 | get => _isSelected;
16 | set => Set(ref _isSelected, value);
17 | }
18 | public NavigateItemBase()
19 | {
20 |
21 | }
22 | public NavigateItemBase(bool isSelected)
23 | {
24 | IsSelected = isSelected;
25 | }
26 | public NavigateItemBase(string name, bool isSelected = false)
27 | {
28 | Name = name;
29 | IsSelected = isSelected;
30 | }
31 |
32 | public override bool Equals(object obj)
33 | {
34 | return obj is NavigateItemBase @base &&
35 | Name == @base.Name;
36 | }
37 |
38 | public override int GetHashCode()
39 | {
40 | return 539060726 + EqualityComparer.Default.GetHashCode(Name);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/UI/NotifyPropertyBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Richasy.Controls.UWP.Models.UI
10 | {
11 | public class NotifyPropertyBase : INotifyPropertyChanged
12 | {
13 | public event PropertyChangedEventHandler PropertyChanged;
14 |
15 | protected void Set(ref T storage, T value, [CallerMemberName] string propertyName = null)
16 | {
17 | if (Equals(storage, value))
18 | {
19 | return;
20 | }
21 |
22 | storage = value;
23 | OnPropertyChanged(propertyName);
24 | }
25 |
26 | private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Models/UI/RichasyPage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Windows.UI.Xaml.Controls;
3 | using Windows.UI.Xaml.Navigation;
4 |
5 | namespace Richasy.Controls.UWP.Models.UI
6 | {
7 | public class RichasyPage : Page
8 | {
9 | public Enum PageType { get; set; }
10 | public bool IsInit { get; set; }
11 | public static RichasyPage Current;
12 | public RichasyPage() : base()
13 | {
14 | NavigationCacheMode = NavigationCacheMode.Enabled;
15 | IsInit = false;
16 | Current = this;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Popups/CenterPopup/CenterPopup.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Popups/TipPopup/TipPopup.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Popups/TipPopup/TipPopup.xaml.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Helper.UWP;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Drawing;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Runtime.InteropServices.WindowsRuntime;
8 | using System.Threading.Tasks;
9 | using Windows.Foundation;
10 | using Windows.Foundation.Collections;
11 | using Windows.UI;
12 | using Windows.UI.Xaml;
13 | using Windows.UI.Xaml.Controls;
14 | using Windows.UI.Xaml.Controls.Primitives;
15 | using Windows.UI.Xaml.Data;
16 | using Windows.UI.Xaml.Input;
17 | using Windows.UI.Xaml.Media;
18 | using Windows.UI.Xaml.Navigation;
19 |
20 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
21 |
22 | namespace Richasy.Controls.UWP.Popups
23 | {
24 | public sealed partial class TipPopup : UserControl
25 | {
26 | private Instance _instance;
27 | private Popup _popup = null;
28 | private Guid _guid;
29 | public TipPopup()
30 | {
31 | this.InitializeComponent();
32 | _guid = Guid.NewGuid();
33 | this.Width = Window.Current.Bounds.Width;
34 | this.Height = Window.Current.Bounds.Height;
35 | _popup = new Popup();
36 | _popup.Child = this;
37 | }
38 |
39 | public TipPopup(Instance instance):this()
40 | {
41 | _instance = instance;
42 | }
43 |
44 | public TipPopup(Instance instance, object content) : this(instance)
45 | {
46 | PopupContent = content;
47 | }
48 |
49 | public Brush PopupBackground
50 | {
51 | get { return (Brush)GetValue(PopupBackgroundProperty); }
52 | set { SetValue(PopupBackgroundProperty, value); }
53 | }
54 |
55 | // Using a DependencyProperty as the backing store for PopupBackground. This enables animation, styling, binding, etc...
56 | public static readonly DependencyProperty PopupBackgroundProperty =
57 | DependencyProperty.Register("PopupBackground", typeof(Brush), typeof(TipPopup), new PropertyMetadata(null));
58 |
59 | public Brush PopupForeground
60 | {
61 | get { return (Brush)GetValue(PopupForegroundProperty); }
62 | set { SetValue(PopupForegroundProperty, value); }
63 | }
64 |
65 | // Using a DependencyProperty as the backing store for PopupForeground. This enables animation, styling, binding, etc...
66 | public static readonly DependencyProperty PopupForegroundProperty =
67 | DependencyProperty.Register("PopupForeground", typeof(Brush), typeof(TipPopup), new PropertyMetadata(new SolidColorBrush(Colors.White)));
68 |
69 | public object PopupContent
70 | {
71 | get { return (object)GetValue(PopupContentProperty); }
72 | set { SetValue(PopupContentProperty, value); }
73 | }
74 |
75 | // Using a DependencyProperty as the backing store for PopupContent. This enables animation, styling, binding, etc...
76 | public static readonly DependencyProperty PopupContentProperty =
77 | DependencyProperty.Register("PopupContent", typeof(object), typeof(TipPopup), new PropertyMetadata(null));
78 |
79 | public Thickness PopupPadding
80 | {
81 | get { return (Thickness)GetValue(PopupPaddingProperty); }
82 | set { SetValue(PopupPaddingProperty, value); }
83 | }
84 |
85 | // Using a DependencyProperty as the backing store for PopupPadding. This enables animation, styling, binding, etc...
86 | public static readonly DependencyProperty PopupPaddingProperty =
87 | DependencyProperty.Register("PopupPadding", typeof(Thickness), typeof(TipPopup), new PropertyMetadata(new Thickness(10)));
88 |
89 | public CornerRadius PopupCornerRadius
90 | {
91 | get { return (CornerRadius)GetValue(PopupCornerRadiusProperty); }
92 | set { SetValue(PopupCornerRadiusProperty, value); }
93 | }
94 |
95 | // Using a DependencyProperty as the backing store for PopupCornerRadius. This enables animation, styling, binding, etc...
96 | public static readonly DependencyProperty PopupCornerRadiusProperty =
97 | DependencyProperty.Register("PopupCornerRadius", typeof(CornerRadius), typeof(TipPopup), new PropertyMetadata(new CornerRadius(3)));
98 |
99 | public double PopupMaxWidth
100 | {
101 | get { return (double)GetValue(PopupMaxWidthProperty); }
102 | set { SetValue(PopupMaxWidthProperty, value); }
103 | }
104 |
105 | // Using a DependencyProperty as the backing store for PopupMaxWidth. This enables animation, styling, binding, etc...
106 | public static readonly DependencyProperty PopupMaxWidthProperty =
107 | DependencyProperty.Register("PopupMaxWidth", typeof(double), typeof(TipPopup), new PropertyMetadata(300.0));
108 |
109 |
110 |
111 | public async void Show(Enum colorType, double staySeconds=1.5)
112 | {
113 | _instance.AddWindowSizeChangeAction(_guid, (size) =>
114 | {
115 | Width = size.Width;
116 | Height = size.Height;
117 | });
118 | PopupBackground = _instance.App.GetThemeBrushFromResource(colorType);
119 | _popup.IsOpen = true;
120 | PopupContainer.Visibility = Visibility.Visible;
121 | await Task.Delay(TimeSpan.FromSeconds(staySeconds));
122 | PopupContainer.Visibility = Visibility.Collapsed;
123 | _popup.IsOpen = false;
124 | _instance.RemoveWindowSizeChangeAction(_guid);
125 | }
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Popups/WaitingPopup/WaitingPopup.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Popups/WaitingPopup/WaitingPopup.xaml.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Helper.UWP;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices.WindowsRuntime;
7 | using Windows.Foundation;
8 | using Windows.Foundation.Collections;
9 | using Windows.UI.Xaml;
10 | using Windows.UI.Xaml.Controls;
11 | using Windows.UI.Xaml.Controls.Primitives;
12 | using Windows.UI.Xaml.Data;
13 | using Windows.UI.Xaml.Input;
14 | using Windows.UI.Xaml.Media;
15 | using Windows.UI.Xaml.Navigation;
16 |
17 | //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板
18 |
19 | namespace Richasy.Controls.UWP.Popups
20 | {
21 | public sealed partial class WaitingPopup : UserControl
22 | {
23 | private Popup _popup = null;
24 | private Guid _guid;
25 | public Action WindowSizeChangedHandle { get; set; }
26 | public WaitingPopup()
27 | {
28 | this.InitializeComponent();
29 | _guid = Guid.NewGuid();
30 | this.Width = Window.Current.Bounds.Width;
31 | this.Height = Window.Current.Bounds.Height;
32 | _popup = new Popup();
33 | _popup.Child = this;
34 | }
35 | public WaitingPopup(Instance instance) : this()
36 | {
37 | Instance = instance;
38 | }
39 | public Instance Instance { get; set; }
40 | public Brush PopupBackground
41 | {
42 | get { return (Brush)GetValue(PopupBackgroundProperty); }
43 | set { SetValue(PopupBackgroundProperty, value); }
44 | }
45 |
46 | // Using a DependencyProperty as the backing store for PopupBackground. This enables animation, styling, binding, etc...
47 | public static readonly DependencyProperty PopupBackgroundProperty =
48 | DependencyProperty.Register("PopupBackground", typeof(Brush), typeof(WaitingPopup), new PropertyMetadata(null));
49 |
50 | public Brush PresenterBackground
51 | {
52 | get { return (Brush)GetValue(PresenterBackgroundProperty); }
53 | set { SetValue(PresenterBackgroundProperty, value); }
54 | }
55 |
56 | // Using a DependencyProperty as the backing store for PresenterBackground. This enables animation, styling, binding, etc...
57 | public static readonly DependencyProperty PresenterBackgroundProperty =
58 | DependencyProperty.Register("PresenterBackground", typeof(Brush), typeof(WaitingPopup), new PropertyMetadata(null));
59 | public double PopupMaxWidth
60 | {
61 | get { return (double)GetValue(PopupMaxWidthProperty); }
62 | set { SetValue(PopupMaxWidthProperty, value); }
63 | }
64 |
65 | // Using a DependencyProperty as the backing store for PopupMaxWidth. This enables animation, styling, binding, etc...
66 | public static readonly DependencyProperty PopupMaxWidthProperty =
67 | DependencyProperty.Register("PopupMaxWidth", typeof(double), typeof(WaitingPopup), new PropertyMetadata(double.NaN));
68 |
69 | public double PopupMaxHeight
70 | {
71 | get { return (double)GetValue(PopupMaxHeightProperty); }
72 | set { SetValue(PopupMaxHeightProperty, value); }
73 | }
74 |
75 | // Using a DependencyProperty as the backing store for PopupMaxHeight. This enables animation, styling, binding, etc...
76 | public static readonly DependencyProperty PopupMaxHeightProperty =
77 | DependencyProperty.Register("PopupMaxHeight", typeof(double), typeof(WaitingPopup), new PropertyMetadata(double.NaN));
78 |
79 |
80 |
81 | public string Text
82 | {
83 | get { return (string)GetValue(TextProperty); }
84 | set { SetValue(TextProperty, value); }
85 | }
86 |
87 | // Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
88 | public static readonly DependencyProperty TextProperty =
89 | DependencyProperty.Register("Text", typeof(string), typeof(WaitingPopup), new PropertyMetadata(""));
90 |
91 | public Style TextStyle
92 | {
93 | get { return (Style)GetValue(TextStyleProperty); }
94 | set { SetValue(TextStyleProperty, value); }
95 | }
96 |
97 | // Using a DependencyProperty as the backing store for TextStyle. This enables animation, styling, binding, etc...
98 | public static readonly DependencyProperty TextStyleProperty =
99 | DependencyProperty.Register("TextStyle", typeof(Style), typeof(WaitingPopup), new PropertyMetadata(null));
100 |
101 | public Style ProgressRingStyle
102 | {
103 | get { return (Style)GetValue(ProgressRingStyleProperty); }
104 | set { SetValue(ProgressRingStyleProperty, value); }
105 | }
106 |
107 | // Using a DependencyProperty as the backing store for ProgressRingStyle. This enables animation, styling, binding, etc...
108 | public static readonly DependencyProperty ProgressRingStyleProperty =
109 | DependencyProperty.Register("ProgressRingStyle", typeof(Style), typeof(WaitingPopup), new PropertyMetadata(null));
110 |
111 |
112 | ///
113 | /// 显示弹出层
114 | ///
115 | public void Show()
116 | {
117 | Instance.AddWindowSizeChangeAction(_guid, (size) =>
118 | {
119 | Width = size.Width;
120 | Height = size.Height;
121 | WindowSizeChangedHandle?.Invoke(size);
122 | });
123 | WindowSizeChangedHandle?.Invoke(new Size(Window.Current.Bounds.Width, Window.Current.Bounds.Height));
124 | PopupContainer.Visibility = Visibility.Visible;
125 | DisplayContainer.Visibility = Visibility.Visible;
126 | _popup.IsOpen = true;
127 | }
128 | ///
129 | /// 隐藏弹出层
130 | ///
131 | public void Hide()
132 | {
133 | PopupContainer.Visibility = Visibility.Collapsed;
134 | DisplayContainer.Visibility = Visibility.Collapsed;
135 | _popup.IsOpen = false;
136 | Instance.RemoveWindowSizeChangeAction(_guid);
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Richasy-Controls-UWP")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Richasy-Controls-UWP")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 程序集的版本信息由下列四个值组成:
18 | //
19 | // 主版本
20 | // 次版本
21 | // 生成号
22 | // 修订号
23 | //
24 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
25 | //通过使用 "*",如下所示:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Properties/Richasy_Controls_UWP.rd.xml:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Richasy-Controls-UWP.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Richasy.Controls.UWP
5 | 1.1.3
6 | Richasy
7 | Richasy
8 | false
9 | MIT
10 | https://github.com/Richasy/Richasy-Controls-UWP
11 | https://i.loli.net/2020/06/28/7M368G1hUoYXJpC.png
12 | Richasy自用的控件集,多是对原有控件的包装
13 | 修改IconButton的部分属性,支持HorizontalContentAlignment/VerticalContentAlignment
14 | Copyright 2020
15 | Richasy uwp controls
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/AppBarComboBoxButton/AppBarComboBoxButton.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/AppBarComboBoxButton/AppBarComboBoxButton.xaml.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Models.Interface;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Runtime.InteropServices.WindowsRuntime;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 |
18 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
19 |
20 | namespace Richasy.Controls.UWP.Widgets
21 | {
22 | public sealed partial class AppBarComboBoxButton : AppBarButton
23 | {
24 | private bool _isItemInvoke = false;
25 | public AppBarComboBoxButton()
26 | {
27 | this.InitializeComponent();
28 | }
29 | public event EventHandler> SelectionChanged;
30 |
31 | public bool IsMultipleSelect
32 | {
33 | get { return (bool)GetValue(IsMultipleSelectProperty); }
34 | set { SetValue(IsMultipleSelectProperty, value); }
35 | }
36 | public static readonly DependencyProperty IsMultipleSelectProperty =
37 | DependencyProperty.Register("IsMultipleSelect", typeof(bool), typeof(AppBarComboBoxButton), new PropertyMetadata(false));
38 |
39 |
40 | public ICollection ItemsSource
41 | {
42 | get { return (ICollection)GetValue(ItemsSourceProperty); }
43 | set { SetValue(ItemsSourceProperty, value); }
44 | }
45 |
46 | public static readonly DependencyProperty ItemsSourceProperty =
47 | DependencyProperty.Register("ItemsSource", typeof(ICollection), typeof(AppBarComboBoxButton), new PropertyMetadata(null, new PropertyChangedCallback(ItemsSource_Changed)));
48 |
49 | private static void ItemsSource_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
50 | {
51 | if (e.NewValue != e.OldValue && e.NewValue is ICollection data)
52 | {
53 | var instance = d as AppBarComboBoxButton;
54 | instance.AppBarMenuFlyout.Items.Clear();
55 | foreach (var temp in data)
56 | {
57 | var item = temp as IAppBarComboBoxItem;
58 | if (!string.IsNullOrEmpty(item.Tag))
59 | {
60 | var toggle = new ToggleMenuFlyoutItem();
61 | toggle.Text = item.Text;
62 | toggle.Tag = item.Tag;
63 | toggle.Icon = item.Icon;
64 | toggle.FontFamily = instance.FontFamily;
65 | toggle.Click += instance.ToggleItem_Click;
66 | toggle.IsChecked = item.IsSelected;
67 | instance.AppBarMenuFlyout.Items.Add(toggle);
68 | }
69 | else
70 | instance.AppBarMenuFlyout.Items.Add(new MenuFlyoutSeparator());
71 | }
72 | }
73 | }
74 |
75 | private void ToggleItem_Click(object sender, RoutedEventArgs e)
76 | {
77 | var selectItem = sender as ToggleMenuFlyoutItem;
78 | var items = AppBarMenuFlyout.Items.OfType();
79 | if (IsMultipleSelect)
80 | {
81 | _isItemInvoke = true;
82 | }
83 | else
84 | {
85 | foreach (var item in items)
86 | {
87 | item.IsChecked = false;
88 | }
89 | selectItem.IsChecked = true;
90 | }
91 | var temp = items.Where(p => p.IsChecked).Select(p => (p.Text, p.Tag)).ToList();
92 | if (temp.Count > 0)
93 | {
94 | var result = new List();
95 | foreach (var item in ItemsSource)
96 | {
97 | var source = item as IAppBarComboBoxItem;
98 | if (temp.Any(p => p.Tag.ToString() == source.Tag && p.Text == source.Text))
99 | {
100 | result.Add(source);
101 | }
102 | }
103 | SelectionChanged?.Invoke(this, result);
104 | }
105 | }
106 |
107 | private void AppBarMenuFlyout_Closing(FlyoutBase sender, FlyoutBaseClosingEventArgs args)
108 | {
109 | if (IsMultipleSelect && _isItemInvoke)
110 | {
111 | args.Cancel = true;
112 | _isItemInvoke = false;
113 | }
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/Bubble/Bubble.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Graphics.Canvas;
2 | using Microsoft.Graphics.Canvas.UI.Composition;
3 | using Richasy.Helper.UWP.Extension;
4 | using System;
5 | using System.Numerics;
6 | using Windows.Foundation;
7 | using Windows.UI;
8 | using Windows.UI.Composition;
9 |
10 | namespace Richasy.Controls.UWP.Widgets
11 | {
12 | public class Bubble : IDisposable
13 | {
14 | public Bubble(Compositor Compositor, CanvasDevice canvasDevice, CompositionGraphicsDevice graphicsDevice, Size TargetSize, Color Color, TimeSpan Duration, bool OnTop, Size? Size = null, bool? IsFill = null)
15 | {
16 | _compositor = Compositor;
17 | _canvasDevice = canvasDevice;
18 | _graphicsDevice = graphicsDevice;
19 | _visual = Compositor.CreateSpriteVisual();
20 |
21 | if (!IsFill.HasValue)
22 | {
23 | var tmp = rnd.Next(2);
24 | IsFill = tmp > 0;
25 | }
26 |
27 | if (Size.HasValue)
28 | {
29 | this.Size = Size.Value.ToVector2();
30 | }
31 | else
32 | {
33 | var maxRadius = (int)Math.Min(TargetSize.Width, TargetSize.Height);
34 | if (IsFill.Value)
35 | {
36 | this.Size = new Vector2(rnd.Next(maxRadius / 7, maxRadius / 4));
37 | }
38 | else
39 | {
40 | this.Size = new Vector2(rnd.Next(maxRadius / 6, maxRadius / 3));
41 | }
42 | }
43 | Draw(IsFill.Value, Color);
44 |
45 | Offset = new Vector3((float)TargetSize.Width / 2, (float)TargetSize.Height / 2, 0f);
46 | _visual.Size = this.Size;
47 | _visual.Offset = Offset;
48 | _visual.Scale = Vector3.Zero;
49 | _visual.BindCenterPoint();
50 | CreateAnimation(TargetSize, _visual.Offset, OnTop, Duration);
51 | }
52 |
53 | ~Bubble()
54 | {
55 | Dispose(false);
56 | }
57 |
58 | private readonly static Random rnd = new Random();
59 |
60 | private static CompositionEasingFunction easing;
61 |
62 | private Compositor _compositor;
63 | private CanvasDevice _canvasDevice;
64 | private CompositionGraphicsDevice _graphicsDevice;
65 | private SpriteVisual _visual;
66 | private CompositionAnimationGroup _animations;
67 | private Vector2 Size;
68 | private Vector3 Offset;
69 | private CompositionDrawingSurface _surface;
70 | private CompositionSurfaceBrush _brush;
71 |
72 |
73 | private void Draw(bool IsFill, Color color)
74 | {
75 | _surface = _graphicsDevice.CreateDrawingSurface(Size.ToSize(), Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied);
76 | using (var dc = CanvasComposition.CreateDrawingSession(_surface))
77 | {
78 | dc.Clear(Colors.Transparent);
79 | if (IsFill)
80 | {
81 | dc.FillCircle(Size / 2, Size.X / 2, color);
82 | }
83 | else
84 | {
85 | dc.DrawCircle(Size / 2, Size.X / 2 - 2, color, 2f);
86 | }
87 | dc.Flush();
88 | }
89 | _brush = _compositor.CreateSurfaceBrush(_surface);
90 | _visual.Brush = _brush;
91 | }
92 |
93 | private void CreateAnimation(Size TargetSize, Vector3 StartOffset, bool OnTop, TimeSpan Duration)
94 | {
95 | if (easing == null)
96 | {
97 | easing = _compositor.CreateCubicBezierEasingFunction(new Vector2(0.17f, 0.67f), new Vector2(0.44f, 0.999f));
98 | }
99 |
100 | _animations = _compositor.CreateAnimationGroup();
101 |
102 | var scalean = _compositor.CreateVector3KeyFrameAnimation();
103 | scalean.InsertKeyFrame(0f, Vector3.Zero);
104 | scalean.InsertKeyFrame(0.2f, Vector3.One, easing);
105 | scalean.InsertKeyFrame(1f, new Vector3(0.06f, 0.06f, 1f), easing);
106 | scalean.Duration = Duration;
107 | scalean.Target = "Scale";
108 | scalean.StopBehavior = AnimationStopBehavior.SetToInitialValue;
109 |
110 | var offsetan = _compositor.CreateVector3KeyFrameAnimation();
111 | offsetan.InsertKeyFrame(0f, StartOffset, easing);
112 | if (OnTop)
113 | {
114 | //在上半部分
115 | offsetan.InsertKeyFrame(1f, new Vector3(rnd.Next(-(int)TargetSize.Width, (int)TargetSize.Width) + (int)TargetSize.Width / 2, rnd.Next(-(int)(TargetSize.Height * 1.5), 0) + (int)TargetSize.Height / 2, 0f), easing);
116 | }
117 | else
118 | {
119 | //在下半部分
120 | offsetan.InsertKeyFrame(1f, new Vector3(rnd.Next(-(int)TargetSize.Width, (int)TargetSize.Width) + (int)TargetSize.Width / 2, rnd.Next(0, (int)(TargetSize.Height * 1.5)) + (int)TargetSize.Height / 2, 0f), easing);
121 | }
122 | offsetan.Duration = Duration;
123 | offsetan.Target = "Offset";
124 | offsetan.StopBehavior = AnimationStopBehavior.SetToInitialValue;
125 |
126 | _animations.Add(scalean);
127 | _animations.Add(offsetan);
128 | }
129 |
130 | public void AddTo(ContainerVisual container)
131 | {
132 | container.Children.InsertAtBottom(_visual);
133 | }
134 |
135 | public void Start()
136 | {
137 | _visual.StopAnimationGroup(_animations);
138 | _visual.StartAnimationGroup(_animations);
139 | }
140 |
141 | public void Dispose()
142 | {
143 | Dispose(true);
144 | }
145 |
146 | private void Dispose(bool IsDisposing)
147 | {
148 | _visual?.Dispose();
149 | _visual = null;
150 |
151 | _brush?.Dispose();
152 | _brush = null;
153 |
154 | _surface?.Dispose();
155 | _surface = null;
156 |
157 | _animations?.Dispose();
158 | _animations = null;
159 |
160 | if (IsDisposing)
161 | {
162 | GC.SuppressFinalize(this);
163 | }
164 | }
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/Bubble/Bubble.xaml:
--------------------------------------------------------------------------------
1 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/Bubble/BubbleView.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Graphics.Canvas;
2 | using Microsoft.Graphics.Canvas.UI.Composition;
3 | using Richasy.Helper.UWP.Extension;
4 | using System;
5 | using System.Collections.Generic;
6 | using Windows.ApplicationModel;
7 | using Windows.Foundation;
8 | using Windows.Graphics.Display;
9 | using Windows.UI;
10 | using Windows.UI.Composition;
11 | using Windows.UI.Xaml;
12 | using Windows.UI.Xaml.Controls;
13 | using Windows.UI.Xaml.Hosting;
14 | using Windows.UI.Xaml.Media;
15 | using Windows.UI.Xaml.Shapes;
16 |
17 | namespace Richasy.Controls.UWP.Widgets
18 | {
19 | public class BubbleView : Control
20 | {
21 | public BubbleView()
22 | {
23 | this.DefaultStyleKey = typeof(BubbleView);
24 | ForegroundPropertyChangedToken = RegisterPropertyChangedCallback(ForegroundProperty, ForegroundPropertyChanged);
25 | //this.Unloaded -= BubbleView_Unloaded;
26 | //this.Unloaded += BubbleView_Unloaded;
27 | }
28 |
29 | Rectangle BubbleHost;
30 | Color ForegroundColor;
31 |
32 | Compositor _Compositor;
33 | Visual _HostVisual;
34 | ContainerVisual _BubblesVisual;
35 |
36 | CanvasDevice _canvasDevice;
37 | CompositionGraphicsDevice _graphicsDevice;
38 |
39 | List Bubbles;
40 |
41 | long ForegroundPropertyChangedToken;
42 |
43 | protected override void OnApplyTemplate()
44 | {
45 | base.OnApplyTemplate();
46 |
47 | BubbleHost = GetTemplateChild("BubbleHost") as Rectangle;
48 | BubbleHost.SizeChanged += BubbleHost_SizeChanged;
49 | SetupComposition();
50 | SetupDevices();
51 | }
52 |
53 | private void SetupComposition()
54 | {
55 | _HostVisual = ElementCompositionPreview.GetElementVisual(BubbleHost);
56 | _Compositor = _HostVisual.Compositor;
57 |
58 | _BubblesVisual = _Compositor.CreateContainerVisual();
59 | _BubblesVisual.BindSize(_HostVisual);
60 |
61 | ElementCompositionPreview.SetElementChildVisual(BubbleHost, _BubblesVisual);
62 | }
63 |
64 | //初始化CanvasDevice和GraphicsDevice
65 | private void SetupDevices()
66 | {
67 | DisplayInformation.DisplayContentsInvalidated += DisplayInformation_DisplayContentsInvalidated;
68 |
69 | _canvasDevice = CanvasDevice.GetSharedDevice();
70 | _graphicsDevice = CanvasComposition.CreateCompositionGraphicsDevice(_Compositor, _canvasDevice);
71 |
72 | _canvasDevice.DeviceLost += _canvasDevice_DeviceLost;
73 | _graphicsDevice.RenderingDeviceReplaced += _graphicsDevice_RenderingDeviceReplaced;
74 | }
75 |
76 | //重新设置CanvasDevice和GraphicsDevice
77 | private void ResetDevices(bool IsDeviceLost)
78 | {
79 | try
80 | {
81 | if (IsDeviceLost)
82 | {
83 | _canvasDevice.DeviceLost -= _canvasDevice_DeviceLost;
84 | _canvasDevice = CanvasDevice.GetSharedDevice();
85 | _canvasDevice.DeviceLost += _canvasDevice_DeviceLost;
86 | }
87 | //重新设置GraphicsDevice,在CanvasDevice丢失时会触发异常
88 | CanvasComposition.SetCanvasDevice(_graphicsDevice, _canvasDevice);
89 | }
90 | catch (Exception e) when (_canvasDevice != null && _canvasDevice.IsDeviceLost(e.HResult))
91 | {
92 | //通知设备已丢失,并触发CanvasDevice.DeviceLost
93 | _canvasDevice.RaiseDeviceLost();
94 | }
95 | }
96 |
97 | private void ClearBubbles()
98 | {
99 | if (Bubbles != null)
100 | {
101 | foreach (var bubble in Bubbles)
102 | {
103 | bubble.Dispose();
104 | }
105 | Bubbles.Clear();
106 | Bubbles = null;
107 | }
108 |
109 | if (_BubblesVisual != null)
110 | {
111 | _BubblesVisual.Children.RemoveAll();
112 | }
113 | }
114 |
115 | private void CreateBubbles()
116 | {
117 | ClearBubbles();
118 | if (DesignMode.DesignModeEnabled) return;
119 | if (_canvasDevice == null || _graphicsDevice == null) return;
120 | if (ForegroundColor != Colors.Transparent && this.ActualWidth > 0 && this.ActualHeight > 0)
121 | {
122 | var count = 20;
123 |
124 | var _Bubbles = new List();
125 |
126 | var duration = TimeSpan.FromSeconds(1d);
127 |
128 | for (int i = 0; i < count; i++)
129 | {
130 | var bubble = new Bubble(_Compositor, _canvasDevice, _graphicsDevice, new Size(this.ActualWidth, this.ActualHeight), ForegroundColor, duration, true);
131 | bubble.AddTo(_BubblesVisual);
132 | _Bubbles.Add(bubble);
133 | }
134 | for (int i = 0; i < count; i++)
135 | {
136 | var bubble = new Bubble(_Compositor, _canvasDevice, _graphicsDevice, new Size(this.ActualWidth, this.ActualHeight), ForegroundColor, duration, false);
137 | bubble.AddTo(_BubblesVisual);
138 | _Bubbles.Add(bubble);
139 | }
140 | Bubbles = _Bubbles;
141 | }
142 | }
143 |
144 | public void ShowBubbles()
145 | {
146 | if (Bubbles != null)
147 | {
148 | foreach (var bubble in Bubbles)
149 | {
150 | bubble.Start();
151 | }
152 | }
153 | }
154 |
155 | //当显示需要重绘时,尝试重新给GraphicsDevice设置CanvasDevice,如果抛出异常,则说明CanvasDevice已丢失
156 | private void DisplayInformation_DisplayContentsInvalidated(DisplayInformation sender, object args)
157 | {
158 | System.Diagnostics.Debug.WriteLine("Display Contents Invalidated");
159 | ResetDevices(false);
160 | }
161 |
162 | //当设备丢失时,重新设置设备
163 | private void _canvasDevice_DeviceLost(CanvasDevice sender, object args)
164 | {
165 | ResetDevices(true);
166 | }
167 |
168 | //GraphicsDevice的绘制设备重置时,即触发CanvasComposition.SetCanvasDevice时,重新绘制气泡
169 | private void _graphicsDevice_RenderingDeviceReplaced(CompositionGraphicsDevice sender, RenderingDeviceReplacedEventArgs args)
170 | {
171 | CreateBubbles();
172 | }
173 |
174 | private void BubbleHost_SizeChanged(object sender, SizeChangedEventArgs e)
175 | {
176 | CreateBubbles();
177 | }
178 |
179 | private void BubbleView_Unloaded(object sender, RoutedEventArgs e)
180 | {
181 | ClearBubbles();
182 | _BubblesVisual?.Dispose();
183 | _BubblesVisual = null;
184 | _canvasDevice = null;
185 | _graphicsDevice?.Dispose();
186 | _graphicsDevice = null;
187 | }
188 |
189 | private void ForegroundPropertyChanged(DependencyObject sender, DependencyProperty dp)
190 | {
191 | if (Foreground is SolidColorBrush brush)
192 | {
193 | ForegroundColor = brush.Color;
194 | }
195 | CreateBubbles();
196 | }
197 |
198 | //当设置IsBubbing = true时,触发ShowBubbles,并将IsBubbing设置为false,等待下次设置IsBubbing = true
199 | public bool IsBubbing
200 | {
201 | get { return (bool)GetValue(IsBubbingProperty); }
202 | set { SetValue(IsBubbingProperty, value); }
203 | }
204 |
205 | public static readonly DependencyProperty IsBubbingProperty =
206 | DependencyProperty.Register("IsBubbing", typeof(bool), typeof(BubbleView), new PropertyMetadata(false, (s, a) =>
207 | {
208 | if (a.NewValue != a.OldValue)
209 | {
210 | if (s is BubbleView sender)
211 | {
212 | if (a.NewValue is true)
213 | {
214 | sender.ShowBubbles();
215 | sender.SetValue(IsBubbingProperty, false);
216 | }
217 | }
218 | }
219 | }));
220 |
221 | }
222 | }
223 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/CenterPopupHeader/CenterPopupHeader.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/CenterPopupHeader/CenterPopupHeader.xaml.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Models.Interface;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices.WindowsRuntime;
7 | using Windows.Foundation;
8 | using Windows.Foundation.Collections;
9 | using Windows.UI.Xaml;
10 | using Windows.UI.Xaml.Controls;
11 | using Windows.UI.Xaml.Controls.Primitives;
12 | using Windows.UI.Xaml.Data;
13 | using Windows.UI.Xaml.Input;
14 | using Windows.UI.Xaml.Media;
15 | using Windows.UI.Xaml.Navigation;
16 |
17 | //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板
18 |
19 | namespace Richasy.Controls.UWP.Widgets
20 | {
21 | public sealed partial class CenterPopupHeader : UserControl, ICenterPopupHeader
22 | {
23 | public CenterPopupHeader()
24 | {
25 | this.InitializeComponent();
26 | }
27 |
28 | public CenterPopupHeader(string title, IconElement icon, Style closeButtonStyle = null, Style titleStyle = null) : this()
29 | {
30 | Title = title;
31 | CloseButtonStyle = closeButtonStyle;
32 | CloseIcon = icon;
33 | TitleTextStyle = titleStyle;
34 | }
35 |
36 | public event EventHandler CloseButtonClick;
37 |
38 | public string Title
39 | {
40 | get { return (string)GetValue(TitleProperty); }
41 | set { SetValue(TitleProperty, value); }
42 | }
43 |
44 | // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
45 | public static readonly DependencyProperty TitleProperty =
46 | DependencyProperty.Register("Title", typeof(string), typeof(CenterPopupHeader), new PropertyMetadata(""));
47 |
48 | public Style TitleTextStyle
49 | {
50 | get { return (Style)GetValue(TitleTextStyleProperty); }
51 | set { SetValue(TitleTextStyleProperty, value); }
52 | }
53 |
54 | // Using a DependencyProperty as the backing store for TitleTextStyle. This enables animation, styling, binding, etc...
55 | public static readonly DependencyProperty TitleTextStyleProperty =
56 | DependencyProperty.Register("TitleTextStyle", typeof(Style), typeof(CenterPopupHeader), new PropertyMetadata(null));
57 |
58 | ///
59 | /// ActionButton Style
60 | ///
61 | public Style CloseButtonStyle
62 | {
63 | get { return (Style)GetValue(CloseButtonStyleProperty); }
64 | set { SetValue(CloseButtonStyleProperty, value); }
65 | }
66 |
67 | // Using a DependencyProperty as the backing store for CloseButtonStyle. This enables animation, styling, binding, etc...
68 | public static readonly DependencyProperty CloseButtonStyleProperty =
69 | DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(CenterPopupHeader), new PropertyMetadata(null));
70 |
71 |
72 | public IconElement CloseIcon
73 | {
74 | get { return (IconElement)GetValue(CloseIconProperty); }
75 | set { SetValue(CloseIconProperty, value); }
76 | }
77 |
78 | // Using a DependencyProperty as the backing store for CloseIcon. This enables animation, styling, binding, etc...
79 | public static readonly DependencyProperty CloseIconProperty =
80 | DependencyProperty.Register("CloseIcon", typeof(IconElement), typeof(CenterPopupHeader), new PropertyMetadata(null));
81 |
82 | public UIElement AdditionElement
83 | {
84 | get { return (UIElement)GetValue(AdditionElementProperty); }
85 | set { SetValue(AdditionElementProperty, value); }
86 | }
87 |
88 | // Using a DependencyProperty as the backing store for AdditionElement. This enables animation, styling, binding, etc...
89 | public static readonly DependencyProperty AdditionElementProperty =
90 | DependencyProperty.Register("AdditionElement", typeof(UIElement), typeof(CenterPopupHeader), new PropertyMetadata(null, new PropertyChangedCallback(AdditionElement_Changed)));
91 |
92 | private static void AdditionElement_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
93 | {
94 | if (e.NewValue != null && e.NewValue is UIElement element)
95 | {
96 | var instance = d as CenterPopupHeader;
97 | instance.AdditionPresenter.Visibility = Visibility.Visible;
98 | }
99 | }
100 |
101 | private void CloseButton_Click(object sender, RoutedEventArgs e)
102 | {
103 | CloseButtonClick?.Invoke(this, EventArgs.Empty);
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/IconTextBlock/IconTextBlock.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/IconTextBlock/IconTextBlock.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.Foundation;
7 | using Windows.Foundation.Collections;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Controls.Primitives;
11 | using Windows.UI.Xaml.Data;
12 | using Windows.UI.Xaml.Input;
13 | using Windows.UI.Xaml.Media;
14 | using Windows.UI.Xaml.Navigation;
15 |
16 | //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板
17 |
18 | namespace Richasy.Controls.UWP.Widgets
19 | {
20 | public sealed partial class IconTextBlock : UserControl
21 | {
22 | public IconTextBlock()
23 | {
24 | this.InitializeComponent();
25 | }
26 |
27 |
28 | public IconElement Icon
29 | {
30 | get { return (IconElement)GetValue(IconProperty); }
31 | set { SetValue(IconProperty, value); }
32 | }
33 |
34 | // Using a DependencyProperty as the backing store for Icon. This enables animation, styling, binding, etc...
35 | public static readonly DependencyProperty IconProperty =
36 | DependencyProperty.Register("Icon", typeof(IconElement), typeof(IconTextBlock), new PropertyMetadata(null));
37 |
38 |
39 |
40 | public GridLength GutterWidth
41 | {
42 | get { return (GridLength)GetValue(GutterWidthProperty); }
43 | set { SetValue(GutterWidthProperty, value); }
44 | }
45 |
46 | // Using a DependencyProperty as the backing store for GutterWidth. This enables animation, styling, binding, etc...
47 | public static readonly DependencyProperty GutterWidthProperty =
48 | DependencyProperty.Register("GutterWidth", typeof(GridLength), typeof(IconTextBlock), new PropertyMetadata(new GridLength(10)));
49 |
50 | public string Text
51 | {
52 | get { return (string)GetValue(TextProperty); }
53 | set { SetValue(TextProperty, value); }
54 | }
55 |
56 | // Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
57 | public static readonly DependencyProperty TextProperty =
58 | DependencyProperty.Register("Text", typeof(string), typeof(IconTextBlock), new PropertyMetadata(""));
59 |
60 | public bool IsTextSelectionEnabled
61 | {
62 | get { return (bool)GetValue(IsTextSelectionEnabledProperty); }
63 | set { SetValue(IsTextSelectionEnabledProperty, value); }
64 | }
65 |
66 | // Using a DependencyProperty as the backing store for IsTextSelectionEnable. This enables animation, styling, binding, etc...
67 | public static readonly DependencyProperty IsTextSelectionEnabledProperty =
68 | DependencyProperty.Register("IsTextSelectionEnabled", typeof(bool), typeof(IconTextBlock), new PropertyMetadata(false));
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/VersionBlock/VersionBlock.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
37 |
42 |
43 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Richasy-Controls-UWP/Widgets/VersionBlock/VersionBlock.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.ApplicationModel;
7 | using Windows.Foundation;
8 | using Windows.Foundation.Collections;
9 | using Windows.UI.Xaml;
10 | using Windows.UI.Xaml.Controls;
11 | using Windows.UI.Xaml.Controls.Primitives;
12 | using Windows.UI.Xaml.Data;
13 | using Windows.UI.Xaml.Input;
14 | using Windows.UI.Xaml.Media;
15 | using Windows.UI.Xaml.Navigation;
16 |
17 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
18 |
19 | namespace Richasy.Controls.UWP.Widgets
20 | {
21 | public sealed partial class VersionBlock : UserControl
22 | {
23 | public static string Version = string.Format("{0}.{1}.{2}.{3}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor, Package.Current.Id.Version.Build, Package.Current.Id.Version.Revision);
24 | public VersionBlock()
25 | {
26 | this.InitializeComponent();
27 | VersionTextBlock.Text = Version;
28 | }
29 | public event EventHandler ActionButtonClick;
30 | public string LogoUri
31 | {
32 | get { return (string)GetValue(LogoUriProperty); }
33 | set { SetValue(LogoUriProperty, value); }
34 | }
35 |
36 | // Using a DependencyProperty as the backing store for LogoUri. This enables animation, styling, binding, etc...
37 | public static readonly DependencyProperty LogoUriProperty =
38 | DependencyProperty.Register("LogoUri", typeof(string), typeof(VersionBlock), new PropertyMetadata(""));
39 |
40 | public string Title
41 | {
42 | get { return (string)GetValue(TitleProperty); }
43 | set { SetValue(TitleProperty, value); }
44 | }
45 |
46 | // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
47 | public static readonly DependencyProperty TitleProperty =
48 | DependencyProperty.Register("Title", typeof(string), typeof(VersionBlock), new PropertyMetadata(""));
49 |
50 | public Style TitleTextStyle
51 | {
52 | get { return (Style)GetValue(TitleTextStyleProperty); }
53 | set { SetValue(TitleTextStyleProperty, value); }
54 | }
55 |
56 | // Using a DependencyProperty as the backing store for TitleTextStyle. This enables animation, styling, binding, etc...
57 | public static readonly DependencyProperty TitleTextStyleProperty =
58 | DependencyProperty.Register("TitleTextStyle", typeof(Style), typeof(VersionBlock), new PropertyMetadata(null, new PropertyChangedCallback(TitleTextStyle_Changed)));
59 |
60 | private static void TitleTextStyle_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
61 | {
62 | if (e.NewValue != null && e.NewValue is Style style)
63 | {
64 | var instance = d as VersionBlock;
65 | instance.TitleBlock.Style = style;
66 | }
67 | }
68 |
69 | public string Description
70 | {
71 | get { return (string)GetValue(DescriptionProperty); }
72 | set { SetValue(DescriptionProperty, value); }
73 | }
74 |
75 | // Using a DependencyProperty as the backing store for Description. This enables animation, styling, binding, etc...
76 | public static readonly DependencyProperty DescriptionProperty =
77 | DependencyProperty.Register("Description", typeof(string), typeof(VersionBlock), new PropertyMetadata(""));
78 |
79 | public Style DescriptionTextStyle
80 | {
81 | get { return (Style)GetValue(DescriptionTextStyleProperty); }
82 | set { SetValue(DescriptionTextStyleProperty, value); }
83 | }
84 |
85 | // Using a DependencyProperty as the backing store for DescriptionTextStyle. This enables animation, styling, binding, etc...
86 | public static readonly DependencyProperty DescriptionTextStyleProperty =
87 | DependencyProperty.Register("DescriptionTextStyle", typeof(Style), typeof(VersionBlock), new PropertyMetadata(null));
88 |
89 | public Style ScrollViewerStyle
90 | {
91 | get { return (Style)GetValue(ScrollViewerStyleProperty); }
92 | set { SetValue(ScrollViewerStyleProperty, value); }
93 | }
94 |
95 | // Using a DependencyProperty as the backing store for ScrollViewerStyle. This enables animation, styling, binding, etc...
96 | public static readonly DependencyProperty ScrollViewerStyleProperty =
97 | DependencyProperty.Register("ScrollViewerStyle", typeof(Style), typeof(VersionBlock), new PropertyMetadata(null));
98 |
99 | public Style ActionButtonStyle
100 | {
101 | get { return (Style)GetValue(ActionButtonStyleProperty); }
102 | set { SetValue(ActionButtonStyleProperty, value); }
103 | }
104 |
105 | // Using a DependencyProperty as the backing store for ActionButtonStyle. This enables animation, styling, binding, etc...
106 | public static readonly DependencyProperty ActionButtonStyleProperty =
107 | DependencyProperty.Register("ActionButtonStyle", typeof(Style), typeof(VersionBlock), new PropertyMetadata(null));
108 |
109 | public Style VersionTextStyle
110 | {
111 | get { return (Style)GetValue(VersionTextStyleProperty); }
112 | set { SetValue(VersionTextStyleProperty, value); }
113 | }
114 |
115 | // Using a DependencyProperty as the backing store for VersionTextStyle. This enables animation, styling, binding, etc...
116 | public static readonly DependencyProperty VersionTextStyleProperty =
117 | DependencyProperty.Register("VersionTextStyle", typeof(Style), typeof(VersionBlock), new PropertyMetadata(null, new PropertyChangedCallback(VersionTextStyle_Changed)));
118 |
119 | private static void VersionTextStyle_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
120 | {
121 | if (e.NewValue != null && e.NewValue is Style style)
122 | {
123 | var instance = d as VersionBlock;
124 | instance.VersionTextBlock.Style = style;
125 | }
126 | }
127 |
128 | public IconElement ActionIcon
129 | {
130 | get { return (IconElement)GetValue(ActionIconProperty); }
131 | set { SetValue(ActionIconProperty, value); }
132 | }
133 |
134 | // Using a DependencyProperty as the backing store for ActionIcon. This enables animation, styling, binding, etc...
135 | public static readonly DependencyProperty ActionIconProperty =
136 | DependencyProperty.Register("ActionIcon", typeof(IconElement), typeof(VersionBlock), new PropertyMetadata(null));
137 |
138 | private void CloseButton_Click(object sender, RoutedEventArgs e)
139 | {
140 | ActionButtonClick?.Invoke(this, EventArgs.Empty);
141 | }
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/SampleApp/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/SampleApp/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Helper.UWP;
2 | using Richasy.Helper.UWP.Models;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Runtime.InteropServices.WindowsRuntime;
8 | using Windows.ApplicationModel;
9 | using Windows.ApplicationModel.Activation;
10 | using Windows.Foundation;
11 | using Windows.Foundation.Collections;
12 | using Windows.UI;
13 | using Windows.UI.Core;
14 | using Windows.UI.ViewManagement;
15 | using Windows.UI.Xaml;
16 | using Windows.UI.Xaml.Controls;
17 | using Windows.UI.Xaml.Controls.Primitives;
18 | using Windows.UI.Xaml.Data;
19 | using Windows.UI.Xaml.Input;
20 | using Windows.UI.Xaml.Media;
21 | using Windows.UI.Xaml.Navigation;
22 |
23 | namespace SampleApp
24 | {
25 | ///
26 | /// Provides application-specific behavior to supplement the default Application class.
27 | ///
28 | sealed partial class App : Application
29 | {
30 | ///
31 | /// Initializes the singleton application object. This is the first line of authored code
32 | /// executed, and as such is the logical equivalent of main() or WinMain().
33 | ///
34 | public static Instance _instance;
35 | public App()
36 | {
37 | this.InitializeComponent();
38 | this.Suspending += OnSuspending;
39 | this.RequestedTheme = ApplicationTheme.Dark;
40 | }
41 |
42 |
43 | ///
44 | /// Invoked when the application is launched normally by the end user. Other entry points
45 | /// will be used such as when the application is launched to open a specific file.
46 | ///
47 | /// Details about the launch request and process.
48 | protected override void OnLaunched(LaunchActivatedEventArgs e)
49 | {
50 | Frame rootFrame = Window.Current.Content as Frame;
51 | var option = new Options();
52 | option.DarkButtonHoverColor = Colors.DarkGray;
53 | option.DarkButtonPressColor = Colors.Black;
54 | option.LightButtonHoverColor = Colors.White;
55 | option.LightButtonPressColor = Colors.Wheat;
56 | option.SettingContainerName = "SampleApp";
57 | _instance = new Instance(option);
58 | // Do not repeat app initialization when the Window already has content,
59 | // just ensure that the window is active
60 | if (rootFrame == null)
61 | {
62 | // Create a Frame to act as the navigation context and navigate to the first page
63 | rootFrame = new Frame();
64 |
65 | rootFrame.NavigationFailed += OnNavigationFailed;
66 |
67 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
68 | {
69 | //TODO: Load state from previously suspended application
70 | }
71 |
72 | // Place the frame in the current Window
73 | Window.Current.Content = rootFrame;
74 | }
75 |
76 | if (e.PrelaunchActivated == false)
77 | {
78 | if (rootFrame.Content == null)
79 | {
80 | // When the navigation stack isn't restored navigate to the first page,
81 | // configuring the new page by passing required information as a navigation
82 | // parameter
83 | rootFrame.Navigate(typeof(MainPage), e.Arguments);
84 | }
85 | // Ensure the current window is active
86 | Window.Current.Activate();
87 | }
88 | _instance.App.SetTitleBarColor(RequestedTheme.ToString());
89 | }
90 |
91 | ///
92 | /// Invoked when Navigation to a certain page fails
93 | ///
94 | /// The Frame which failed navigation
95 | /// Details about the navigation failure
96 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
97 | {
98 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
99 | }
100 |
101 | ///
102 | /// Invoked when application execution is being suspended. Application state is saved
103 | /// without knowing whether the application will be terminated or resumed with the contents
104 | /// of memory still intact.
105 | ///
106 | /// The source of the suspend request.
107 | /// Details about the suspend request.
108 | private void OnSuspending(object sender, SuspendingEventArgs e)
109 | {
110 | var deferral = e.SuspendingOperation.GetDeferral();
111 | //TODO: Save application state and stop any background activity
112 | deferral.Complete();
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/SampleApp/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Richasy/Richasy-Controls-UWP/271ef3b3704f5ac727074e42a377a8aa680acca8/SampleApp/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/SampleApp/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Richasy/Richasy-Controls-UWP/271ef3b3704f5ac727074e42a377a8aa680acca8/SampleApp/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/SampleApp/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Richasy/Richasy-Controls-UWP/271ef3b3704f5ac727074e42a377a8aa680acca8/SampleApp/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/SampleApp/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Richasy/Richasy-Controls-UWP/271ef3b3704f5ac727074e42a377a8aa680acca8/SampleApp/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/SampleApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Richasy/Richasy-Controls-UWP/271ef3b3704f5ac727074e42a377a8aa680acca8/SampleApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/SampleApp/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Richasy/Richasy-Controls-UWP/271ef3b3704f5ac727074e42a377a8aa680acca8/SampleApp/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/SampleApp/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Richasy/Richasy-Controls-UWP/271ef3b3704f5ac727074e42a377a8aa680acca8/SampleApp/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/SampleApp/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
36 |
38 |
39 |
40 |
41 |
42 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
64 |
65 |
68 |
69 |
70 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/SampleApp/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Richasy.Controls.UWP.Models.UI;
2 | using Richasy.Font.UWP.Enums;
3 | using SampleApp.Models.UI;
4 | using System;
5 | using System.Collections.ObjectModel;
6 | using System.Linq;
7 | using Windows.UI.Xaml.Controls;
8 | using Windows.UI.Xaml.Media.Animation;
9 |
10 | // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
11 |
12 | namespace SampleApp
13 | {
14 | ///
15 | /// An empty page that can be used on its own or navigated to within a Frame.
16 | ///
17 | public sealed partial class MainPage : RichasyPage
18 | {
19 | private ObservableCollection