FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ScriptText/ScriptText/ScriptText/ScriptText/Library.cs at master · jan-patrick/ScriptText · GitHub
jan-patrick
/
ScriptText
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
4
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ScriptText
/
ScriptText
/
ScriptText
/
ScriptText
/
Library.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
84 lines (76 loc) · 2.41 KB
Breadcrumbs
ScriptText
/
ScriptText
/
ScriptText
/
ScriptText
/
Library.cs
Copy path
File metadata and controls
84 lines (76 loc) · 2.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Threading
.
Tasks
;
using
Windows
.
Storage
;
using
Windows
.
Storage
.
Pickers
;
using
Windows
.
Storage
.
Provider
;
using
Windows
.
UI
.
Popups
;
using
Windows
.
UI
.
Xaml
.
Controls
;
using
Windows
.
ApplicationModel
;
using
Windows
.
ApplicationModel
.
DataTransfer
;
public
class
Library
{
public
async
Task
<
bool
>
Confirm
(
string
content
,
string
title
,
string
ok
,
string
cancel
)
{
bool
result
=
false
;
MessageDialog
dialog
=
new
MessageDialog
(
content
,
title
)
;
dialog
.
Commands
.
Add
(
new
UICommand
(
ok
,
new
UICommandInvokedHandler
(
(
cmd
)
=>
result
=
true
)
)
)
;
dialog
.
Commands
.
Add
(
new
UICommand
(
cancel
,
new
UICommandInvokedHandler
(
(
cmd
)
=>
result
=
false
)
)
)
;
await
dialog
.
ShowAsync
(
)
;
return
result
;
}
public
async
void
New
(
TextBox
display
)
{
if
(
await
Confirm
(
"Create New Document?"
,
"Codetext"
,
"Yes"
,
"No"
)
)
{
display
.
Text
=
string
.
Empty
;
display
.
Select
(
display
.
Text
.
Length
,
0
)
;
}
}
public
async
void
Open
(
TextBox
display
)
{
try
{
FileOpenPicker
picker
=
new
FileOpenPicker
(
)
;
picker
.
SuggestedStartLocation
=
PickerLocationId
.
DocumentsLibrary
;
picker
.
FileTypeFilter
.
Add
(
".txt"
)
;
StorageFile
file
=
await
picker
.
PickSingleFileAsync
(
)
;
display
.
Text
=
await
FileIO
.
ReadTextAsync
(
file
)
;
display
.
Select
(
display
.
Text
.
Length
,
0
)
;
}
catch
{
}
}
public
async
void
Save
(
TextBox
display
)
{
try
{
FileSavePicker
picker
=
new
FileSavePicker
(
)
;
picker
.
SuggestedStartLocation
=
PickerLocationId
.
DocumentsLibrary
;
picker
.
FileTypeChoices
.
Add
(
"Plain Text"
,
new
List
<
string
>
(
)
{
".txt"
}
)
;
picker
.
DefaultFileExtension
=
".txt"
;
picker
.
SuggestedFileName
=
"Document"
;
StorageFile
file
=
await
picker
.
PickSaveFileAsync
(
)
;
if
(
file
!=
null
)
{
CachedFileManager
.
DeferUpdates
(
file
)
;
await
FileIO
.
WriteTextAsync
(
file
,
display
.
Text
)
;
FileUpdateStatus
status
=
await
CachedFileManager
.
CompleteUpdatesAsync
(
file
)
;
}
}
catch
{
}
}
public
void
Share
(
TextBox
display
)
{
try
{
DataTransferManager
.
ShowShareUI
(
)
;
}
catch
{
}
}
}
Back
|
FazBrowse Home
|
New Git URL