Example #1
0
        /* =============
         * = 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 { }
                });
            });
        }
Example #2
0
        /* =============
         * = 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 { }
                });
            });
        }