Browse Source

Make IHasPropertyContainer a [ViewContentService].

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
9193b83219
  1. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs
  2. 4
      src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs
  3. 8
      src/Main/Base/Project/Src/Gui/AbstractPadContent.cs
  4. 2
      src/Main/Base/Project/Src/Gui/IPadContent.cs
  5. 2
      src/Main/Base/Project/Src/Gui/IWorkbench.cs
  6. 2
      src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs
  7. 9
      src/Main/Base/Project/Src/Gui/Pads/FileScout.cs
  8. 1
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs
  9. 5
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  10. 2
      src/Main/SharpDevelop/Workbench/AvalonDockLayout.cs
  11. 4
      src/Main/SharpDevelop/Workbench/WpfWorkbench.cs

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs

@ -133,7 +133,7 @@ namespace ICSharpCode.XmlEditor
protected override void LoadFromPrimary() protected override void LoadFromPrimary()
{ {
IFileDocumentProvider provider = this.PrimaryViewContent as IFileDocumentProvider; IFileDocumentProvider provider = this.PrimaryViewContent.GetRequiredService<IFileDocumentProvider>();
IDocument document = provider.GetDocumentForFile(this.PrimaryFile); IDocument document = provider.GetDocumentForFile(this.PrimaryFile);
treeViewContainer.LoadXml(document.Text); treeViewContainer.LoadXml(document.Text);
XmlView view = XmlView.ForFile(this.PrimaryFile); XmlView view = XmlView.ForFile(this.PrimaryFile);

4
src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs

@ -46,7 +46,7 @@ namespace SearchAndReplace
class SearchableFileContentFinder class SearchableFileContentFinder
{ {
FileName[] viewContentFileNamesCollection = WorkbenchSingleton.SafeThreadFunction(() => SD.FileService.OpenedFiles.Select(f => f.FileName).ToArray()); FileName[] viewContentFileNamesCollection = SD.MainThread.InvokeIfRequired(() => SD.FileService.OpenedFiles.Select(f => f.FileName).ToArray());
static ITextSource ReadFile(FileName fileName) static ITextSource ReadFile(FileName fileName)
{ {
@ -75,7 +75,7 @@ namespace SearchAndReplace
using (Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { using (Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) {
if (MimeTypeDetection.FindMimeType(stream).StartsWith("text/")) { if (MimeTypeDetection.FindMimeType(stream).StartsWith("text/")) {
stream.Position = 0; stream.Position = 0;
return new StringTextSource(ICSharpCode.AvalonEdit.Utils.FileReader.ReadFileContent(stream, Encoding.Default)); return new StringTextSource(ICSharpCode.AvalonEdit.Utils.FileReader.ReadFileContent(stream, SD.FileService.DefaultFileEncoding));
} }
} }
return null; return null;

8
src/Main/Base/Project/Src/Gui/AbstractPadContent.cs

@ -38,5 +38,13 @@ namespace ICSharpCode.SharpDevelop.Gui
return WorkbenchSingleton.Workbench.GetPad(GetType()); return WorkbenchSingleton.Workbench.GetPad(GetType());
} }
} }
public virtual object GetService(Type serviceType)
{
if (serviceType.IsInstanceOfType(this))
return this;
else
return null;
}
} }
} }

2
src/Main/Base/Project/Src/Gui/IPadContent.cs

@ -10,7 +10,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// The IPadContent interface is the basic interface to all "tool" windows /// The IPadContent interface is the basic interface to all "tool" windows
/// in SharpDevelop. /// in SharpDevelop.
/// </summary> /// </summary>
public interface IPadContent : IDisposable public interface IPadContent : IDisposable, IServiceProvider
{ {
/// <summary> /// <summary>
/// This is the UI element for the view. /// This is the UI element for the view.

2
src/Main/Base/Project/Src/Gui/IWorkbench.cs

@ -98,7 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// If a document is currently active, this will be equal to ActiveViewContent, /// If a document is currently active, this will be equal to ActiveViewContent,
/// if a pad has the focus, this property will return the IPadContent instance. /// if a pad has the focus, this property will return the IPadContent instance.
/// </summary> /// </summary>
object ActiveContent { IServiceProvider ActiveContent {
get; get;
} }

2
src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// The active content. This can be either a IViewContent or a IPadContent, depending on /// The active content. This can be either a IViewContent or a IPadContent, depending on
/// where the focus currently is. /// where the focus currently is.
/// </summary> /// </summary>
object ActiveContent { IServiceProvider ActiveContent {
get; get;
} }

9
src/Main/Base/Project/Src/Gui/Pads/FileScout.cs

@ -323,18 +323,23 @@ namespace ICSharpCode.SharpDevelop.Gui
public class FileScout : UserControl, IPadContent public class FileScout : UserControl, IPadContent
{ {
public object Control { object IPadContent.Control {
get { get {
return this; return this;
} }
} }
public object InitiallyFocusedControl { object IPadContent.InitiallyFocusedControl {
get { get {
return null; return null;
} }
} }
object IServiceProvider.GetService(Type type)
{
return null;
}
Splitter splitter1 = new Splitter(); Splitter splitter1 = new Splitter();
FileList filelister = new FileList(); FileList filelister = new FileList();

1
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs

@ -14,6 +14,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// One view/pad content instance has to always return the same property container instance /// One view/pad content instance has to always return the same property container instance
/// and has to change only the properties on that PropertyContainer. /// and has to change only the properties on that PropertyContainer.
/// </summary> /// </summary>
[ViewContentService]
public interface IHasPropertyContainer public interface IHasPropertyContainer
{ {
PropertyContainer PropertyContainer { get; } PropertyContainer PropertyContainer { get; }

5
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs

@ -127,10 +127,11 @@ namespace ICSharpCode.SharpDevelop.Gui
void WorkbenchActiveContentChanged(object sender, EventArgs e) void WorkbenchActiveContentChanged(object sender, EventArgs e)
{ {
IHasPropertyContainer c = WorkbenchSingleton.Workbench.ActiveContent as IHasPropertyContainer; var activeViewOrPad = WorkbenchSingleton.Workbench.ActiveContent;
IHasPropertyContainer c = activeViewOrPad != null ? activeViewOrPad.GetService<IHasPropertyContainer>() : null;
if (c == null) { if (c == null) {
if (previousContent == null) { if (previousContent == null) {
c = WorkbenchSingleton.Workbench.ActiveViewContent as IHasPropertyContainer; c = SD.GetActiveViewContentService<IHasPropertyContainer>();
} else { } else {
// if the previous content is no longer visible, we have to remove the active container // if the previous content is no longer visible, we have to remove the active container
if (previousContent is IViewContent && previousContent != WorkbenchSingleton.Workbench.ActiveViewContent) { if (previousContent is IViewContent && previousContent != WorkbenchSingleton.Workbench.ActiveViewContent) {

2
src/Main/SharpDevelop/Workbench/AvalonDockLayout.cs

@ -92,7 +92,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
public event EventHandler ActiveContentChanged; public event EventHandler ActiveContentChanged;
public object ActiveContent { public IServiceProvider ActiveContent {
get { get {
object activeContent = dockingManager.ActiveContent; object activeContent = dockingManager.ActiveContent;
AvalonPadContent padContent = activeContent as AvalonPadContent; AvalonPadContent padContent = activeContent as AvalonPadContent;

4
src/Main/SharpDevelop/Workbench/WpfWorkbench.cs

@ -340,9 +340,9 @@ namespace ICSharpCode.SharpDevelop.Workbench
} }
} }
object activeContent; IServiceProvider activeContent;
public object ActiveContent { public IServiceProvider ActiveContent {
get { get {
WorkbenchSingleton.AssertMainThread(); WorkbenchSingleton.AssertMainThread();
return activeContent; return activeContent;

Loading…
Cancel
Save