public async void createNewSheet(string sheetName, string pathHTMLPage) { await DispatcherHelper.ExecuteOnUIThreadAsync(async() => { ModuleHTMLView view = new ModuleHTMLView(); view.LoadPage(pathHTMLPage, id); Messenger.Default.Send(new ModuleSheetNotification { id = id, sheetName = sheetName, type = ModuleSheetNotificationType.NewSheet, sheetContent = view, sheetIcon = await ModulesAccessManager.GetModuleIconViaIDAsync(id, ModulesAccessManager.GetModuleViaID(id).ModuleSystem), sheetSystem = false }); }); }
/* ============= * = FUNCTIONS = * ============= */ private void SetMessenger() { Messenger.Default.Register <SMSNotification>(this, async(notification) => { await DispatcherHelper.ExecuteOnUIThreadAsync(async() => { try { switch (notification.Type) { case TypeUpdateModule.ModuleDeleted: RemoveModule(notification.ID); ModulesPinned.RemoveModule(notification.ID); break; case TypeUpdateModule.NewModule: await AddModule(notification.ID); break; case TypeUpdateModule.UpdateModule: break; } } catch { } }); }); Messenger.Default.Register <ModulesPinnedNotification>(this, async(notification) => { await DispatcherHelper.ExecuteOnUIThreadAsync(async() => { try { switch (notification.Modification) { case ModulesPinedModification.Added: await AddModule(notification.ID); break; case ModulesPinedModification.Removed: RemoveModule(notification.ID); break; } } catch { } }); }); Messenger.Default.Register <EditorViewNotification>(this, async(notification_ui) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { SetTheme(); } catch { } }); }); Messenger.Default.Register <ToolbarNotification>(this, async(notification_toolbar) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { StackPanel widget = (StackPanel)ToolbarContent.FindName("" + notification_toolbar.id); switch (notification_toolbar.propertie) { case ToolbarProperties.ButtonEnabled: ((Button)widget.FindName(notification_toolbar.uiElementName + notification_toolbar.id)).IsEnabled = (bool)notification_toolbar.content; break; case ToolbarProperties.IsButtonEnabled when !notification_toolbar.answerNotification: Button element = (Button)widget.FindName(notification_toolbar.uiElementName + notification_toolbar.id); Messenger.Default.Send(new ToolbarNotification { id = notification_toolbar.id, uiElementName = notification_toolbar.uiElementName, propertie = ToolbarProperties.IsButtonEnabled, answerNotification = true, content = element.IsEnabled }); break; case ToolbarProperties.SetTextBoxContent: ((TextBox)widget.FindName(notification_toolbar.uiElementName + notification_toolbar.id)).Text = (string)notification_toolbar.content; break; case ToolbarProperties.GetTextBoxContent when !notification_toolbar.answerNotification: TextBox elementb = (TextBox)widget.FindName(notification_toolbar.uiElementName + notification_toolbar.id); Messenger.Default.Send(new ToolbarNotification { id = notification_toolbar.id, guid = notification_toolbar.guid, uiElementName = notification_toolbar.uiElementName, propertie = ToolbarProperties.GetTextBoxContent, answerNotification = true, content = elementb.Text }); break; case ToolbarProperties.OpenFlyout: UIElement UIElement = (UIElement)widget.FindName(notification_toolbar.uiElementName + notification_toolbar.id); Flyout FlyoutElement; if (UIElement.ContextFlyout == null) { FlyoutElement = new Flyout(); ModuleHTMLView HTMLView = new ModuleHTMLView(); HTMLView.Height = 300; HTMLView.Width = 300; HTMLView.LoadPage((string)notification_toolbar.content, notification_toolbar.id); FlyoutElement.Content = HTMLView; FlyoutElement.FlyoutPresenterStyle = (Style)Application.Current.Resources["FlyoutBorderless"]; UIElement.ContextFlyout = FlyoutElement; UIElement.ContextFlyout.ShowAt(UIElement as FrameworkElement); } else { if ((string)notification_toolbar.content != "") { FlyoutElement = (UIElement.ContextFlyout as Flyout); (FlyoutElement.Content as ModuleHTMLView).LoadPage((string)notification_toolbar.content, notification_toolbar.id); } UIElement.ContextFlyout.ShowAt(UIElement as FrameworkElement); } break; } } catch { } }); }); }