private async void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); try { if (GlobalVariables.CurrentIDs.ID_Tab != 0) { //Code content string content = await ContentViewer.GetCode(); await TabsWriteManager.PushTabContentViaIDAsync(GlobalVariables.CurrentIDs, content, false); //Cursor position PositionSCEE CursorPosition = await ContentViewer.GetCursorPosition(); InfosTab Tab = TabsAccessManager.GetTabViaID(GlobalVariables.CurrentIDs); Tab.TabCursorPosition = new CursorPosition { column = CursorPosition.column, row = CursorPosition.row }; await TabsWriteManager.PushUpdateTabAsync(Tab, GlobalVariables.CurrentIDs.ID_TabsList, false); deferral.Complete(); } else { deferral.Complete(); } } catch { deferral.Complete(); } }
public async void ManageQueueTabs() { while (!CanManageQueue) { await Task.Delay(20); } if (CanManageQueue) { CanManageQueue = false; try { if (GlobalVariables.CurrentIDs.ID_Tab != 0) { //Code content string content = await ContentViewer.GetCode(); SerrisModulesServer.Manager.AsyncHelpers.RunSync(() => TabsWriteManager.PushTabContentViaIDAsync(GlobalVariables.CurrentIDs, content, false)); //Cursor position PositionSCEE CursorPosition = await ContentViewer.GetCursorPosition(); InfosTab Tab = TabsAccessManager.GetTabViaID(GlobalVariables.CurrentIDs); Tab.TabCursorPosition = new CursorPosition { column = CursorPosition.column, row = CursorPosition.row }; await TabsWriteManager.PushUpdateTabAsync(Tab, GlobalVariables.CurrentIDs.ID_TabsList, false); } } catch { } foreach (CoreApplicationView view in CoreApplication.Views) { if (Dispatcher != view.Dispatcher) { await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messenger.Default.Send(new STSNotification { Type = TypeUpdateTab.TabUpdated, ID = GlobalVariables.CurrentIDs }); }); } } GlobalVariables.CurrentIDs = new TabID { ID_Tab = Queue_Tabs[0].tabID, ID_TabsList = Queue_Tabs[0].tabsListID }; ContentViewer.MonacoModelID = Queue_Tabs[0].monacoModelID; ContentViewer.CursorPositionColumn = Queue_Tabs[0].cursorPositionColumn; ContentViewer.CursorPositionRow = Queue_Tabs[0].cursorPositionLineNumber; ContentViewer.CodeLanguage = Queue_Tabs[0].typeLanguage; ContentViewer.Code = Queue_Tabs[0].code; ChangePushed = false; Queue_Tabs.RemoveAt(0); CanManageQueue = true; } }
public async void ManageQueueTabs() { while (!CanManageQueue) { await Task.Delay(20); } if (CanManageQueue) { CanManageQueue = false; try { if (GlobalVariables.CurrentIDs.ID_Tab != 0) { string content = await ContentViewer.GetCode(); SerrisModulesServer.Manager.AsyncHelpers.RunSync(() => TabsWriteManager.PushTabContentViaIDAsync(GlobalVariables.CurrentIDs, content, false)); } } catch { } foreach (CoreApplicationView view in CoreApplication.Views) { if (Dispatcher != view.Dispatcher) { await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messenger.Default.Send(new STSNotification { Type = TypeUpdateTab.TabUpdated, ID = GlobalVariables.CurrentIDs }); }); } } GlobalVariables.CurrentIDs = new TabID { ID_Tab = Queue_Tabs[0].tabID, ID_TabsList = Queue_Tabs[0].tabsListID }; ContentViewer.CodeLanguage = Queue_Tabs[0].typeLanguage; ContentViewer.Code = Queue_Tabs[0].code; Queue_Tabs.RemoveAt(0); CanManageQueue = true; } }
/* ============= * = FUNCTIONS = * ============= */ private void SetMessenger() { Messenger.Default.Register <TabSelectedNotification>(this, async(notification) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { switch (notification.contactType) { case ContactTypeSCEE.SetCodeForEditor: Queue_Tabs.Add(notification); ManageQueueTabs(); if (GlobalVariables.CurrentDevice == SCEELibs.Editor.CurrentDevice.Desktop) { SetTilebarText(notification.tabName); } break; case ContactTypeSCEE.SetCodeForEditorWithoutUpdate: ContentViewer.MonacoModelID = notification.monacoModelID; ContentViewer.CodeLanguage = notification.typeCode; ContentViewer.Code = notification.code; if (GlobalVariables.CurrentDevice == SCEELibs.Editor.CurrentDevice.Desktop) { SetTilebarText(notification.tabName); } break; case ContactTypeSCEE.ReloadLanguage: if (GlobalVariables.CurrentIDs.ID_Tab == notification.tabID && GlobalVariables.CurrentIDs.ID_TabsList == notification.tabsListID) { ContentViewer.CodeLanguage = notification.typeLanguage; ContentViewer.ForceUpdateLanguage(); } break; } } catch { } }); }); Messenger.Default.Register <EditorViewNotification>(this, async(notification_ui) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { SetTheme(); SetMonacoTheme(); } catch { } }); }); Messenger.Default.Register <BonjourViewControl>(this, async(notification_bjrview) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { PopupGrid.Visibility = Visibility.Collapsed; FrameBonjourView.Content = null; } catch { } }); }); Messenger.Default.Register <SheetViewerNotification>(this, async(notification_ui) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { switch (notification_ui) { case SheetViewerNotification.DeployViewer: UpdateUI(true, false); break; case SheetViewerNotification.MinimizeViewer: UpdateUI(false, false); break; case SheetViewerNotification.DisableAutoDeployer: AutoDeployerEnabled = false; break; case SheetViewerNotification.EnableAutoDeployer: AutoDeployerEnabled = true; break; case SheetViewerNotification.PinViewer: SheetViewerPinned = true; SheetViewSplit.DisplayMode = SplitViewDisplayMode.Inline; SheetsManager.Visibility = Visibility.Collapsed; ContentViewerGrid.Margin = new Thickness(SheetViewSplit.OpenPaneLength, BackgroundPrincipalUIControl.ActualHeight, 0, 0); break; case SheetViewerNotification.UnpinViewer: SheetViewerPinned = false; if (AppSettings.Values.ContainsKey("ui_leftpanelength")) { ContentViewerGrid.Margin = new Thickness((int)AppSettings.Values["ui_leftpanelength"], BackgroundPrincipalUIControl.ActualHeight, 0, 0); } else { ContentViewerGrid.Margin = new Thickness(60, BackgroundPrincipalUIControl.ActualHeight, 0, 0); } UpdateUI(true, true); break; } } catch { } }); }); Messenger.Default.Register <SettingsNotification>(this, async(notification_settings) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { if (notification_settings.SettingsUpdatedName == DefaultSettings.DefaultSettingsMenuList[0].Name && EditorIsLoaded) //If settings updated for Editor, then... { LoadSettings(); } else if (notification_settings.SettingsUpdatedName == DefaultSettings.DefaultSettingsMenuList[1].Name) { SetInterface(); } } catch { } }); }); Messenger.Default.Register <SCEENotification>(this, async(notification_scee) => { await DispatcherHelper.ExecuteOnUIThreadAsync(async() => { try { switch (notification_scee.type) { case SCEENotifType.Injection: ContentViewer.SendAndExecuteJavaScript((string)notification_scee.content); break; case SCEENotifType.SaveCurrentTab when !notification_scee.answerNotification: string content = await ContentViewer.GetCode(); await TabsWriteManager.PushTabContentViaIDAsync(GlobalVariables.CurrentIDs, content, false); Messenger.Default.Send(new SCEENotification { type = SCEENotifType.SaveCurrentTab, answerNotification = true }); ChangePushed = false; break; case SCEENotifType.InjectionAndReturn when !notification_scee.answerNotification: Messenger.Default.Send(new SCEENotification { type = SCEENotifType.InjectionAndReturn, answerNotification = true, content = await ContentViewer.SendAndExecuteJavaScriptWithReturn((string)notification_scee.content) }); break; } } catch { } }); }); }
/* ============= * = FUNCTIONS = * ============= */ private void SetMessenger() { Messenger.Default.Register <TabSelectedNotification>(this, async(notification) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { switch (notification.contactType) { case ContactTypeSCEE.SetCodeForEditor: Queue_Tabs.Add(notification); ManageQueueTabs(); break; case ContactTypeSCEE.SetCodeForEditorWithoutUpdate: ContentViewer.CodeLanguage = notification.typeCode; ContentViewer.Code = notification.code; break; } } catch { } }); }); Messenger.Default.Register <EditorViewNotification>(this, async(notification_ui) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { SetTheme(); SetMonacoTheme(); } catch { } }); }); Messenger.Default.Register <SettingsNotification>(this, async(notification_settings) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { try { if (notification_settings.SettingsUpdatedName == DefaultSettings.DefaultSettingsMenuList[0].Name && EditorIsLoaded) //If settings updated for Editor, then... { LoadSettings(); } else if (notification_settings.SettingsUpdatedName == DefaultSettings.DefaultSettingsMenuList[1].Name) { SetInterface(); } } catch { } }); }); Messenger.Default.Register <SCEENotification>(this, async(notification_scee) => { await DispatcherHelper.ExecuteOnUIThreadAsync(async() => { try { switch (notification_scee.type) { case SCEENotifType.Injection: ContentViewer.SendAndExecuteJavaScript((string)notification_scee.content); break; case SCEENotifType.SaveCurrentTab when !notification_scee.answerNotification: string content = await ContentViewer.GetCode(); await TabsWriteManager.PushTabContentViaIDAsync(GlobalVariables.CurrentIDs, content, false); Messenger.Default.Send(new SCEENotification { type = SCEENotifType.SaveCurrentTab, answerNotification = true }); break; case SCEENotifType.InjectionAndReturn when !notification_scee.answerNotification: Messenger.Default.Send(new SCEENotification { type = SCEENotifType.InjectionAndReturn, answerNotification = true, content = await ContentViewer.SendAndExecuteJavaScriptWithReturn((string)notification_scee.content) }); break; } } catch { } }); }); }