Example #1
0
        private void StartProctoring()
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                try
                {
                    var content = LoadContent(settings);

                    filePath = Path.Combine(appConfig.TemporaryDirectory, $"{Path.GetRandomFileName()}_index.html");
                    fileSystem.Save(content, filePath);

                    control = new ProctoringControl(logger.CloneFor(nameof(ProctoringControl)));
                    control.EnsureCoreWebView2Async().ContinueWith(_ =>
                    {
                        control.Dispatcher.Invoke(() =>
                        {
                            control.CoreWebView2.Navigate(filePath);
                        });
                    });

                    window = uiFactory.CreateProctoringWindow(control);
                    window.SetTitle(settings.JitsiMeet.Enabled ? settings.JitsiMeet.Subject : settings.Zoom.UserName);
                    window.Show();

                    if (settings.WindowVisibility == WindowVisibility.AllowToShow || settings.WindowVisibility == WindowVisibility.Hidden)
                    {
                        window.Hide();
                    }

                    IconResource = new XamlIconResource {
                        Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Active.xaml")
                    };
                    Tooltip = text.Get(TextKey.Notification_ProctoringActiveTooltip);
                    NotificationChanged?.Invoke();

                    logger.Info($"Started proctoring with {(settings.JitsiMeet.Enabled ? "Jitsi Meet" : "Zoom")}.");
                }
                catch (Exception e)
                {
                    logger.Error($"Failed to start proctoring! Reason: {e.Message}", e);
                }
            });
        }
        private void OnNotificationClosed(BaseNotification notification)
        {
            if (notification is null)
            {
                return;
            }

            notification.Closed -= OnNotificationClosed;


            // remove associated config
            if (_configs.TryGetValue(notification, out var config) && config != null)
            {
                config.Created -= OnNotificationCreated;
                _configs.Remove(notification);
            }

            NotificationChanged?.Invoke(this, new NotificationChanged(ChangeType.Remove, notification));
        }
        private void OnNotificationCreated(BaseNotification baseNotification)
        {
            if (baseNotification is null)
            {
                return;
            }

            baseNotification.Closed += OnNotificationClosed;

            switch (baseNotification)
            {
            case Notification notification:
                _notifications.Add(notification);
                break;

            case TaskNotification taskNotification:
                _tasks.Add(taskNotification);
                break;
            }

            NotificationChanged?.Invoke(this, new NotificationChanged(ChangeType.Add, baseNotification));
        }