From f35fe33171a1438f4f13d438495c4db950fbc577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 11 Oct 2015 18:50:08 +0200 Subject: [PATCH] bug fix in renaming form .pas file --- PluginsSupport/Interfaces.cs | 2 ++ VisualPascalABCNET/Projects/ProjectExplorer.cs | 9 +++++++-- VisualPascalABCNET/Workbench/DesignerService.cs | 6 ++++++ VisualPascalABCNET/Workbench/FileOperations.cs | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/PluginsSupport/Interfaces.cs b/PluginsSupport/Interfaces.cs index 3077374f2..9db90d7d2 100644 --- a/PluginsSupport/Interfaces.cs +++ b/PluginsSupport/Interfaces.cs @@ -263,6 +263,7 @@ namespace VisualPascalABCPlugins void RenameFile(string OldFileName, string NewFileName); void CloseFile(string FileName); void ReloadFile(string FileName); + bool SaveAll(bool Question); void SetFileAsChanged(string FileName); void OpenTabWithText(string tabName, string Text); ICodeFileDocument OpenFileForDebug(string FileName); @@ -282,6 +283,7 @@ namespace VisualPascalABCPlugins void DisableDesigner(); void EnableDesigner(); void GenerateAllDesignersCode(); + void SetActiveDesignerDirty(); } public interface IWorkbenchRunService diff --git a/VisualPascalABCNET/Projects/ProjectExplorer.cs b/VisualPascalABCNET/Projects/ProjectExplorer.cs index 0080e1266..0ec10890d 100644 --- a/VisualPascalABCNET/Projects/ProjectExplorer.cs +++ b/VisualPascalABCNET/Projects/ProjectExplorer.cs @@ -391,9 +391,10 @@ namespace VisualPascalABC { ProjectFactory.Instance.CurrentProject.MainFile = System.IO.Path.Combine(ProjectFactory.Instance.CurrentProject.ProjectDirectory,e.Label); } - VisualPABCSingleton.MainForm.RenameFile(oldFileName,fi.Path); + WorkbenchServiceFactory.FileService.RenameFile(oldFileName, fi.Path); CodeCompletionActionsManager.RenameUnit(fi.Path, Path.GetFileNameWithoutExtension(e.Label)); string oldFileNameWithoutExt = Path.Combine(Path.GetDirectoryName(oldFileName),Path.GetFileNameWithoutExtension(oldFileName)); + string newFilePath = Path.Combine(Path.GetDirectoryName(oldFileName), e.Label); if (File.Exists(oldFileNameWithoutExt+".fmabc")) { string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc"); @@ -401,7 +402,11 @@ namespace VisualPascalABC File.Delete(fmabcFullName); } ProjectFactory.Instance.SaveProject(); - VisualPABCSingleton.MainForm.SaveAll(false); + WorkbenchServiceFactory.FileService.SaveAll(false); + WorkbenchServiceFactory.FileService.CloseFile(newFilePath); + WorkbenchServiceFactory.FileService.OpenFile(newFilePath, Path.GetFileName(newFilePath)); + WorkbenchServiceFactory.DesignerService.SetActiveDesignerDirty(); + WorkbenchServiceFactory.DesignerService.GenerateAllDesignersCode(); /*if (File.Exists(oldFileNameWithoutExt + ".resources")) { string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc"); diff --git a/VisualPascalABCNET/Workbench/DesignerService.cs b/VisualPascalABCNET/Workbench/DesignerService.cs index 0f4c9ce3d..9fa058d0a 100644 --- a/VisualPascalABCNET/Workbench/DesignerService.cs +++ b/VisualPascalABCNET/Workbench/DesignerService.cs @@ -26,6 +26,12 @@ namespace VisualPascalABC } } + public void SetActiveDesignerDirty() + { + if (_currentCodeFileDocument.Designer != null) + _currentCodeFileDocument.Designer.IsDirty = true; + } + public void UpdateDesignerIsActive() { bool active = diff --git a/VisualPascalABCNET/Workbench/FileOperations.cs b/VisualPascalABCNET/Workbench/FileOperations.cs index 07417a74c..491075b54 100644 --- a/VisualPascalABCNET/Workbench/FileOperations.cs +++ b/VisualPascalABCNET/Workbench/FileOperations.cs @@ -398,7 +398,7 @@ namespace VisualPascalABC } - internal bool SaveAll(bool Question) + public bool SaveAll(bool Question) { if (ProjectFactory.Instance.ProjectLoaded && Question) {