diff --git a/src/Main/Base/Project/Src/Gui/IWorkbench.cs b/src/Main/Base/Project/Src/Gui/IWorkbench.cs index d1ebbaee2e..5dac4c4ffd 100644 --- a/src/Main/Base/Project/Src/Gui/IWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/IWorkbench.cs @@ -157,18 +157,6 @@ namespace ICSharpCode.SharpDevelop.Gui /// void CloseAllViews(); - /// - /// Re-initializes all components of the workbench, should be called - /// when a special property is changed that affects layout stuff. - /// (like language change) - /// - void RedrawAllComponents(); - - /// - /// Updates the toolstrip renderer. - /// - void UpdateRenderer(); - /// /// Is called, when a workbench view was opened /// diff --git a/src/Main/Base/Project/Src/Gui/Workbench/SingleInstanceHelper.cs b/src/Main/Base/Project/Src/Gui/Workbench/SingleInstanceHelper.cs index 8ca1fa72e8..258069a317 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/SingleInstanceHelper.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/SingleInstanceHelper.cs @@ -1,7 +1,7 @@ // // // -// +// // $Revision$ // @@ -59,17 +59,18 @@ namespace ICSharpCode.SharpDevelop.Gui } } - internal static bool PreFilterMessage(ref Message m) + internal static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { - if (m.Msg != CUSTOM_MESSAGE) - return false; - long fileNumber = m.WParam.ToInt64(); - long openEvenIfProjectIsOpened = m.LParam.ToInt64(); + if (msg != CUSTOM_MESSAGE) { + return IntPtr.Zero; + } + handled = true; + long fileNumber = wParam.ToInt64(); + long openEvenIfProjectIsOpened = lParam.ToInt64(); LoggingService.Info("Receiving custom message..."); if (openEvenIfProjectIsOpened == 0 && ProjectService.OpenSolution != null) { - m.Result = new IntPtr(RESULT_PROJECT_IS_OPEN); + return new IntPtr(RESULT_PROJECT_IS_OPEN); } else { - m.Result = new IntPtr(RESULT_FILES_HANDLED); try { WorkbenchSingleton.SafeThreadAsyncCall( delegate { NativeMethods.SetForegroundWindow(WorkbenchSingleton.MainWin32Window.Handle) ; } @@ -84,8 +85,8 @@ namespace ICSharpCode.SharpDevelop.Gui } catch (Exception ex) { LoggingService.Warn(ex); } + return new IntPtr(RESULT_FILES_HANDLED); } - return true; } } } diff --git a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs index d6dc9e947d..7c0b8e6086 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs @@ -16,6 +16,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Navigation; using ICSharpCode.Core; @@ -71,6 +72,7 @@ namespace ICSharpCode.SharpDevelop.Gui { this.MainWin32Window = this.GetWin32Window(); base.OnSourceInitialized(e); + HwndSource.FromHwnd(this.MainWin32Window.Handle).AddHook(SingleInstanceHelper.WndProc); } public void Initialize() @@ -96,6 +98,13 @@ namespace ICSharpCode.SharpDevelop.Gui AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(OnRequestNavigate)); Project.ProjectService.CurrentProjectChanged += SetProjectTitle; + FileService.FileRemoved += CheckRemovedOrReplacedFile; + FileService.FileReplaced += CheckRemovedOrReplacedFile; + FileService.FileRenamed += CheckRenamedFile; + + FileService.FileRemoved += FileService.RecentOpen.FileRemoved; + FileService.FileRenamed += FileService.RecentOpen.FileRenamed; + requerySuggestedEventHandler = new EventHandler(CommandManager_RequerySuggested); CommandManager.RequerySuggested += requerySuggestedEventHandler; @@ -133,6 +142,42 @@ namespace ICSharpCode.SharpDevelop.Gui } } + void CheckRemovedOrReplacedFile(object sender, FileEventArgs e) + { + foreach (OpenedFile file in FileService.OpenedFiles) { + if (FileUtility.IsBaseDirectory(e.FileName, file.FileName)) { + foreach (IViewContent content in file.RegisteredViewContents.ToArray()) { + // content.WorkbenchWindow can be null if multiple view contents + // were in the same WorkbenchWindow and both should be closed + // (e.g. Windows Forms Designer, Subversion History View) + if (content.WorkbenchWindow != null) { + content.WorkbenchWindow.CloseWindow(true); + } + } + } + } + } + + void CheckRenamedFile(object sender, FileRenameEventArgs e) + { + if (e.IsDirectory) { + foreach (OpenedFile file in FileService.OpenedFiles) { + if (file.FileName != null && FileUtility.IsBaseDirectory(e.SourceFile, file.FileName)) { + file.FileName = FileUtility.RenameBaseDirectory(file.FileName, e.SourceFile, e.TargetFile); + } + } + } else { + foreach (OpenedFile file in FileService.OpenedFiles) { + if (file.FileName != null && + FileUtility.IsEqualFileName(file.FileName, e.SourceFile)) + { + file.FileName = e.TargetFile; + return; + } + } + } + } + void UpdateMenu() { MenuService.UpdateStatus(mainMenu.ItemsSource); @@ -433,14 +478,6 @@ namespace ICSharpCode.SharpDevelop.Gui } #endregion - public void RedrawAllComponents() - { - } - - public void UpdateRenderer() - { - } - public Properties CreateMemento() { Properties prop = new Properties(); @@ -467,6 +504,12 @@ namespace ICSharpCode.SharpDevelop.Gui { base.OnClosing(e); if (!e.Cancel) { + if (Project.ProjectService.IsBuilding) { + MessageService.ShowMessage(StringParser.Parse("${res:MainWindow.CannotCloseWithBuildInProgressMessage}")); + e.Cancel = true; + return; + } + Project.ProjectService.SaveSolutionPreferences(); while (WorkbenchSingleton.Workbench.WorkbenchWindowCollection.Count > 0) { @@ -488,6 +531,69 @@ namespace ICSharpCode.SharpDevelop.Gui } } + protected override void OnDragEnter(DragEventArgs e) + { + try { + base.OnDragEnter(e); + if (!e.Handled) { + e.Effects = GetEffect(e.Data); + e.Handled = true; + } + } catch (Exception ex) { + MessageService.ShowError(ex); + } + } + + protected override void OnDragOver(DragEventArgs e) + { + try { + base.OnDragOver(e); + if (!e.Handled) { + e.Effects = GetEffect(e.Data); + e.Handled = true; + } + } catch (Exception ex) { + MessageService.ShowError(ex); + } + } + + DragDropEffects GetEffect(IDataObject data) + { + if (data != null && data.GetDataPresent(DataFormats.FileDrop)) { + string[] files = (string[])data.GetData(DataFormats.FileDrop); + foreach (string file in files) { + if (File.Exists(file)) { + return DragDropEffects.Link; + } + } + } + return DragDropEffects.None; + } + + protected override void OnDrop(DragEventArgs e) + { + try { + base.OnDrop(e); + if (!e.Handled && e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) { + e.Handled = true; + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + + foreach (string file in files) { + if (File.Exists(file)) { + Project.IProjectLoader loader = Project.ProjectService.GetProjectLoader(file); + if (loader != null) { + FileUtility.ObservedLoad(new NamedFileOperationDelegate(loader.Load), file); + } else { + FileService.OpenFile(file); + } + } + } + } + } catch (Exception ex) { + MessageService.ShowError(ex); + } + } + void InitFocusTrackingEvents() { #if DEBUG @@ -495,7 +601,7 @@ namespace ICSharpCode.SharpDevelop.Gui this.PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(WpfWorkbench_PreviewGotKeyboardFocus); #endif } - + #if DEBUG bool toggle; diff --git a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml index 8928b9c59f..3b49ed4abe 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml +++ b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml @@ -4,7 +4,8 @@ xmlns:core = "http://icsharpcode.net/sharpdevelop/core" Title = "{core:Localize MainWindow.DialogName}" WindowStartupLocation = "Manual" - Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" + Background = "{DynamicResource {x:Static SystemColors.ControlBrushKey}}" + AllowDrop = "True" > diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index 21d0326dc1..28302e5cdb 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -57,25 +57,6 @@ namespace ICSharpCode.SharpDevelop.Gui } } - /// - /// This method handles the redraw all event for specific changed IDE properties - /// - static void TrackPropertyChanges(object sender, PropertyChangedEventArgs e) - { - if (e.OldValue != e.NewValue && workbench != null) { - switch (e.Key) { - case "ICSharpCode.SharpDevelop.Gui.StatusBarVisible": - case "ICSharpCode.SharpDevelop.Gui.VisualStyle": - case "ICSharpCode.SharpDevelop.Gui.ToolBarVisible": - workbench.RedrawAllComponents(); - break; - case "ICSharpCode.SharpDevelop.Gui.UseProfessionalRenderer": - workbench.UpdateRenderer(); - break; - } - } - } - /// /// Runs workbench initialization. /// Is called by ICSharpCode.SharpDevelop.Sda and should not be called manually! @@ -106,9 +87,6 @@ namespace ICSharpCode.SharpDevelop.Gui WinFormsMessageService.DialogOwner = workbench.MainWin32Window; WinFormsMessageService.DialogSynchronizeInvoke = workbench.SynchronizingObject; - PropertyService.PropertyChanged += new PropertyChangedEventHandler(TrackPropertyChanges); - ResourceService.LanguageChanged += delegate { workbench.RedrawAllComponents(); }; - workbench.Initialize(); workbench.SetMemento(PropertyService.Get(workbenchMemento, new Properties())); workbench.WorkbenchLayout = layout; diff --git a/src/Tools/UpdateAssemblyInfo/Main.cs b/src/Tools/UpdateAssemblyInfo/Main.cs index a5cf29f7a4..40b29f014e 100644 --- a/src/Tools/UpdateAssemblyInfo/Main.cs +++ b/src/Tools/UpdateAssemblyInfo/Main.cs @@ -188,12 +188,6 @@ namespace UpdateAssemblyInfo Console.WriteLine("The revision number of the SharpDevelop version being compiled could not be retrieved."); Console.WriteLine(); Console.WriteLine("Build continues with revision number '0'..."); - try { - Process[] p = Process.GetProcessesByName("msbuild"); - if (p != null && p.Length > 0) { - System.Threading.Thread.Sleep(3000); - } - } catch {} return "0"; } } @@ -220,8 +214,9 @@ namespace UpdateAssemblyInfo if (revisionNumber == null || revisionNumber.Length == 0 || revisionNumber == "0") { revisionNumber = ReadRevisionFromFile(); } - if (revisionNumber == null || revisionNumber.Length == 0 || revisionNumber == "0") { - throw new ApplicationException("Error reading revision number"); + if (revisionNumber == null || revisionNumber.Length == 0) { + revisionNumber = "0"; + //throw new ApplicationException("Error reading revision number"); } } #endregion diff --git a/src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe b/src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe index c702a24e6b..e5bb0dc9a8 100755 Binary files a/src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe and b/src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe differ