-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWidgetImplBase.cs
More file actions
47 lines (38 loc) · 1.42 KB
/
Copy pathWidgetImplBase.cs
File metadata and controls
47 lines (38 loc) · 1.42 KB
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.Windows.Widgets.Providers;
using System;
using Windows.Storage;
namespace MiniTimerWidget
{
internal delegate WidgetImplBase WidgetCreateDelegate(string widgetId, string initialState);
internal abstract class WidgetImplBase
{
protected string id;
protected string state;
protected bool isActivated = false;
protected WidgetImplBase(string widgetId, string initialState)
{
state = initialState;
id = widgetId;
}
public string Id { get => id; }
public string State { get => state; }
public bool IsActivated { get => isActivated; }
protected static string ReadPackageFileFromUri(string packageUri)
{
var uri = new Uri(packageUri);
var storageFileTask = StorageFile.GetFileFromApplicationUriAsync(uri).AsTask();
storageFileTask.Wait();
var readTextTask = FileIO.ReadTextAsync(storageFileTask.Result).AsTask();
readTextTask.Wait();
return readTextTask.Result;
}
public virtual void Activate(WidgetContext widgetContext) { }
public virtual void Deactivate() { }
public virtual void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs) { }
public virtual void OnWidgetContextChanged(WidgetContextChangedArgs contextChangedArgs) { }
public abstract string GetTemplateForWidget();
public abstract string GetDataForWidget();
}
}