Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MainPage.xaml.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using System.Runtime.InteropServices.WindowsRuntime;
6using Windows.Foundation;
7using Windows.Foundation.Collections;
8using Windows.UI.Xaml;
9using Windows.UI.Xaml.Controls;
10using Windows.UI.Xaml.Controls.Primitives;
11using Windows.UI.Xaml.Data;
12using Windows.UI.Xaml.Input;
13using Windows.UI.Xaml.Media.Imaging;
14using Windows.UI.Xaml.Navigation;
15using Waher.Events;
16using Waher.Mock;
17using System.Threading.Tasks;
18
19namespace Waher.Mock.Lamp.UWP
20{
24 public sealed partial class MainPage : Page
25 {
26 private static ListViewSniffer sniffer = null;
27 private static ListViewEventSink eventSink = null;
28 private static MainPage instance = null;
29
30 public MainPage()
31 {
33
34 if (sniffer is null)
35 sniffer = new ListViewSniffer(this.SnifferListView);
36
37 if (eventSink is null)
38 {
39 eventSink = new ListViewEventSink("List View Event Sink.", this.EventsListView);
40 Log.Register(eventSink);
41 }
42
43 if (instance is null)
44 instance = this;
45
46 App.OwnershipChanged += this.App_OwnershipChanged;
47 }
48
49 private Task App_OwnershipChanged(object Sender, EventArgs e)
50 {
51 if (string.IsNullOrEmpty(App.OwnerJid))
52 {
53 this.OwnerLabel.Visibility = Visibility.Collapsed;
54 this.Owner.Visibility = Visibility.Collapsed;
55 this.QrCodeLabel.Visibility = Visibility.Visible;
56 this.QrCode.Source = new BitmapImage(new Uri(App.QrCodeUrl));
57 this.QrCode.Visibility = Visibility.Visible;
58 }
59 else
60 {
61 this.OwnerLabel.Visibility = Visibility.Visible;
62 this.Owner.Text = App.OwnerJid;
63 this.Owner.Visibility = Visibility.Visible;
64 this.QrCodeLabel.Visibility = Visibility.Collapsed;
65 this.QrCode.Visibility = Visibility.Collapsed;
66 }
67
68 return Task.CompletedTask;
69 }
70
71 private void Page_Unloaded(object _, RoutedEventArgs __)
72 {
73 if (!(sniffer is null) && sniffer.ListView == this.SnifferListView)
74 sniffer = null;
75
76 if (!(eventSink is null) && eventSink.ListView == this.EventsListView)
77 {
78 Log.Unregister(eventSink);
79 eventSink.Dispose();
80 eventSink = null;
81 }
82
83 if (instance == this)
84 instance = null;
85 }
86
87 public static ListViewSniffer Sniffer
88 {
89 get { return sniffer; }
90 }
91
92 public static MainPage Instance
93 {
94 get { return instance; }
95 }
96 }
97}
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:13
static void Register(IEventSink EventSink)
Registers an event sink with the event log. Call Unregister(IEventSink) to unregister it,...
Definition: Log.cs:29
static bool Unregister(IEventSink EventSink)
Unregisters an event sink from the event log.
Definition: Log.cs:46
virtual void Dispose()
IDisposable.Dispose()
Definition: LogObject.cs:1134
Provides application-specific behavior to supplement the default Application class.
Definition: App.xaml.cs:34
An empty page that can be used on its own or navigated to within a Frame.
void InitializeComponent()
InitializeComponent()
Definition: MainPage.g.i.cs:39
Event sink displaying incoming events in a ListView component.
ListView ListView
Component receiving logged events.
Sniffer displaying incoming events in a ListView component.