Browse Source

Implemented option panels for text editor.

Replaced ContentControl with ContentPresenter where possible.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5076 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
45761d3824
  1. 11
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  2. 3
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  3. 8
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
  4. 6
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/BehaviorOptions.xaml
  5. 75
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
  6. 21
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml
  7. 17
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml.cs
  8. 29
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml
  9. 32
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml.cs
  10. 2
      src/AddIns/Misc/SearchAndReplace/Project/Gui/ResultsTreeView.xaml
  11. 4
      src/Main/Base/Project/Src/Editor/Search/SearchResultsPad.cs
  12. 2
      src/Main/Base/Project/Src/Gui/AbstractViewContentHandlingLoadErrors.cs
  13. 14
      src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
  14. 2
      src/Main/Base/Project/Src/Gui/Dialogs/TreeViewOptionsDialog.xaml
  15. 3
      src/Main/Base/Project/Src/Gui/Dialogs/TreeViewOptionsDialog.xaml.cs
  16. 2
      src/Main/Base/Project/Src/Gui/Pads/OutlinePad.cs
  17. 4
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  18. 2
      src/Main/Base/Project/Src/Gui/Pads/ToolsPad.cs
  19. 2
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml
  20. 37
      src/Main/Base/Project/Src/Util/ExtensionMethods.cs
  21. 2
      src/Main/ICSharpCode.Core.Presentation/CollapsiblePanel.cs

11
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj

@ -50,6 +50,7 @@
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase"> <Reference Include="WindowsBase">
@ -90,6 +91,10 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Src\Options\CodeEditorOptions.cs" /> <Compile Include="Src\Options\CodeEditorOptions.cs" />
<Compile Include="Src\Options\TextViewOptions.xaml.cs">
<DependentUpon>TextViewOptions.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Snippets\CodeSnippet.cs" /> <Compile Include="Src\Snippets\CodeSnippet.cs" />
<Compile Include="Src\Snippets\CodeSnippetGroup.cs" /> <Compile Include="Src\Snippets\CodeSnippetGroup.cs" />
<Compile Include="Src\Snippets\SnippetCompletionItem.cs" /> <Compile Include="Src\Snippets\SnippetCompletionItem.cs" />
@ -136,6 +141,11 @@
<Name>ICSharpCode.Core.Presentation</Name> <Name>ICSharpCode.Core.Presentation</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj">
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project>
<Name>ICSharpCode.Core.WinForms</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> <ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> <Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name> <Name>ICSharpCode.SharpDevelop.Dom</Name>
@ -144,6 +154,7 @@
<Page Include="Src\Commands\SortOptionsDialog.xaml" /> <Page Include="Src\Commands\SortOptionsDialog.xaml" />
<Page Include="Src\Options\BehaviorOptions.xaml" /> <Page Include="Src\Options\BehaviorOptions.xaml" />
<Page Include="Src\Options\GeneralEditorOptions.xaml" /> <Page Include="Src\Options\GeneralEditorOptions.xaml" />
<Page Include="Src\Options\TextViewOptions.xaml" />
<Page Include="Src\Snippets\SnippetOptionPanel.xaml"> <Page Include="Src\Snippets\SnippetOptionPanel.xaml">
<DependentUpon>SnippetOptionPanel.cs</DependentUpon> <DependentUpon>SnippetOptionPanel.cs</DependentUpon>
</Page> </Page>

3
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -167,9 +167,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
textView.Services.AddService(typeof(CodeEditor), this); textView.Services.AddService(typeof(CodeEditor), this);
textEditor.Background = Brushes.White; textEditor.Background = Brushes.White;
textEditor.FontFamily = new FontFamily("Consolas, Courier New");
textEditor.FontSize = 13;
textEditor.ShowLineNumbers = true;
textEditor.TextArea.TextEntering += TextAreaTextEntering; textEditor.TextArea.TextEntering += TextAreaTextEntering;
textEditor.TextArea.TextEntered += TextAreaTextEntered; textEditor.TextArea.TextEntered += TextAreaTextEntered;
textEditor.TextArea.Caret.PositionChanged += TextAreaCaretPositionChanged; textEditor.TextArea.Caret.PositionChanged += TextAreaCaretPositionChanged;

8
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs

@ -14,6 +14,7 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.AvalonEdit.AddIn.Options;
using ICSharpCode.AvalonEdit.AddIn.Snippets; using ICSharpCode.AvalonEdit.AddIn.Snippets;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
@ -34,10 +35,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
public ITextEditor Adapter { get; set; } public ITextEditor Adapter { get; set; }
CodeEditorOptions options;
public CodeEditorView() public CodeEditorView()
{ {
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted));
this.Options = ICSharpCode.AvalonEdit.AddIn.Options.CodeEditorOptions.Instance; options = ICSharpCode.AvalonEdit.AddIn.Options.CodeEditorOptions.Instance;
options.BindToTextEditor(this);
this.MouseHover += TextEditorMouseHover; this.MouseHover += TextEditorMouseHover;
this.MouseHoverStopped += TextEditorMouseHoverStopped; this.MouseHoverStopped += TextEditorMouseHoverStopped;
@ -269,7 +273,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
// close existing popup immediately on text editor mouse down // close existing popup immediately on text editor mouse down
TryCloseExistingPopup(false); TryCloseExistingPopup(false);
if (e.ChangedButton == MouseButton.Left && Keyboard.Modifiers == ModifierKeys.Control) { if (options.CtrlClickGoToDefinition && e.ChangedButton == MouseButton.Left && Keyboard.Modifiers == ModifierKeys.Control) {
var position = GetPositionFromPoint(e.GetPosition(this)); var position = GetPositionFromPoint(e.GetPosition(this));
if (position != null) { if (position != null) {
Core.AnalyticsMonitorService.TrackFeature(typeof(GoToDefinition).FullName, "Ctrl+Click"); Core.AnalyticsMonitorService.TrackFeature(typeof(GoToDefinition).FullName, "Ctrl+Click");

6
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/BehaviorOptions.xaml

@ -17,6 +17,8 @@
IsChecked="{core:OptionBinding local:CodeEditorOptions.ConvertTabsToSpaces}" IsChecked="{core:OptionBinding local:CodeEditorOptions.ConvertTabsToSpaces}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.ConvertTabsToSpacesCheckBox}" /> Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.ConvertTabsToSpacesCheckBox}" />
<CheckBox <CheckBox
IsEnabled="False"
IsChecked="True"
Content="(TODO: translate) Use smart indentation" /> Content="(TODO: translate) Use smart indentation" />
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
@ -24,13 +26,13 @@
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.BehaviourGroupBox}"> Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.BehaviourGroupBox}">
<StackPanel> <StackPanel>
<CheckBox <CheckBox
IsEnabled="False"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.MouseWheelZoomCheckBoxCheckBox}" /> Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.MouseWheelZoomCheckBoxCheckBox}" />
<CheckBox <CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.CutCopyWholeLine}" IsChecked="{core:OptionBinding local:CodeEditorOptions.CutCopyWholeLine}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.CutCopyWholeLine}" /> Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.CutCopyWholeLine}" />
<CheckBox <CheckBox
Content="(TODO: translate) Word-wrap" /> IsChecked="{core:OptionBinding local:CodeEditorOptions.CtrlClickGoToDefinition}"
<CheckBox
Content="(TODO: translate) Use Ctrl+Click for &quot;Go to Definition&quot;" /> Content="(TODO: translate) Use Ctrl+Click for &quot;Go to Definition&quot;" />
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>

75
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs

@ -7,6 +7,8 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Data;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
@ -28,5 +30,78 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
throw new NotSupportedException(); throw new NotSupportedException();
} }
} }
string fontFamily = Core.WinForms.WinFormsResourceService.DefaultMonospacedFont.Name;
public string FontFamily {
get { return fontFamily; }
set {
if (fontFamily != value) {
fontFamily = value;
OnPropertyChanged("FontFamily");
}
}
}
double fontSize = 13.0;
[DefaultValue(13.0)]
public double FontSize {
get { return fontSize; }
set {
if (fontSize != value) {
fontSize = value;
OnPropertyChanged("FontSize");
}
}
}
bool showLineNumbers = true;
[DefaultValue(true)]
public bool ShowLineNumbers {
get { return showLineNumbers; }
set {
if (showLineNumbers != value) {
showLineNumbers = value;
OnPropertyChanged("ShowLineNumbers");
}
}
}
bool wordWrap;
[DefaultValue(false)]
public bool WordWrap {
get { return wordWrap; }
set {
if (wordWrap != value) {
wordWrap = value;
OnPropertyChanged("WordWrap");
}
}
}
bool ctrlClickGoToDefinition = true;
[DefaultValue(true)]
public bool CtrlClickGoToDefinition {
get { return ctrlClickGoToDefinition; }
set {
if (ctrlClickGoToDefinition != value) {
ctrlClickGoToDefinition = value;
OnPropertyChanged("CtrlClickGoToDefinition");
}
}
}
public void BindToTextEditor(TextEditor editor)
{
editor.Options = this;
editor.SetBinding(TextEditor.FontFamilyProperty, new Binding("FontFamily") { Source = this });
editor.SetBinding(TextEditor.FontSizeProperty, new Binding("FontSize") { Source = this });
editor.SetBinding(TextEditor.ShowLineNumbersProperty, new Binding("ShowLineNumbers") { Source = this });
editor.SetBinding(TextEditor.WordWrapProperty, new Binding("WordWrap") { Source = this });
}
} }
} }

21
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml

@ -1,19 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<gui:OptionPanel <gui:OptionPanel
x:Class="ICSharpCode.AvalonEdit.AddIn.Options.GeneralEditorOptions" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:winforms="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"> x:Class="ICSharpCode.AvalonEdit.AddIn.Options.GeneralEditorOptions" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:winforms="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" xmlns:local="clr-namespace:ICSharpCode.AvalonEdit.AddIn.Options">
<StackPanel> <StackPanel>
<GroupBox <GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FontGroupBox}"> Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FontGroupBox}">
<winforms:WindowsFormsHost> <winforms:WindowsFormsHost Height="112">
<gui:FontSelectionPanel x:Name="fontSelectionPanel" /> <gui:FontSelectionPanel x:Name="fontSelectionPanel" />
</winforms:WindowsFormsHost> </winforms:WindowsFormsHost>
</GroupBox> </GroupBox>
<GroupBox <GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.GeneralOptionsGroupBox}"> Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.GeneralOptionsGroupBox}">
<StackPanel> <StackPanel>
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FoldingCheckBox}" /> <CheckBox
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.ShowQuickClassBrowserCheckBox}" /> IsChecked="{core:OptionBinding local:CodeEditorOptions.WordWrap}"
<CheckBox Content="(TODO: translate) show line numbers" /> Content="(TODO: translate) Word-wrap" />
<CheckBox
IsEnabled="False"
IsChecked="True"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FoldingCheckBox}" />
<CheckBox
IsEnabled="False"
IsChecked="True"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.ShowQuickClassBrowserCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.ShowLineNumbers}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.LineNumberCheckBox}" />
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
</StackPanel> </StackPanel>

17
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml.cs

@ -15,6 +15,7 @@ using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.AvalonEdit.AddIn.Options namespace ICSharpCode.AvalonEdit.AddIn.Options
@ -28,5 +29,21 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
{ {
InitializeComponent(); InitializeComponent();
} }
public override void LoadOptions()
{
base.LoadOptions();
CodeEditorOptions options = CodeEditorOptions.Instance;
fontSelectionPanel.CurrentFont = WinFormsResourceService.LoadFont(
options.FontFamily, (int)Math.Round(options.FontSize * 72.0 / 96.0));
}
public override bool SaveOptions()
{
CodeEditorOptions options = CodeEditorOptions.Instance;
options.FontFamily = fontSelectionPanel.CurrentFont.Name;
options.FontSize = Math.Round(fontSelectionPanel.CurrentFont.Size * 96.0 / 72.0);
return base.SaveOptions();
}
} }
} }

29
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<gui:OptionPanel
x:Class="ICSharpCode.AvalonEdit.AddIn.Options.TextViewOptions" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" xmlns:local="clr-namespace:ICSharpCode.AvalonEdit.AddIn.Options">
<StackPanel>
<GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.MarkersGroupBox}">
<StackPanel>
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.ShowSpaces}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.SpacesCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.ShowTabs}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.TabsCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.ShowEndOfLine}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.EOLMarkersCheckBox}" />
<CheckBox
Margin="0,16,0,0"
IsChecked="True"
IsEnabled="False"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.UnderLineErrorsCheckBox}" />
<CheckBox
IsChecked="True"
IsEnabled="False"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.HiglightBracketCheckBox}" />
</StackPanel>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

32
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml.cs

@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.AvalonEdit.AddIn.Options
{
/// <summary>
/// Interaction logic for TextViewOptions.xaml
/// </summary>
public partial class TextViewOptions : OptionPanel
{
public TextViewOptions()
{
InitializeComponent();
}
}
}

2
src/AddIns/Misc/SearchAndReplace/Project/Gui/ResultsTreeView.xaml

@ -11,7 +11,7 @@
<TreeView.ItemTemplate> <TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}"> <HierarchicalDataTemplate ItemsSource="{Binding Children}">
<ContentControl Focusable="False" Content="{Binding Text}"/> <ContentPresenter Content="{Binding Text}"/>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</TreeView.ItemTemplate> </TreeView.ItemTemplate>
</TreeView> </TreeView>

4
src/Main/Base/Project/Src/Editor/Search/SearchResultsPad.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search
DockPanel dockPanel; DockPanel dockPanel;
ToolBar toolBar; ToolBar toolBar;
ContentControl contentPlaceholder; ContentPresenter contentPlaceholder;
IList defaultToolbarItems; IList defaultToolbarItems;
public SearchResultsPad() public SearchResultsPad()
@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search
} }
DockPanel.SetDock(toolBar, Dock.Top); DockPanel.SetDock(toolBar, Dock.Top);
contentPlaceholder = new ContentControl(); contentPlaceholder = new ContentPresenter();
dockPanel = new DockPanel { dockPanel = new DockPanel {
Children = { toolBar, contentPlaceholder } Children = { toolBar, contentPlaceholder }
}; };

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

@ -29,7 +29,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
public abstract class AbstractViewContentHandlingLoadErrors : AbstractViewContent public abstract class AbstractViewContentHandlingLoadErrors : AbstractViewContent
{ {
ContentControl contentControl = new ContentControl(); ContentPresenter contentControl = new ContentPresenter();
object userContent; object userContent;
protected AbstractViewContentHandlingLoadErrors() protected AbstractViewContentHandlingLoadErrors()

14
src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs

@ -8,6 +8,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
@ -20,9 +21,15 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
public class OptionPanel : UserControl, IOptionPanel, IOptionBindingContainer public class OptionPanel : UserControl, IOptionPanel, IOptionBindingContainer
{ {
static OptionPanel()
{
MarginProperty.OverrideMetadata(typeof(OptionPanel),
new FrameworkPropertyMetadata(new Thickness(2, 0, 4, 0)));
}
public virtual object Owner { get; set; } public virtual object Owner { get; set; }
IList<OptionBinding> bindings; IList<OptionBinding> bindings = new List<OptionBinding>();
public IList<OptionBinding> Bindings { public IList<OptionBinding> Bindings {
get { get {
@ -50,11 +57,6 @@ namespace ICSharpCode.SharpDevelop.Gui
return true; return true;
} }
public OptionPanel()
{
this.bindings = new List<OptionBinding>();
}
public void AddBinding(OptionBinding binding) public void AddBinding(OptionBinding binding)
{ {
this.bindings.Add(binding); this.bindings.Add(binding);

2
src/Main/Base/Project/Src/Gui/Dialogs/TreeViewOptionsDialog.xaml

@ -60,7 +60,7 @@
</LinearGradientBrush> </LinearGradientBrush>
</TextBlock.Background> </TextBlock.Background>
</TextBlock> </TextBlock>
<ContentControl Name="optionPanelContent" /> <ContentPresenter Name="optionPanelContent" />
</DockPanel> </DockPanel>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>

3
src/Main/Base/Project/Src/Gui/Dialogs/TreeViewOptionsDialog.xaml.cs

@ -119,6 +119,9 @@ namespace ICSharpCode.SharpDevelop.Gui
get { get {
if (optionPanel == null) { if (optionPanel == null) {
optionPanel = OptionPanelDescriptor.OptionPanel; optionPanel = OptionPanelDescriptor.OptionPanel;
if (optionPanel == null) {
return null;
}
optionPanel.LoadOptions(); optionPanel.LoadOptions();
dialog.optionPanels.Add(optionPanel); dialog.optionPanels.Add(optionPanel);
} }

2
src/Main/Base/Project/Src/Gui/Pads/OutlinePad.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
public class OutlinePad : AbstractPadContent public class OutlinePad : AbstractPadContent
{ {
ContentControl contentControl = new ContentControl(); ContentPresenter contentControl = new ContentPresenter();
public override object Control { public override object Control {
get { get {

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

@ -98,7 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
System.Windows.Controls.ContentControl contentControl; System.Windows.Controls.ContentPresenter contentControl;
Panel panel; Panel panel;
ComboBox comboBox; ComboBox comboBox;
PropertyGrid grid; PropertyGrid grid;
@ -154,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public PropertyPad() public PropertyPad()
{ {
instance = this; instance = this;
contentControl = new System.Windows.Controls.ContentControl(); contentControl = new System.Windows.Controls.ContentPresenter();
panel = new Panel(); panel = new Panel();
grid = new PropertyGrid(); grid = new PropertyGrid();

2
src/Main/Base/Project/Src/Gui/Pads/ToolsPad.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
public class ToolsPad : AbstractPadContent public class ToolsPad : AbstractPadContent
{ {
ContentControl contentControl = new ContentControl(); ContentPresenter contentControl = new ContentPresenter();
public override object Control { public override object Control {
get { get {

2
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml

@ -11,6 +11,6 @@
<Menu Name="mainMenu" DockPanel.Dock="Top"/> <Menu Name="mainMenu" DockPanel.Dock="Top"/>
<!-- Toolbars will be inserted here (index: 1) --> <!-- Toolbars will be inserted here (index: 1) -->
<!-- Statusbar will be inserted here (index: Count-2) --> <!-- Statusbar will be inserted here (index: Count-2) -->
<ContentControl Name="mainContent" Focusable="False"/> <ContentPresenter Name="mainContent" />
</DockPanel> </DockPanel>
</Window> </Window>

37
src/Main/Base/Project/Src/Util/ExtensionMethods.cs

@ -180,6 +180,11 @@ namespace ICSharpCode.SharpDevelop
SetContent(contentControl, content, null); SetContent(contentControl, content, null);
} }
public static void SetContent(this ContentPresenter contentControl, object content)
{
SetContent(contentControl, content, null);
}
public static void SetContent(this ContentControl contentControl, object content, object serviceObject) public static void SetContent(this ContentControl contentControl, object content, object serviceObject)
{ {
if (contentControl == null) if (contentControl == null)
@ -211,6 +216,38 @@ namespace ICSharpCode.SharpDevelop
} }
} }
public static void SetContent(this ContentPresenter contentControl, object content, object serviceObject)
{
if (contentControl == null)
throw new ArgumentNullException("contentControl");
// serviceObject = object implementing the old clipboard/undo interfaces
// to allow WinForms AddIns to handle WPF commands
var host = contentControl.Content as SDWindowsFormsHost;
if (host != null) {
if (host.Child == content) {
host.ServiceObject = serviceObject;
return;
}
host.Dispose();
}
if (content is WinForms.Control) {
contentControl.Content = new SDWindowsFormsHost {
Child = (WinForms.Control)content,
ServiceObject = serviceObject,
DisposeChild = false
};
} else if (content is string) {
contentControl.Content = new TextBlock {
Text = content.ToString(),
TextWrapping = TextWrapping.Wrap
};
} else {
contentControl.Content = content;
}
}
#region System.Drawing <-> WPF conversions #region System.Drawing <-> WPF conversions
public static System.Drawing.Point ToSystemDrawing(this Point p) public static System.Drawing.Point ToSystemDrawing(this Point p)
{ {

2
src/Main/ICSharpCode.Core.Presentation/CollapsiblePanel.cs

@ -22,6 +22,8 @@ namespace ICSharpCode.Core.Presentation
{ {
DefaultStyleKeyProperty.OverrideMetadata(typeof(CollapsiblePanel), DefaultStyleKeyProperty.OverrideMetadata(typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(typeof(CollapsiblePanel))); new FrameworkPropertyMetadata(typeof(CollapsiblePanel)));
FocusableProperty.OverrideMetadata(typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(false));
} }
public static readonly DependencyProperty IsCollapsedProperty = DependencyProperty.Register( public static readonly DependencyProperty IsCollapsedProperty = DependencyProperty.Register(

Loading…
Cancel
Save