Browse Source

Implemented SplitButton.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3575 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
2f2bff9e9a
  1. 102
      src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs
  2. 12
      src/Main/Base/Project/Src/Commands/NavigationCommands.cs
  3. 2
      src/Main/Base/Project/Src/Gui/App.xaml
  4. 5
      src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj
  5. 8
      src/Main/ICSharpCode.Core.Presentation/Menu/MenuCommand.cs
  6. 16
      src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs
  7. 6
      src/Main/ICSharpCode.Core.Presentation/Properties/AssemblyInfo.cs
  8. 94
      src/Main/ICSharpCode.Core.Presentation/SplitButton.cs
  9. 6
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarComboBox.cs
  10. 3
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarService.cs
  11. 65
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarSplitButton.cs
  12. 81
      src/Main/ICSharpCode.Core.Presentation/themes/Aero.NormalColor.xaml
  13. 81
      src/Main/ICSharpCode.Core.Presentation/themes/generic.xaml

102
src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs

@ -5,27 +5,28 @@ @@ -5,27 +5,28 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Internal.ExternalTool;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Util;
namespace ICSharpCode.SharpDevelop.Commands
{
public class NavigationHistoryMenuBuilder : ISubmenuBuilder
public class NavigationHistoryMenuBuilder : IMenuItemBuilder
{
// TODO: refactor BuildSubmenu to add a choice between flat and perfile, eventually per class/method sorting of the list
ToolStripItem[] BuildMenuFlat(ICollection<INavigationPoint> points, int additionalItems)
/*ToolStripItem[] BuildMenuFlat(ICollection<INavigationPoint> points, int additionalItems)
{
ToolStripItem[] items = new ToolStripItem[points.Count+additionalItems];
MenuCommand cmd = null;
@ -44,9 +45,10 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -44,9 +45,10 @@ namespace ICSharpCode.SharpDevelop.Commands
items[i++] = cmd;
}
return items;
}
ToolStripItem[] BuildMenuByFile(ICollection<INavigationPoint> points, int additionalItems)
}*/
List<FrameworkElement> BuildMenuByFile(ICollection<INavigationPoint> points)
{
List<FrameworkElement> items = new List<FrameworkElement>();
Dictionary<string, List<INavigationPoint>> files =
new Dictionary<string, List<INavigationPoint>>();
List<string> fileNames = new List<string>();
@ -66,25 +68,24 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -66,25 +68,24 @@ namespace ICSharpCode.SharpDevelop.Commands
fileNames.Sort();
ToolStripItem[] items =
new ToolStripItem[fileNames.Count + additionalItems];
ToolStripMenuItem containerItem = null;
MenuCommand cmd = null;
int i = 0;
MenuItem containerItem = null;
MenuItem cmd = null;
foreach (string fname in fileNames) {
// create a menu bucket
containerItem = new ToolStripMenuItem();
containerItem.Text = System.IO.Path.GetFileName(fname);
containerItem.ToolTipText = fname;
containerItem = new MenuItem();
containerItem.Header = System.IO.Path.GetFileName(fname);
containerItem.ToolTip = fname;
// sort and populate the bucket's contents
// files[fname].Sort();
foreach(INavigationPoint p in files[fname]) {
cmd = new MenuCommand(p.Description, new EventHandler(NavigateTo));
cmd = new MenuItem();
cmd.Header = p.Description;
cmd.Click += NavigateTo;
cmd.Tag = p;
containerItem.DropDownItems.Add(cmd);
containerItem.Items.Add(cmd);
}
// if there's only one nested item, add it
@ -98,49 +99,41 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -98,49 +99,41 @@ namespace ICSharpCode.SharpDevelop.Commands
// items[i++] = containerItem;
// }
// add the bucket to the result
items[i++] = containerItem;
items.Add(containerItem);
}
return items;
}
public ToolStripItem[] BuildSubmenu(Codon codon, object owner)
public ICollection BuildItems(Codon codon, object owner)
{
MenuCommand cmd = null;
if (NavigationService.CanNavigateBack || NavigationService.CanNavigateForwards) {
ICollection<INavigationPoint> points = NavigationService.Points;
//ToolStripItem[] items = BuildMenuFlat(points, numberOfAdditionalItems);
ToolStripItem[] items = BuildMenuByFile(points, numberOfAdditionalItems);
int i = items.Length - numberOfAdditionalItems;
var result = BuildMenuByFile(points);
// additional item 1
items[i++] = new ToolStripSeparator();
result.Add(new Separator());
// additional item 2
cmd = new MenuCommand("${res:XML.MainMenu.Navigation.ClearHistory}", new EventHandler(ClearHistory));
items[i++] = cmd;
MenuItem clearHistory = new MenuItem();
clearHistory.Header = StringParser.Parse("${res:XML.MainMenu.Navigation.ClearHistory}");
clearHistory.Click += delegate { NavigationService.ClearHistory(); };
result.Add(clearHistory);
return items;
return result;
}
// default is to disable the dropdown feature...
return null;
}
int numberOfAdditionalItems = 2;
public void NavigateTo(object sender, EventArgs e)
{
MenuCommand item = (MenuCommand)sender;
MenuItem item = (MenuItem)sender;
NavigationService.Go((INavigationPoint)item.Tag);
}
public void ClearHistory(object sender, EventArgs e)
{
NavigationService.ClearHistory();
}
}
public class RecentFilesMenuBuilder : IMenuItemBuilder
@ -243,7 +236,7 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -243,7 +236,7 @@ namespace ICSharpCode.SharpDevelop.Commands
try {
if (tool.UseOutputPad) {
ProcessRunner processRunner = new ProcessRunner();
processRunner.LogStandardOutputAndError = false;
processRunner.LogStandardOutputAndError = false;
processRunner.ProcessExited += ProcessExitEvent;
processRunner.OutputLineReceived += process_OutputLineReceived;
processRunner.ErrorLineReceived += process_OutputLineReceived;
@ -434,32 +427,8 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -434,32 +427,8 @@ namespace ICSharpCode.SharpDevelop.Commands
}
}
public abstract class ViewMenuBuilder : ISubmenuBuilder, IMenuItemBuilder
public abstract class ViewMenuBuilder : IMenuItemBuilder
{
class MyMenuItem : MenuCommand
{
PadDescriptor padDescriptor;
public MyMenuItem(PadDescriptor padDescriptor) : base(null, null)
{
this.padDescriptor = padDescriptor;
Text = StringParser.Parse(padDescriptor.Title);
if (!string.IsNullOrEmpty(padDescriptor.Icon)) {
base.Image = IconService.GetBitmap(padDescriptor.Icon);
}
if (padDescriptor.Shortcut != null) {
ShortcutKeys = MenuCommand.ParseShortcut(padDescriptor.Shortcut);
}
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
padDescriptor.BringPadToFront();
}
}
class BringPadToFrontCommand : System.Windows.Input.ICommand
{
PadDescriptor padDescriptor;
@ -486,17 +455,6 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -486,17 +455,6 @@ namespace ICSharpCode.SharpDevelop.Commands
get;
}
public ToolStripItem[] BuildSubmenu(Codon codon, object owner)
{
List<ToolStripItem> items = new List<ToolStripItem>();
foreach (PadDescriptor padContent in WorkbenchSingleton.Workbench.PadContentCollection) {
if (padContent.Category == Category) {
items.Add(new MyMenuItem(padContent));
}
}
return items.ToArray();
}
public ICollection BuildItems(Codon codon, object owner)
{
ArrayList list = new ArrayList();

12
src/Main/Base/Project/Src/Commands/NavigationCommands.cs

@ -7,13 +7,14 @@ @@ -7,13 +7,14 @@
using System;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.Core.Presentation;
using System.Windows.Input;
namespace ICSharpCode.SharpDevelop.Commands
{
public class NavigateBack : AbstractMenuCommand
{
ToolBarSplitButton splitButton = null;
SplitButton splitButton = null;
public override bool IsEnabled {
get {
@ -33,7 +34,7 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -33,7 +34,7 @@ namespace ICSharpCode.SharpDevelop.Commands
base.OnOwnerChanged(e);
// grab the owner so we can manipulate the buttons later
splitButton = (ToolBarSplitButton)Owner;
splitButton = (SplitButton)Owner;
// wire up our event handlers
NavigationService.HistoryChanged += NavHistoryChanged;
@ -54,8 +55,9 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -54,8 +55,9 @@ namespace ICSharpCode.SharpDevelop.Commands
public void UpdateEnabledState()
{
splitButton.ButtonEnabled = NavigationService.CanNavigateBack;
splitButton.DropDownEnabled = NavigationService.Count>1;
CommandManager.InvalidateRequerySuggested();
//splitButton.IsEnabled = NavigationService.CanNavigateBack;
//splitButton.IsDropDownEnabled = NavigationService.Count>1;
}
}

2
src/Main/Base/Project/Src/Gui/App.xaml

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<Application.Resources>
<Style TargetType="{x:Type Image}" x:Key="{x:Static core:ToolBarService.ImageStyleKey}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
<Setter Property="Opacity" Value="0.30" />
</DataTrigger>
</Style.Triggers>

5
src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj

@ -70,9 +70,11 @@ @@ -70,9 +70,11 @@
<Compile Include="PixelSnapper.cs" />
<Compile Include="PresentationResourceService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SplitButton.cs" />
<Compile Include="ToolBar\ToolBarButton.cs" />
<Compile Include="ToolBar\ToolBarComboBox.cs" />
<Compile Include="ToolBar\ToolBarService.cs" />
<Compile Include="ToolBar\ToolBarSplitButton.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Project\ICSharpCode.Core.csproj">
@ -81,6 +83,9 @@ @@ -81,6 +83,9 @@
<Private>False</Private>
</ProjectReference>
<Folder Include="Menu" />
<Folder Include="themes" />
<Folder Include="ToolBar" />
<Page Include="themes\Aero.NormalColor.xaml" />
<Page Include="themes\generic.xaml" />
</ItemGroup>
</Project>

8
src/Main/ICSharpCode.Core.Presentation/Menu/MenuCommand.cs

@ -32,6 +32,14 @@ namespace ICSharpCode.Core.Presentation @@ -32,6 +32,14 @@ namespace ICSharpCode.Core.Presentation
}
}
public CommandWrapper(Codon codon, object caller, ICommand command)
{
this.codon = codon;
this.caller = caller;
this.addInCommand = command;
commandCreated = true;
}
void CreateCommand()
{
commandCreated = true;

16
src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs

@ -35,6 +35,18 @@ namespace ICSharpCode.Core.Presentation @@ -35,6 +35,18 @@ namespace ICSharpCode.Core.Presentation
return null;
}
internal static ContextMenu CreateContextMenu(IList subItems)
{
var contextMenu = new ContextMenu() {
ItemsSource = new object[1]
};
contextMenu.Opened += (sender, args) => {
contextMenu.ItemsSource = ExpandMenuBuilders(subItems);
args.Handled = true;
};
return contextMenu;
}
public static IList CreateMenuItems(UIElement inputBindingOwner, object owner, string addInTreePath)
{
return CreateMenuItems(inputBindingOwner, AddInTree.BuildItems<MenuItemDescriptor>(addInTreePath, owner, false));
@ -74,7 +86,9 @@ namespace ICSharpCode.Core.Presentation @@ -74,7 +86,9 @@ namespace ICSharpCode.Core.Presentation
foreach (object o in input) {
MenuItemBuilderPlaceholder p = o as MenuItemBuilderPlaceholder;
if (p != null) {
result.AddRange(p.BuildItems());
ICollection c = p.BuildItems();
if (c != null)
result.AddRange(c);
} else {
result.Add(o);
IStatusUpdate statusUpdate = o as IStatusUpdate;

6
src/Main/ICSharpCode.Core.Presentation/Properties/AssemblyInfo.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Markup;
[assembly: CLSCompliant(true)]
@ -19,5 +20,10 @@ using System.Windows.Markup; @@ -19,5 +20,10 @@ using System.Windows.Markup;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly, //where theme specific resource dictionaries are located
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
)]
[assembly: XmlnsPrefix("http://icsharpcode.net/sharpdevelop/core", "core")]
[assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/core", "ICSharpCode.Core.Presentation")]

94
src/Main/ICSharpCode.Core.Presentation/SplitButton.cs

@ -0,0 +1,94 @@ @@ -0,0 +1,94 @@
// <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 System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
namespace ICSharpCode.Core.Presentation
{
/// <summary>
/// A button with drop-down menu.
/// </summary>
public class SplitButton : ButtonBase
{
public static readonly DependencyProperty DropDownMenuProperty
= DependencyProperty.Register("DropDownMenu", typeof(ContextMenu),
typeof(SplitButton), new FrameworkPropertyMetadata(null));
protected static readonly DependencyPropertyKey IsDropDownMenuOpenPropertyKey
= DependencyProperty.RegisterReadOnly("IsDropDownMenuOpen", typeof(bool),
typeof(SplitButton), new FrameworkPropertyMetadata(false));
public static readonly DependencyProperty IsDropDownMenuOpenProperty = IsDropDownMenuOpenPropertyKey.DependencyProperty;
static SplitButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SplitButton), new FrameworkPropertyMetadata(typeof(SplitButton)));
}
public ContextMenu DropDownMenu {
get { return (ContextMenu)GetValue(DropDownMenuProperty); }
set { SetValue(DropDownMenuProperty, value); }
}
public bool IsDropDownMenuOpen {
get { return (bool)GetValue(IsDropDownMenuOpenProperty); }
protected set { SetValue(IsDropDownMenuOpenPropertyKey, value); }
}
FrameworkElement dropDownButton;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
dropDownButton = (FrameworkElement)Template.FindName("PART_DropDownButton", this);
}
bool IsOverDropDownButton(MouseEventArgs e)
{
if (dropDownButton == null)
return false;
return e.GetPosition(dropDownButton).X >= 0;
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
if (IsOverDropDownButton(e)) {
e.Handled = true;
if (DropDownMenu != null) {
DropDownMenu.Placement = PlacementMode.Bottom;
DropDownMenu.PlacementTarget = this;
DropDownMenu.IsOpen = true;
DropDownMenu.Closed += DropDownMenu_Closed;
this.IsDropDownMenuOpen = true;
}
} else {
base.OnMouseLeftButtonDown(e);
}
}
void DropDownMenu_Closed(object sender, RoutedEventArgs e)
{
((ContextMenu)sender).Closed -= DropDownMenu_Closed;
this.IsDropDownMenuOpen = false;
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
if (!IsMouseCaptured && IsOverDropDownButton(e)) {
e.Handled = true;
} else {
base.OnMouseLeftButtonUp(e);
}
}
}
}

6
src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarComboBox.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Windows;
using System.Windows.Controls;
namespace ICSharpCode.Core.Presentation
@ -18,10 +19,15 @@ namespace ICSharpCode.Core.Presentation @@ -18,10 +19,15 @@ namespace ICSharpCode.Core.Presentation
public ToolBarComboBox(Codon codon, object caller)
{
if (codon == null)
throw new ArgumentNullException("codon");
this.IsEditable = false;
menuCommand = (IComboBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
menuCommand.Owner = this;
SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ComboBoxStyleKey);
}
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
base.OnSelectionChanged(e);

3
src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarService.cs

@ -75,8 +75,7 @@ namespace ICSharpCode.Core.Presentation @@ -75,8 +75,7 @@ namespace ICSharpCode.Core.Presentation
return "DropDownButton";
//return new ToolBarDropDownButton(codon, caller, MenuService.CreateMenuItems(descriptor.SubItems));
case "SplitButton":
return "SplitButton";
//return new ToolBarSplitButton(codon, caller, MenuService.CreateMenuItems(descriptor.SubItems));
return new ToolBarSplitButton(codon, caller, MenuService.CreateMenuItems(null, descriptor.SubItems));
case "Builder":
return codon.AddIn.CreateObject(codon.Properties["class"]);
default:

65
src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarSplitButton.cs

@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
// <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.Collections;
using System.Windows;
using System.Windows.Controls;
namespace ICSharpCode.Core.Presentation
{
/// <summary>
/// A tool bar button based on the AddIn-tree.
/// </summary>
sealed class ToolBarSplitButton : SplitButton, IStatusUpdate
{
ICommand menuCommand;
object caller;
Codon codon;
public ToolBarSplitButton(Codon codon, object caller, IList submenu)
{
ToolTipService.SetShowOnDisabled(this, true);
this.codon = codon;
this.caller = caller;
if (codon.Properties.Contains("icon")) {
var image = PresentationResourceService.GetImage(StringParser.Parse(codon.Properties["icon"]));
image.Height = 16;
image.SetResourceReference(StyleProperty, ToolBarService.ImageStyleKey);
this.Content = new PixelSnapper(image);
}
menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
menuCommand.Owner = this;
this.Command = new CommandWrapper(codon, caller, menuCommand);
this.DropDownMenu = MenuService.CreateContextMenu(submenu);
UpdateText();
}
public void UpdateText()
{
if (codon.Properties.Contains("label")){
this.Content = StringParser.Parse(codon.Properties["label"]);
}
if (codon.Properties.Contains("tooltip")) {
this.ToolTip = StringParser.Parse(codon.Properties["tooltip"]);
}
}
public void UpdateStatus()
{
if (codon.GetFailedAction(caller) == ConditionFailedAction.Exclude)
this.Visibility = Visibility.Collapsed;
else
this.Visibility = Visibility.Visible;
}
}
}

81
src/Main/ICSharpCode.Core.Presentation/themes/Aero.NormalColor.xaml

@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.Core.Presentation"
>
<Style TargetType="{x:Type local:SplitButton}">
<Setter Property="TextElement.Foreground" Value = "{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Control.Padding" Value="2,2,2,2"/>
<Setter Property="Border.BorderThickness" Value="1,1,1,1"/>
<Setter Property="Panel.Background" Value="Transparent"/>
<Setter Property="Border.BorderBrush" Value="Transparent"/>
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Center"/>
<Setter Property="FrameworkElement.VerticalAlignment" Value="Center"/>
<Setter Property="Control.HorizontalContentAlignment" Value="Center"/>
<Setter Property="Control.VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:SplitButton"
xmlns:s="clr-namespace:System;assembly=mscorlib">
<Border
BorderThickness="{TemplateBinding Border.BorderThickness}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
Name="OuterBorder"
SnapsToDevicePixels="True"
>
<StackPanel Orientation="Horizontal">
<ContentPresenter
Margin="{TemplateBinding Control.Padding}"
Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
<Border
Name="PART_DropDownButton"
BorderThickness="1,0,0,0"
BorderBrush="{Binding ElementName=OuterBorder, Path=BorderBrush}"
SnapsToDevicePixels="True"
>
<Path Margin="2"
Data = "M0,0 L1,0 0.5,1 z"
Fill = "{TemplateBinding TextElement.Foreground}"
Width = "7"
Height = "3.5"
Stretch = "Fill"/>
</Border>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#FF3399FF" />
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="#FFC2E0FF"/>
<Setter Property="Panel.Background" TargetName="PART_DropDownButton" Value="#FFC2E0FF"/>
</Trigger>
<Trigger Property="UIElement.IsKeyboardFocused" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#FF3399FF"/>
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="#FFC2E0FF"/>
<Setter Property="Panel.Background" TargetName="PART_DropDownButton" Value="#FFC2E0FF"/>
</Trigger>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#FF3399FF"/>
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="#FF99CCFF"/>
</Trigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
<Trigger Property="local:SplitButton.IsDropDownMenuOpen" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
<Setter Property="Border.BorderBrush" TargetName="PART_DropDownButton" Value="Transparent" />
<Setter Property="Border.BorderThickness" TargetName="OuterBorder" Value="1,1,1,0" />
<Setter Property="Border.Padding" TargetName="OuterBorder" Value="0,0,0,1" />
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="Transparent"/>
<Setter Property="Panel.Background" TargetName="PART_DropDownButton" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

81
src/Main/ICSharpCode.Core.Presentation/themes/generic.xaml

@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.Core.Presentation"
>
<Style TargetType="{x:Type local:SplitButton}">
<Setter Property="TextElement.Foreground" Value = "{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Control.Padding" Value="2,2,2,2"/>
<Setter Property="Border.BorderThickness" Value="1,1,1,1"/>
<Setter Property="Panel.Background" Value="Transparent"/>
<Setter Property="Border.BorderBrush" Value="Transparent"/>
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Center"/>
<Setter Property="FrameworkElement.VerticalAlignment" Value="Center"/>
<Setter Property="Control.HorizontalContentAlignment" Value="Center"/>
<Setter Property="Control.VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:SplitButton"
xmlns:s="clr-namespace:System;assembly=mscorlib">
<Border
BorderThickness="{TemplateBinding Border.BorderThickness}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
Name="OuterBorder"
SnapsToDevicePixels="True"
>
<StackPanel Orientation="Horizontal">
<ContentPresenter
Margin="{TemplateBinding Control.Padding}"
Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
<Border
Name="PART_DropDownButton"
BorderThickness="1,0,0,0"
BorderBrush="{Binding ElementName=OuterBorder, Path=BorderBrush}"
SnapsToDevicePixels="True"
>
<Path Margin="2"
Data = "M0,0 L1,0 0.5,1 z"
Fill = "{TemplateBinding TextElement.Foreground}"
Width = "7"
Height = "3.5"
Stretch = "Fill"/>
</Border>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#FF0A246A" />
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="#FFB6BDD2"/>
<Setter Property="Panel.Background" TargetName="PART_DropDownButton" Value="#FFB6BDD2"/>
</Trigger>
<Trigger Property="UIElement.IsKeyboardFocused" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#FF0A246A"/>
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="#FFB6BDD2"/>
<Setter Property="Panel.Background" TargetName="PART_DropDownButton" Value="#FFB6BDD2"/>
</Trigger>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="#FF0A246A"/>
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="#FF8592B5"/>
</Trigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
<Trigger Property="local:SplitButton.IsDropDownMenuOpen" Value="True">
<Setter Property="Border.BorderBrush" TargetName="OuterBorder" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
<Setter Property="Border.BorderBrush" TargetName="PART_DropDownButton" Value="Transparent" />
<Setter Property="Border.BorderThickness" TargetName="OuterBorder" Value="1,1,1,0" />
<Setter Property="Border.Padding" TargetName="OuterBorder" Value="0,0,0,1" />
<Setter Property="Panel.Background" TargetName="OuterBorder" Value="Transparent"/>
<Setter Property="Panel.Background" TargetName="PART_DropDownButton" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Loading…
Cancel
Save