Browse Source

Add WPF ToolBar ComboBox.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0wpf@3456 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
88fe850807
  1. 17
      src/AddIns/Misc/SearchAndReplace/Project/Commands/SearchToolbarCommands.cs
  2. 9
      src/AddIns/Misc/SearchAndReplace/Project/SearchAndReplace.csproj
  3. 17
      src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs
  4. 1
      src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj
  5. 31
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarComboBox.cs
  6. 3
      src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarService.cs

17
src/AddIns/Misc/SearchAndReplace/Project/Commands/SearchToolbarCommands.cs

@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
// </file>
using System;
using System.Windows.Forms;
using System.Windows.Controls;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using System.Windows.Input;
namespace SearchAndReplace
{
@ -18,6 +18,7 @@ namespace SearchAndReplace @@ -18,6 +18,7 @@ namespace SearchAndReplace
public class FindComboBox : AbstractComboBoxCommand
{
ComboBox comboBox;
public FindComboBox()
{
}
@ -31,9 +32,9 @@ namespace SearchAndReplace @@ -31,9 +32,9 @@ namespace SearchAndReplace
comboBox.Text = SearchOptions.FindPattern;
}
void OnKeyPress(object sender, KeyPressEventArgs e)
void OnKeyPress(object sender, KeyEventArgs e)
{
if (e.KeyChar == '\r') {
if (e.Key == Key.Enter) {
CommitSearch();
e.Handled = true;
}
@ -60,10 +61,10 @@ namespace SearchAndReplace @@ -60,10 +61,10 @@ namespace SearchAndReplace
protected override void OnOwnerChanged(EventArgs e)
{
base.OnOwnerChanged(e);
ToolBarComboBox toolbarItem = (ToolBarComboBox)Owner;
comboBox = toolbarItem.ComboBox;
comboBox.DropDownStyle = ComboBoxStyle.DropDown;
comboBox.KeyPress += OnKeyPress;
comboBox = (ComboBox)Owner;
comboBox.IsEditable = true;
comboBox.KeyDown += OnKeyPress;
comboBox.Width = 130;
SearchOptions.Properties.PropertyChanged += new PropertyChangedEventHandler(SearchOptionsChanged);
RefreshComboBox();

9
src/AddIns/Misc/SearchAndReplace/Project/SearchAndReplace.csproj

@ -36,6 +36,12 @@ @@ -36,6 +36,12 @@
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -44,6 +50,9 @@ @@ -44,6 +50,9 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\FindPanel.xfrm" />

17
src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs

@ -8,11 +8,10 @@ @@ -8,11 +8,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Gui;
using System.Windows.Forms;
namespace ICSharpCode.SharpDevelop.Commands
{
@ -42,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -42,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Commands
if (editingLayout) return;
LoggingService.Debug("ChooseLayoutCommand.Run()");
ComboBox comboBox = ((ToolBarComboBox)Owner).ComboBox;
var comboBox = (System.Windows.Controls.ComboBox)Owner;
string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts");
string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts");
if (!Directory.Exists(configPath)) {
@ -157,8 +156,7 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -157,8 +156,7 @@ namespace ICSharpCode.SharpDevelop.Commands
{
if (editingLayout) return;
LoggingService.Debug("ChooseLayoutCommand.LayoutChanged(object,EventArgs)");
ToolBarComboBox toolbarItem = (ToolBarComboBox)Owner;
ComboBox comboBox = toolbarItem.ComboBox;
var comboBox = (System.Windows.Controls.ComboBox)Owner;
for (int i = 0; i < comboBox.Items.Count; ++i) {
if (((LayoutConfiguration)comboBox.Items[i]).Name == LayoutConfiguration.CurrentLayoutName) {
comboBox.SelectedIndex = i;
@ -169,8 +167,10 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -169,8 +167,10 @@ namespace ICSharpCode.SharpDevelop.Commands
protected override void OnOwnerChanged(EventArgs e)
{
base.OnOwnerChanged(e);
ToolBarComboBox toolbarItem = (ToolBarComboBox)Owner;
ComboBox comboBox = toolbarItem.ComboBox;
editingLayout = true;
try {
var comboBox = (System.Windows.Controls.ComboBox)Owner;
comboBox.Items.Clear();
int index = 0;
foreach (LayoutConfiguration config in LayoutConfiguration.Layouts) {
@ -186,6 +186,9 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -186,6 +186,9 @@ namespace ICSharpCode.SharpDevelop.Commands
resetIndex = comboBox.Items.Count;
comboBox.Items.Add(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.ResetToDefaultItem}"));
comboBox.SelectedIndex = index;
} finally {
editingLayout = false;
}
}
}
}

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

@ -71,6 +71,7 @@ @@ -71,6 +71,7 @@
<Compile Include="PresentationResourceService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ToolBar\ToolBarButton.cs" />
<Compile Include="ToolBar\ToolBarComboBox.cs" />
<Compile Include="ToolBar\ToolBarService.cs" />
</ItemGroup>
<ItemGroup>

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

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// <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.Controls;
namespace ICSharpCode.Core.Presentation
{
sealed class ToolBarComboBox : ComboBox
{
// readonly Codon codon;
// readonly object caller;
IComboBoxCommand menuCommand;
public ToolBarComboBox(Codon codon, object caller)
{
this.IsEditable = false;
menuCommand = (IComboBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
menuCommand.Owner = this;
}
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
base.OnSelectionChanged(e);
menuCommand.Run();
}
}
}

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

@ -64,8 +64,7 @@ namespace ICSharpCode.Core.Presentation @@ -64,8 +64,7 @@ namespace ICSharpCode.Core.Presentation
case "Item":
return new ToolBarButton(codon, caller, createCommand);
case "ComboBox":
return "ComboBox";
//return new ToolBarComboBox(codon, caller);
return new ToolBarComboBox(codon, caller);
case "TextBox":
return "TextBox";
//return new ToolBarTextBox(codon, caller);

Loading…
Cancel
Save