Browse Source

Add outline view pad.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3499 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
08ccdbccfd
  1. BIN
      data/resources/StringResources.es-mx.resources
  2. BIN
      data/resources/StringResources.es.resources
  3. BIN
      data/resources/StringResources.nl.resources
  4. 16
      data/resources/layouts/Debug.xml
  5. 13
      data/resources/layouts/Default.xml
  6. 59
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/OutlineViewPad.cs
  7. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/SharpDevelopElementHost.cs
  8. 59
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  9. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj
  10. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin
  11. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

16
data/resources/layouts/Debug.xml

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
<!--DockPanel configuration file. Author: Weifen Luo, all rights reserved.-->
<!--!!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!!-->
<DockPanel FormatVersion="1.0" DockLeftPortion="0.196180555555556" DockRightPortion="0.171180555555556" DockTopPortion="0.25" DockBottomPortion="0.25" ActiveDocumentPane="10" ActivePane="-1">
<Contents Count="32">
<Contents Count="33">
<Content ID="0" PersistString="ICSharpCode.SharpDevelop.Project.ProjectBrowserPad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="1" PersistString="ICSharpCode.SharpDevelop.Gui.ClassBrowser.ClassBrowserPad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="2" PersistString="ICSharpCode.SharpDevelop.Gui.ErrorListPad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
@ -33,8 +33,9 @@ @@ -33,8 +33,9 @@
<Content ID="27" PersistString="Grunwald.BooBinding.InteractiveInterpreterPad" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
<Content ID="28" PersistString="ICSharpCode.SharpDevelop.Gui.Pads.ConsolePad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="29" PersistString="ICSharpCode.SharpDevelop.Gui.Pads.WatchPad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="30" PersistString="ICSharpCode.SharpDevelop.Gui.SdiWorkspaceWindow" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="31" PersistString="FSharpBinding.FSharpInteractive" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
<Content ID="30" PersistString="FSharpBinding.FSharpInteractive" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
<Content ID="31" PersistString="ICSharpCode.SharpDevelop.Gui.SdiWorkspaceWindow" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="32" PersistString="ICSharpCode.WpfDesign.AddIn.OutlineViewPad" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
</Contents>
<Panes Count="11">
<Pane ID="0" DockState="DockLeft" ActiveContent="0">
@ -76,7 +77,7 @@ @@ -76,7 +77,7 @@
<Content ID="13" RefID="20" />
<Content ID="14" RefID="27" />
<Content ID="15" RefID="11" />
<Content ID="16" RefID="31" />
<Content ID="16" RefID="30" />
</Contents>
</Pane>
<Pane ID="4" DockState="Float" ActiveContent="-1">
@ -105,12 +106,13 @@ @@ -105,12 +106,13 @@
</Contents>
</Pane>
<Pane ID="8" DockState="DockRight" ActiveContent="-1">
<Contents Count="5">
<Contents Count="6">
<Content ID="0" RefID="5" />
<Content ID="1" RefID="25" />
<Content ID="2" RefID="17" />
<Content ID="3" RefID="18" />
<Content ID="4" RefID="16" />
<Content ID="5" RefID="32" />
</Contents>
</Pane>
<Pane ID="9" DockState="Float" ActiveContent="-1">
@ -118,9 +120,9 @@ @@ -118,9 +120,9 @@
<Content ID="0" RefID="29" />
</Contents>
</Pane>
<Pane ID="10" DockState="Document" ActiveContent="30">
<Pane ID="10" DockState="Document" ActiveContent="31">
<Contents Count="1">
<Content ID="0" RefID="30" />
<Content ID="0" RefID="31" />
</Contents>
</Pane>
</Panes>

13
data/resources/layouts/Default.xml

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
<!--DockPanel configuration file. Author: Weifen Luo, all rights reserved.-->
<!--!!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!!-->
<DockPanel FormatVersion="1.0" DockLeftPortion="0.196180555555556" DockRightPortion="0.172743055555556" DockTopPortion="0.25" DockBottomPortion="0.25" ActiveDocumentPane="-1" ActivePane="-1">
<Contents Count="31">
<Contents Count="32">
<Content ID="0" PersistString="ICSharpCode.SharpDevelop.Project.ProjectBrowserPad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="1" PersistString="ICSharpCode.SharpDevelop.Gui.ClassBrowser.ClassBrowserPad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="2" PersistString="ICSharpCode.SharpDevelop.Gui.ErrorListPad" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
@ -34,8 +34,9 @@ @@ -34,8 +34,9 @@
<Content ID="28" PersistString="ICSharpCode.SharpDevelop.Gui.Pads.ConsolePad" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
<Content ID="29" PersistString="ICSharpCode.SharpDevelop.Gui.Pads.WatchPad" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
<Content ID="30" PersistString="FSharpBinding.FSharpInteractive" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
<Content ID="31" PersistString="ICSharpCode.WpfDesign.AddIn.OutlineViewPad" AutoHidePortion="0.25" IsHidden="True" IsFloat="False" />
</Contents>
<Panes Count="5">
<Panes Count="6">
<Pane ID="0" DockState="DockRight" ActiveContent="5">
<Contents Count="6">
<Content ID="0" RefID="5" />
@ -90,14 +91,20 @@ @@ -90,14 +91,20 @@
<Content ID="6" RefID="11" />
</Contents>
</Pane>
<Pane ID="5" DockState="DockLeft" ActiveContent="-1">
<Contents Count="1">
<Content ID="0" RefID="31" />
</Contents>
</Pane>
</Panes>
<DockWindows>
<DockWindow ID="0" DockState="Document" ZOrderIndex="1">
<NestedPanes Count="0" />
</DockWindow>
<DockWindow ID="1" DockState="DockLeft" ZOrderIndex="4">
<NestedPanes Count="1">
<NestedPanes Count="2">
<Pane ID="0" RefID="1" PrevPane="-1" Alignment="Bottom" Proportion="0.5" />
<Pane ID="1" RefID="5" PrevPane="1" Alignment="Bottom" Proportion="0.5" />
</NestedPanes>
</DockWindow>
<DockWindow ID="2" DockState="DockRight" ZOrderIndex="5">

59
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/OutlineViewPad.cs

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.WpfDesign.AddIn
{
public class OutlineViewPad : AbstractPadContent
{
SharpDevelopElementHost host = new SharpDevelopElementHost();
TextBlock notAvailableTextBlock = new TextBlock {
Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.OutlinePad.NotAvailable}"),
TextWrapping = TextWrapping.Wrap
};
public OutlineViewPad()
{
WorkbenchSingleton.Workbench.ActiveViewContentChanged += WorkbenchActiveViewContentChanged;
WorkbenchActiveViewContentChanged(null, null);
}
void WorkbenchActiveViewContentChanged(object sender, EventArgs e)
{
WpfViewContent wpfView = WorkbenchSingleton.Workbench.ActiveViewContent as WpfViewContent;
if (wpfView != null) {
host.Child = wpfView.Outline;
} else {
host.Child = notAvailableTextBlock;
}
}
/// <summary>
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
/// </summary>
public override System.Windows.Forms.Control Control {
get {
return host;
}
}
/// <summary>
/// Cleans up all used resources
/// </summary>
public override void Dispose()
{
host.Dispose();
base.Dispose();
}
}
}

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/SharpDevelopElementHost.cs

@ -22,13 +22,17 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -22,13 +22,17 @@ namespace ICSharpCode.WpfDesign.AddIn
[ThreadStatic]
static bool registeredErrorHandler;
public SharpDevelopElementHost(WpfViewContent viewContent, UIElement child)
public SharpDevelopElementHost()
{
if (!registeredErrorHandler) {
registeredErrorHandler = true;
Dispatcher.CurrentDispatcher.UnhandledException += CurrentDispatcher_UnhandledException;
}
}
public SharpDevelopElementHost(WpfViewContent viewContent, UIElement child)
: this()
{
this.viewContent = viewContent;
this.Child = child;
}
@ -43,15 +47,19 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -43,15 +47,19 @@ namespace ICSharpCode.WpfDesign.AddIn
bool IsEnabled(RoutedCommand command)
{
if (command.CanExecute(null, null)) return true;
return command.CanExecute(null, viewContent.DesignSurface);
if (command.CanExecute(null, null))
return true;
else if (viewContent != null)
return command.CanExecute(null, viewContent.DesignSurface);
else
return false;
}
void Run(RoutedCommand command)
{
if (command.CanExecute(null, null)) {
command.Execute(null, null);
} else {
} else if (viewContent != null) {
command.Execute(null, viewContent.DesignSurface);
}
}

59
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

@ -5,24 +5,24 @@ @@ -5,24 +5,24 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using System.Windows.Markup;
using System.Xml;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using System.IO;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
namespace ICSharpCode.WpfDesign.AddIn
{
@ -30,23 +30,23 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -30,23 +30,23 @@ namespace ICSharpCode.WpfDesign.AddIn
/// IViewContent implementation that hosts the WPF designer.
/// </summary>
public class WpfViewContent : AbstractViewContentHandlingLoadErrors, IHasPropertyContainer, IToolsHost
{
{
public WpfViewContent(OpenedFile file) : base(file)
{
BasicMetadata.Register();
this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}";
this.IsActiveViewContentChanged += OnIsActiveViewContentChanged;
this.editor = file.RegisteredViewContents[0] as TextEditorDisplayBindingWrapper;
}
ElementHost wpfHost;
DesignSurface designer;
List<Task> tasks = new List<Task>();
// save text from editor when designer cannot be saved (e.g. invalid xml)
TextEditorDisplayBindingWrapper editor;
TextEditorDisplayBindingWrapper editor;
public DesignSurface DesignSurface {
get { return designer; }
}
@ -58,15 +58,18 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -58,15 +58,18 @@ namespace ICSharpCode.WpfDesign.AddIn
protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
{
Debug.Assert(file == this.PrimaryFile);
if (designer == null) {
// initialize designer on first load
DragDropExceptionHandler.HandleException = ICSharpCode.Core.MessageService.ShowError;
designer = new DesignSurface();
wpfHost = new SharpDevelopElementHost(this, designer);
wpfHost = new SharpDevelopElementHost(this, designer);
this.UserControl = wpfHost;
InitPropertyEditor();
}
if (outline != null) {
outline.Root = null;
}
using (XmlTextReader r = new XmlTextReader(stream)) {
XamlLoadSettings settings = new XamlLoadSettings();
settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly);
@ -81,9 +84,13 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -81,9 +84,13 @@ namespace ICSharpCode.WpfDesign.AddIn
settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile);
designer.LoadDesigner(r, settings);
UpdateTasks();
if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) {
outline.Root = OutlineNode.Create(designer.DesignContext.RootItem);
}
propertyGridView.PropertyGrid.SelectedItems = null;
designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged;
designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged;
@ -105,20 +112,20 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -105,20 +112,20 @@ namespace ICSharpCode.WpfDesign.AddIn
editor.Save(file, stream);
}
}
public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView)
{
return newView == editor && !designer.DesignContext.CanSave;
}
void UpdateTasks()
{
foreach (var task in tasks) {
TaskService.Remove(task);
}
tasks.Clear();
var xamlErrorService = designer.DesignContext.Services.GetService<XamlErrorService>();
foreach (var error in xamlErrorService.Errors) {
var task = new Task(PrimaryFile.FileName, error.Message, error.Column - 1, error.Line - 1, TaskType.Error);
@ -140,7 +147,7 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -140,7 +147,7 @@ namespace ICSharpCode.WpfDesign.AddIn
void InitPropertyEditor()
{
propertyGridView = new PropertyGridView();
propertyEditorHost = new SharpDevelopElementHost(this, propertyGridView);
propertyEditorHost = new SharpDevelopElementHost(this, propertyGridView);
propertyContainer.PropertyGridReplacementControl = propertyEditorHost;
}
@ -195,5 +202,19 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -195,5 +202,19 @@ namespace ICSharpCode.WpfDesign.AddIn
}
}
}
Outline outline;
public Outline Outline {
get {
if (outline == null) {
outline = new Outline();
if (DesignSurface != null && DesignSurface.DesignContext != null && DesignSurface.DesignContext.RootItem != null) {
outline.Root = OutlineNode.Create(DesignSurface.DesignContext.RootItem);
}
}
return outline;
}
}
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj

@ -65,6 +65,7 @@ @@ -65,6 +65,7 @@
<Compile Include="Src\ObjectEditor.xaml.cs">
<DependentUpon>ObjectEditor.xaml</DependentUpon>
</Compile>
<Compile Include="Src\OutlineViewPad.cs" />
<Compile Include="Src\PropertyDescriptionService.cs" />
<Compile Include="Src\SharpDevelopElementHost.cs" />
<Compile Include="Src\WpfAndWinFormsTopLevelWindowService.cs" />

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin

@ -23,4 +23,13 @@ @@ -23,4 +23,13 @@
class = "ICSharpCode.WpfDesign.AddIn.WpfSecondaryDisplayBinding"
fileNamePattern = "\.xaml$"/>
</Path>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "OutlineViewPad"
category = "Tools"
title = "${res:ICSharpCode.SharpDevelop.Gui.OutlinePad}"
icon = "PadIcons.BreakPoints"
shortcut = "Control|Alt|I"
class = "ICSharpCode.WpfDesign.AddIn.OutlineViewPad"/>
</Path>
</AddIn>

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save