Browse Source

Add WindowClone.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2243 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
e22a8beca8
  1. 26
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml
  2. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs
  3. 139
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
  4. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  5. 42
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml

26
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml

@ -6,18 +6,20 @@ @@ -6,18 +6,20 @@
<TabControl TabStripPlacement="Bottom" Name="tabControl" SelectionChanged="tabControlSelectionChanged">
<TabItem Header="Code">
<TextBox Name="CodeTextBox" AcceptsReturn="True" xml:space="preserve"><![CDATA[
<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" BorderThickness="10">
<StackPanel>
<Canvas Height="50" Background="White"></Canvas>
<Button>Button 1</Button>
<Button>Button 2</Button>
<TabControl Width="300" Height="300">
<TabItem Header="Page 1"><StackPanel><Button>a</Button></StackPanel> </TabItem>
<TabItem Header="Page 2"><Button>button on page 2</Button></TabItem>
</TabControl>
</StackPanel>
</Border>
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowTitle"
BorderThickness="10" Width="400" Height="300">
<StackPanel>
<Canvas Height="50" Background="White"></Canvas>
<Button>Button 1</Button>
<Button>Button 2</Button>
<TabControl Width="300" MinHeight="100">
<TabItem Header="Page 1"><StackPanel><Button>a</Button></StackPanel> </TabItem>
<TabItem Header="Page 2"><Button>button on page 2</Button></TabItem>
</TabControl>
</StackPanel>
</Window>
]]></TextBox>
</TabItem>
<TabItem Header="Design" Name="designTab">

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs

@ -13,7 +13,6 @@ using System.Windows.Shapes; @@ -13,7 +13,6 @@ using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer.Controls
{

139
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs

@ -0,0 +1,139 @@ @@ -0,0 +1,139 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.ComponentModel;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using System.Diagnostics;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A custom control that imitates the properties of <see cref="Window"/>, but is not a top-level control.
/// </summary>
public class WindowClone : ContentControl
{
static WindowClone()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(typeof(WindowClone)));
Control.IsTabStopProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(false));
KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(true));
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public bool AllowsTransparency {
get { return (bool)GetValue(Window.AllowsTransparencyProperty); }
set { SetValue(Window.AllowsTransparencyProperty, value); }
}
/// <summary>
/// Specifies the icon to use.
/// </summary>
public ImageSource Icon {
get { return (ImageSource)GetValue(Window.IconProperty); }
set { SetValue(Window.IconProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
[TypeConverter(typeof(LengthConverter))]
public double Left {
get { return (double)GetValue(Window.LeftProperty); }
set { SetValue(Window.LeftProperty, value); }
}
/// <summary>
/// Gets or sets the resize mode.
/// </summary>
public ResizeMode ResizeMode {
get { return (ResizeMode)GetValue(Window.ResizeModeProperty); }
set { SetValue(Window.ResizeModeProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public bool ShowInTaskbar {
get { return (bool)GetValue(Window.ShowInTaskbarProperty); }
set { SetValue(Window.ShowInTaskbarProperty, value); }
}
/// <summary>
/// Gets or sets a value that specifies whether a window will automatically size itself to fit the size of its content.
/// </summary>
public SizeToContent SizeToContent {
get { return (SizeToContent)GetValue(Window.SizeToContentProperty); }
set { SetValue(Window.SizeToContentProperty, value); }
}
/// <summary>
/// The title to display in the Window's title bar.
/// </summary>
public string Title {
get { return (string)GetValue(Window.TitleProperty); }
set { SetValue(Window.TitleProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
[TypeConverter(typeof(LengthConverter))]
public double Top {
get { return (double)GetValue(Window.TopProperty); }
set { SetValue(Window.TopProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public bool Topmost {
get { return (bool)GetValue(Window.TopmostProperty); }
set { SetValue(Window.TopmostProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public WindowStyle WindowStyle {
get { return (WindowStyle)GetValue(Window.WindowStyleProperty); }
set { SetValue(Window.WindowStyleProperty, value); }
}
}
/// <summary>
/// A <see cref="CustomInstanceFactory"/> for <see cref="Window"/>.
/// </summary>
[ExtensionFor(typeof(Window))]
public class WindowCloneExtension : CustomInstanceFactory
{
/// <summary>
/// Used to create instances of <see cref="WindowClone"/>.
/// </summary>
public override object CreateInstance(Type type, params object[] arguments)
{
Debug.Assert(arguments.Length == 0);
Debug.Assert(type == typeof(Window));
return new WindowClone();
}
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -60,6 +60,7 @@ @@ -60,6 +60,7 @@
<Compile Include="Controls\ContainerDragHandle.cs" />
<Compile Include="Controls\ResizeThumb.cs" />
<Compile Include="Controls\SingleVisualChildElement.cs" />
<Compile Include="Controls\WindowClone.cs" />
<Compile Include="DesignPanel.cs" />
<Compile Include="Extensions\SelectedElementRectangleExtension.cs" />
<Compile Include="Extensions\TabItemClickableExtension.cs" />

42
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer"
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
>
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Style TargetType="{x:Type src:Controls.ResizeThumb}">
<Style TargetType="{x:Type src:ResizeThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:Controls.ResizeThumb}">
<ControlTemplate TargetType="{x:Type src:ResizeThumb}">
<Rectangle Name="thumbRectangle"
Width="7" Height="7" SnapsToDevicePixels="True"
Stroke="Black" Fill="White" RadiusX="1.4142" RadiusY="1.4142"/>
@ -27,10 +27,10 @@ @@ -27,10 +27,10 @@
</Setter>
</Style>
<Style TargetType="{x:Type src:Controls.ContainerDragHandle}">
<Style TargetType="{x:Type src:ContainerDragHandle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:Controls.ContainerDragHandle}">
<ControlTemplate TargetType="{x:Type src:ContainerDragHandle}">
<Canvas Height="13" Width="13" Name="Canvas" Background="#00FFFFFF" SnapsToDevicePixels="True">
<Rectangle Height="13" Width="13" RadiusX="2" RadiusY="2"
Fill="#669ABFE5" Name="BorderRectangle" Stroke="#FF9ABFE5" StrokeThickness="1" />
@ -49,4 +49,36 @@ @@ -49,4 +49,36 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type src:WindowClone}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="src:WindowClone">
<Border Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5">
<DockPanel Margin="4,0,4,4">
<DockPanel Height="26" DockPanel.Dock="Top">
<Image Width="16" Height="16" Margin="1,0,0,0" Source="{TemplateBinding Window.Icon}" />
<Button x:Name="CloseButton" VerticalAlignment="Top" Width="23.51" Height="14.857" Content="" DockPanel.Dock="Right"/>
<Button x:Name="MaximiseButton" VerticalAlignment="Top" Width="18.286" Height="14.857" Content="" DockPanel.Dock="Right"/>
<Button x:Name="MinimizeButton" VerticalAlignment="Top" Width="18.286" Height="14.857" Content="" DockPanel.Dock="Right"/>
<Label Margin="4,0,0,0" Content="{TemplateBinding Window.Title}"/>
</DockPanel>
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<Border
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
Background="{TemplateBinding Panel.Background}">
<AdornerDecorator>
<ContentPresenter
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
Content="{TemplateBinding ContentControl.Content}" />
</AdornerDecorator>
</Border>
</Border>
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

Loading…
Cancel
Save