public static void GenerateCodeFor(ScreenSave screenSave, bool save = false) { var isNetworkScreen = NetworkScreenViewModel.IsNetworked(screenSave); if (isNetworkScreen) { var screenGeneratedCode = GetGeneratedScreenCode(screenSave); var generatedScreenNetworkFilePath = CodeGeneratorCommonLogic.GetGeneratedElementNetworkFilePathFor(screenSave); CodeGeneratorCommonLogic.SaveFile(screenGeneratedCode, generatedScreenNetworkFilePath); CodeGeneratorCommonLogic.AddCodeFileToProject(generatedScreenNetworkFilePath); var customScreenNetworkFilePath = CodeGeneratorCommonLogic.GetCustomElementNetworkFilePathFor(screenSave); if (customScreenNetworkFilePath.Exists() == false) { var customScreenNetworkCode = GenerateEmptyCustomScreenNetworkCode(screenSave); CodeGeneratorCommonLogic.SaveFile(customScreenNetworkCode, customScreenNetworkFilePath); } CodeGeneratorCommonLogic.AddCodeFileToProject(customScreenNetworkFilePath); GlueCommands.Self.ProjectCommands.MakeGeneratedCodeItemsNested(); if (save) { GlueCommands.Self.ProjectCommands.SaveProjects(); } } }
private void HandleGluxLoaded() { TaskManager.Self.AddSync(() => { var areAnyNetworked = false; foreach (var screen in GlueState.Self.CurrentGlueProject.Screens) { if (NetworkScreenViewModel.IsNetworked(screen)) { areAnyNetworked = true; NetworkScreenCodeGenerator.GenerateCodeFor(screen, save: false); } } foreach (var entity in GlueState.Self.CurrentGlueProject.Entities) { if (NetworkEntityViewModel.IsNetworked(entity)) { areAnyNetworked = true; NetworkEntityCodeGenerator.GenerateCodeFor(entity, save: false); } } if (areAnyNetworked) { NetworkConfigurationCodeGenerator.GenerateConfiguration(); GlueCommands.Self.ProjectCommands.SaveProjects(); } }, "Regenerating network files"); }
private void HandleScreenRemoved(ScreenSave screen, List <string> filesToRemove) { if (NetworkScreenViewModel.IsNetworked(screen)) { filesToRemove.Add(CodeGeneratorCommonLogic.GetGeneratedElementNetworkFilePathFor(screen).FullPath); filesToRemove.Add(CodeGeneratorCommonLogic.GetCustomElementNetworkFilePathFor(screen).FullPath); } }
public static void GenerateAllNetworkScreenCode() { var screensToRegenerate = GlueState.Self.CurrentGlueProject.Screens .Where(item => NetworkScreenViewModel.IsNetworked(item)) .ToArray(); foreach (var screen in screensToRegenerate) { NetworkScreenCodeGenerator.GenerateCodeFor(screen); } }
private void HandleItemSelected(TreeNode selectedTreeNode) { if (selectedTreeNode.IsEntityNode()) { var entity = GlueState.Self.CurrentEntitySave; entityViewModel = new NetworkEntityViewModel(); entityViewModel.SetFrom(entity); entityViewModel.PropertyChanged += HandleEntityViewModelPropertyChanged; mainEntityView.DataContext = entityViewModel; if (entityTab.LastTabControl == null) { this.ShowTab(entityTab, TabLocation.Center); } else { this.ShowTab(entityTab); } } else { this.RemoveTab(entityTab); } if (selectedTreeNode.IsScreenNode()) { var screen = GlueState.Self.CurrentScreenSave; screenViewModel = new NetworkScreenViewModel(); screenViewModel.SetFrom(screen); screenViewModel.PropertyChanged += HandleScreenViewModelPropertyChanged; mainScreenView.DataContext = screenViewModel; if (screenTab.LastTabControl == null) { this.ShowTab(screenTab, TabLocation.Center); } else { this.ShowTab(screenTab); } } else { this.RemoveTab(screenTab); } }
private void HandleScreenViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) { var currentScreen = GlueState.Self.CurrentScreenSave; if (currentScreen != null && screenViewModel != null) { TaskManager.Self.AddSync(() => { screenViewModel.ApplyTo(currentScreen); GlueCommands.Self.GluxCommands.SaveGluxTask(); var shouldRegenerate = true; if (e.PropertyName == nameof(NetworkScreenViewModel.IsNetworkScreen)) { if (NetworkScreenViewModel.IsNetworked(currentScreen) == false) { shouldRegenerate = false; CodeGeneratorCommonLogic.RemoveCodeFileFromProject( CodeGeneratorCommonLogic.GetGeneratedElementNetworkFilePathFor(currentScreen)); CodeGeneratorCommonLogic.RemoveCodeFileFromProject( CodeGeneratorCommonLogic.GetCustomElementNetworkFilePathFor(currentScreen)); } else { NetworkConfigurationCodeGenerator.GenerateConfiguration(); MessagesCodeGenerator.GenerateAllMessages(); } } if (shouldRegenerate) { NetworkScreenCodeGenerator.GenerateCodeFor(currentScreen); } }, $"Regenerating network screen {currentScreen}"); } }